feat: report bug and fix color transition

This commit is contained in:
FunkyMuse 2023-07-21 17:43:13 +02:00
parent 5da68f1606
commit 304b4c2ebb
2 changed files with 11 additions and 11 deletions

View File

@ -14,7 +14,6 @@ import com.simplemobiletools.calculator.compose.extensions.TransparentSystemBars
import com.simplemobiletools.calculator.compose.extensions.onEventValue
import com.simplemobiletools.calculator.compose.screens.SettingsScreen
import com.simplemobiletools.calculator.compose.theme.AppThemeSurface
import com.simplemobiletools.calculator.compose.theme.OnLifecycleEvent
import com.simplemobiletools.calculator.compose.theme.getAppIconIds
import com.simplemobiletools.calculator.compose.theme.getAppLauncherName
import com.simplemobiletools.calculator.extensions.*
@ -47,16 +46,18 @@ class SettingsActivity : AppCompatActivity() {
}
}
val isOrWasThankYouInstalled = onEventValue { context.isOrWasThankYouInstalled() }
val lockedCustomizeColorText by remember(isOrWasThankYouInstalled) {
derivedStateOf { if (isOrWasThankYouInstalled) null else getCustomizeColorsString() }
}
val statusBarColor = onEventValue { context.getColoredMaterialStatusBarColor() }
val contrastColor = onEventValue { statusBarColor.getContrastColor() }
SettingsScreen(
topBarsContentColor = Color(contrastColor),
goBack = ::finish,
customizeColors = ::handleCustomizeColorsClick,
customizeWidgetColors = ::setupCustomizeWidgetColors,
topBarsScrolledContainerColor = Color(statusBarColor),
preventPhoneFromSleeping = preventPhoneFromSleeping,
customizeColors = ::handleCustomizeColorsClick,
goBack = ::finish,
customizeWidgetColors = ::setupCustomizeWidgetColors,
onPreventPhoneFromSleeping = preferences::preventPhoneFromSleeping::set,
vibrateOnButtonPressFlow = vibrateOnButtonPressFlow,
onVibrateOnButtonPressFlow = preferences::vibrateOnButtonPress::set,
@ -77,7 +78,8 @@ class SettingsActivity : AppCompatActivity() {
applicationContext.calculatorDB.deleteHistory()
}
},
lockedCustomizeColorText = if (isOrWasThankYouInstalled) null else getCustomizeColorsString()
lockedCustomizeColorText = lockedCustomizeColorText,
topBarsContentColor = Color(contrastColor)
)
}
}

View File

@ -35,7 +35,6 @@ fun SettingsScreen(
customizeWidgetColors: () -> Unit,
topBarsScrolledContainerColor: Color = MaterialTheme.colorScheme.primary,
nonScrolledTextColor: Color = if (isSurfaceLitWell()) Color.Black else Color.White,
scrolledTextColor: Color = if (topBarsScrolledContainerColor.isLitWell()) Color.Black else Color.White,
preventPhoneFromSleeping: Boolean,
onPreventPhoneFromSleeping: (Boolean) -> Unit,
vibrateOnButtonPressFlow: Boolean,
@ -58,7 +57,7 @@ fun SettingsScreen(
val fraction = if (colorTransitionFraction > 0.01f) 1f else 0f
val scrolledColor = lerp(
start = nonScrolledTextColor,
stop = scrolledTextColor,
stop = topBarsContentColor,
fraction = fraction
)
SideEffect {
@ -192,7 +191,6 @@ private fun SettingsScreenPreview() {
customizeWidgetColors = {},
topBarsScrolledContainerColor = MaterialTheme.colorScheme.primary,
nonScrolledTextColor = Color.White,
scrolledTextColor = Color.Black,
preventPhoneFromSleeping = false,
onPreventPhoneFromSleeping = {},
vibrateOnButtonPressFlow = false,
@ -202,8 +200,8 @@ private fun SettingsScreenPreview() {
isUseEnglishEnabled = false,
isUseEnglishChecked = false,
onUseEnglishPress = {},
onSetupLanguagePress = {}, useCommaAsDecimalMarkFlow = false, onUseCommaAsDecimalMarkFlow = {},
lockedCustomizeColorText = null,
onSetupLanguagePress = {},
useCommaAsDecimalMarkFlow = false, onUseCommaAsDecimalMarkFlow = {}, lockedCustomizeColorText = null,
topBarsContentColor = MaterialTheme.colorScheme.onPrimary
)
}