make the composables previewable again and also fix some ui glitches
This commit is contained in:
parent
e966dc0b43
commit
221f1a2a88
5 changed files with 143 additions and 118 deletions
|
@ -15,6 +15,7 @@ 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.*
|
||||||
import com.simplemobiletools.commons.activities.CustomizationActivity
|
import com.simplemobiletools.commons.activities.CustomizationActivity
|
||||||
|
import com.simplemobiletools.commons.extensions.getCustomizeColorsString
|
||||||
import com.simplemobiletools.commons.extensions.isOrWasThankYouInstalled
|
import com.simplemobiletools.commons.extensions.isOrWasThankYouInstalled
|
||||||
import com.simplemobiletools.commons.extensions.launchPurchaseThankYouIntent
|
import com.simplemobiletools.commons.extensions.launchPurchaseThankYouIntent
|
||||||
import com.simplemobiletools.commons.helpers.*
|
import com.simplemobiletools.commons.helpers.*
|
||||||
|
@ -44,7 +45,7 @@ class SettingsActivity : AppCompatActivity() {
|
||||||
var isOrWasThankYouInstalled by remember { mutableStateOf(false) }
|
var isOrWasThankYouInstalled by remember { mutableStateOf(false) }
|
||||||
|
|
||||||
OnLifecycleEvent { event ->
|
OnLifecycleEvent { event ->
|
||||||
if (event == androidx.lifecycle.Lifecycle.Event.ON_RESUME) {
|
if (event == androidx.lifecycle.Lifecycle.Event.ON_START) {
|
||||||
isOrWasThankYouInstalled = context.isOrWasThankYouInstalled()
|
isOrWasThankYouInstalled = context.isOrWasThankYouInstalled()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,6 +74,7 @@ class SettingsActivity : AppCompatActivity() {
|
||||||
applicationContext.calculatorDB.deleteHistory()
|
applicationContext.calculatorDB.deleteHistory()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
lockedCustomizeColorText = if (isOrWasThankYouInstalled) null else getCustomizeColorsString()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.simplemobiletools.calculator.compose.screens
|
package com.simplemobiletools.calculator.compose.screens
|
||||||
|
|
||||||
|
import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.clickable
|
import androidx.compose.foundation.clickable
|
||||||
import androidx.compose.foundation.layout.*
|
import androidx.compose.foundation.layout.*
|
||||||
import androidx.compose.foundation.rememberScrollState
|
import androidx.compose.foundation.rememberScrollState
|
||||||
|
@ -14,6 +15,7 @@ import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.graphics.lerp
|
import androidx.compose.ui.graphics.lerp
|
||||||
import androidx.compose.ui.input.nestedscroll.nestedScroll
|
import androidx.compose.ui.input.nestedscroll.nestedScroll
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
|
import androidx.compose.ui.platform.LocalView
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import com.simplemobiletools.calculator.compose.extensions.MyDevices
|
import com.simplemobiletools.calculator.compose.extensions.MyDevices
|
||||||
|
@ -27,7 +29,6 @@ import com.simplemobiletools.commons.R
|
||||||
import com.simplemobiletools.commons.extensions.getCustomizeColorsString
|
import com.simplemobiletools.commons.extensions.getCustomizeColorsString
|
||||||
import com.simplemobiletools.commons.helpers.isTiramisuPlus
|
import com.simplemobiletools.commons.helpers.isTiramisuPlus
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
import kotlin.reflect.KFunction1
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun SettingsScreen(
|
fun SettingsScreen(
|
||||||
|
@ -49,9 +50,8 @@ fun SettingsScreen(
|
||||||
onSetupLanguagePress: () -> Unit,
|
onSetupLanguagePress: () -> Unit,
|
||||||
useCommaAsDecimalMarkFlow: Boolean,
|
useCommaAsDecimalMarkFlow: Boolean,
|
||||||
onUseCommaAsDecimalMarkFlow: (Boolean) -> Unit,
|
onUseCommaAsDecimalMarkFlow: (Boolean) -> Unit,
|
||||||
|
lockedCustomizeColorText: String?
|
||||||
) {
|
) {
|
||||||
val context = LocalContext.current
|
|
||||||
val lockedCustomizeColorText = if (isOrWasThankYouInstalled) null else context.getCustomizeColorsString()
|
|
||||||
val displayLanguage = remember { Locale.getDefault().displayLanguage }
|
val displayLanguage = remember { Locale.getDefault().displayLanguage }
|
||||||
val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior(rememberTopAppBarState())
|
val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior(rememberTopAppBarState())
|
||||||
val colorTransitionFraction = scrollBehavior.state.overlappedFraction
|
val colorTransitionFraction = scrollBehavior.state.overlappedFraction
|
||||||
|
@ -63,8 +63,8 @@ fun SettingsScreen(
|
||||||
)
|
)
|
||||||
Scaffold(
|
Scaffold(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxSize()
|
.nestedScroll(scrollBehavior.nestedScrollConnection)
|
||||||
.nestedScroll(scrollBehavior.nestedScrollConnection),
|
.fillMaxSize(),
|
||||||
topBar = {
|
topBar = {
|
||||||
TopAppBar(
|
TopAppBar(
|
||||||
title = {
|
title = {
|
||||||
|
@ -92,62 +92,69 @@ fun SettingsScreen(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
) { paddingValues ->
|
) { paddingValues ->
|
||||||
Column(
|
Box(
|
||||||
Modifier
|
modifier = Modifier
|
||||||
|
.fillMaxSize()
|
||||||
.padding(paddingValues)
|
.padding(paddingValues)
|
||||||
.verticalScroll(rememberScrollState())
|
.background(MaterialTheme.colorScheme.surface)
|
||||||
) {
|
) {
|
||||||
SettingsGroup(title = {
|
Column(
|
||||||
SettingsTitleTextComponent(text = stringResource(id = R.string.color_customization))
|
Modifier
|
||||||
}) {
|
.matchParentSize()
|
||||||
SettingsPreferenceComponent(
|
.verticalScroll(rememberScrollState())
|
||||||
preferenceTitle = stringResource(id = R.string.customize_colors),
|
) {
|
||||||
doOnPreferenceClick = customizeColors,
|
SettingsGroup(title = {
|
||||||
isPreferenceEnabled = isOrWasThankYouInstalled,
|
SettingsTitleTextComponent(text = stringResource(id = R.string.color_customization))
|
||||||
preferenceSummary = lockedCustomizeColorText
|
}) {
|
||||||
)
|
|
||||||
SettingsPreferenceComponent(
|
|
||||||
preferenceTitle = stringResource(id = R.string.customize_widget_colors),
|
|
||||||
doOnPreferenceClick = customizeWidgetColors
|
|
||||||
)
|
|
||||||
Spacer(modifier = Modifier.padding(bottom = 16.dp))
|
|
||||||
}
|
|
||||||
Divider()
|
|
||||||
SettingsGroup(title = {
|
|
||||||
SettingsTitleTextComponent(text = stringResource(id = R.string.general_settings))
|
|
||||||
}) {
|
|
||||||
if (!isOrWasThankYouInstalled) {
|
|
||||||
SettingsPreferenceComponent(preferenceTitle = stringResource(id = R.string.purchase_simple_thank_you), doOnPreferenceClick = onThankYou)
|
|
||||||
}
|
|
||||||
if (isUseEnglishEnabled) {
|
|
||||||
SettingsCheckBoxComponent(
|
|
||||||
title = stringResource(id = R.string.use_english_language),
|
|
||||||
initialValue = isUseEnglishChecked,
|
|
||||||
onChange = onUseEnglishPress
|
|
||||||
)
|
|
||||||
}
|
|
||||||
if (isTiramisuPlus()) {
|
|
||||||
SettingsPreferenceComponent(
|
SettingsPreferenceComponent(
|
||||||
preferenceTitle = stringResource(id = R.string.language),
|
preferenceTitle = stringResource(id = R.string.customize_colors),
|
||||||
preferenceSummary = displayLanguage,
|
doOnPreferenceClick = customizeColors,
|
||||||
doOnPreferenceClick = onSetupLanguagePress
|
isPreferenceEnabled = isOrWasThankYouInstalled,
|
||||||
|
preferenceSummary = lockedCustomizeColorText
|
||||||
|
)
|
||||||
|
SettingsPreferenceComponent(
|
||||||
|
preferenceTitle = stringResource(id = R.string.customize_widget_colors),
|
||||||
|
doOnPreferenceClick = customizeWidgetColors
|
||||||
|
)
|
||||||
|
Spacer(modifier = Modifier.padding(bottom = 16.dp))
|
||||||
|
}
|
||||||
|
Divider()
|
||||||
|
SettingsGroup(title = {
|
||||||
|
SettingsTitleTextComponent(text = stringResource(id = R.string.general_settings))
|
||||||
|
}) {
|
||||||
|
if (!isOrWasThankYouInstalled) {
|
||||||
|
SettingsPreferenceComponent(preferenceTitle = stringResource(id = R.string.purchase_simple_thank_you), doOnPreferenceClick = onThankYou)
|
||||||
|
}
|
||||||
|
if (isUseEnglishEnabled) {
|
||||||
|
SettingsCheckBoxComponent(
|
||||||
|
title = stringResource(id = R.string.use_english_language),
|
||||||
|
initialValue = isUseEnglishChecked,
|
||||||
|
onChange = onUseEnglishPress
|
||||||
|
)
|
||||||
|
}
|
||||||
|
if (isTiramisuPlus()) {
|
||||||
|
SettingsPreferenceComponent(
|
||||||
|
preferenceTitle = stringResource(id = R.string.language),
|
||||||
|
preferenceSummary = displayLanguage,
|
||||||
|
doOnPreferenceClick = onSetupLanguagePress
|
||||||
|
)
|
||||||
|
}
|
||||||
|
SettingsCheckBoxComponent(
|
||||||
|
title = stringResource(id = R.string.vibrate_on_button_press),
|
||||||
|
initialValue = vibrateOnButtonPressFlow,
|
||||||
|
onChange = onVibrateOnButtonPressFlow
|
||||||
|
)
|
||||||
|
SettingsCheckBoxComponent(
|
||||||
|
title = stringResource(id = R.string.prevent_phone_from_sleeping),
|
||||||
|
initialValue = preventPhoneFromSleeping,
|
||||||
|
onChange = onPreventPhoneFromSleeping
|
||||||
|
)
|
||||||
|
SettingsCheckBoxComponent(
|
||||||
|
title = stringResource(id = com.simplemobiletools.calculator.R.string.use_comma_as_decimal_mark),
|
||||||
|
initialValue = useCommaAsDecimalMarkFlow,
|
||||||
|
onChange = onUseCommaAsDecimalMarkFlow
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
SettingsCheckBoxComponent(
|
|
||||||
title = stringResource(id = R.string.vibrate_on_button_press),
|
|
||||||
initialValue = vibrateOnButtonPressFlow,
|
|
||||||
onChange = onVibrateOnButtonPressFlow
|
|
||||||
)
|
|
||||||
SettingsCheckBoxComponent(
|
|
||||||
title = stringResource(id = R.string.prevent_phone_from_sleeping),
|
|
||||||
initialValue = preventPhoneFromSleeping,
|
|
||||||
onChange = onPreventPhoneFromSleeping
|
|
||||||
)
|
|
||||||
SettingsCheckBoxComponent(
|
|
||||||
title = stringResource(id = com.simplemobiletools.calculator.R.string.use_comma_as_decimal_mark),
|
|
||||||
initialValue = useCommaAsDecimalMarkFlow,
|
|
||||||
onChange = onUseCommaAsDecimalMarkFlow
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -173,7 +180,8 @@ private fun SettingsScreenPreview() {
|
||||||
isUseEnglishEnabled = false,
|
isUseEnglishEnabled = false,
|
||||||
isUseEnglishChecked = false,
|
isUseEnglishChecked = false,
|
||||||
onUseEnglishPress = {},
|
onUseEnglishPress = {},
|
||||||
onSetupLanguagePress = {}, useCommaAsDecimalMarkFlow = false, onUseCommaAsDecimalMarkFlow = {}
|
onSetupLanguagePress = {}, useCommaAsDecimalMarkFlow = false, onUseCommaAsDecimalMarkFlow = {},
|
||||||
|
lockedCustomizeColorText = null
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package com.simplemobiletools.calculator.compose.settings
|
package com.simplemobiletools.calculator.compose.settings
|
||||||
|
|
||||||
import androidx.compose.animation.AnimatedVisibility
|
import androidx.compose.animation.AnimatedVisibility
|
||||||
|
import androidx.compose.foundation.clickable
|
||||||
|
import androidx.compose.foundation.interaction.MutableInteractionSource
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
|
@ -8,6 +10,7 @@ import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.material3.Checkbox
|
import androidx.compose.material3.Checkbox
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
|
@ -26,10 +29,12 @@ fun SettingsCheckBoxComponent(
|
||||||
isPreferenceEnabled: Boolean = true,
|
isPreferenceEnabled: Boolean = true,
|
||||||
onChange: ((Boolean) -> Unit)? = null,
|
onChange: ((Boolean) -> Unit)? = null,
|
||||||
) {
|
) {
|
||||||
|
val interactionSource = remember { MutableInteractionSource() }
|
||||||
Row(
|
Row(
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
modifier = modifier
|
modifier = modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
|
.clickable(indication = null, interactionSource = interactionSource, onClick = { onChange?.invoke(!initialValue) })
|
||||||
.padding(vertical = 14.dp, horizontal = 16.dp),
|
.padding(vertical = 14.dp, horizontal = 16.dp),
|
||||||
) {
|
) {
|
||||||
Column(
|
Column(
|
||||||
|
@ -40,7 +45,6 @@ fun SettingsCheckBoxComponent(
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.padding(end = 16.dp),
|
.padding(end = 16.dp),
|
||||||
text = title,
|
text = title,
|
||||||
fontSize = 16.sp,
|
|
||||||
color = preferenceTitleColor(isEnabled = isPreferenceEnabled),
|
color = preferenceTitleColor(isEnabled = isPreferenceEnabled),
|
||||||
)
|
)
|
||||||
AnimatedVisibility(visible = !summary.isNullOrBlank()) {
|
AnimatedVisibility(visible = !summary.isNullOrBlank()) {
|
||||||
|
@ -50,7 +54,6 @@ fun SettingsCheckBoxComponent(
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.padding(vertical = 4.dp)
|
.padding(vertical = 4.dp)
|
||||||
.padding(end = 16.dp),
|
.padding(end = 16.dp),
|
||||||
fontSize = 14.sp,
|
|
||||||
color = preferenceSummaryColor(isEnabled = isPreferenceEnabled),
|
color = preferenceSummaryColor(isEnabled = isPreferenceEnabled),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,6 @@ fun SettingsPreferenceComponent(
|
||||||
Text(
|
Text(
|
||||||
text = preferenceTitle,
|
text = preferenceTitle,
|
||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = Modifier.fillMaxWidth(),
|
||||||
fontSize = 16.sp,
|
|
||||||
color = preferenceTitleColor(isEnabled = isPreferenceEnabled),
|
color = preferenceTitleColor(isEnabled = isPreferenceEnabled),
|
||||||
)
|
)
|
||||||
AnimatedVisibility(visible = !preferenceSummary.isNullOrBlank()) {
|
AnimatedVisibility(visible = !preferenceSummary.isNullOrBlank()) {
|
||||||
|
@ -48,7 +47,6 @@ fun SettingsPreferenceComponent(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.padding(vertical = 4.dp),
|
.padding(vertical = 4.dp),
|
||||||
fontSize = 14.sp,
|
|
||||||
color = preferenceSummaryColor(isEnabled = isPreferenceEnabled),
|
color = preferenceSummaryColor(isEnabled = isPreferenceEnabled),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@ import androidx.compose.ui.graphics.luminance
|
||||||
import androidx.compose.ui.graphics.toArgb
|
import androidx.compose.ui.graphics.toArgb
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.platform.LocalLifecycleOwner
|
import androidx.compose.ui.platform.LocalLifecycleOwner
|
||||||
|
import androidx.compose.ui.platform.LocalView
|
||||||
import androidx.lifecycle.Lifecycle
|
import androidx.lifecycle.Lifecycle
|
||||||
import androidx.lifecycle.LifecycleEventObserver
|
import androidx.lifecycle.LifecycleEventObserver
|
||||||
import androidx.lifecycle.LifecycleOwner
|
import androidx.lifecycle.LifecycleOwner
|
||||||
|
@ -148,52 +149,55 @@ fun Color.isNotLitWell() = luminance() < LUMINANCE_THRESHOLD
|
||||||
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun Theme(
|
private fun Theme(
|
||||||
useTransparentNavigation: Boolean = true,
|
useTransparentNavigation: Boolean = true,
|
||||||
theme: Theme,
|
theme: Theme = systemDefaultMaterialYou(),
|
||||||
content: @Composable () -> Unit,
|
content: @Composable () -> Unit,
|
||||||
) {
|
) {
|
||||||
|
val view = LocalView.current
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
val systemUiController = rememberSystemUiController()
|
val systemUiController = rememberSystemUiController()
|
||||||
val window = context.getActivity().window
|
|
||||||
val baseConfig = remember { context.config }
|
|
||||||
|
|
||||||
val colorScheme = when {
|
val colorScheme = if (!view.isInEditMode){
|
||||||
theme is Theme.SystemDefaultMaterialYou && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> {
|
val baseConfig = remember { context.config }
|
||||||
if (isSystemInDarkTheme()) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context)
|
|
||||||
|
val colorScheme = when {
|
||||||
|
theme is Theme.SystemDefaultMaterialYou && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> {
|
||||||
|
if (isSystemInDarkTheme()) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context)
|
||||||
|
}
|
||||||
|
|
||||||
|
theme is Theme.Custom || theme is Theme.Dark -> darkColorScheme(
|
||||||
|
primary = theme.primaryColor, surface = theme.backgroundColor,
|
||||||
|
onSurface = theme.textColor
|
||||||
|
)
|
||||||
|
|
||||||
|
theme is Theme.White -> darkColorScheme(
|
||||||
|
primary = Color(theme.accentColor),
|
||||||
|
surface = theme.backgroundColor,
|
||||||
|
tertiary = theme.primaryColor,
|
||||||
|
onSurface = theme.textColor
|
||||||
|
)
|
||||||
|
|
||||||
|
theme is Theme.BlackAndWhite -> darkColorScheme(
|
||||||
|
primary = Color(theme.accentColor),
|
||||||
|
surface = theme.backgroundColor,
|
||||||
|
tertiary = theme.primaryColor,
|
||||||
|
onSurface = theme.textColor
|
||||||
|
)
|
||||||
|
|
||||||
|
else -> darkColorScheme
|
||||||
}
|
}
|
||||||
|
|
||||||
theme is Theme.Custom || theme is Theme.Dark -> darkColorScheme(
|
LaunchedEffect(Unit) {
|
||||||
primary = theme.primaryColor, surface = theme.backgroundColor,
|
/* if (context.navigationBarHeight > 0 || context.isUsingGestureNavigation() && useTransparentNavigation) {
|
||||||
onSurface = theme.textColor
|
systemUiController.isNavigationBarVisible = false
|
||||||
)
|
} else {
|
||||||
|
systemUiController.isNavigationBarVisible = true
|
||||||
|
}*/
|
||||||
|
|
||||||
theme is Theme.White -> darkColorScheme(
|
/* if (context.navigationBarHeight > 0 || context.isUsingGestureNavigation()) {
|
||||||
primary = Color(theme.accentColor),
|
window.decorView.systemUiVisibility = window.decorView.systemUiVisibility.addBit(View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION)
|
||||||
surface = theme.backgroundColor,
|
*//* updateTopBottomInsets(statusBarHeight, navigationBarHeight)
|
||||||
tertiary = theme.primaryColor,
|
|
||||||
onSurface = theme.textColor
|
|
||||||
)
|
|
||||||
|
|
||||||
theme is Theme.BlackAndWhite -> darkColorScheme(
|
|
||||||
primary = Color(theme.accentColor),
|
|
||||||
surface = theme.backgroundColor,
|
|
||||||
tertiary = theme.primaryColor,
|
|
||||||
onSurface = theme.textColor
|
|
||||||
)
|
|
||||||
|
|
||||||
else -> darkColorScheme
|
|
||||||
}
|
|
||||||
LaunchedEffect(Unit) {
|
|
||||||
/* if (context.navigationBarHeight > 0 || context.isUsingGestureNavigation() && useTransparentNavigation) {
|
|
||||||
systemUiController.isNavigationBarVisible = false
|
|
||||||
} else {
|
|
||||||
systemUiController.isNavigationBarVisible = true
|
|
||||||
}*/
|
|
||||||
|
|
||||||
/* if (context.navigationBarHeight > 0 || context.isUsingGestureNavigation()) {
|
|
||||||
window.decorView.systemUiVisibility = window.decorView.systemUiVisibility.addBit(View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION)
|
|
||||||
*//* updateTopBottomInsets(statusBarHeight, navigationBarHeight)
|
|
||||||
// Don't touch this. Window Inset API often has a domino effect and things will most likely break.
|
// Don't touch this. Window Inset API often has a domino effect and things will most likely break.
|
||||||
onApplyWindowInsets {
|
onApplyWindowInsets {
|
||||||
val insets = it.getInsets(WindowInsetsCompat.Type.systemBars() or WindowInsetsCompat.Type.ime())
|
val insets = it.getInsets(WindowInsetsCompat.Type.systemBars() or WindowInsetsCompat.Type.ime())
|
||||||
|
@ -203,25 +207,26 @@ fun Theme(
|
||||||
window.decorView.systemUiVisibility = window.decorView.systemUiVisibility.removeBit(View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION)
|
window.decorView.systemUiVisibility = window.decorView.systemUiVisibility.removeBit(View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION)
|
||||||
//updateTopBottomInsets(0, 0)
|
//updateTopBottomInsets(0, 0)
|
||||||
}*/
|
}*/
|
||||||
systemUiController.setStatusBarColor(
|
systemUiController.setStatusBarColor(
|
||||||
color = colorScheme.surface
|
color = colorScheme.surface
|
||||||
)
|
)
|
||||||
context.getActivity().setTaskDescription(ActivityManager.TaskDescription(null, null, colorScheme.surface.toArgb()))
|
context.getActivity().setTaskDescription(ActivityManager.TaskDescription(null, null, colorScheme.surface.toArgb()))
|
||||||
systemUiController.setNavigationBarColor(Color(theme.backgroundColor.toArgb().adjustAlpha(HIGHER_ALPHA)))
|
systemUiController.setNavigationBarColor(Color(theme.backgroundColor.toArgb().adjustAlpha(HIGHER_ALPHA)))
|
||||||
}
|
}
|
||||||
|
|
||||||
SideEffect {
|
SideEffect {
|
||||||
updateRecentsAppIcon(baseConfig, context)
|
updateRecentsAppIcon(baseConfig, context)
|
||||||
}
|
}
|
||||||
|
|
||||||
CompositionLocalProvider(
|
colorScheme
|
||||||
LocalOverscrollConfiguration provides null,
|
|
||||||
) {
|
} else darkColorScheme
|
||||||
MaterialTheme(
|
|
||||||
colorScheme = colorScheme,
|
|
||||||
content = content,
|
MaterialTheme(
|
||||||
)
|
colorScheme = colorScheme,
|
||||||
}
|
content = content,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun Context.getAppIconIds(): List<Int> = getActivity().getAppIconIds()
|
private fun Context.getAppIconIds(): List<Int> = getActivity().getAppIconIds()
|
||||||
|
@ -262,11 +267,20 @@ fun AppThemeSurface(
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
content: @Composable () -> Unit,
|
content: @Composable () -> Unit,
|
||||||
) {
|
) {
|
||||||
|
val view = LocalView.current
|
||||||
|
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
val materialYouTheme = systemDefaultMaterialYou()
|
val materialYouTheme = systemDefaultMaterialYou()
|
||||||
var currentTheme by remember { mutableStateOf(getTheme(context = context, materialYouTheme = materialYouTheme)) }
|
var currentTheme by remember {
|
||||||
|
mutableStateOf(
|
||||||
|
if (view.isInEditMode) materialYouTheme else getTheme(
|
||||||
|
context = context,
|
||||||
|
materialYouTheme = materialYouTheme
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
OnLifecycleEvent { event ->
|
OnLifecycleEvent { event ->
|
||||||
if (event == Lifecycle.Event.ON_RESUME) {
|
if (event == Lifecycle.Event.ON_START && !view.isInEditMode) {
|
||||||
currentTheme = getTheme(context = context, materialYouTheme = materialYouTheme)
|
currentTheme = getTheme(context = context, materialYouTheme = materialYouTheme)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue