From 9fea2bca1a4973647e41b8985ff31a94b01a51af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ensar=20Saraj=C4=8Di=C4=87?= Date: Wed, 18 Oct 2023 13:29:28 +0200 Subject: [PATCH] Add background for status and navigation bar in widget configuration activities --- .../WidgetBrightDisplayConfigureActivity.kt | 19 ++++++++++++++++++- .../WidgetTorchConfigureActivity.kt | 18 +++++++++++++++++- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/flashlight/activities/WidgetBrightDisplayConfigureActivity.kt b/app/src/main/kotlin/com/simplemobiletools/flashlight/activities/WidgetBrightDisplayConfigureActivity.kt index 6fe73b7..1baec5e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/flashlight/activities/WidgetBrightDisplayConfigureActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/flashlight/activities/WidgetBrightDisplayConfigureActivity.kt @@ -9,12 +9,18 @@ import androidx.activity.compose.setContent import androidx.activity.viewModels import androidx.annotation.ColorInt import androidx.compose.runtime.Composable +import androidx.compose.runtime.DisposableEffect import androidx.compose.runtime.getValue +import androidx.compose.ui.graphics.Color import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.simplemobiletools.commons.compose.alert_dialog.rememberAlertDialogState import com.simplemobiletools.commons.compose.extensions.enableEdgeToEdgeSimple +import com.simplemobiletools.commons.compose.system_ui_controller.rememberSystemUiController import com.simplemobiletools.commons.compose.theme.AppTheme +import com.simplemobiletools.commons.compose.theme.SimpleTheme +import com.simplemobiletools.commons.compose.theme.isLitWell import com.simplemobiletools.commons.dialogs.ColorPickerAlertDialog +import com.simplemobiletools.commons.extensions.isUsingSystemDarkTheme import com.simplemobiletools.commons.helpers.IS_CUSTOMIZING_COLORS import com.simplemobiletools.flashlight.R import com.simplemobiletools.flashlight.activities.viewmodel.WidgetConfigureViewModel @@ -37,9 +43,20 @@ class WidgetBrightDisplayConfigureActivity : ComponentActivity() { finish() } - enableEdgeToEdgeSimple() setContent { AppTheme { + + val systemUiController = rememberSystemUiController() + val surfaceColor = SimpleTheme.colorScheme.surface + + DisposableEffect(systemUiController, !isUsingSystemDarkTheme(), surfaceColor) { + systemUiController.setSystemBarsColor( + color = surfaceColor, + darkIcons = surfaceColor.isLitWell() + ) + onDispose { } + } + val widgetColor by viewModel.widgetColor.collectAsStateWithLifecycle() val widgetAlpha by viewModel.widgetAlpha.collectAsStateWithLifecycle() diff --git a/app/src/main/kotlin/com/simplemobiletools/flashlight/activities/WidgetTorchConfigureActivity.kt b/app/src/main/kotlin/com/simplemobiletools/flashlight/activities/WidgetTorchConfigureActivity.kt index 1c9f126..2b6cc04 100644 --- a/app/src/main/kotlin/com/simplemobiletools/flashlight/activities/WidgetTorchConfigureActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/flashlight/activities/WidgetTorchConfigureActivity.kt @@ -9,12 +9,17 @@ import androidx.activity.compose.setContent import androidx.activity.viewModels import androidx.annotation.ColorInt import androidx.compose.runtime.Composable +import androidx.compose.runtime.DisposableEffect import androidx.compose.runtime.getValue import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.simplemobiletools.commons.compose.alert_dialog.rememberAlertDialogState import com.simplemobiletools.commons.compose.extensions.enableEdgeToEdgeSimple +import com.simplemobiletools.commons.compose.system_ui_controller.rememberSystemUiController import com.simplemobiletools.commons.compose.theme.AppTheme +import com.simplemobiletools.commons.compose.theme.SimpleTheme +import com.simplemobiletools.commons.compose.theme.isLitWell import com.simplemobiletools.commons.dialogs.ColorPickerAlertDialog +import com.simplemobiletools.commons.extensions.isUsingSystemDarkTheme import com.simplemobiletools.commons.helpers.IS_CUSTOMIZING_COLORS import com.simplemobiletools.flashlight.R import com.simplemobiletools.flashlight.activities.viewmodel.WidgetConfigureViewModel @@ -38,9 +43,20 @@ class WidgetTorchConfigureActivity : ComponentActivity() { finish() } - enableEdgeToEdgeSimple() setContent { AppTheme { + + val systemUiController = rememberSystemUiController() + val surfaceColor = SimpleTheme.colorScheme.surface + + DisposableEffect(systemUiController, !isUsingSystemDarkTheme(), surfaceColor) { + systemUiController.setSystemBarsColor( + color = surfaceColor, + darkIcons = surfaceColor.isLitWell() + ) + onDispose { } + } + val widgetColor by viewModel.widgetColor.collectAsStateWithLifecycle() val widgetAlpha by viewModel.widgetAlpha.collectAsStateWithLifecycle()