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

View File

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