Make top app bar lift behavior more consistent

This commit is contained in:
arkon 2022-08-31 16:31:08 -04:00
parent 4c1da1bd1d
commit 504844a892
22 changed files with 73 additions and 90 deletions

View File

@ -38,7 +38,7 @@ fun BrowseLatestScreen(
} }
Scaffold( Scaffold(
topBar = { topBar = { scrollBehavior ->
BrowseLatestToolbar( BrowseLatestToolbar(
navigateUp = navigateUp, navigateUp = navigateUp,
source = presenter.source!!, source = presenter.source!!,
@ -46,6 +46,7 @@ fun BrowseLatestScreen(
onDisplayModeChange = { presenter.displayMode = it }, onDisplayModeChange = { presenter.displayMode = it },
onHelpClick = onHelpClick, onHelpClick = onHelpClick,
onWebViewClick = onWebViewClick, onWebViewClick = onWebViewClick,
scrollBehavior = scrollBehavior,
) )
}, },
) { paddingValues -> ) { paddingValues ->

View File

@ -71,7 +71,7 @@ fun BrowseSourceScreen(
} }
Scaffold( Scaffold(
topBar = { topBar = { scrollBehavior ->
BrowseSourceToolbar( BrowseSourceToolbar(
state = presenter, state = presenter,
source = presenter.source!!, source = presenter.source!!,
@ -81,6 +81,7 @@ fun BrowseSourceScreen(
onWebViewClick = onWebViewClick, onWebViewClick = onWebViewClick,
onHelpClick = onHelpClick, onHelpClick = onHelpClick,
onSearch = { presenter.search() }, onSearch = { presenter.search() },
scrollBehavior = scrollBehavior,
) )
}, },
floatingActionButton = { floatingActionButton = {

View File

@ -21,7 +21,6 @@ import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.navigationBars import androidx.compose.foundation.layout.navigationBars
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.statusBarsPadding
import androidx.compose.foundation.layout.width import androidx.compose.foundation.layout.width
import androidx.compose.foundation.lazy.items import androidx.compose.foundation.lazy.items
import androidx.compose.material.icons.Icons import androidx.compose.material.icons.Icons
@ -80,8 +79,7 @@ fun ExtensionDetailsScreen(
val uriHandler = LocalUriHandler.current val uriHandler = LocalUriHandler.current
Scaffold( Scaffold(
modifier = Modifier.statusBarsPadding(), topBar = { scrollBehavior ->
topBar = {
AppBar( AppBar(
title = stringResource(R.string.label_extension_info), title = stringResource(R.string.label_extension_info),
navigateUp = navigateUp, navigateUp = navigateUp,
@ -123,6 +121,7 @@ fun ExtensionDetailsScreen(
}, },
) )
}, },
scrollBehavior = scrollBehavior,
) )
}, },
) { paddingValues -> ) { paddingValues ->

View File

@ -4,7 +4,6 @@ import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.WindowInsets import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.asPaddingValues import androidx.compose.foundation.layout.asPaddingValues
import androidx.compose.foundation.layout.navigationBars import androidx.compose.foundation.layout.navigationBars
import androidx.compose.foundation.layout.statusBarsPadding
import androidx.compose.foundation.lazy.items import androidx.compose.foundation.lazy.items
import androidx.compose.material3.Switch import androidx.compose.material3.Switch
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
@ -32,11 +31,11 @@ fun ExtensionFilterScreen(
) { ) {
val context = LocalContext.current val context = LocalContext.current
Scaffold( Scaffold(
modifier = Modifier.statusBarsPadding(), topBar = { scrollBehavior ->
topBar = {
AppBar( AppBar(
title = stringResource(R.string.label_extensions), title = stringResource(R.string.label_extensions),
navigateUp = navigateUp, navigateUp = navigateUp,
scrollBehavior = scrollBehavior,
) )
}, },
) { paddingValues -> ) { paddingValues ->

View File

@ -4,7 +4,6 @@ import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.WindowInsets import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.asPaddingValues import androidx.compose.foundation.layout.asPaddingValues
import androidx.compose.foundation.layout.navigationBars import androidx.compose.foundation.layout.navigationBars
import androidx.compose.foundation.layout.statusBarsPadding
import androidx.compose.foundation.lazy.items import androidx.compose.foundation.lazy.items
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.LaunchedEffect
@ -34,11 +33,11 @@ fun MigrateMangaScreen(
) { ) {
val context = LocalContext.current val context = LocalContext.current
Scaffold( Scaffold(
modifier = Modifier.statusBarsPadding(), topBar = { scrollBehavior ->
topBar = {
AppBar( AppBar(
title = title, title = title,
navigateUp = navigateUp, navigateUp = navigateUp,
scrollBehavior = scrollBehavior,
) )
}, },
) { paddingValues -> ) { paddingValues ->

View File

@ -4,7 +4,6 @@ import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.WindowInsets import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.asPaddingValues import androidx.compose.foundation.layout.asPaddingValues
import androidx.compose.foundation.layout.navigationBars import androidx.compose.foundation.layout.navigationBars
import androidx.compose.foundation.layout.statusBarsPadding
import androidx.compose.foundation.lazy.items import androidx.compose.foundation.lazy.items
import androidx.compose.material3.Checkbox import androidx.compose.material3.Checkbox
import androidx.compose.material3.Switch import androidx.compose.material3.Switch
@ -38,11 +37,11 @@ fun SourcesFilterScreen(
) { ) {
val context = LocalContext.current val context = LocalContext.current
Scaffold( Scaffold(
modifier = Modifier.statusBarsPadding(), topBar = { scrollBehavior ->
topBar = {
AppBar( AppBar(
title = stringResource(R.string.label_sources), title = stringResource(R.string.label_sources),
navigateUp = navigateUp, navigateUp = navigateUp,
scrollBehavior = scrollBehavior,
) )
}, },
) { paddingValues -> ) { paddingValues ->

View File

@ -9,6 +9,7 @@ import androidx.compose.material.icons.outlined.ViewModule
import androidx.compose.material3.DropdownMenuItem import androidx.compose.material3.DropdownMenuItem
import androidx.compose.material3.Icon import androidx.compose.material3.Icon
import androidx.compose.material3.Text import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBarScrollBehavior
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.mutableStateOf
@ -31,6 +32,7 @@ fun BrowseLatestToolbar(
onDisplayModeChange: (LibraryDisplayMode) -> Unit, onDisplayModeChange: (LibraryDisplayMode) -> Unit,
onHelpClick: () -> Unit, onHelpClick: () -> Unit,
onWebViewClick: () -> Unit, onWebViewClick: () -> Unit,
scrollBehavior: TopAppBarScrollBehavior,
) { ) {
AppBar( AppBar(
navigateUp = navigateUp, navigateUp = navigateUp,
@ -101,5 +103,6 @@ fun BrowseLatestToolbar(
) )
} }
}, },
scrollBehavior = scrollBehavior,
) )
} }

View File

@ -15,6 +15,7 @@ import androidx.compose.material3.DropdownMenuItem
import androidx.compose.material3.Icon import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBarScrollBehavior
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue import androidx.compose.runtime.getValue
@ -47,6 +48,7 @@ fun BrowseSourceToolbar(
onWebViewClick: () -> Unit, onWebViewClick: () -> Unit,
onHelpClick: () -> Unit, onHelpClick: () -> Unit,
onSearch: () -> Unit, onSearch: () -> Unit,
scrollBehavior: TopAppBarScrollBehavior,
) { ) {
if (state.searchQuery == null) { if (state.searchQuery == null) {
BrowseSourceRegularToolbar( BrowseSourceRegularToolbar(
@ -57,6 +59,7 @@ fun BrowseSourceToolbar(
onSearchClick = { state.searchQuery = "" }, onSearchClick = { state.searchQuery = "" },
onWebViewClick = onWebViewClick, onWebViewClick = onWebViewClick,
onHelpClick = onHelpClick, onHelpClick = onHelpClick,
scrollBehavior = scrollBehavior,
) )
} else { } else {
BrowseSourceSearchToolbar( BrowseSourceSearchToolbar(
@ -68,6 +71,7 @@ fun BrowseSourceToolbar(
}, },
onResetClick = { state.searchQuery = "" }, onResetClick = { state.searchQuery = "" },
onSearchClick = onSearch, onSearchClick = onSearch,
scrollBehavior = scrollBehavior,
) )
} }
} }
@ -81,6 +85,7 @@ fun BrowseSourceRegularToolbar(
onSearchClick: () -> Unit, onSearchClick: () -> Unit,
onWebViewClick: () -> Unit, onWebViewClick: () -> Unit,
onHelpClick: () -> Unit, onHelpClick: () -> Unit,
scrollBehavior: TopAppBarScrollBehavior,
) { ) {
AppBar( AppBar(
navigateUp = navigateUp, navigateUp = navigateUp,
@ -156,6 +161,7 @@ fun BrowseSourceRegularToolbar(
) )
} }
}, },
scrollBehavior = scrollBehavior,
) )
} }
@ -166,6 +172,7 @@ fun BrowseSourceSearchToolbar(
navigateUp: () -> Unit, navigateUp: () -> Unit,
onResetClick: () -> Unit, onResetClick: () -> Unit,
onSearchClick: () -> Unit, onSearchClick: () -> Unit,
scrollBehavior: TopAppBarScrollBehavior,
) { ) {
val focusRequester = remember { FocusRequester() } val focusRequester = remember { FocusRequester() }
AppBar( AppBar(
@ -197,6 +204,7 @@ fun BrowseSourceSearchToolbar(
), ),
) )
}, },
scrollBehavior = scrollBehavior,
) )
LaunchedEffect(Unit) { LaunchedEffect(Unit) {
// TODO: https://issuetracker.google.com/issues/204502668 // TODO: https://issuetracker.google.com/issues/204502668

View File

@ -1,11 +1,9 @@
package eu.kanade.presentation.category package eu.kanade.presentation.category
import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.statusBarsPadding
import androidx.compose.foundation.lazy.rememberLazyListState import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.LaunchedEffect
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource import androidx.compose.ui.res.stringResource
import eu.kanade.presentation.category.components.CategoryContent import eu.kanade.presentation.category.components.CategoryContent
@ -33,11 +31,11 @@ fun CategoryScreen(
) { ) {
val lazyListState = rememberLazyListState() val lazyListState = rememberLazyListState()
Scaffold( Scaffold(
modifier = Modifier.statusBarsPadding(), topBar = { scrollBehavior ->
topBar = {
AppBar( AppBar(
title = stringResource(R.string.action_edit_categories), title = stringResource(R.string.action_edit_categories),
navigateUp = navigateUp, navigateUp = navigateUp,
scrollBehavior = scrollBehavior,
) )
}, },
floatingActionButton = { floatingActionButton = {

View File

@ -17,6 +17,12 @@
package eu.kanade.presentation.components package eu.kanade.presentation.components
import androidx.compose.foundation.layout.PaddingValues 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.ExperimentalMaterial3Api
import androidx.compose.material3.FloatingActionButton import androidx.compose.material3.FloatingActionButton
import androidx.compose.material3.LocalContentColor import androidx.compose.material3.LocalContentColor
@ -27,13 +33,17 @@ import androidx.compose.material3.Snackbar
import androidx.compose.material3.SnackbarHost import androidx.compose.material3.SnackbarHost
import androidx.compose.material3.SnackbarHostState import androidx.compose.material3.SnackbarHostState
import androidx.compose.material3.Surface import androidx.compose.material3.Surface
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.material3.TopAppBarScrollBehavior
import androidx.compose.material3.contentColorFor import androidx.compose.material3.contentColorFor
import androidx.compose.material3.rememberTopAppBarState
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.Immutable import androidx.compose.runtime.Immutable
import androidx.compose.runtime.staticCompositionLocalOf import androidx.compose.runtime.staticCompositionLocalOf
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.Color
import androidx.compose.ui.input.nestedscroll.nestedScroll
import androidx.compose.ui.layout.SubcomposeLayout import androidx.compose.ui.layout.SubcomposeLayout
import androidx.compose.ui.unit.Constraints import androidx.compose.ui.unit.Constraints
import androidx.compose.ui.unit.LayoutDirection import androidx.compose.ui.unit.LayoutDirection
@ -81,7 +91,7 @@ import androidx.compose.ui.unit.dp
@Composable @Composable
fun Scaffold( fun Scaffold(
modifier: Modifier = Modifier, modifier: Modifier = Modifier,
topBar: @Composable () -> Unit = {}, topBar: @Composable (TopAppBarScrollBehavior) -> Unit = {},
bottomBar: @Composable () -> Unit = {}, bottomBar: @Composable () -> Unit = {},
snackbarHost: @Composable () -> Unit = {}, snackbarHost: @Composable () -> Unit = {},
floatingActionButton: @Composable () -> Unit = {}, floatingActionButton: @Composable () -> Unit = {},
@ -90,10 +100,25 @@ fun Scaffold(
contentColor: Color = contentColorFor(containerColor), contentColor: Color = contentColorFor(containerColor),
content: @Composable (PaddingValues) -> Unit, 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( ScaffoldLayout(
fabPosition = floatingActionButtonPosition, fabPosition = floatingActionButtonPosition,
topBar = topBar, topBar = { topBar(scrollBehavior) },
bottomBar = bottomBar, bottomBar = bottomBar,
content = content, content = content,
snackbar = snackbarHost, snackbar = snackbarHost,

View File

@ -4,7 +4,6 @@ import androidx.annotation.StringRes
import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.statusBarsPadding
import androidx.compose.material3.Tab import androidx.compose.material3.Tab
import androidx.compose.material3.TabRow import androidx.compose.material3.TabRow
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
@ -33,7 +32,6 @@ fun TabbedScreen(
} }
Scaffold( Scaffold(
modifier = Modifier.statusBarsPadding(),
topBar = { topBar = {
AppBar( AppBar(
title = stringResource(titleRes), title = stringResource(titleRes),

View File

@ -1,23 +1,13 @@
package eu.kanade.presentation.history 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.Composable
import androidx.compose.runtime.LaunchedEffect 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.compose.ui.platform.LocalContext
import androidx.paging.LoadState import androidx.paging.LoadState
import eu.kanade.domain.history.model.HistoryWithRelations import eu.kanade.domain.history.model.HistoryWithRelations
import eu.kanade.presentation.components.EmptyScreen import eu.kanade.presentation.components.EmptyScreen
import eu.kanade.presentation.components.LoadingScreen 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.HistoryContent
import eu.kanade.presentation.history.components.HistoryDeleteAllDialog import eu.kanade.presentation.history.components.HistoryDeleteAllDialog
import eu.kanade.presentation.history.components.HistoryDeleteDialog import eu.kanade.presentation.history.components.HistoryDeleteDialog
@ -38,15 +28,9 @@ fun HistoryScreen(
onClickResume: (HistoryWithRelations) -> Unit, onClickResume: (HistoryWithRelations) -> Unit,
) { ) {
val context = LocalContext.current val context = LocalContext.current
val insetPaddingValue = WindowInsets.navigationBars
.only(WindowInsetsSides.Horizontal + WindowInsetsSides.Bottom)
.asPaddingValues()
val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior(rememberTopAppBarState())
Scaffold( Scaffold(
modifier = Modifier topBar = { scrollBehavior ->
.padding(insetPaddingValue)
.nestedScroll(scrollBehavior.nestedScrollConnection),
topBar = {
HistoryToolbar( HistoryToolbar(
state = presenter, state = presenter,
incognitoMode = presenter.isIncognitoMode, incognitoMode = presenter.isIncognitoMode,

View File

@ -1,17 +1,8 @@
package eu.kanade.presentation.library package eu.kanade.presentation.library
import androidx.compose.animation.Crossfade 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.Composable
import androidx.compose.runtime.getValue 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.domain.category.model.Category
import eu.kanade.presentation.components.LibraryBottomActionMenu import eu.kanade.presentation.components.LibraryBottomActionMenu
import eu.kanade.presentation.components.LoadingScreen import eu.kanade.presentation.components.LoadingScreen
@ -37,16 +28,11 @@ fun LibraryScreen(
onClickFilter: () -> Unit, onClickFilter: () -> Unit,
onClickRefresh: (Category?) -> Boolean, onClickRefresh: (Category?) -> Boolean,
) { ) {
val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior(rememberTopAppBarState())
val insets = WindowInsets.navigationBars.only(WindowInsetsSides.Horizontal)
Crossfade(targetState = presenter.isLoading) { state -> Crossfade(targetState = presenter.isLoading) { state ->
when (state) { when (state) {
true -> LoadingScreen() true -> LoadingScreen()
false -> Scaffold( false -> Scaffold(
modifier = Modifier topBar = { scrollBehavior ->
.windowInsetsPadding(insets)
.nestedScroll(scrollBehavior.nestedScrollConnection),
topBar = {
val title by presenter.getToolbarTitle() val title by presenter.getToolbarTitle()
val tabVisible = presenter.tabVisibility && presenter.categories.size > 1 val tabVisible = presenter.tabVisibility && presenter.categories.size > 1
LibraryToolbar( LibraryToolbar(

View File

@ -210,7 +210,6 @@ private fun MangaScreenSmallImpl(
val layoutDirection = LocalLayoutDirection.current val layoutDirection = LocalLayoutDirection.current
val chapterListState = rememberLazyListState() val chapterListState = rememberLazyListState()
val insetPadding = WindowInsets.systemBars.only(WindowInsetsSides.Horizontal).asPaddingValues()
val chapters = remember(state) { state.processedChapters.toList() } val chapters = remember(state) { state.processedChapters.toList() }
val internalOnBackPressed = { val internalOnBackPressed = {
@ -223,8 +222,6 @@ private fun MangaScreenSmallImpl(
BackHandler(onBack = internalOnBackPressed) BackHandler(onBack = internalOnBackPressed)
Scaffold( Scaffold(
modifier = Modifier
.padding(insetPadding),
topBar = { topBar = {
val firstVisibleItemIndex by remember { val firstVisibleItemIndex by remember {
derivedStateOf { chapterListState.firstVisibleItemIndex } derivedStateOf { chapterListState.firstVisibleItemIndex }

View File

@ -3,7 +3,6 @@ package eu.kanade.presentation.more
import androidx.compose.foundation.layout.WindowInsets import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.asPaddingValues import androidx.compose.foundation.layout.asPaddingValues
import androidx.compose.foundation.layout.navigationBars import androidx.compose.foundation.layout.navigationBars
import androidx.compose.foundation.layout.statusBarsPadding
import androidx.compose.material.icons.Icons import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.CloudOff import androidx.compose.material.icons.outlined.CloudOff
import androidx.compose.material.icons.outlined.GetApp 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.Composable
import androidx.compose.runtime.collectAsState import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.vector.rememberVectorPainter import androidx.compose.ui.graphics.vector.rememberVectorPainter
import androidx.compose.ui.platform.LocalUriHandler import androidx.compose.ui.platform.LocalUriHandler
import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.painterResource
@ -47,12 +45,12 @@ fun MoreScreen(
val downloadQueueState by presenter.downloadQueueState.collectAsState() val downloadQueueState by presenter.downloadQueueState.collectAsState()
Scaffold( Scaffold(
modifier = Modifier.statusBarsPadding(), topBar = { scrollBehavior ->
topBar = {
AppBar( AppBar(
title = stringResource(R.string.label_more), title = stringResource(R.string.label_more),
downloadedOnlyMode = presenter.downloadedOnly.value, downloadedOnlyMode = presenter.downloadedOnly.value,
incognitoMode = presenter.incognitoMode.value, incognitoMode = presenter.incognitoMode.value,
scrollBehavior = scrollBehavior,
) )
}, },
) { paddingValues -> ) { paddingValues ->

View File

@ -6,7 +6,6 @@ import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.asPaddingValues import androidx.compose.foundation.layout.asPaddingValues
import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.navigationBars import androidx.compose.foundation.layout.navigationBars
import androidx.compose.foundation.layout.statusBarsPadding
import androidx.compose.material.icons.Icons import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.Public import androidx.compose.material.icons.outlined.Public
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
@ -40,11 +39,11 @@ fun AboutScreen(
val uriHandler = LocalUriHandler.current val uriHandler = LocalUriHandler.current
Scaffold( Scaffold(
modifier = Modifier.statusBarsPadding(), topBar = { scrollBehavior ->
topBar = {
AppBar( AppBar(
title = stringResource(R.string.pref_category_about), title = stringResource(R.string.pref_category_about),
navigateUp = navigateUp, navigateUp = navigateUp,
scrollBehavior = scrollBehavior,
) )
}, },
) { paddingValues -> ) { paddingValues ->

View File

@ -4,7 +4,6 @@ import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.asPaddingValues import androidx.compose.foundation.layout.asPaddingValues
import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.navigationBars import androidx.compose.foundation.layout.navigationBars
import androidx.compose.foundation.layout.statusBarsPadding
import androidx.compose.material3.MaterialTheme import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
@ -21,11 +20,11 @@ fun LicensesScreen(
navigateUp: () -> Unit, navigateUp: () -> Unit,
) { ) {
Scaffold( Scaffold(
modifier = Modifier.statusBarsPadding(), topBar = { scrollBehavior ->
topBar = {
AppBar( AppBar(
title = stringResource(R.string.licenses), title = stringResource(R.string.licenses),
navigateUp = navigateUp, navigateUp = navigateUp,
scrollBehavior = scrollBehavior,
) )
}, },
) { paddingValues -> ) { paddingValues ->

View File

@ -4,11 +4,9 @@ import androidx.annotation.StringRes
import androidx.compose.foundation.layout.WindowInsets import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.asPaddingValues import androidx.compose.foundation.layout.asPaddingValues
import androidx.compose.foundation.layout.navigationBars import androidx.compose.foundation.layout.navigationBars
import androidx.compose.foundation.layout.statusBarsPadding
import androidx.compose.material.icons.Icons import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.Search import androidx.compose.material.icons.outlined.Search
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.painter.Painter import androidx.compose.ui.graphics.painter.Painter
import androidx.compose.ui.res.stringResource import androidx.compose.ui.res.stringResource
import eu.kanade.presentation.components.AppBar import eu.kanade.presentation.components.AppBar
@ -26,8 +24,7 @@ fun SettingsMainScreen(
onClickSearch: () -> Unit, onClickSearch: () -> Unit,
) { ) {
Scaffold( Scaffold(
modifier = Modifier.statusBarsPadding(), topBar = { scrollBehavior ->
topBar = {
AppBar( AppBar(
title = stringResource(R.string.label_settings), title = stringResource(R.string.label_settings),
navigateUp = navigateUp, navigateUp = navigateUp,
@ -42,6 +39,7 @@ fun SettingsMainScreen(
), ),
) )
}, },
scrollBehavior = scrollBehavior,
) )
}, },
) { paddingValues -> ) { paddingValues ->

View File

@ -7,7 +7,6 @@ import androidx.compose.foundation.layout.asPaddingValues
import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.navigationBars import androidx.compose.foundation.layout.navigationBars
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.statusBarsPadding
import androidx.compose.foundation.lazy.items import androidx.compose.foundation.lazy.items
import androidx.compose.material3.MaterialTheme import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text import androidx.compose.material3.Text
@ -39,8 +38,7 @@ fun SettingsSearchScreen(
var query by remember { mutableStateOf("") } var query by remember { mutableStateOf("") }
Scaffold( Scaffold(
modifier = Modifier.statusBarsPadding(), topBar = { scrollBehavior ->
topBar = {
SearchToolbar( SearchToolbar(
searchQuery = query, searchQuery = query,
onChangeSearchQuery = { onChangeSearchQuery = {
@ -49,6 +47,7 @@ fun SettingsSearchScreen(
}, },
onClickCloseSearch = navigateUp, onClickCloseSearch = navigateUp,
onClickResetSearch = { query = "" }, onClickResetSearch = { query = "" },
scrollBehavior = scrollBehavior,
) )
// TODO: search placeholder // TODO: search placeholder

View File

@ -19,12 +19,13 @@ fun ClearDatabaseScreen(
) { ) {
val context = LocalContext.current val context = LocalContext.current
Scaffold( Scaffold(
topBar = { topBar = { scrollBehavior ->
ClearDatabaseToolbar( ClearDatabaseToolbar(
state = presenter, state = presenter,
navigateUp = navigateUp, navigateUp = navigateUp,
onClickSelectAll = { presenter.selectAll() }, onClickSelectAll = { presenter.selectAll() },
onClickInvertSelection = { presenter.invertSelection() }, onClickInvertSelection = { presenter.invertSelection() },
scrollBehavior = scrollBehavior,
) )
}, },
floatingActionButton = { floatingActionButton = {

View File

@ -3,6 +3,7 @@ package eu.kanade.presentation.more.settings.database.components
import androidx.compose.material.icons.Icons import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.FlipToBack import androidx.compose.material.icons.outlined.FlipToBack
import androidx.compose.material.icons.outlined.SelectAll import androidx.compose.material.icons.outlined.SelectAll
import androidx.compose.material3.TopAppBarScrollBehavior
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.ui.res.stringResource import androidx.compose.ui.res.stringResource
import eu.kanade.presentation.components.AppBar import eu.kanade.presentation.components.AppBar
@ -16,6 +17,7 @@ fun ClearDatabaseToolbar(
navigateUp: () -> Unit, navigateUp: () -> Unit,
onClickSelectAll: () -> Unit, onClickSelectAll: () -> Unit,
onClickInvertSelection: () -> Unit, onClickInvertSelection: () -> Unit,
scrollBehavior: TopAppBarScrollBehavior,
) { ) {
AppBar( AppBar(
title = stringResource(R.string.pref_clear_database), title = stringResource(R.string.pref_clear_database),
@ -38,5 +40,6 @@ fun ClearDatabaseToolbar(
) )
} }
}, },
scrollBehavior = scrollBehavior,
) )
} }

View File

@ -10,7 +10,6 @@ import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.navigationBars import androidx.compose.foundation.layout.navigationBars
import androidx.compose.foundation.layout.only import androidx.compose.foundation.layout.only
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.rememberLazyListState import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.material.icons.Icons import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.FlipToBack 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.material.icons.filled.SelectAll
import androidx.compose.material3.Icon import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton import androidx.compose.material3.IconButton
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.material3.TopAppBarScrollBehavior import androidx.compose.material3.TopAppBarScrollBehavior
import androidx.compose.material3.rememberTopAppBarState
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue import androidx.compose.runtime.getValue
@ -29,7 +26,6 @@ import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.setValue import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.input.nestedscroll.nestedScroll
import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalLayoutDirection import androidx.compose.ui.platform.LocalLayoutDirection
import androidx.compose.ui.res.stringResource import androidx.compose.ui.res.stringResource
@ -67,9 +63,6 @@ fun UpdateScreen(
onDownloadChapter: (List<UpdatesItem>, ChapterDownloadAction) -> Unit, onDownloadChapter: (List<UpdatesItem>, ChapterDownloadAction) -> Unit,
) { ) {
val updatesListState = rememberLazyListState() val updatesListState = rememberLazyListState()
val insetPaddingValue = WindowInsets.navigationBars
.only(WindowInsetsSides.Horizontal)
.asPaddingValues()
val internalOnBackPressed = { val internalOnBackPressed = {
if (presenter.selectionMode) { if (presenter.selectionMode) {
@ -88,12 +81,8 @@ fun UpdateScreen(
started started
} }
val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior(rememberTopAppBarState())
Scaffold( Scaffold(
modifier = Modifier topBar = { scrollBehavior ->
.padding(insetPaddingValue)
.nestedScroll(scrollBehavior.nestedScrollConnection),
topBar = {
UpdatesAppBar( UpdatesAppBar(
incognitoMode = presenter.isIncognitoMode, incognitoMode = presenter.isIncognitoMode,
downloadedOnlyMode = presenter.isDownloadOnly, downloadedOnlyMode = presenter.isDownloadOnly,