Improved the toolbar's title in night theme according to our theme.

This commit is contained in:
MohitMaliFtechiz 2025-03-11 14:57:32 +05:30
parent f918fe4eff
commit e153bfc38a

View File

@ -20,6 +20,7 @@ package org.kiwix.kiwixmobile.core.ui.components
import androidx.annotation.StringRes import androidx.annotation.StringRes
import androidx.compose.foundation.background import androidx.compose.foundation.background
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.fillMaxWidth
@ -41,6 +42,8 @@ import androidx.compose.ui.text.font.FontWeight.Companion.SemiBold
import org.kiwix.kiwixmobile.core.ui.models.ActionMenuItem import org.kiwix.kiwixmobile.core.ui.models.ActionMenuItem
import org.kiwix.kiwixmobile.core.ui.models.IconItem import org.kiwix.kiwixmobile.core.ui.models.IconItem
import org.kiwix.kiwixmobile.core.ui.theme.Black import org.kiwix.kiwixmobile.core.ui.theme.Black
import org.kiwix.kiwixmobile.core.ui.theme.KiwixTheme
import org.kiwix.kiwixmobile.core.ui.theme.MineShaftGray350
import org.kiwix.kiwixmobile.core.ui.theme.White import org.kiwix.kiwixmobile.core.ui.theme.White
import org.kiwix.kiwixmobile.core.utils.ComposeDimens.KIWIX_APP_BAR_HEIGHT import org.kiwix.kiwixmobile.core.utils.ComposeDimens.KIWIX_APP_BAR_HEIGHT
import org.kiwix.kiwixmobile.core.utils.ComposeDimens.SIXTEEN_DP import org.kiwix.kiwixmobile.core.utils.ComposeDimens.SIXTEEN_DP
@ -55,23 +58,25 @@ fun KiwixAppBar(
// Optional search bar, used in fragments that require it // Optional search bar, used in fragments that require it
searchBar: (@Composable () -> Unit)? = null searchBar: (@Composable () -> Unit)? = null
) { ) {
Row( KiwixTheme {
modifier = Modifier Row(
.fillMaxWidth() modifier = Modifier
.height(KIWIX_APP_BAR_HEIGHT) .fillMaxWidth()
.background(color = Black), .height(KIWIX_APP_BAR_HEIGHT)
verticalAlignment = Alignment.CenterVertically .background(color = Black),
) { verticalAlignment = Alignment.CenterVertically
navigationIcon() ) {
searchBar?.let { navigationIcon()
// Display the search bar when provided searchBar?.let {
it() // Display the search bar when provided
} ?: run { it()
// Otherwise, show the title } ?: run {
AppBarTitle(titleId) // Otherwise, show the title
AppBarTitle(titleId)
}
Spacer(Modifier.weight(1f))
ActionMenu(actionMenuItems)
} }
Spacer(Modifier.weight(1f))
ActionMenu(actionMenuItems)
} }
} }
@ -79,11 +84,18 @@ fun KiwixAppBar(
private fun AppBarTitle( private fun AppBarTitle(
@StringRes titleId: Int @StringRes titleId: Int
) { ) {
val appBarTitleColor = if (isSystemInDarkTheme()) {
MineShaftGray350
} else {
White
}
Text( Text(
text = stringResource(titleId), text = stringResource(titleId),
color = White, color = appBarTitleColor,
style = MaterialTheme.typography.titleLarge.copy(fontWeight = SemiBold), style = MaterialTheme.typography.titleLarge.copy(fontWeight = SemiBold),
modifier = Modifier.padding(horizontal = SIXTEEN_DP).testTag(TOOLBAR_TITLE_TESTING_TAG) modifier = Modifier
.padding(horizontal = SIXTEEN_DP)
.testTag(TOOLBAR_TITLE_TESTING_TAG)
) )
} }