From 0ed106cf8195f64c041fbf15112d5cbd2a9546d0 Mon Sep 17 00:00:00 2001 From: MohitMaliFtechiz Date: Tue, 11 Mar 2025 15:31:01 +0530 Subject: [PATCH] Added `KiwixDialogTheme` to ensure consistent dialog styling with the app's light and dark themes. --- .../core/main/AddNoteDialogScreen.kt | 4 +-- .../kiwix/kiwixmobile/core/ui/theme/Color.kt | 1 + .../kiwix/kiwixmobile/core/ui/theme/Theme.kt | 30 +++++++++++++++++-- 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/main/AddNoteDialogScreen.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/main/AddNoteDialogScreen.kt index 4a0fd70d8..e5fa69df3 100644 --- a/core/src/main/java/org/kiwix/kiwixmobile/core/main/AddNoteDialogScreen.kt +++ b/core/src/main/java/org/kiwix/kiwixmobile/core/main/AddNoteDialogScreen.kt @@ -51,7 +51,7 @@ import org.kiwix.kiwixmobile.core.R import org.kiwix.kiwixmobile.core.ui.components.KiwixAppBar import org.kiwix.kiwixmobile.core.ui.components.KiwixSnackbarHost import org.kiwix.kiwixmobile.core.ui.models.ActionMenuItem -import org.kiwix.kiwixmobile.core.ui.theme.KiwixTheme +import org.kiwix.kiwixmobile.core.ui.theme.KiwixDialogTheme import org.kiwix.kiwixmobile.core.utils.ComposeDimens.FIVE_DP import org.kiwix.kiwixmobile.core.utils.ComposeDimens.FOUR_DP import org.kiwix.kiwixmobile.core.utils.ComposeDimens.MINIMUM_HEIGHT_OF_NOTE_TEXT_FILED @@ -77,7 +77,7 @@ fun AddNoteDialogScreen( ) { val focusRequester = remember { FocusRequester() } val focusManager = LocalFocusManager.current - KiwixTheme { + KiwixDialogTheme { Scaffold( snackbarHost = { KiwixSnackbarHost(snackbarHostState = snackBarHostState) } ) { paddingValues -> diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/ui/theme/Color.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/ui/theme/Color.kt index 8473c7072..77a12dfd0 100644 --- a/core/src/main/java/org/kiwix/kiwixmobile/core/ui/theme/Color.kt +++ b/core/src/main/java/org/kiwix/kiwixmobile/core/ui/theme/Color.kt @@ -26,6 +26,7 @@ val MineShaftGray350 = Color(0xFFD6D6D6) val MineShaftGray500 = Color(0xFF9E9E9E) val ScorpionGray = Color(0xFF5A5A5A) val MineShaftGray600 = Color(0xFF737373) +val MineShaftGray700 = Color(0xFF424242) val MineShaftGray850 = Color(0xFF303030) val MineShaftGray900 = Color(0xFF212121) val Black = Color(0xFF000000) diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/ui/theme/Theme.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/ui/theme/Theme.kt index a1d18d025..d57b12269 100644 --- a/core/src/main/java/org/kiwix/kiwixmobile/core/ui/theme/Theme.kt +++ b/core/src/main/java/org/kiwix/kiwixmobile/core/ui/theme/Theme.kt @@ -34,7 +34,8 @@ private val DarkColorScheme = darkColorScheme( onSecondary = MineShaftGray350, onBackground = White, onSurface = White, - onError = White + onError = White, + onTertiary = MineShaftGray500 ) private val LightColorScheme = lightColorScheme( @@ -47,7 +48,8 @@ private val LightColorScheme = lightColorScheme( onSecondary = ScorpionGray, onBackground = Black, onSurface = Black, - onError = AlabasterWhite + onError = AlabasterWhite, + onTertiary = MineShaftGray600 ) @Composable @@ -67,3 +69,27 @@ fun KiwixTheme( typography = KiwixTypography ) } + +/** + * A custom MaterialTheme specifically for dialogs in the Kiwix app. + * + * This theme applies a modified dark mode background for dialogs while keeping + * the rest of the color scheme unchanged. In light mode, it uses the + * standard app theme(KiwixTheme). + */ +@Composable +fun KiwixDialogTheme( + darkTheme: Boolean = isSystemInDarkTheme(), + content: @Composable () -> Unit +) { + val colorScheme = when { + darkTheme -> DarkColorScheme.copy(background = MineShaftGray700) + else -> LightColorScheme + } + MaterialTheme( + colorScheme = colorScheme, + content = content, + shapes = shapes, + typography = KiwixTypography + ) +}