mirror of
				https://github.com/mihonapp/mihon.git
				synced 2025-10-31 14:27:57 +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:
		| @@ -2,6 +2,7 @@ package eu.kanade.presentation.library | ||||
|  | ||||
| import androidx.compose.runtime.Composable | ||||
| import androidx.compose.runtime.getValue | ||||
| import eu.kanade.domain.category.model.Category | ||||
| import eu.kanade.presentation.components.LibraryBottomActionMenu | ||||
| import eu.kanade.presentation.components.Scaffold | ||||
| import eu.kanade.presentation.library.components.LibraryContent | ||||
| @@ -23,7 +24,7 @@ fun LibraryScreen( | ||||
|     onClickSelectAll: () -> Unit, | ||||
|     onClickInvertSelection: () -> Unit, | ||||
|     onClickFilter: () -> Unit, | ||||
|     onClickRefresh: () -> Unit, | ||||
|     onClickRefresh: (Category?) -> Unit, | ||||
| ) { | ||||
|     Scaffold( | ||||
|         topBar = { | ||||
| @@ -35,7 +36,7 @@ fun LibraryScreen( | ||||
|                 onClickSelectAll = onClickSelectAll, | ||||
|                 onClickInvertSelection = onClickInvertSelection, | ||||
|                 onClickFilter = onClickFilter, | ||||
|                 onClickRefresh = onClickRefresh, | ||||
|                 onClickRefresh = { onClickRefresh(null) }, | ||||
|             ) | ||||
|         }, | ||||
|         bottomBar = { | ||||
|   | ||||
| @@ -29,7 +29,7 @@ fun LazyLibraryGrid( | ||||
|     LazyVerticalGrid( | ||||
|         modifier = modifier, | ||||
|         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), | ||||
|         horizontalArrangement = Arrangement.spacedBy(12.dp), | ||||
|         content = content, | ||||
|   | ||||
| @@ -12,6 +12,7 @@ import com.google.accompanist.pager.rememberPagerState | ||||
| import com.google.accompanist.swiperefresh.SwipeRefresh | ||||
| import com.google.accompanist.swiperefresh.rememberSwipeRefreshState | ||||
| import eu.kanade.core.prefs.PreferenceMutableState | ||||
| import eu.kanade.domain.category.model.Category | ||||
| import eu.kanade.presentation.components.EmptyScreen | ||||
| import eu.kanade.presentation.components.LoadingScreen | ||||
| import eu.kanade.presentation.components.SwipeRefreshIndicator | ||||
| @@ -35,17 +36,17 @@ fun LibraryContent( | ||||
|     onChangeCurrentPage: (Int) -> Unit, | ||||
|     onMangaClicked: (Long) -> Unit, | ||||
|     onToggleSelection: (LibraryManga) -> Unit, | ||||
|     onRefresh: () -> Unit, | ||||
|     onRefresh: (Category?) -> Unit, | ||||
|     onGlobalSearchClicked: () -> Unit, | ||||
|     getNumberOfMangaForCategory: @Composable (Long) -> State<Int?>, | ||||
|     getDisplayModeForPage: @Composable (Int) -> State<DisplayModeSetting>, | ||||
|     getColumnsForOrientation: (Boolean) -> PreferenceMutableState<Int>, | ||||
|     getLibraryForPage: @Composable (Int) -> State<List<LibraryItem>>, | ||||
| ) { | ||||
|     val pagerState = rememberPagerState(currentPage) | ||||
|  | ||||
|     val categories = state.categories | ||||
|  | ||||
|     val pagerState = rememberPagerState(currentPage.coerceAtMost(categories.lastIndex)) | ||||
|  | ||||
|     if (categories.isEmpty()) { | ||||
|         LoadingScreen() | ||||
|         return | ||||
| @@ -78,7 +79,7 @@ fun LibraryContent( | ||||
|  | ||||
|         SwipeRefresh( | ||||
|             state = rememberSwipeRefreshState(isRefreshing = false), | ||||
|             onRefresh = onRefresh, | ||||
|             onRefresh = { onRefresh(categories[currentPage]) }, | ||||
|             indicator = { s, trigger -> | ||||
|                 SwipeRefreshIndicator( | ||||
|                     state = s, | ||||
|   | ||||
| @@ -54,7 +54,10 @@ fun LibraryTabs( | ||||
|                         Row( | ||||
|                             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) { | ||||
|                                 Pill( | ||||
|                                     text = "$count", | ||||
|   | ||||
| @@ -3,7 +3,7 @@ package eu.kanade.presentation.library.components | ||||
| import androidx.compose.foundation.isSystemInDarkTheme | ||||
| import androidx.compose.foundation.layout.Row | ||||
| 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.material.icons.Icons | ||||
| import androidx.compose.material.icons.outlined.ArrowBack | ||||
| @@ -79,7 +79,7 @@ fun LibraryRegularToolbar( | ||||
|     val pillAlpha = if (isSystemInDarkTheme()) 0.12f else 0.08f | ||||
|     val filterTint = if (hasFilters) MaterialTheme.colorScheme.active else LocalContentColor.current | ||||
|     SmallTopAppBar( | ||||
|         modifier = Modifier.statusBarsPadding(), | ||||
|         modifier = Modifier.safeDrawingPadding(), | ||||
|         title = { | ||||
|             Row(verticalAlignment = Alignment.CenterVertically) { | ||||
|                 Text( | ||||
| @@ -124,7 +124,7 @@ fun LibrarySelectionToolbar( | ||||
|             .drawBehind { | ||||
|                 drawRect(backgroundColor.copy(alpha = 1f)) | ||||
|             } | ||||
|             .statusBarsPadding(), | ||||
|             .safeDrawingPadding(), | ||||
|         navigationIcon = { | ||||
|             IconButton(onClick = onClickUnselectAll) { | ||||
|                 Icon(Icons.Outlined.Close, contentDescription = "close") | ||||
| @@ -156,7 +156,7 @@ fun LibrarySearchToolbar( | ||||
| ) { | ||||
|     val focusRequester = remember { FocusRequester.Default } | ||||
|     SmallTopAppBar( | ||||
|         modifier = Modifier.statusBarsPadding(), | ||||
|         modifier = Modifier.safeDrawingPadding(), | ||||
|         navigationIcon = { | ||||
|             IconButton(onClick = onClickCloseSearch) { | ||||
|                 Icon(Icons.Outlined.ArrowBack, contentDescription = "back") | ||||
|   | ||||
| @@ -62,7 +62,7 @@ class LibraryController( | ||||
|             onDeleteClicked = ::showDeleteMangaDialog, | ||||
|             onClickFilter = ::showSettingsSheet, | ||||
|             onClickRefresh = { | ||||
|                 if (LibraryUpdateService.start(context)) { | ||||
|                 if (LibraryUpdateService.start(context, it)) { | ||||
|                     context.toast(R.string.updating_library) | ||||
|                 } | ||||
|             }, | ||||
|   | ||||
		Reference in New Issue
	
	Block a user