From 0190c36d20a0ef070fad8a6ab55906c25390144c Mon Sep 17 00:00:00 2001 From: Ivan Iskandar <12537387+ivaniskandar@users.noreply.github.com> Date: Sun, 25 Sep 2022 21:15:01 +0700 Subject: [PATCH] BrowseSourceScreen: Adjust browse mode chips placement (#8076) The chips row is now scrollable too and filter fab is removed --- .../presentation/browse/BrowseSourceScreen.kt | 73 +++++++++---------- .../components/BrowseSourceComfortableGrid.kt | 7 -- .../components/BrowseSourceCompactGrid.kt | 7 -- .../browse/components/BrowseSourceList.kt | 7 -- .../browse/components/BrowseSourceToolbar.kt | 6 +- .../source/browse/BrowseSourceController.kt | 2 +- 6 files changed, 40 insertions(+), 62 deletions(-) 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 389882c4d4..4402b8aa01 100644 --- a/app/src/main/java/eu/kanade/presentation/browse/BrowseSourceScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/browse/BrowseSourceScreen.kt @@ -1,13 +1,17 @@ package eu.kanade.presentation.browse import androidx.compose.animation.AnimatedVisibility +import androidx.compose.foundation.background +import androidx.compose.foundation.horizontalScroll import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.navigationBarsPadding +import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.lazy.grid.GridCells +import androidx.compose.foundation.rememberScrollState import androidx.compose.material.icons.Icons import androidx.compose.material.icons.outlined.Favorite import androidx.compose.material.icons.outlined.FilterList @@ -15,6 +19,7 @@ import androidx.compose.material.icons.outlined.NewReleases import androidx.compose.material3.FilterChip import androidx.compose.material3.FilterChipDefaults import androidx.compose.material3.Icon +import androidx.compose.material3.MaterialTheme import androidx.compose.material3.SnackbarDuration import androidx.compose.material3.SnackbarHost import androidx.compose.material3.SnackbarHostState @@ -42,6 +47,7 @@ import eu.kanade.presentation.browse.components.BrowseSourceCompactGrid import eu.kanade.presentation.browse.components.BrowseSourceList import eu.kanade.presentation.browse.components.BrowseSourceToolbar import eu.kanade.presentation.components.AppStateBanners +import eu.kanade.presentation.components.Divider import eu.kanade.presentation.components.EmptyScreen import eu.kanade.presentation.components.ExtendedFloatingActionButton import eu.kanade.presentation.components.LoadingScreen @@ -56,7 +62,7 @@ import eu.kanade.tachiyomi.widget.EmptyView fun BrowseSourceScreen( presenter: BrowseSourcePresenter, navigateUp: () -> Unit, - onFabClick: () -> Unit, + openFilterSheet: () -> Unit, onMangaClick: (Manga) -> Unit, onMangaLongClick: (Manga) -> Unit, onWebViewClick: () -> Unit, @@ -76,8 +82,8 @@ fun BrowseSourceScreen( } Scaffold( - topBar = { scrollBehavior -> - Column { + topBar = { + Column(modifier = Modifier.background(MaterialTheme.colorScheme.surface)) { BrowseSourceToolbar( state = presenter, source = presenter.source!!, @@ -87,37 +93,12 @@ fun BrowseSourceScreen( onWebViewClick = onWebViewClick, onHelpClick = onHelpClick, onSearch = { presenter.search() }, - scrollBehavior = scrollBehavior, ) - AppStateBanners(downloadedOnlyMode, incognitoMode) - } - }, - floatingActionButton = { - BrowseSourceFloatingActionButton( - isVisible = presenter.filters.isNotEmpty() && presenter.currentFilter is BrowseSourcePresenter.Filter.UserInput, - onFabClick = onFabClick, - ) - }, - snackbarHost = { - SnackbarHost(hostState = snackbarHostState) - }, - ) { paddingValues -> - BrowseSourceContent( - state = presenter, - mangaList = mangaList, - getMangaState = { presenter.getManga(it) }, - columns = columns, - displayMode = presenter.displayMode, - snackbarHostState = snackbarHostState, - contentPadding = paddingValues, - onWebViewClick = onWebViewClick, - onHelpClick = { uriHandler.openUri(MoreController.URL_HELP) }, - onLocalSourceHelpClick = onHelpClick, - onMangaClick = onMangaClick, - onMangaLongClick = onMangaLongClick, - header = { Row( + modifier = Modifier + .horizontalScroll(rememberScrollState()) + .padding(horizontal = 8.dp), horizontalArrangement = Arrangement.spacedBy(8.dp), ) { FilterChip( @@ -161,7 +142,7 @@ fun BrowseSourceScreen( if (presenter.filters.isNotEmpty()) { FilterChip( selected = presenter.currentFilter is BrowseSourcePresenter.Filter.UserInput, - onClick = onFabClick, + onClick = openFilterSheet, leadingIcon = { Icon( imageVector = Icons.Outlined.FilterList, @@ -176,7 +157,29 @@ fun BrowseSourceScreen( ) } } - }, + + Divider() + + AppStateBanners(downloadedOnlyMode, incognitoMode) + } + }, + snackbarHost = { + SnackbarHost(hostState = snackbarHostState) + }, + ) { paddingValues -> + BrowseSourceContent( + state = presenter, + mangaList = mangaList, + getMangaState = { presenter.getManga(it) }, + columns = columns, + displayMode = presenter.displayMode, + snackbarHostState = snackbarHostState, + contentPadding = paddingValues, + onWebViewClick = onWebViewClick, + onHelpClick = { uriHandler.openUri(MoreController.URL_HELP) }, + onLocalSourceHelpClick = onHelpClick, + onMangaClick = onMangaClick, + onMangaLongClick = onMangaLongClick, ) } } @@ -202,7 +205,6 @@ fun BrowseSourceContent( state: BrowseSourceState, mangaList: LazyPagingItems, getMangaState: @Composable ((Manga) -> State), - header: (@Composable () -> Unit)? = null, columns: GridCells, displayMode: LibraryDisplayMode, snackbarHostState: SnackbarHostState, @@ -274,7 +276,6 @@ fun BrowseSourceContent( contentPadding = contentPadding, onMangaClick = onMangaClick, onMangaLongClick = onMangaLongClick, - header = header, ) } LibraryDisplayMode.List -> { @@ -284,7 +285,6 @@ fun BrowseSourceContent( contentPadding = contentPadding, onMangaClick = onMangaClick, onMangaLongClick = onMangaLongClick, - header = header, ) } else -> { @@ -295,7 +295,6 @@ fun BrowseSourceContent( contentPadding = contentPadding, onMangaClick = onMangaClick, onMangaLongClick = onMangaLongClick, - header = header, ) } } diff --git a/app/src/main/java/eu/kanade/presentation/browse/components/BrowseSourceComfortableGrid.kt b/app/src/main/java/eu/kanade/presentation/browse/components/BrowseSourceComfortableGrid.kt index 9bfd6ee07f..7bea057afb 100644 --- a/app/src/main/java/eu/kanade/presentation/browse/components/BrowseSourceComfortableGrid.kt +++ b/app/src/main/java/eu/kanade/presentation/browse/components/BrowseSourceComfortableGrid.kt @@ -30,7 +30,6 @@ import eu.kanade.tachiyomi.R fun BrowseSourceComfortableGrid( mangaList: LazyPagingItems, getMangaState: @Composable ((Manga) -> State), - header: (@Composable () -> Unit)? = null, columns: GridCells, contentPadding: PaddingValues, onMangaClick: (Manga) -> Unit, @@ -42,12 +41,6 @@ fun BrowseSourceComfortableGrid( horizontalArrangement = Arrangement.spacedBy(8.dp), verticalArrangement = Arrangement.spacedBy(8.dp), ) { - if (header != null) { - item(span = { GridItemSpan(maxLineSpan) }) { - header() - } - } - if (mangaList.loadState.prepend is LoadState.Loading) { item(span = { GridItemSpan(maxLineSpan) }) { BrowseSourceLoadingItem() diff --git a/app/src/main/java/eu/kanade/presentation/browse/components/BrowseSourceCompactGrid.kt b/app/src/main/java/eu/kanade/presentation/browse/components/BrowseSourceCompactGrid.kt index 573737f851..4d416634ad 100644 --- a/app/src/main/java/eu/kanade/presentation/browse/components/BrowseSourceCompactGrid.kt +++ b/app/src/main/java/eu/kanade/presentation/browse/components/BrowseSourceCompactGrid.kt @@ -41,7 +41,6 @@ fun BrowseSourceCompactGrid( contentPadding: PaddingValues, onMangaClick: (Manga) -> Unit, onMangaLongClick: (Manga) -> Unit, - header: (@Composable () -> Unit)? = null, ) { LazyVerticalGrid( columns = columns, @@ -49,12 +48,6 @@ fun BrowseSourceCompactGrid( horizontalArrangement = Arrangement.spacedBy(8.dp), verticalArrangement = Arrangement.spacedBy(8.dp), ) { - if (header != null) { - item(span = { GridItemSpan(maxLineSpan) }) { - header() - } - } - item(span = { GridItemSpan(maxLineSpan) }) { if (mangaList.loadState.prepend is LoadState.Loading) { BrowseSourceLoadingItem() diff --git a/app/src/main/java/eu/kanade/presentation/browse/components/BrowseSourceList.kt b/app/src/main/java/eu/kanade/presentation/browse/components/BrowseSourceList.kt index aee4ee435c..64e4e0aaf0 100644 --- a/app/src/main/java/eu/kanade/presentation/browse/components/BrowseSourceList.kt +++ b/app/src/main/java/eu/kanade/presentation/browse/components/BrowseSourceList.kt @@ -30,17 +30,10 @@ fun BrowseSourceList( contentPadding: PaddingValues, onMangaClick: (Manga) -> Unit, onMangaLongClick: (Manga) -> Unit, - header: (@Composable () -> Unit)? = null, ) { LazyColumn( contentPadding = contentPadding, ) { - if (header != null) { - item { - header() - } - } - item { if (mangaList.loadState.prepend is LoadState.Loading) { BrowseSourceLoadingItem() 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 f3fdc6ea86..c51873cc98 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 @@ -39,7 +39,7 @@ fun BrowseSourceToolbar( onWebViewClick: () -> Unit, onHelpClick: () -> Unit, onSearch: () -> Unit, - scrollBehavior: TopAppBarScrollBehavior, + scrollBehavior: TopAppBarScrollBehavior? = null, ) { if (state.searchQuery == null) { BrowseSourceRegularToolbar( @@ -75,7 +75,7 @@ fun BrowseSourceRegularToolbar( onSearchClick: () -> Unit, onWebViewClick: () -> Unit, onHelpClick: () -> Unit, - scrollBehavior: TopAppBarScrollBehavior, + scrollBehavior: TopAppBarScrollBehavior?, ) { AppBar( navigateUp = navigateUp, @@ -162,7 +162,7 @@ fun BrowseSourceSearchToolbar( navigateUp: () -> Unit, onResetClick: () -> Unit, onSearchClick: () -> Unit, - scrollBehavior: TopAppBarScrollBehavior, + scrollBehavior: TopAppBarScrollBehavior?, ) { SearchToolbar( searchQuery = searchQuery, diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourceController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourceController.kt index c9f0acc081..a89f39e1c5 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourceController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourceController.kt @@ -59,7 +59,7 @@ open class BrowseSourceController(bundle: Bundle) : router.popCurrentController() } }, - onFabClick = { filterSheet?.show() }, + openFilterSheet = { filterSheet?.show() }, onMangaClick = { router.pushController(MangaController(it.id, true)) }, onMangaLongClick = { manga -> scope.launchIO {