fix(android): smoother Erkunden swipe + top charts no longer vertically centered
- Pre-compose the neighbour page (beyondViewportPageCount = 1) so the first swipe doesn't hitch while the heavy LazyColumn builds. - Drive the TabRow indicator off pagerState.currentPage so it moves with the swipe (at the half-way point) instead of only on settle — the lag read as "not smooth". - Wrap each pager page in Box(fillMaxSize) so short content (the Top-Alben charts row) sits at the top again, not vertically centered. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
1 parent
7f5d25a03b
commit
6f455b565f
1 file changed
+12
-3
@@ -163,20 +163,22 @@ fun ExploreScreen(
|
|||||||
|
|
||||||
Column(Modifier.fillMaxSize()) {
|
Column(Modifier.fillMaxSize()) {
|
||||||
// ── Tabs ─────────────────────────────────────────────────────────────
|
// ── Tabs ─────────────────────────────────────────────────────────────
|
||||||
|
// Drive the indicator off the pager's current page so it moves WITH the swipe (at the
|
||||||
|
// half-way point), not only once the swipe settles — that lag read as "not smooth".
|
||||||
TabRow(
|
TabRow(
|
||||||
selectedTabIndex = state.tab.ordinal,
|
selectedTabIndex = pagerState.currentPage,
|
||||||
containerColor = MaterialTheme.colorScheme.background,
|
containerColor = MaterialTheme.colorScheme.background,
|
||||||
contentColor = NsAccent,
|
contentColor = NsAccent,
|
||||||
) {
|
) {
|
||||||
Tab(
|
Tab(
|
||||||
selected = state.tab == ExploreTab.LIBRARY,
|
selected = pagerState.currentPage == ExploreTab.LIBRARY.ordinal,
|
||||||
onClick = { vm.selectTab(ExploreTab.LIBRARY); vm.stopPreview() },
|
onClick = { vm.selectTab(ExploreTab.LIBRARY); vm.stopPreview() },
|
||||||
text = { Text("Bibliothek", maxLines = 1) },
|
text = { Text("Bibliothek", maxLines = 1) },
|
||||||
selectedContentColor = NsAccent,
|
selectedContentColor = NsAccent,
|
||||||
unselectedContentColor = MaterialTheme.colorScheme.onSurfaceVariant,
|
unselectedContentColor = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||||
)
|
)
|
||||||
Tab(
|
Tab(
|
||||||
selected = state.tab == ExploreTab.GLOBAL,
|
selected = pagerState.currentPage == ExploreTab.GLOBAL.ordinal,
|
||||||
onClick = { vm.selectTab(ExploreTab.GLOBAL); vm.stopPreview() },
|
onClick = { vm.selectTab(ExploreTab.GLOBAL); vm.stopPreview() },
|
||||||
text = { Text("Erkunden", maxLines = 1) },
|
text = { Text("Erkunden", maxLines = 1) },
|
||||||
selectedContentColor = NsAccent,
|
selectedContentColor = NsAccent,
|
||||||
@@ -246,8 +248,14 @@ fun ExploreScreen(
|
|||||||
// ── Content (swipeable) ────────────────────────────────────────────────
|
// ── Content (swipeable) ────────────────────────────────────────────────
|
||||||
HorizontalPager(
|
HorizontalPager(
|
||||||
state = pagerState,
|
state = pagerState,
|
||||||
|
// Pre-compose the neighbour page so the swipe doesn't hitch while its (heavy) LazyColumn
|
||||||
|
// builds on first drag.
|
||||||
|
beyondViewportPageCount = 1,
|
||||||
modifier = Modifier.weight(1f),
|
modifier = Modifier.weight(1f),
|
||||||
) { page ->
|
) { page ->
|
||||||
|
// fillMaxSize so short content (e.g. the Top-Alben charts row) sits at the top, not
|
||||||
|
// vertically centered in the page.
|
||||||
|
Box(Modifier.fillMaxSize()) {
|
||||||
when (page) {
|
when (page) {
|
||||||
ExploreTab.LIBRARY.ordinal -> LibrarySearchContent(
|
ExploreTab.LIBRARY.ordinal -> LibrarySearchContent(
|
||||||
query = state.query,
|
query = state.query,
|
||||||
@@ -270,6 +278,7 @@ fun ExploreScreen(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ── Library (local Navidrome) search ─────────────────────────────────────────
|
// ── Library (local Navidrome) search ─────────────────────────────────────────
|
||||||
|
|||||||
Reference in new issue
Block a user