mirror of
https://github.com/austinried/subtracks.git
synced 2026-11-11 15:29:15 +01:00
theme the pull-to-refresh indicator from the artwork and stop the library reflow on search
- the indicator now uses the artwork primary and player surface instead of the default onSurfaceVariant - keep the tab bar height in the list inset while searching so the content does not expand for a frame before the keyboard lands
This commit is contained in:
@@ -54,6 +54,8 @@ import androidx.compose.material3.TextField
|
|||||||
import androidx.compose.material3.TextFieldDefaults
|
import androidx.compose.material3.TextFieldDefaults
|
||||||
import androidx.compose.material3.minimumInteractiveComponentSize
|
import androidx.compose.material3.minimumInteractiveComponentSize
|
||||||
import androidx.compose.material3.pulltorefresh.PullToRefreshBox
|
import androidx.compose.material3.pulltorefresh.PullToRefreshBox
|
||||||
|
import androidx.compose.material3.pulltorefresh.PullToRefreshDefaults
|
||||||
|
import androidx.compose.material3.pulltorefresh.rememberPullToRefreshState
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.LaunchedEffect
|
import androidx.compose.runtime.LaunchedEffect
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
@@ -309,7 +311,7 @@ fun LibraryScreen(
|
|||||||
var tabBarHeightPx by remember { mutableFloatStateOf(0f) }
|
var tabBarHeightPx by remember { mutableFloatStateOf(0f) }
|
||||||
val tabBarHeight = with(density) { tabBarHeightPx.toDp() }
|
val tabBarHeight = with(density) { tabBarHeightPx.toDp() }
|
||||||
val listTopInset = statusBarTop
|
val listTopInset = statusBarTop
|
||||||
val listBottomInset = if (searchActive) SEARCH_BAR_CLEARANCE else tabBarHeight + FAB_CLEARANCE
|
val listBottomInset = tabBarHeight + if (searchActive) SEARCH_BAR_CLEARANCE else FAB_CLEARANCE
|
||||||
val headerColor = artwork?.let(::playerSurfaceColor) ?: MaterialTheme.colorScheme.background
|
val headerColor = artwork?.let(::playerSurfaceColor) ?: MaterialTheme.colorScheme.background
|
||||||
|
|
||||||
Box(
|
Box(
|
||||||
@@ -324,9 +326,20 @@ fun LibraryScreen(
|
|||||||
) { page ->
|
) { page ->
|
||||||
val pageTab = LibraryTab.entries[page]
|
val pageTab = LibraryTab.entries[page]
|
||||||
val resetKey = resetKeys[pageTab]
|
val resetKey = resetKeys[pageTab]
|
||||||
|
val pullToRefreshState = rememberPullToRefreshState()
|
||||||
PullToRefreshBox(
|
PullToRefreshBox(
|
||||||
isRefreshing = syncing,
|
isRefreshing = syncing,
|
||||||
onRefresh = onSync,
|
onRefresh = onSync,
|
||||||
|
state = pullToRefreshState,
|
||||||
|
indicator = {
|
||||||
|
PullToRefreshDefaults.Indicator(
|
||||||
|
state = pullToRefreshState,
|
||||||
|
isRefreshing = syncing,
|
||||||
|
modifier = Modifier.align(Alignment.TopCenter),
|
||||||
|
containerColor = headerColor,
|
||||||
|
color = artwork?.scheme?.primary ?: MaterialTheme.colorScheme.primary,
|
||||||
|
)
|
||||||
|
},
|
||||||
modifier = Modifier.fillMaxSize(),
|
modifier = Modifier.fillMaxSize(),
|
||||||
) {
|
) {
|
||||||
when (pageTab) {
|
when (pageTab) {
|
||||||
|
|||||||
Reference in New Issue
Block a user