mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-09 07:16:04 -04:00
Created KiwixSnackToastTheme
to manage the theme of Toast and Snackbar messages separately from the app's main theme, ensuring consistency and preventing unintended style changes.
* Minor refinement in showing the `NoFileView`.
This commit is contained in:
parent
9a7df5e1d9
commit
075f2c0e8c
@ -46,6 +46,7 @@ import androidx.compose.ui.platform.LocalDensity
|
|||||||
import androidx.compose.ui.res.painterResource
|
import androidx.compose.ui.res.painterResource
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.text.font.FontWeight
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
|
import androidx.compose.ui.text.style.TextAlign
|
||||||
import androidx.compose.ui.unit.Dp
|
import androidx.compose.ui.unit.Dp
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import org.kiwix.kiwixmobile.R.string
|
import org.kiwix.kiwixmobile.R.string
|
||||||
@ -64,6 +65,7 @@ import org.kiwix.kiwixmobile.core.ui.theme.KiwixTheme
|
|||||||
import org.kiwix.kiwixmobile.core.ui.theme.White
|
import org.kiwix.kiwixmobile.core.ui.theme.White
|
||||||
import org.kiwix.kiwixmobile.core.utils.ComposeDimens.EIGHT_DP
|
import org.kiwix.kiwixmobile.core.utils.ComposeDimens.EIGHT_DP
|
||||||
import org.kiwix.kiwixmobile.core.utils.ComposeDimens.FAB_ICON_BOTTOM_MARGIN
|
import org.kiwix.kiwixmobile.core.utils.ComposeDimens.FAB_ICON_BOTTOM_MARGIN
|
||||||
|
import org.kiwix.kiwixmobile.core.utils.ComposeDimens.FOUR_DP
|
||||||
import org.kiwix.kiwixmobile.core.zim_manager.fileselect_view.adapter.BooksOnDiskListItem
|
import org.kiwix.kiwixmobile.core.zim_manager.fileselect_view.adapter.BooksOnDiskListItem
|
||||||
import org.kiwix.kiwixmobile.core.zim_manager.fileselect_view.adapter.BooksOnDiskListItem.BookOnDisk
|
import org.kiwix.kiwixmobile.core.zim_manager.fileselect_view.adapter.BooksOnDiskListItem.BookOnDisk
|
||||||
import org.kiwix.kiwixmobile.ui.BookItem
|
import org.kiwix.kiwixmobile.ui.BookItem
|
||||||
@ -207,13 +209,14 @@ fun NoFilesView(
|
|||||||
onDownloadButtonClick: () -> Unit
|
onDownloadButtonClick: () -> Unit
|
||||||
) {
|
) {
|
||||||
Column(
|
Column(
|
||||||
modifier = Modifier.fillMaxSize(),
|
modifier = Modifier.fillMaxSize().padding(horizontal = FOUR_DP),
|
||||||
horizontalAlignment = Alignment.CenterHorizontally,
|
horizontalAlignment = Alignment.CenterHorizontally,
|
||||||
verticalArrangement = Arrangement.Center
|
verticalArrangement = Arrangement.Center
|
||||||
) {
|
) {
|
||||||
Text(
|
Text(
|
||||||
text = noFilesViewItem.first,
|
text = noFilesViewItem.first,
|
||||||
style = MaterialTheme.typography.titleLarge.copy(fontWeight = FontWeight.Medium)
|
style = MaterialTheme.typography.titleLarge.copy(fontWeight = FontWeight.Medium),
|
||||||
|
textAlign = TextAlign.Center
|
||||||
)
|
)
|
||||||
Spacer(modifier = Modifier.height(EIGHT_DP))
|
Spacer(modifier = Modifier.height(EIGHT_DP))
|
||||||
KiwixButton(noFilesViewItem.second, onDownloadButtonClick)
|
KiwixButton(noFilesViewItem.second, onDownloadButtonClick)
|
||||||
|
@ -25,6 +25,7 @@ import androidx.compose.material3.SnackbarHost
|
|||||||
import androidx.compose.material3.SnackbarHostState
|
import androidx.compose.material3.SnackbarHostState
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import org.kiwix.kiwixmobile.core.ui.theme.DenimBlue400
|
import org.kiwix.kiwixmobile.core.ui.theme.DenimBlue400
|
||||||
|
import org.kiwix.kiwixmobile.core.ui.theme.KiwixSnackToastTheme
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A custom SnackbarHost for displaying snackbars with theme-aware action button colors.
|
* A custom SnackbarHost for displaying snackbars with theme-aware action button colors.
|
||||||
@ -37,6 +38,7 @@ import org.kiwix.kiwixmobile.core.ui.theme.DenimBlue400
|
|||||||
*/
|
*/
|
||||||
@Composable
|
@Composable
|
||||||
fun KiwixSnackbarHost(snackbarHostState: SnackbarHostState) {
|
fun KiwixSnackbarHost(snackbarHostState: SnackbarHostState) {
|
||||||
|
KiwixSnackToastTheme {
|
||||||
val actionColor = if (isSystemInDarkTheme()) {
|
val actionColor = if (isSystemInDarkTheme()) {
|
||||||
MaterialTheme.colorScheme.surface
|
MaterialTheme.colorScheme.surface
|
||||||
} else {
|
} else {
|
||||||
@ -48,4 +50,5 @@ fun KiwixSnackbarHost(snackbarHostState: SnackbarHostState) {
|
|||||||
actionColor = actionColor
|
actionColor = actionColor
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,9 @@ import androidx.compose.material3.MaterialTheme
|
|||||||
import androidx.compose.material3.darkColorScheme
|
import androidx.compose.material3.darkColorScheme
|
||||||
import androidx.compose.material3.lightColorScheme
|
import androidx.compose.material3.lightColorScheme
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.ui.text.TextStyle
|
||||||
|
import org.kiwix.kiwixmobile.core.utils.ComposeDimens.MEDIUM_BODY_LETTER_SPACING
|
||||||
|
import org.kiwix.kiwixmobile.core.utils.ComposeDimens.MEDIUM_BODY_TEXT_SIZE
|
||||||
|
|
||||||
private val DarkColorScheme = darkColorScheme(
|
private val DarkColorScheme = darkColorScheme(
|
||||||
primary = DenimBlue200,
|
primary = DenimBlue200,
|
||||||
@ -95,3 +98,37 @@ fun KiwixDialogTheme(
|
|||||||
typography = KiwixTypography
|
typography = KiwixTypography
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A custom theme specifically designed for displaying short-lived UI messages,
|
||||||
|
* such as Snackbars, and Toasts.
|
||||||
|
*
|
||||||
|
* This theme overrides the default `bodyMedium` typography to remove bold styling,
|
||||||
|
* ensuring that Snackbar and Toast messages appear in a normal-weight font.
|
||||||
|
*
|
||||||
|
* @param darkTheme Determines whether the theme should use dark mode colors.
|
||||||
|
* Defaults to the system's dark mode setting.
|
||||||
|
* @param content The composable content that will be wrapped with this theme.
|
||||||
|
*/
|
||||||
|
@Composable
|
||||||
|
fun KiwixSnackToastTheme(
|
||||||
|
darkTheme: Boolean = isSystemInDarkTheme(),
|
||||||
|
content: @Composable () -> Unit
|
||||||
|
) {
|
||||||
|
val colorScheme = when {
|
||||||
|
darkTheme -> DarkColorScheme
|
||||||
|
else -> LightColorScheme
|
||||||
|
}
|
||||||
|
val snackBarTypography = KiwixTypography.copy(
|
||||||
|
bodyMedium = TextStyle(
|
||||||
|
fontSize = MEDIUM_BODY_TEXT_SIZE,
|
||||||
|
letterSpacing = MEDIUM_BODY_LETTER_SPACING
|
||||||
|
)
|
||||||
|
)
|
||||||
|
MaterialTheme(
|
||||||
|
colorScheme = colorScheme,
|
||||||
|
content = content,
|
||||||
|
shapes = shapes,
|
||||||
|
typography = snackBarTypography
|
||||||
|
)
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user