From 504844a892635fe9554a3eb907ad328b94ffab29 Mon Sep 17 00:00:00 2001 From: arkon Date: Wed, 31 Aug 2022 16:31:08 -0400 Subject: [PATCH] Make top app bar lift behavior more consistent --- .../presentation/browse/BrowseLatestScreen.kt | 3 +- .../presentation/browse/BrowseSourceScreen.kt | 3 +- .../browse/ExtensionDetailsScreen.kt | 5 ++- .../browse/ExtensionFilterScreen.kt | 5 ++- .../presentation/browse/MigrateMangaScreen.kt | 5 ++- .../browse/SourcesFilterScreen.kt | 5 ++- .../browse/components/BrowseLatestToolbar.kt | 3 ++ .../browse/components/BrowseSourceToolbar.kt | 8 +++++ .../presentation/category/CategoryScreen.kt | 6 ++-- .../presentation/components/Scaffold.kt | 31 +++++++++++++++++-- .../presentation/components/TabbedScreen.kt | 2 -- .../presentation/history/HistoryScreen.kt | 22 ++----------- .../presentation/library/LibraryScreen.kt | 16 +--------- .../kanade/presentation/manga/MangaScreen.kt | 3 -- .../eu/kanade/presentation/more/MoreScreen.kt | 6 ++-- .../presentation/more/about/AboutScreen.kt | 5 ++- .../presentation/more/about/LicensesScreen.kt | 5 ++- .../more/settings/SettingsMainScreen.kt | 6 ++-- .../more/settings/SettingsSearchScreen.kt | 5 ++- .../settings/database/ClearDatabaseScreen.kt | 3 +- .../components/ClearDatabaseToolbar.kt | 3 ++ .../presentation/updates/UpdatesScreen.kt | 13 +------- 22 files changed, 73 insertions(+), 90 deletions(-) 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 73d2f5813f..0eba56cf6d 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 cef02b13d7..3eca115040 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 2d68ebe157..10356878be 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 0243c97643..af2176bf66 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 a2916dc7d3..a0a06519ba 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 37700094b1..13cf93b4ab 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 cbff31300e..46b7bd4c26 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 3f896cc697..2a95bf9bd8 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 0ad6358f6c..0e161e7939 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 08492cdcf1..95d6fbbb81 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 09997eef8c..6f4c1ea769 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 8b28d7c796..4dd6d11718 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 21ebf71774..c45aacd1aa 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 269356de59..b0368a87d8 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 99912891e3..25c12c9056 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 ba5af68d47..89d636a6cf 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 48c94cebc2..cfca9441a1 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 bc07d20861..8fd7b5b009 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 ca42734a60..af391d4611 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 2e0c87282b..ee19250a9f 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 1e92c01250..fce2c7b649 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 ad1ae7111f..4639914247 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,