From 26379d6b67c43697985d91b11a65d826339529e4 Mon Sep 17 00:00:00 2001 From: Saifuddin Date: Thu, 10 Oct 2024 09:26:28 +0530 Subject: [PATCH] Status bar and navigation bar styles updated --- .../kotlin/org/mifos/mobile/HomeActivity.kt | 23 ++++++++++ .../src/main/res/values-night/color.xml | 4 ++ .../src/main/res/values-night/theme.xml | 12 +++++ androidApp/src/main/res/values/colors.xml | 1 + androidApp/src/main/res/values/splash.xml | 44 ++++++++++++++----- .../mobile/core/designsystem/theme/Color.kt | 3 ++ .../mobile/core/designsystem/theme/Theme.kt | 17 +------ 7 files changed, 77 insertions(+), 27 deletions(-) create mode 100644 androidApp/src/main/res/values-night/color.xml create mode 100644 androidApp/src/main/res/values-night/theme.xml diff --git a/androidApp/src/main/kotlin/org/mifos/mobile/HomeActivity.kt b/androidApp/src/main/kotlin/org/mifos/mobile/HomeActivity.kt index 7ced2b270..f4df10006 100644 --- a/androidApp/src/main/kotlin/org/mifos/mobile/HomeActivity.kt +++ b/androidApp/src/main/kotlin/org/mifos/mobile/HomeActivity.kt @@ -9,15 +9,20 @@ */ package org.mifos.mobile +import android.graphics.Color import android.os.Bundle import androidx.activity.ComponentActivity +import androidx.activity.SystemBarStyle import androidx.activity.compose.setContent import androidx.activity.enableEdgeToEdge import androidx.activity.viewModels +import androidx.compose.foundation.isSystemInDarkTheme import androidx.compose.runtime.CompositionLocalProvider +import androidx.compose.runtime.DisposableEffect import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.setValue +import androidx.compose.ui.graphics.toArgb import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen import androidx.lifecycle.Lifecycle import androidx.lifecycle.lifecycleScope @@ -30,6 +35,8 @@ import kotlinx.coroutines.launch import org.mifos.mobile.HomeActivityUiState.Success import org.mifos.mobile.core.data.utils.NetworkMonitor import org.mifos.mobile.core.designsystem.theme.MifosMobileTheme +import org.mifos.mobile.core.designsystem.theme.darkScrim +import org.mifos.mobile.core.designsystem.theme.lightScrim import org.mifos.mobile.navigation.MifosNavGraph.AUTH_GRAPH import org.mifos.mobile.navigation.MifosNavGraph.PASSCODE_GRAPH import org.mifos.mobile.navigation.RootNavGraph @@ -73,6 +80,8 @@ class HomeActivity : ComponentActivity() { val appState = rememberMifosMobileState(networkMonitor = networkMonitor) + val darkTheme = isSystemInDarkTheme() + val navDestination = when (uiState) { is Success -> if ((uiState as Success).userData.isAuthenticated) { PASSCODE_GRAPH @@ -83,6 +92,20 @@ class HomeActivity : ComponentActivity() { else -> AUTH_GRAPH } + DisposableEffect(darkTheme) { + enableEdgeToEdge( + statusBarStyle = SystemBarStyle.auto( + Color.TRANSPARENT, + Color.TRANSPARENT, + ) { darkTheme }, + navigationBarStyle = SystemBarStyle.auto( + lightScrim.toArgb(), + darkScrim.toArgb() + ) { darkTheme }, + ) + onDispose {} + } + CompositionLocalProvider { MifosMobileTheme { RootNavGraph( diff --git a/androidApp/src/main/res/values-night/color.xml b/androidApp/src/main/res/values-night/color.xml new file mode 100644 index 000000000..35a39b1eb --- /dev/null +++ b/androidApp/src/main/res/values-night/color.xml @@ -0,0 +1,4 @@ + + + #FF1B1B1F // dark/color.xml + \ No newline at end of file diff --git a/androidApp/src/main/res/values-night/theme.xml b/androidApp/src/main/res/values-night/theme.xml new file mode 100644 index 000000000..5a9f53fd3 --- /dev/null +++ b/androidApp/src/main/res/values-night/theme.xml @@ -0,0 +1,12 @@ + + + + + + + + \ No newline at end of file diff --git a/androidApp/src/main/res/values/colors.xml b/androidApp/src/main/res/values/colors.xml index 94394e4c5..638e61ec0 100644 --- a/androidApp/src/main/res/values/colors.xml +++ b/androidApp/src/main/res/values/colors.xml @@ -54,6 +54,7 @@ #33CCCCCC + #FFFEFBFF diff --git a/androidApp/src/main/res/values/splash.xml b/androidApp/src/main/res/values/splash.xml index 9ee17867e..5448132ff 100644 --- a/androidApp/src/main/res/values/splash.xml +++ b/androidApp/src/main/res/values/splash.xml @@ -8,18 +8,40 @@ See https://github.com/openMF/mobile-mobile/blob/master/LICENSE.md --> - - --> + + + + + + + + + + + + + + - + + diff --git a/core/designsystem/src/main/kotlin/org/mifos/mobile/core/designsystem/theme/Color.kt b/core/designsystem/src/main/kotlin/org/mifos/mobile/core/designsystem/theme/Color.kt index 5f6ec2a0b..4b43495a0 100644 --- a/core/designsystem/src/main/kotlin/org/mifos/mobile/core/designsystem/theme/Color.kt +++ b/core/designsystem/src/main/kotlin/org/mifos/mobile/core/designsystem/theme/Color.kt @@ -35,3 +35,6 @@ val DarkGray = Color(0xBB666666) val GreenSuccess = Color(0xff14c416) val LightSurfaceTint = Color(0xFF325CA8) val DarkSurfaceTint = Color(0xFFAEC6FF) + +val lightScrim = Color(0x80FFFFFF) // Light scrim with 50% opacity +val darkScrim = Color(0x80000000) // Dark scrim with 50% opacity \ No newline at end of file diff --git a/core/designsystem/src/main/kotlin/org/mifos/mobile/core/designsystem/theme/Theme.kt b/core/designsystem/src/main/kotlin/org/mifos/mobile/core/designsystem/theme/Theme.kt index 34f73cffb..d5c34ea67 100644 --- a/core/designsystem/src/main/kotlin/org/mifos/mobile/core/designsystem/theme/Theme.kt +++ b/core/designsystem/src/main/kotlin/org/mifos/mobile/core/designsystem/theme/Theme.kt @@ -9,18 +9,12 @@ */ package org.mifos.mobile.core.designsystem.theme -import android.app.Activity import androidx.compose.foundation.isSystemInDarkTheme import androidx.compose.material3.MaterialTheme import androidx.compose.material3.darkColorScheme import androidx.compose.material3.lightColorScheme import androidx.compose.runtime.Composable -import androidx.compose.runtime.SideEffect import androidx.compose.ui.graphics.Color -import androidx.compose.ui.graphics.toArgb -import androidx.compose.ui.platform.LocalView -import androidx.core.view.WindowCompat -import androidx.core.view.WindowInsetsControllerCompat private val LightThemeColors = lightColorScheme( primary = LightPrimary, @@ -39,7 +33,7 @@ private val DarkThemeColors = darkColorScheme( secondary = Black1, error = RedErrorDark, background = BackgroundDark, - surface = Black1, + surface = BackgroundDark, onSurface = Color.White, onSecondary = Color.White, outlineVariant = Color.White, @@ -56,15 +50,6 @@ fun MifosMobileTheme( else -> LightThemeColors } - val view = LocalView.current - if (!view.isInEditMode) { - SideEffect { - val window = (view.context as Activity).window - WindowCompat.setDecorFitsSystemWindows(window, false) - WindowInsetsControllerCompat(window, window.decorView).isAppearanceLightStatusBars = true - } - } - MaterialTheme( colorScheme = colors, content = content,