Move app state banner to the very top (#8706)
This moves the banners to the root composable and so eliminates the need to track the app states in every screen.
This commit is contained in:
@@ -63,9 +63,6 @@ fun AppBar(
|
||||
actionModeCounter: Int = 0,
|
||||
onCancelActionMode: () -> Unit = {},
|
||||
actionModeActions: @Composable RowScope.() -> Unit = {},
|
||||
// Banners
|
||||
downloadedOnlyMode: Boolean = false,
|
||||
incognitoMode: Boolean = false,
|
||||
|
||||
scrollBehavior: TopAppBarScrollBehavior? = null,
|
||||
) {
|
||||
@@ -93,8 +90,6 @@ fun AppBar(
|
||||
},
|
||||
isActionMode = isActionMode,
|
||||
onCancelActionMode = onCancelActionMode,
|
||||
downloadedOnlyMode = downloadedOnlyMode,
|
||||
incognitoMode = incognitoMode,
|
||||
scrollBehavior = scrollBehavior,
|
||||
)
|
||||
}
|
||||
@@ -112,9 +107,6 @@ fun AppBar(
|
||||
// Action mode
|
||||
isActionMode: Boolean = false,
|
||||
onCancelActionMode: () -> Unit = {},
|
||||
// Banners
|
||||
downloadedOnlyMode: Boolean = false,
|
||||
incognitoMode: Boolean = false,
|
||||
|
||||
scrollBehavior: TopAppBarScrollBehavior? = null,
|
||||
) {
|
||||
@@ -150,8 +142,6 @@ fun AppBar(
|
||||
),
|
||||
scrollBehavior = scrollBehavior,
|
||||
)
|
||||
|
||||
AppStateBanners(downloadedOnlyMode, incognitoMode)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -236,8 +226,6 @@ fun SearchToolbar(
|
||||
onSearch: (String) -> Unit = {},
|
||||
onClickCloseSearch: () -> Unit = { onChangeSearchQuery(null) },
|
||||
actions: @Composable RowScope.() -> Unit = {},
|
||||
incognitoMode: Boolean = false,
|
||||
downloadedOnlyMode: Boolean = false,
|
||||
scrollBehavior: TopAppBarScrollBehavior? = null,
|
||||
visualTransformation: VisualTransformation = VisualTransformation.None,
|
||||
interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
|
||||
@@ -326,8 +314,6 @@ fun SearchToolbar(
|
||||
key("actions") { actions() }
|
||||
},
|
||||
isActionMode = false,
|
||||
downloadedOnlyMode = downloadedOnlyMode,
|
||||
incognitoMode = incognitoMode,
|
||||
scrollBehavior = scrollBehavior,
|
||||
)
|
||||
LaunchedEffect(searchClickCount) {
|
||||
|
||||
@@ -3,8 +3,13 @@ package eu.kanade.presentation.components
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.WindowInsets
|
||||
import androidx.compose.foundation.layout.WindowInsetsSides
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.only
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.systemBars
|
||||
import androidx.compose.foundation.layout.windowInsetsPadding
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
@@ -37,24 +42,34 @@ fun AppStateBanners(
|
||||
incognitoMode: Boolean,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
val insets = WindowInsets.systemBars.only(WindowInsetsSides.Top + WindowInsetsSides.Horizontal)
|
||||
Column(modifier = modifier) {
|
||||
if (downloadedOnlyMode) {
|
||||
DownloadedOnlyModeBanner()
|
||||
DownloadedOnlyModeBanner(
|
||||
modifier = Modifier.windowInsetsPadding(insets),
|
||||
)
|
||||
}
|
||||
if (incognitoMode) {
|
||||
IncognitoModeBanner()
|
||||
IncognitoModeBanner(
|
||||
modifier = if (!downloadedOnlyMode) {
|
||||
Modifier.windowInsetsPadding(insets)
|
||||
} else {
|
||||
Modifier
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun DownloadedOnlyModeBanner() {
|
||||
private fun DownloadedOnlyModeBanner(modifier: Modifier = Modifier) {
|
||||
Text(
|
||||
text = stringResource(R.string.label_downloaded_only),
|
||||
modifier = Modifier
|
||||
.background(color = MaterialTheme.colorScheme.tertiary)
|
||||
.fillMaxWidth()
|
||||
.padding(4.dp),
|
||||
.padding(4.dp)
|
||||
.then(modifier),
|
||||
color = MaterialTheme.colorScheme.onTertiary,
|
||||
textAlign = TextAlign.Center,
|
||||
style = MaterialTheme.typography.labelMedium,
|
||||
@@ -62,13 +77,14 @@ private fun DownloadedOnlyModeBanner() {
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun IncognitoModeBanner() {
|
||||
private fun IncognitoModeBanner(modifier: Modifier = Modifier) {
|
||||
Text(
|
||||
text = stringResource(R.string.pref_incognito_mode),
|
||||
modifier = Modifier
|
||||
.background(color = MaterialTheme.colorScheme.primary)
|
||||
.fillMaxWidth()
|
||||
.padding(4.dp),
|
||||
.padding(4.dp)
|
||||
.then(modifier),
|
||||
color = MaterialTheme.colorScheme.onPrimary,
|
||||
textAlign = TextAlign.Center,
|
||||
style = MaterialTheme.typography.labelMedium,
|
||||
|
||||
@@ -29,8 +29,6 @@ fun TabbedScreen(
|
||||
startIndex: Int? = null,
|
||||
searchQuery: String? = null,
|
||||
onChangeSearchQuery: (String?) -> Unit = {},
|
||||
incognitoMode: Boolean,
|
||||
downloadedOnlyMode: Boolean,
|
||||
) {
|
||||
val scope = rememberCoroutineScope()
|
||||
val state = rememberPagerState()
|
||||
@@ -78,8 +76,6 @@ fun TabbedScreen(
|
||||
}
|
||||
}
|
||||
|
||||
AppStateBanners(downloadedOnlyMode, incognitoMode)
|
||||
|
||||
HorizontalPager(
|
||||
count = tabs.size,
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
|
||||
Reference in New Issue
Block a user