diff --git a/app/src/main/java/eu/kanade/presentation/browse/BrowseLatestScreen.kt b/app/src/main/java/eu/kanade/presentation/browse/BrowseLatestScreen.kt index 73d2f5813..0eba56cf6 100644 --- a/app/src/main/java/eu/kanade/presentation/browse/BrowseLatestScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/browse/BrowseLatestScreen.kt @@ -38,7 +38,7 @@ fun BrowseLatestScreen( } Scaffold( - topBar = { + topBar = { scrollBehavior -> BrowseLatestToolbar( navigateUp = navigateUp, source = presenter.source!!, @@ -46,6 +46,7 @@ fun BrowseLatestScreen( onDisplayModeChange = { presenter.displayMode = it }, onHelpClick = onHelpClick, onWebViewClick = onWebViewClick, + scrollBehavior = scrollBehavior, ) }, ) { paddingValues -> diff --git a/app/src/main/java/eu/kanade/presentation/browse/BrowseSourceScreen.kt b/app/src/main/java/eu/kanade/presentation/browse/BrowseSourceScreen.kt index cef02b13d..3eca11504 100644 --- a/app/src/main/java/eu/kanade/presentation/browse/BrowseSourceScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/browse/BrowseSourceScreen.kt @@ -71,7 +71,7 @@ fun BrowseSourceScreen( } Scaffold( - topBar = { + topBar = { scrollBehavior -> BrowseSourceToolbar( state = presenter, source = presenter.source!!, @@ -81,6 +81,7 @@ fun BrowseSourceScreen( onWebViewClick = onWebViewClick, onHelpClick = onHelpClick, onSearch = { presenter.search() }, + scrollBehavior = scrollBehavior, ) }, floatingActionButton = { diff --git a/app/src/main/java/eu/kanade/presentation/browse/ExtensionDetailsScreen.kt b/app/src/main/java/eu/kanade/presentation/browse/ExtensionDetailsScreen.kt index 2d68ebe15..10356878b 100644 --- a/app/src/main/java/eu/kanade/presentation/browse/ExtensionDetailsScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/browse/ExtensionDetailsScreen.kt @@ -21,7 +21,6 @@ import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.navigationBars import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size -import androidx.compose.foundation.layout.statusBarsPadding import androidx.compose.foundation.layout.width import androidx.compose.foundation.lazy.items import androidx.compose.material.icons.Icons @@ -80,8 +79,7 @@ fun ExtensionDetailsScreen( val uriHandler = LocalUriHandler.current Scaffold( - modifier = Modifier.statusBarsPadding(), - topBar = { + topBar = { scrollBehavior -> AppBar( title = stringResource(R.string.label_extension_info), navigateUp = navigateUp, @@ -123,6 +121,7 @@ fun ExtensionDetailsScreen( }, ) }, + scrollBehavior = scrollBehavior, ) }, ) { paddingValues -> diff --git a/app/src/main/java/eu/kanade/presentation/browse/ExtensionFilterScreen.kt b/app/src/main/java/eu/kanade/presentation/browse/ExtensionFilterScreen.kt index 0243c9764..af2176bf6 100644 --- a/app/src/main/java/eu/kanade/presentation/browse/ExtensionFilterScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/browse/ExtensionFilterScreen.kt @@ -4,7 +4,6 @@ import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.WindowInsets import androidx.compose.foundation.layout.asPaddingValues import androidx.compose.foundation.layout.navigationBars -import androidx.compose.foundation.layout.statusBarsPadding import androidx.compose.foundation.lazy.items import androidx.compose.material3.Switch import androidx.compose.runtime.Composable @@ -32,11 +31,11 @@ fun ExtensionFilterScreen( ) { val context = LocalContext.current Scaffold( - modifier = Modifier.statusBarsPadding(), - topBar = { + topBar = { scrollBehavior -> AppBar( title = stringResource(R.string.label_extensions), navigateUp = navigateUp, + scrollBehavior = scrollBehavior, ) }, ) { paddingValues -> diff --git a/app/src/main/java/eu/kanade/presentation/browse/MigrateMangaScreen.kt b/app/src/main/java/eu/kanade/presentation/browse/MigrateMangaScreen.kt index a2916dc7d..a0a06519b 100644 --- a/app/src/main/java/eu/kanade/presentation/browse/MigrateMangaScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/browse/MigrateMangaScreen.kt @@ -4,7 +4,6 @@ import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.WindowInsets import androidx.compose.foundation.layout.asPaddingValues import androidx.compose.foundation.layout.navigationBars -import androidx.compose.foundation.layout.statusBarsPadding import androidx.compose.foundation.lazy.items import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect @@ -34,11 +33,11 @@ fun MigrateMangaScreen( ) { val context = LocalContext.current Scaffold( - modifier = Modifier.statusBarsPadding(), - topBar = { + topBar = { scrollBehavior -> AppBar( title = title, navigateUp = navigateUp, + scrollBehavior = scrollBehavior, ) }, ) { paddingValues -> diff --git a/app/src/main/java/eu/kanade/presentation/browse/SourcesFilterScreen.kt b/app/src/main/java/eu/kanade/presentation/browse/SourcesFilterScreen.kt index 37700094b..13cf93b4a 100644 --- a/app/src/main/java/eu/kanade/presentation/browse/SourcesFilterScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/browse/SourcesFilterScreen.kt @@ -4,7 +4,6 @@ import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.WindowInsets import androidx.compose.foundation.layout.asPaddingValues import androidx.compose.foundation.layout.navigationBars -import androidx.compose.foundation.layout.statusBarsPadding import androidx.compose.foundation.lazy.items import androidx.compose.material3.Checkbox import androidx.compose.material3.Switch @@ -38,11 +37,11 @@ fun SourcesFilterScreen( ) { val context = LocalContext.current Scaffold( - modifier = Modifier.statusBarsPadding(), - topBar = { + topBar = { scrollBehavior -> AppBar( title = stringResource(R.string.label_sources), navigateUp = navigateUp, + scrollBehavior = scrollBehavior, ) }, ) { paddingValues -> diff --git a/app/src/main/java/eu/kanade/presentation/browse/components/BrowseLatestToolbar.kt b/app/src/main/java/eu/kanade/presentation/browse/components/BrowseLatestToolbar.kt index cbff31300..46b7bd4c2 100644 --- a/app/src/main/java/eu/kanade/presentation/browse/components/BrowseLatestToolbar.kt +++ b/app/src/main/java/eu/kanade/presentation/browse/components/BrowseLatestToolbar.kt @@ -9,6 +9,7 @@ import androidx.compose.material.icons.outlined.ViewModule import androidx.compose.material3.DropdownMenuItem import androidx.compose.material3.Icon import androidx.compose.material3.Text +import androidx.compose.material3.TopAppBarScrollBehavior import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf @@ -31,6 +32,7 @@ fun BrowseLatestToolbar( onDisplayModeChange: (LibraryDisplayMode) -> Unit, onHelpClick: () -> Unit, onWebViewClick: () -> Unit, + scrollBehavior: TopAppBarScrollBehavior, ) { AppBar( navigateUp = navigateUp, @@ -101,5 +103,6 @@ fun BrowseLatestToolbar( ) } }, + scrollBehavior = scrollBehavior, ) } diff --git a/app/src/main/java/eu/kanade/presentation/browse/components/BrowseSourceToolbar.kt b/app/src/main/java/eu/kanade/presentation/browse/components/BrowseSourceToolbar.kt index 3f896cc69..2a95bf9bd 100644 --- a/app/src/main/java/eu/kanade/presentation/browse/components/BrowseSourceToolbar.kt +++ b/app/src/main/java/eu/kanade/presentation/browse/components/BrowseSourceToolbar.kt @@ -15,6 +15,7 @@ import androidx.compose.material3.DropdownMenuItem import androidx.compose.material3.Icon import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text +import androidx.compose.material3.TopAppBarScrollBehavior import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue @@ -47,6 +48,7 @@ fun BrowseSourceToolbar( onWebViewClick: () -> Unit, onHelpClick: () -> Unit, onSearch: () -> Unit, + scrollBehavior: TopAppBarScrollBehavior, ) { if (state.searchQuery == null) { BrowseSourceRegularToolbar( @@ -57,6 +59,7 @@ fun BrowseSourceToolbar( onSearchClick = { state.searchQuery = "" }, onWebViewClick = onWebViewClick, onHelpClick = onHelpClick, + scrollBehavior = scrollBehavior, ) } else { BrowseSourceSearchToolbar( @@ -68,6 +71,7 @@ fun BrowseSourceToolbar( }, onResetClick = { state.searchQuery = "" }, onSearchClick = onSearch, + scrollBehavior = scrollBehavior, ) } } @@ -81,6 +85,7 @@ fun BrowseSourceRegularToolbar( onSearchClick: () -> Unit, onWebViewClick: () -> Unit, onHelpClick: () -> Unit, + scrollBehavior: TopAppBarScrollBehavior, ) { AppBar( navigateUp = navigateUp, @@ -156,6 +161,7 @@ fun BrowseSourceRegularToolbar( ) } }, + scrollBehavior = scrollBehavior, ) } @@ -166,6 +172,7 @@ fun BrowseSourceSearchToolbar( navigateUp: () -> Unit, onResetClick: () -> Unit, onSearchClick: () -> Unit, + scrollBehavior: TopAppBarScrollBehavior, ) { val focusRequester = remember { FocusRequester() } AppBar( @@ -197,6 +204,7 @@ fun BrowseSourceSearchToolbar( ), ) }, + scrollBehavior = scrollBehavior, ) LaunchedEffect(Unit) { // TODO: https://issuetracker.google.com/issues/204502668 diff --git a/app/src/main/java/eu/kanade/presentation/category/CategoryScreen.kt b/app/src/main/java/eu/kanade/presentation/category/CategoryScreen.kt index 0ad6358f6..0e161e793 100644 --- a/app/src/main/java/eu/kanade/presentation/category/CategoryScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/category/CategoryScreen.kt @@ -1,11 +1,9 @@ package eu.kanade.presentation.category import androidx.compose.foundation.layout.PaddingValues -import androidx.compose.foundation.layout.statusBarsPadding import androidx.compose.foundation.lazy.rememberLazyListState import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect -import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource import eu.kanade.presentation.category.components.CategoryContent @@ -33,11 +31,11 @@ fun CategoryScreen( ) { val lazyListState = rememberLazyListState() Scaffold( - modifier = Modifier.statusBarsPadding(), - topBar = { + topBar = { scrollBehavior -> AppBar( title = stringResource(R.string.action_edit_categories), navigateUp = navigateUp, + scrollBehavior = scrollBehavior, ) }, floatingActionButton = { diff --git a/app/src/main/java/eu/kanade/presentation/components/Scaffold.kt b/app/src/main/java/eu/kanade/presentation/components/Scaffold.kt index 08492cdcf..95d6fbbb8 100644 --- a/app/src/main/java/eu/kanade/presentation/components/Scaffold.kt +++ b/app/src/main/java/eu/kanade/presentation/components/Scaffold.kt @@ -17,6 +17,12 @@ package eu.kanade.presentation.components import androidx.compose.foundation.layout.PaddingValues +import androidx.compose.foundation.layout.WindowInsets +import androidx.compose.foundation.layout.WindowInsetsSides +import androidx.compose.foundation.layout.asPaddingValues +import androidx.compose.foundation.layout.navigationBars +import androidx.compose.foundation.layout.only +import androidx.compose.foundation.layout.padding import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.FloatingActionButton import androidx.compose.material3.LocalContentColor @@ -27,13 +33,17 @@ import androidx.compose.material3.Snackbar import androidx.compose.material3.SnackbarHost import androidx.compose.material3.SnackbarHostState import androidx.compose.material3.Surface +import androidx.compose.material3.TopAppBarDefaults +import androidx.compose.material3.TopAppBarScrollBehavior import androidx.compose.material3.contentColorFor +import androidx.compose.material3.rememberTopAppBarState import androidx.compose.runtime.Composable import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.runtime.Immutable import androidx.compose.runtime.staticCompositionLocalOf import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color +import androidx.compose.ui.input.nestedscroll.nestedScroll import androidx.compose.ui.layout.SubcomposeLayout import androidx.compose.ui.unit.Constraints import androidx.compose.ui.unit.LayoutDirection @@ -81,7 +91,7 @@ import androidx.compose.ui.unit.dp @Composable fun Scaffold( modifier: Modifier = Modifier, - topBar: @Composable () -> Unit = {}, + topBar: @Composable (TopAppBarScrollBehavior) -> Unit = {}, bottomBar: @Composable () -> Unit = {}, snackbarHost: @Composable () -> Unit = {}, floatingActionButton: @Composable () -> Unit = {}, @@ -90,10 +100,25 @@ fun Scaffold( contentColor: Color = contentColorFor(containerColor), content: @Composable (PaddingValues) -> Unit, ) { - Surface(modifier = modifier, color = containerColor, contentColor = contentColor) { + /** + * Tachiyomi: always handle insets and pass scroll behavior to topBar + */ + val insetPaddingValue = WindowInsets.navigationBars + .only(WindowInsetsSides.Horizontal + WindowInsetsSides.Bottom) + .asPaddingValues() + val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior(rememberTopAppBarState()) + + Surface( + modifier = Modifier + .padding(insetPaddingValue) + .nestedScroll(scrollBehavior.nestedScrollConnection) + .then(modifier), + color = containerColor, + contentColor = contentColor, + ) { ScaffoldLayout( fabPosition = floatingActionButtonPosition, - topBar = topBar, + topBar = { topBar(scrollBehavior) }, bottomBar = bottomBar, content = content, snackbar = snackbarHost, diff --git a/app/src/main/java/eu/kanade/presentation/components/TabbedScreen.kt b/app/src/main/java/eu/kanade/presentation/components/TabbedScreen.kt index 09997eef8..6f4c1ea76 100644 --- a/app/src/main/java/eu/kanade/presentation/components/TabbedScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/components/TabbedScreen.kt @@ -4,7 +4,6 @@ import androidx.annotation.StringRes import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.statusBarsPadding import androidx.compose.material3.Tab import androidx.compose.material3.TabRow import androidx.compose.runtime.Composable @@ -33,7 +32,6 @@ fun TabbedScreen( } Scaffold( - modifier = Modifier.statusBarsPadding(), topBar = { AppBar( title = stringResource(titleRes), diff --git a/app/src/main/java/eu/kanade/presentation/history/HistoryScreen.kt b/app/src/main/java/eu/kanade/presentation/history/HistoryScreen.kt index 8b28d7c79..4dd6d1171 100644 --- a/app/src/main/java/eu/kanade/presentation/history/HistoryScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/history/HistoryScreen.kt @@ -1,23 +1,13 @@ package eu.kanade.presentation.history -import androidx.compose.foundation.layout.WindowInsets -import androidx.compose.foundation.layout.WindowInsetsSides -import androidx.compose.foundation.layout.asPaddingValues -import androidx.compose.foundation.layout.navigationBars -import androidx.compose.foundation.layout.only -import androidx.compose.foundation.layout.padding -import androidx.compose.material3.Scaffold -import androidx.compose.material3.TopAppBarDefaults -import androidx.compose.material3.rememberTopAppBarState import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect -import androidx.compose.ui.Modifier -import androidx.compose.ui.input.nestedscroll.nestedScroll import androidx.compose.ui.platform.LocalContext import androidx.paging.LoadState import eu.kanade.domain.history.model.HistoryWithRelations import eu.kanade.presentation.components.EmptyScreen import eu.kanade.presentation.components.LoadingScreen +import eu.kanade.presentation.components.Scaffold import eu.kanade.presentation.history.components.HistoryContent import eu.kanade.presentation.history.components.HistoryDeleteAllDialog import eu.kanade.presentation.history.components.HistoryDeleteDialog @@ -38,15 +28,9 @@ fun HistoryScreen( onClickResume: (HistoryWithRelations) -> Unit, ) { val context = LocalContext.current - val insetPaddingValue = WindowInsets.navigationBars - .only(WindowInsetsSides.Horizontal + WindowInsetsSides.Bottom) - .asPaddingValues() - val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior(rememberTopAppBarState()) + Scaffold( - modifier = Modifier - .padding(insetPaddingValue) - .nestedScroll(scrollBehavior.nestedScrollConnection), - topBar = { + topBar = { scrollBehavior -> HistoryToolbar( state = presenter, incognitoMode = presenter.isIncognitoMode, diff --git a/app/src/main/java/eu/kanade/presentation/library/LibraryScreen.kt b/app/src/main/java/eu/kanade/presentation/library/LibraryScreen.kt index 21ebf7177..c45aacd1a 100644 --- a/app/src/main/java/eu/kanade/presentation/library/LibraryScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/library/LibraryScreen.kt @@ -1,17 +1,8 @@ package eu.kanade.presentation.library import androidx.compose.animation.Crossfade -import androidx.compose.foundation.layout.WindowInsets -import androidx.compose.foundation.layout.WindowInsetsSides -import androidx.compose.foundation.layout.navigationBars -import androidx.compose.foundation.layout.only -import androidx.compose.foundation.layout.windowInsetsPadding -import androidx.compose.material3.TopAppBarDefaults -import androidx.compose.material3.rememberTopAppBarState import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue -import androidx.compose.ui.Modifier -import androidx.compose.ui.input.nestedscroll.nestedScroll import eu.kanade.domain.category.model.Category import eu.kanade.presentation.components.LibraryBottomActionMenu import eu.kanade.presentation.components.LoadingScreen @@ -37,16 +28,11 @@ fun LibraryScreen( onClickFilter: () -> Unit, onClickRefresh: (Category?) -> Boolean, ) { - val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior(rememberTopAppBarState()) - val insets = WindowInsets.navigationBars.only(WindowInsetsSides.Horizontal) Crossfade(targetState = presenter.isLoading) { state -> when (state) { true -> LoadingScreen() false -> Scaffold( - modifier = Modifier - .windowInsetsPadding(insets) - .nestedScroll(scrollBehavior.nestedScrollConnection), - topBar = { + topBar = { scrollBehavior -> val title by presenter.getToolbarTitle() val tabVisible = presenter.tabVisibility && presenter.categories.size > 1 LibraryToolbar( diff --git a/app/src/main/java/eu/kanade/presentation/manga/MangaScreen.kt b/app/src/main/java/eu/kanade/presentation/manga/MangaScreen.kt index 269356de5..b0368a87d 100644 --- a/app/src/main/java/eu/kanade/presentation/manga/MangaScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/manga/MangaScreen.kt @@ -210,7 +210,6 @@ private fun MangaScreenSmallImpl( val layoutDirection = LocalLayoutDirection.current val chapterListState = rememberLazyListState() - val insetPadding = WindowInsets.systemBars.only(WindowInsetsSides.Horizontal).asPaddingValues() val chapters = remember(state) { state.processedChapters.toList() } val internalOnBackPressed = { @@ -223,8 +222,6 @@ private fun MangaScreenSmallImpl( BackHandler(onBack = internalOnBackPressed) Scaffold( - modifier = Modifier - .padding(insetPadding), topBar = { val firstVisibleItemIndex by remember { derivedStateOf { chapterListState.firstVisibleItemIndex } diff --git a/app/src/main/java/eu/kanade/presentation/more/MoreScreen.kt b/app/src/main/java/eu/kanade/presentation/more/MoreScreen.kt index 99912891e..25c12c905 100644 --- a/app/src/main/java/eu/kanade/presentation/more/MoreScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/more/MoreScreen.kt @@ -3,7 +3,6 @@ package eu.kanade.presentation.more import androidx.compose.foundation.layout.WindowInsets import androidx.compose.foundation.layout.asPaddingValues import androidx.compose.foundation.layout.navigationBars -import androidx.compose.foundation.layout.statusBarsPadding import androidx.compose.material.icons.Icons import androidx.compose.material.icons.outlined.CloudOff import androidx.compose.material.icons.outlined.GetApp @@ -15,7 +14,6 @@ import androidx.compose.material.icons.outlined.SettingsBackupRestore import androidx.compose.runtime.Composable import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue -import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.vector.rememberVectorPainter import androidx.compose.ui.platform.LocalUriHandler import androidx.compose.ui.res.painterResource @@ -47,12 +45,12 @@ fun MoreScreen( val downloadQueueState by presenter.downloadQueueState.collectAsState() Scaffold( - modifier = Modifier.statusBarsPadding(), - topBar = { + topBar = { scrollBehavior -> AppBar( title = stringResource(R.string.label_more), downloadedOnlyMode = presenter.downloadedOnly.value, incognitoMode = presenter.incognitoMode.value, + scrollBehavior = scrollBehavior, ) }, ) { paddingValues -> diff --git a/app/src/main/java/eu/kanade/presentation/more/about/AboutScreen.kt b/app/src/main/java/eu/kanade/presentation/more/about/AboutScreen.kt index ba5af68d4..89d636a6c 100644 --- a/app/src/main/java/eu/kanade/presentation/more/about/AboutScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/more/about/AboutScreen.kt @@ -6,7 +6,6 @@ import androidx.compose.foundation.layout.WindowInsets import androidx.compose.foundation.layout.asPaddingValues import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.navigationBars -import androidx.compose.foundation.layout.statusBarsPadding import androidx.compose.material.icons.Icons import androidx.compose.material.icons.outlined.Public import androidx.compose.runtime.Composable @@ -40,11 +39,11 @@ fun AboutScreen( val uriHandler = LocalUriHandler.current Scaffold( - modifier = Modifier.statusBarsPadding(), - topBar = { + topBar = { scrollBehavior -> AppBar( title = stringResource(R.string.pref_category_about), navigateUp = navigateUp, + scrollBehavior = scrollBehavior, ) }, ) { paddingValues -> diff --git a/app/src/main/java/eu/kanade/presentation/more/about/LicensesScreen.kt b/app/src/main/java/eu/kanade/presentation/more/about/LicensesScreen.kt index 48c94cebc..cfca9441a 100644 --- a/app/src/main/java/eu/kanade/presentation/more/about/LicensesScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/more/about/LicensesScreen.kt @@ -4,7 +4,6 @@ import androidx.compose.foundation.layout.WindowInsets import androidx.compose.foundation.layout.asPaddingValues import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.navigationBars -import androidx.compose.foundation.layout.statusBarsPadding import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier @@ -21,11 +20,11 @@ fun LicensesScreen( navigateUp: () -> Unit, ) { Scaffold( - modifier = Modifier.statusBarsPadding(), - topBar = { + topBar = { scrollBehavior -> AppBar( title = stringResource(R.string.licenses), navigateUp = navigateUp, + scrollBehavior = scrollBehavior, ) }, ) { paddingValues -> diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/SettingsMainScreen.kt b/app/src/main/java/eu/kanade/presentation/more/settings/SettingsMainScreen.kt index bc07d2086..8fd7b5b00 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/SettingsMainScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/SettingsMainScreen.kt @@ -4,11 +4,9 @@ import androidx.annotation.StringRes import androidx.compose.foundation.layout.WindowInsets import androidx.compose.foundation.layout.asPaddingValues import androidx.compose.foundation.layout.navigationBars -import androidx.compose.foundation.layout.statusBarsPadding import androidx.compose.material.icons.Icons import androidx.compose.material.icons.outlined.Search import androidx.compose.runtime.Composable -import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.painter.Painter import androidx.compose.ui.res.stringResource import eu.kanade.presentation.components.AppBar @@ -26,8 +24,7 @@ fun SettingsMainScreen( onClickSearch: () -> Unit, ) { Scaffold( - modifier = Modifier.statusBarsPadding(), - topBar = { + topBar = { scrollBehavior -> AppBar( title = stringResource(R.string.label_settings), navigateUp = navigateUp, @@ -42,6 +39,7 @@ fun SettingsMainScreen( ), ) }, + scrollBehavior = scrollBehavior, ) }, ) { paddingValues -> diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/SettingsSearchScreen.kt b/app/src/main/java/eu/kanade/presentation/more/settings/SettingsSearchScreen.kt index ca42734a6..af391d461 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/SettingsSearchScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/SettingsSearchScreen.kt @@ -7,7 +7,6 @@ import androidx.compose.foundation.layout.asPaddingValues import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.navigationBars import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.statusBarsPadding import androidx.compose.foundation.lazy.items import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text @@ -39,8 +38,7 @@ fun SettingsSearchScreen( var query by remember { mutableStateOf("") } Scaffold( - modifier = Modifier.statusBarsPadding(), - topBar = { + topBar = { scrollBehavior -> SearchToolbar( searchQuery = query, onChangeSearchQuery = { @@ -49,6 +47,7 @@ fun SettingsSearchScreen( }, onClickCloseSearch = navigateUp, onClickResetSearch = { query = "" }, + scrollBehavior = scrollBehavior, ) // TODO: search placeholder diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/database/ClearDatabaseScreen.kt b/app/src/main/java/eu/kanade/presentation/more/settings/database/ClearDatabaseScreen.kt index 2e0c87282..ee19250a9 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/database/ClearDatabaseScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/database/ClearDatabaseScreen.kt @@ -19,12 +19,13 @@ fun ClearDatabaseScreen( ) { val context = LocalContext.current Scaffold( - topBar = { + topBar = { scrollBehavior -> ClearDatabaseToolbar( state = presenter, navigateUp = navigateUp, onClickSelectAll = { presenter.selectAll() }, onClickInvertSelection = { presenter.invertSelection() }, + scrollBehavior = scrollBehavior, ) }, floatingActionButton = { diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/database/components/ClearDatabaseToolbar.kt b/app/src/main/java/eu/kanade/presentation/more/settings/database/components/ClearDatabaseToolbar.kt index 1e92c0125..fce2c7b64 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/database/components/ClearDatabaseToolbar.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/database/components/ClearDatabaseToolbar.kt @@ -3,6 +3,7 @@ package eu.kanade.presentation.more.settings.database.components import androidx.compose.material.icons.Icons import androidx.compose.material.icons.outlined.FlipToBack import androidx.compose.material.icons.outlined.SelectAll +import androidx.compose.material3.TopAppBarScrollBehavior import androidx.compose.runtime.Composable import androidx.compose.ui.res.stringResource import eu.kanade.presentation.components.AppBar @@ -16,6 +17,7 @@ fun ClearDatabaseToolbar( navigateUp: () -> Unit, onClickSelectAll: () -> Unit, onClickInvertSelection: () -> Unit, + scrollBehavior: TopAppBarScrollBehavior, ) { AppBar( title = stringResource(R.string.pref_clear_database), @@ -38,5 +40,6 @@ fun ClearDatabaseToolbar( ) } }, + scrollBehavior = scrollBehavior, ) } diff --git a/app/src/main/java/eu/kanade/presentation/updates/UpdatesScreen.kt b/app/src/main/java/eu/kanade/presentation/updates/UpdatesScreen.kt index ad1ae7111..463991424 100644 --- a/app/src/main/java/eu/kanade/presentation/updates/UpdatesScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/updates/UpdatesScreen.kt @@ -10,7 +10,6 @@ import androidx.compose.foundation.layout.fillMaxHeight import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.navigationBars import androidx.compose.foundation.layout.only -import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.rememberLazyListState import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.FlipToBack @@ -18,9 +17,7 @@ import androidx.compose.material.icons.filled.Refresh import androidx.compose.material.icons.filled.SelectAll import androidx.compose.material3.Icon import androidx.compose.material3.IconButton -import androidx.compose.material3.TopAppBarDefaults import androidx.compose.material3.TopAppBarScrollBehavior -import androidx.compose.material3.rememberTopAppBarState import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue @@ -29,7 +26,6 @@ import androidx.compose.runtime.remember import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier -import androidx.compose.ui.input.nestedscroll.nestedScroll import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalLayoutDirection import androidx.compose.ui.res.stringResource @@ -67,9 +63,6 @@ fun UpdateScreen( onDownloadChapter: (List, ChapterDownloadAction) -> Unit, ) { val updatesListState = rememberLazyListState() - val insetPaddingValue = WindowInsets.navigationBars - .only(WindowInsetsSides.Horizontal) - .asPaddingValues() val internalOnBackPressed = { if (presenter.selectionMode) { @@ -88,12 +81,8 @@ fun UpdateScreen( started } - val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior(rememberTopAppBarState()) Scaffold( - modifier = Modifier - .padding(insetPaddingValue) - .nestedScroll(scrollBehavior.nestedScrollConnection), - topBar = { + topBar = { scrollBehavior -> UpdatesAppBar( incognitoMode = presenter.isIncognitoMode, downloadedOnlyMode = presenter.isDownloadOnly,