mirror of
				https://github.com/mihonapp/mihon.git
				synced 2025-10-31 14:27:57 +01:00 
			
		
		
		
	Replace our custom Pager (#9494)
Turns out that changing the pagerSnapDistance is enough to achieve the same result.
This commit is contained in:
		| @@ -7,6 +7,7 @@ import androidx.compose.foundation.layout.ColumnScope | ||||
| import androidx.compose.foundation.layout.PaddingValues | ||||
| import androidx.compose.foundation.layout.Row | ||||
| import androidx.compose.foundation.layout.wrapContentSize | ||||
| import androidx.compose.foundation.pager.rememberPagerState | ||||
| import androidx.compose.material.icons.Icons | ||||
| import androidx.compose.material.icons.filled.MoreVert | ||||
| import androidx.compose.material3.Icon | ||||
| @@ -31,7 +32,6 @@ import kotlinx.coroutines.launch | ||||
| import tachiyomi.presentation.core.components.HorizontalPager | ||||
| import tachiyomi.presentation.core.components.material.Divider | ||||
| import tachiyomi.presentation.core.components.material.TabIndicator | ||||
| import tachiyomi.presentation.core.components.rememberPagerState | ||||
|  | ||||
| object TabbedDialogPaddings { | ||||
|     val Horizontal = 24.dp | ||||
| @@ -84,7 +84,7 @@ fun TabbedDialog( | ||||
|  | ||||
|             HorizontalPager( | ||||
|                 modifier = Modifier.animateContentSize(), | ||||
|                 count = tabTitles.size, | ||||
|                 pageCount = tabTitles.size, | ||||
|                 state = pagerState, | ||||
|                 verticalAlignment = Alignment.Top, | ||||
|             ) { page -> | ||||
|   | ||||
| @@ -7,6 +7,7 @@ import androidx.compose.foundation.layout.calculateEndPadding | ||||
| import androidx.compose.foundation.layout.calculateStartPadding | ||||
| import androidx.compose.foundation.layout.fillMaxSize | ||||
| import androidx.compose.foundation.layout.padding | ||||
| import androidx.compose.foundation.pager.rememberPagerState | ||||
| import androidx.compose.material3.MaterialTheme | ||||
| import androidx.compose.material3.SnackbarHost | ||||
| import androidx.compose.material3.SnackbarHostState | ||||
| @@ -25,7 +26,6 @@ import tachiyomi.presentation.core.components.HorizontalPager | ||||
| import tachiyomi.presentation.core.components.material.Scaffold | ||||
| import tachiyomi.presentation.core.components.material.TabIndicator | ||||
| import tachiyomi.presentation.core.components.material.TabText | ||||
| import tachiyomi.presentation.core.components.rememberPagerState | ||||
|  | ||||
| @Composable | ||||
| fun TabbedScreen( | ||||
| @@ -82,7 +82,7 @@ fun TabbedScreen( | ||||
|             } | ||||
|  | ||||
|             HorizontalPager( | ||||
|                 count = tabs.size, | ||||
|                 pageCount = tabs.size, | ||||
|                 modifier = Modifier.fillMaxSize(), | ||||
|                 state = state, | ||||
|                 verticalAlignment = Alignment.Top, | ||||
|   | ||||
| @@ -5,6 +5,7 @@ import androidx.compose.foundation.layout.PaddingValues | ||||
| import androidx.compose.foundation.layout.calculateEndPadding | ||||
| import androidx.compose.foundation.layout.calculateStartPadding | ||||
| import androidx.compose.foundation.layout.padding | ||||
| import androidx.compose.foundation.pager.rememberPagerState | ||||
| import androidx.compose.runtime.Composable | ||||
| import androidx.compose.runtime.LaunchedEffect | ||||
| import androidx.compose.runtime.getValue | ||||
| @@ -22,7 +23,6 @@ import tachiyomi.domain.category.model.Category | ||||
| import tachiyomi.domain.library.model.LibraryDisplayMode | ||||
| import tachiyomi.domain.library.model.LibraryManga | ||||
| import tachiyomi.presentation.core.components.material.PullRefresh | ||||
| import tachiyomi.presentation.core.components.rememberPagerState | ||||
| import kotlin.time.Duration.Companion.seconds | ||||
|  | ||||
| @Composable | ||||
| @@ -60,8 +60,10 @@ fun LibraryContent( | ||||
|         var isRefreshing by remember(pagerState.currentPage) { mutableStateOf(false) } | ||||
|  | ||||
|         if (showPageTabs && categories.size > 1) { | ||||
|             if (categories.size <= pagerState.currentPage) { | ||||
|                 pagerState.currentPage = categories.size - 1 | ||||
|             LaunchedEffect(categories) { | ||||
|                 if (categories.size <= pagerState.currentPage) { | ||||
|                     pagerState.scrollToPage(categories.size - 1) | ||||
|                 } | ||||
|             } | ||||
|             LibraryTabs( | ||||
|                 categories = categories, | ||||
|   | ||||
| @@ -6,6 +6,7 @@ import androidx.compose.foundation.layout.PaddingValues | ||||
| import androidx.compose.foundation.layout.fillMaxSize | ||||
| import androidx.compose.foundation.layout.fillMaxWidth | ||||
| import androidx.compose.foundation.layout.padding | ||||
| import androidx.compose.foundation.pager.PagerState | ||||
| import androidx.compose.foundation.rememberScrollState | ||||
| import androidx.compose.foundation.verticalScroll | ||||
| import androidx.compose.runtime.Composable | ||||
| @@ -22,7 +23,6 @@ import eu.kanade.tachiyomi.ui.library.LibraryItem | ||||
| import tachiyomi.domain.library.model.LibraryDisplayMode | ||||
| import tachiyomi.domain.library.model.LibraryManga | ||||
| import tachiyomi.presentation.core.components.HorizontalPager | ||||
| import tachiyomi.presentation.core.components.PagerState | ||||
| import tachiyomi.presentation.core.screens.EmptyScreen | ||||
| import tachiyomi.presentation.core.util.plus | ||||
|  | ||||
| @@ -43,7 +43,7 @@ fun LibraryPager( | ||||
|     onClickContinueReading: ((LibraryManga) -> Unit)?, | ||||
| ) { | ||||
|     HorizontalPager( | ||||
|         count = pageCount, | ||||
|         pageCount = pageCount, | ||||
|         modifier = Modifier.fillMaxSize(), | ||||
|         state = state, | ||||
|         verticalAlignment = Alignment.Top, | ||||
|   | ||||
| @@ -1,6 +1,7 @@ | ||||
| package eu.kanade.presentation.library.components | ||||
|  | ||||
| import androidx.compose.foundation.layout.Column | ||||
| import androidx.compose.foundation.pager.PagerState | ||||
| import androidx.compose.material3.MaterialTheme | ||||
| import androidx.compose.material3.ScrollableTabRow | ||||
| import androidx.compose.material3.Tab | ||||
| @@ -8,7 +9,6 @@ import androidx.compose.runtime.Composable | ||||
| import androidx.compose.ui.unit.dp | ||||
| import eu.kanade.presentation.category.visualName | ||||
| import tachiyomi.domain.category.model.Category | ||||
| import tachiyomi.presentation.core.components.PagerState | ||||
| import tachiyomi.presentation.core.components.material.Divider | ||||
| import tachiyomi.presentation.core.components.material.TabIndicator | ||||
| import tachiyomi.presentation.core.components.material.TabText | ||||
|   | ||||
		Reference in New Issue
	
	Block a user