mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-22 11:01:52 +01:00
Tweaks on Library screen (#7597)
- Toolbar not having padding in landscape - Fix library always refreshing everything even though user is refreshing category - Tab text using primary color - Fix Grid having to big of a top padding - Fix Pager crashing when initial page is greater than the number of categories
This commit is contained in:
parent
59f8c1a288
commit
bc1f6ba517
@ -2,6 +2,7 @@ package eu.kanade.presentation.library
|
|||||||
|
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
|
import eu.kanade.domain.category.model.Category
|
||||||
import eu.kanade.presentation.components.LibraryBottomActionMenu
|
import eu.kanade.presentation.components.LibraryBottomActionMenu
|
||||||
import eu.kanade.presentation.components.Scaffold
|
import eu.kanade.presentation.components.Scaffold
|
||||||
import eu.kanade.presentation.library.components.LibraryContent
|
import eu.kanade.presentation.library.components.LibraryContent
|
||||||
@ -23,7 +24,7 @@ fun LibraryScreen(
|
|||||||
onClickSelectAll: () -> Unit,
|
onClickSelectAll: () -> Unit,
|
||||||
onClickInvertSelection: () -> Unit,
|
onClickInvertSelection: () -> Unit,
|
||||||
onClickFilter: () -> Unit,
|
onClickFilter: () -> Unit,
|
||||||
onClickRefresh: () -> Unit,
|
onClickRefresh: (Category?) -> Unit,
|
||||||
) {
|
) {
|
||||||
Scaffold(
|
Scaffold(
|
||||||
topBar = {
|
topBar = {
|
||||||
@ -35,7 +36,7 @@ fun LibraryScreen(
|
|||||||
onClickSelectAll = onClickSelectAll,
|
onClickSelectAll = onClickSelectAll,
|
||||||
onClickInvertSelection = onClickInvertSelection,
|
onClickInvertSelection = onClickInvertSelection,
|
||||||
onClickFilter = onClickFilter,
|
onClickFilter = onClickFilter,
|
||||||
onClickRefresh = onClickRefresh,
|
onClickRefresh = { onClickRefresh(null) },
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
bottomBar = {
|
bottomBar = {
|
||||||
|
@ -29,7 +29,7 @@ fun LazyLibraryGrid(
|
|||||||
LazyVerticalGrid(
|
LazyVerticalGrid(
|
||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
columns = if (columns == 0) GridCells.Adaptive(128.dp) else GridCells.Fixed(columns),
|
columns = if (columns == 0) GridCells.Adaptive(128.dp) else GridCells.Fixed(columns),
|
||||||
contentPadding = bottomNavPaddingValues + PaddingValues(12.dp) + WindowInsets.navigationBars.asPaddingValues(),
|
contentPadding = bottomNavPaddingValues + PaddingValues(12.dp, 2.dp) + WindowInsets.navigationBars.asPaddingValues(),
|
||||||
verticalArrangement = Arrangement.spacedBy(12.dp),
|
verticalArrangement = Arrangement.spacedBy(12.dp),
|
||||||
horizontalArrangement = Arrangement.spacedBy(12.dp),
|
horizontalArrangement = Arrangement.spacedBy(12.dp),
|
||||||
content = content,
|
content = content,
|
||||||
|
@ -12,6 +12,7 @@ import com.google.accompanist.pager.rememberPagerState
|
|||||||
import com.google.accompanist.swiperefresh.SwipeRefresh
|
import com.google.accompanist.swiperefresh.SwipeRefresh
|
||||||
import com.google.accompanist.swiperefresh.rememberSwipeRefreshState
|
import com.google.accompanist.swiperefresh.rememberSwipeRefreshState
|
||||||
import eu.kanade.core.prefs.PreferenceMutableState
|
import eu.kanade.core.prefs.PreferenceMutableState
|
||||||
|
import eu.kanade.domain.category.model.Category
|
||||||
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.SwipeRefreshIndicator
|
import eu.kanade.presentation.components.SwipeRefreshIndicator
|
||||||
@ -35,17 +36,17 @@ fun LibraryContent(
|
|||||||
onChangeCurrentPage: (Int) -> Unit,
|
onChangeCurrentPage: (Int) -> Unit,
|
||||||
onMangaClicked: (Long) -> Unit,
|
onMangaClicked: (Long) -> Unit,
|
||||||
onToggleSelection: (LibraryManga) -> Unit,
|
onToggleSelection: (LibraryManga) -> Unit,
|
||||||
onRefresh: () -> Unit,
|
onRefresh: (Category?) -> Unit,
|
||||||
onGlobalSearchClicked: () -> Unit,
|
onGlobalSearchClicked: () -> Unit,
|
||||||
getNumberOfMangaForCategory: @Composable (Long) -> State<Int?>,
|
getNumberOfMangaForCategory: @Composable (Long) -> State<Int?>,
|
||||||
getDisplayModeForPage: @Composable (Int) -> State<DisplayModeSetting>,
|
getDisplayModeForPage: @Composable (Int) -> State<DisplayModeSetting>,
|
||||||
getColumnsForOrientation: (Boolean) -> PreferenceMutableState<Int>,
|
getColumnsForOrientation: (Boolean) -> PreferenceMutableState<Int>,
|
||||||
getLibraryForPage: @Composable (Int) -> State<List<LibraryItem>>,
|
getLibraryForPage: @Composable (Int) -> State<List<LibraryItem>>,
|
||||||
) {
|
) {
|
||||||
val pagerState = rememberPagerState(currentPage)
|
|
||||||
|
|
||||||
val categories = state.categories
|
val categories = state.categories
|
||||||
|
|
||||||
|
val pagerState = rememberPagerState(currentPage.coerceAtMost(categories.lastIndex))
|
||||||
|
|
||||||
if (categories.isEmpty()) {
|
if (categories.isEmpty()) {
|
||||||
LoadingScreen()
|
LoadingScreen()
|
||||||
return
|
return
|
||||||
@ -78,7 +79,7 @@ fun LibraryContent(
|
|||||||
|
|
||||||
SwipeRefresh(
|
SwipeRefresh(
|
||||||
state = rememberSwipeRefreshState(isRefreshing = false),
|
state = rememberSwipeRefreshState(isRefreshing = false),
|
||||||
onRefresh = onRefresh,
|
onRefresh = { onRefresh(categories[currentPage]) },
|
||||||
indicator = { s, trigger ->
|
indicator = { s, trigger ->
|
||||||
SwipeRefreshIndicator(
|
SwipeRefreshIndicator(
|
||||||
state = s,
|
state = s,
|
||||||
|
@ -54,7 +54,10 @@ fun LibraryTabs(
|
|||||||
Row(
|
Row(
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
) {
|
) {
|
||||||
Text(text = category.name)
|
Text(
|
||||||
|
text = category.name,
|
||||||
|
color = if (state.currentPage == index) MaterialTheme.colorScheme.primary else MaterialTheme.colorScheme.onBackground,
|
||||||
|
)
|
||||||
if (count != null) {
|
if (count != null) {
|
||||||
Pill(
|
Pill(
|
||||||
text = "$count",
|
text = "$count",
|
||||||
|
@ -3,7 +3,7 @@ package eu.kanade.presentation.library.components
|
|||||||
import androidx.compose.foundation.isSystemInDarkTheme
|
import androidx.compose.foundation.isSystemInDarkTheme
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.statusBarsPadding
|
import androidx.compose.foundation.layout.safeDrawingPadding
|
||||||
import androidx.compose.foundation.text.BasicTextField
|
import androidx.compose.foundation.text.BasicTextField
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.outlined.ArrowBack
|
import androidx.compose.material.icons.outlined.ArrowBack
|
||||||
@ -79,7 +79,7 @@ fun LibraryRegularToolbar(
|
|||||||
val pillAlpha = if (isSystemInDarkTheme()) 0.12f else 0.08f
|
val pillAlpha = if (isSystemInDarkTheme()) 0.12f else 0.08f
|
||||||
val filterTint = if (hasFilters) MaterialTheme.colorScheme.active else LocalContentColor.current
|
val filterTint = if (hasFilters) MaterialTheme.colorScheme.active else LocalContentColor.current
|
||||||
SmallTopAppBar(
|
SmallTopAppBar(
|
||||||
modifier = Modifier.statusBarsPadding(),
|
modifier = Modifier.safeDrawingPadding(),
|
||||||
title = {
|
title = {
|
||||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
Row(verticalAlignment = Alignment.CenterVertically) {
|
||||||
Text(
|
Text(
|
||||||
@ -124,7 +124,7 @@ fun LibrarySelectionToolbar(
|
|||||||
.drawBehind {
|
.drawBehind {
|
||||||
drawRect(backgroundColor.copy(alpha = 1f))
|
drawRect(backgroundColor.copy(alpha = 1f))
|
||||||
}
|
}
|
||||||
.statusBarsPadding(),
|
.safeDrawingPadding(),
|
||||||
navigationIcon = {
|
navigationIcon = {
|
||||||
IconButton(onClick = onClickUnselectAll) {
|
IconButton(onClick = onClickUnselectAll) {
|
||||||
Icon(Icons.Outlined.Close, contentDescription = "close")
|
Icon(Icons.Outlined.Close, contentDescription = "close")
|
||||||
@ -156,7 +156,7 @@ fun LibrarySearchToolbar(
|
|||||||
) {
|
) {
|
||||||
val focusRequester = remember { FocusRequester.Default }
|
val focusRequester = remember { FocusRequester.Default }
|
||||||
SmallTopAppBar(
|
SmallTopAppBar(
|
||||||
modifier = Modifier.statusBarsPadding(),
|
modifier = Modifier.safeDrawingPadding(),
|
||||||
navigationIcon = {
|
navigationIcon = {
|
||||||
IconButton(onClick = onClickCloseSearch) {
|
IconButton(onClick = onClickCloseSearch) {
|
||||||
Icon(Icons.Outlined.ArrowBack, contentDescription = "back")
|
Icon(Icons.Outlined.ArrowBack, contentDescription = "back")
|
||||||
|
@ -62,7 +62,7 @@ class LibraryController(
|
|||||||
onDeleteClicked = ::showDeleteMangaDialog,
|
onDeleteClicked = ::showDeleteMangaDialog,
|
||||||
onClickFilter = ::showSettingsSheet,
|
onClickFilter = ::showSettingsSheet,
|
||||||
onClickRefresh = {
|
onClickRefresh = {
|
||||||
if (LibraryUpdateService.start(context)) {
|
if (LibraryUpdateService.start(context, it)) {
|
||||||
context.toast(R.string.updating_library)
|
context.toast(R.string.updating_library)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user