Improve insets handling

This commit is contained in:
vfsfitvnm 2022-10-08 12:15:06 +02:00
parent bead21be04
commit 6fb377d743
23 changed files with 250 additions and 104 deletions

View file

@ -22,10 +22,11 @@ import androidx.compose.foundation.LocalIndication
import androidx.compose.foundation.background
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.BoxWithConstraints
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.asPaddingValues
import androidx.compose.foundation.layout.WindowInsetsSides
import androidx.compose.foundation.layout.add
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.only
import androidx.compose.foundation.layout.systemBars
import androidx.compose.material.ripple.LocalRippleTheme
import androidx.compose.material.ripple.RippleAlpha
@ -34,6 +35,7 @@ import androidx.compose.material.ripple.rememberRipple
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.derivedStateOf
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
@ -46,7 +48,8 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.toArgb
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.unit.coerceIn
import androidx.compose.ui.unit.dp
import androidx.core.view.WindowCompat
import androidx.lifecycle.lifecycleScope
@ -298,20 +301,23 @@ class MainActivity : ComponentActivity() {
.fillMaxSize()
.background(appearance.colorPalette.background0)
) {
val paddingValues = WindowInsets.systemBars.asPaddingValues()
val density = LocalDensity.current
val windowsInsets = WindowInsets.systemBars
val bottomDp = with(density) { windowsInsets.getBottom(density).toDp() }
val playerBottomSheetState = rememberBottomSheetState(
dismissedBound = 0.dp,
collapsedBound = Dimensions.collapsedPlayer + paddingValues.calculateBottomPadding(),
collapsedBound = Dimensions.collapsedPlayer + bottomDp,
expandedBound = maxHeight,
)
val playerAwarePaddingValues = if (playerBottomSheetState.isDismissed) {
paddingValues
} else {
object : PaddingValues by paddingValues {
override fun calculateBottomPadding(): Dp =
paddingValues.calculateBottomPadding() + Dimensions.collapsedPlayer
val playerAwareWindowInsets by remember(bottomDp, playerBottomSheetState.value) {
derivedStateOf {
val bottom = playerBottomSheetState.value.coerceIn(bottomDp, playerBottomSheetState.collapsedBound)
windowsInsets
.only(WindowInsetsSides.Horizontal + WindowInsetsSides.Top)
.add(WindowInsets(bottom = bottom))
}
}
@ -321,7 +327,7 @@ class MainActivity : ComponentActivity() {
LocalRippleTheme provides rippleTheme,
LocalShimmerTheme provides shimmerTheme,
LocalPlayerServiceBinder provides binder,
LocalPlayerAwarePaddingValues provides playerAwarePaddingValues
LocalPlayerAwareWindowInsets provides playerAwareWindowInsets
) {
HomeScreen(
onPlaylistUrl = { url ->
@ -335,39 +341,39 @@ class MainActivity : ComponentActivity() {
.align(Alignment.BottomCenter)
)
DisposableEffect(binder?.player) {
val player = binder?.player ?: return@DisposableEffect onDispose { }
if (player.currentMediaItem == null) {
if (!playerBottomSheetState.isDismissed) {
playerBottomSheetState.dismiss()
}
} else {
if (playerBottomSheetState.isDismissed) {
if (launchedFromNotification) {
intent.replaceExtras(Bundle())
playerBottomSheetState.expandSoft()
} else {
playerBottomSheetState.collapseSoft()
}
}
}
player.listener(object : Player.Listener {
override fun onMediaItemTransition(mediaItem: MediaItem?, reason: Int) {
if (reason == Player.MEDIA_ITEM_TRANSITION_REASON_PLAYLIST_CHANGED && mediaItem != null) {
playerBottomSheetState.expand(tween(500))
}
}
})
}
BottomSheetMenu(
state = LocalMenuState.current,
modifier = Modifier
.align(Alignment.BottomCenter)
)
}
DisposableEffect(binder?.player) {
val player = binder?.player ?: return@DisposableEffect onDispose { }
if (player.currentMediaItem == null) {
if (!playerBottomSheetState.isDismissed) {
playerBottomSheetState.dismiss()
}
} else {
if (playerBottomSheetState.isDismissed) {
if (launchedFromNotification) {
intent.replaceExtras(Bundle())
playerBottomSheetState.expandSoft()
} else {
playerBottomSheetState.collapseSoft()
}
}
}
player.listener(object : Player.Listener {
override fun onMediaItemTransition(mediaItem: MediaItem?, reason: Int) {
if (reason == Player.MEDIA_ITEM_TRANSITION_REASON_PLAYLIST_CHANGED && mediaItem != null) {
playerBottomSheetState.expand(tween(500))
}
}
})
}
}
}
@ -440,4 +446,4 @@ class MainActivity : ComponentActivity() {
val LocalPlayerServiceBinder = staticCompositionLocalOf<PlayerService.Binder?> { null }
val LocalPlayerAwarePaddingValues = staticCompositionLocalOf<PaddingValues> { TODO() }
val LocalPlayerAwareWindowInsets = staticCompositionLocalOf<WindowInsets> { TODO() }

View file

@ -11,6 +11,9 @@ import androidx.compose.foundation.ScrollState
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.BoxScope
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.WindowInsetsSides
import androidx.compose.foundation.layout.asPaddingValues
import androidx.compose.foundation.layout.only
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyListState
import androidx.compose.foundation.lazy.grid.LazyGridState
@ -20,7 +23,7 @@ import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import it.vfsfitvnm.vimusic.LocalPlayerAwarePaddingValues
import it.vfsfitvnm.vimusic.LocalPlayerAwareWindowInsets
import it.vfsfitvnm.vimusic.R
import it.vfsfitvnm.vimusic.utils.ScrollingInfo
import it.vfsfitvnm.vimusic.utils.scrollingInfo
@ -102,7 +105,9 @@ fun BoxScope.FloatingActions(
onClick: (() -> Unit)? = null,
) {
val transition = updateTransition(transitionState, "")
val paddingValues = LocalPlayerAwarePaddingValues.current
val windowInsets = LocalPlayerAwareWindowInsets.current
val bottomPaddingValues = windowInsets.only(WindowInsetsSides.Bottom).asPaddingValues()
Row(
horizontalArrangement = Arrangement.spacedBy(16.dp),
@ -110,6 +115,7 @@ fun BoxScope.FloatingActions(
modifier = modifier
.align(Alignment.BottomEnd)
.padding(end = 16.dp)
.padding(windowInsets.only(WindowInsetsSides.End).asPaddingValues())
) {
onScrollToTop?.let {
transition.AnimatedVisibility(
@ -129,7 +135,7 @@ fun BoxScope.FloatingActions(
iconId = R.drawable.chevron_up,
modifier = Modifier
.padding(bottom = 16.dp)
.padding(paddingValues)
.padding(bottomPaddingValues)
)
}
}
@ -147,7 +153,7 @@ fun BoxScope.FloatingActions(
enabled = transition.targetState?.isScrollingDown == false,
modifier = Modifier
.padding(bottom = 16.dp)
.padding(paddingValues)
.padding(bottomPaddingValues)
)
}
}

View file

@ -9,7 +9,10 @@ import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ColumnScope
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.WindowInsetsSides
import androidx.compose.foundation.layout.asPaddingValues
import androidx.compose.foundation.layout.offset
import androidx.compose.foundation.layout.only
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.rememberScrollState
@ -28,7 +31,7 @@ import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.layout.layout
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.dp
import it.vfsfitvnm.vimusic.LocalPlayerAwarePaddingValues
import it.vfsfitvnm.vimusic.LocalPlayerAwareWindowInsets
import it.vfsfitvnm.vimusic.ui.styling.Dimensions
import it.vfsfitvnm.vimusic.ui.styling.LocalAppearance
import it.vfsfitvnm.vimusic.utils.isLandscape
@ -47,10 +50,13 @@ inline fun NavigationRail(
val isLandscape = isLandscape
val paddingValues = LocalPlayerAwareWindowInsets.current
.only(WindowInsetsSides.Vertical + WindowInsetsSides.Start).asPaddingValues()
Column(
horizontalAlignment = Alignment.CenterHorizontally,
modifier = modifier
.padding(LocalPlayerAwarePaddingValues.current)
.padding(paddingValues)
.verticalScroll(rememberScrollState())
) {
Box(

View file

@ -18,7 +18,10 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.style.TextOverflow
import it.vfsfitvnm.vimusic.Database
import it.vfsfitvnm.vimusic.LocalPlayerAwarePaddingValues
import it.vfsfitvnm.vimusic.LocalPlayerAwareWindowInsets
import androidx.compose.foundation.layout.WindowInsetsSides
import androidx.compose.foundation.layout.asPaddingValues
import androidx.compose.foundation.layout.only
import it.vfsfitvnm.vimusic.LocalPlayerServiceBinder
import it.vfsfitvnm.vimusic.R
import it.vfsfitvnm.vimusic.models.DetailedSong
@ -75,7 +78,8 @@ fun AlbumSongs(
Box {
LazyColumn(
state = lazyListState,
contentPadding = LocalPlayerAwarePaddingValues.current,
contentPadding = LocalPlayerAwareWindowInsets.current
.only(WindowInsetsSides.Vertical + WindowInsetsSides.End).asPaddingValues(),
modifier = Modifier
.background(colorPalette.background0)
.fillMaxSize()

View file

@ -14,7 +14,10 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import it.vfsfitvnm.vimusic.Database
import it.vfsfitvnm.vimusic.LocalPlayerAwarePaddingValues
import it.vfsfitvnm.vimusic.LocalPlayerAwareWindowInsets
import androidx.compose.foundation.layout.WindowInsetsSides
import androidx.compose.foundation.layout.asPaddingValues
import androidx.compose.foundation.layout.only
import it.vfsfitvnm.vimusic.LocalPlayerServiceBinder
import it.vfsfitvnm.vimusic.R
import it.vfsfitvnm.vimusic.models.DetailedSong
@ -70,7 +73,8 @@ fun ArtistLocalSongs(
Box {
LazyColumn(
state = lazyListState,
contentPadding = LocalPlayerAwarePaddingValues.current,
contentPadding = LocalPlayerAwareWindowInsets.current
.only(WindowInsetsSides.Vertical + WindowInsetsSides.End).asPaddingValues(),
modifier = Modifier
.background(colorPalette.background0)
.fillMaxSize()

View file

@ -9,8 +9,11 @@ import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.WindowInsetsSides
import androidx.compose.foundation.layout.asPaddingValues
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.only
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyRow
import androidx.compose.foundation.lazy.items
@ -21,7 +24,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import it.vfsfitvnm.vimusic.LocalPlayerAwarePaddingValues
import it.vfsfitvnm.vimusic.LocalPlayerAwareWindowInsets
import it.vfsfitvnm.vimusic.LocalPlayerServiceBinder
import it.vfsfitvnm.vimusic.R
import it.vfsfitvnm.vimusic.ui.components.LocalMenuState
@ -60,12 +63,15 @@ fun ArtistOverview(
val (colorPalette, typography) = LocalAppearance.current
val binder = LocalPlayerServiceBinder.current
val menuState = LocalMenuState.current
val windowInsets = LocalPlayerAwareWindowInsets.current
val songThumbnailSizeDp = Dimensions.thumbnails.song
val songThumbnailSizePx = songThumbnailSizeDp.px
val albumThumbnailSizeDp = 108.dp
val albumThumbnailSizePx = albumThumbnailSizeDp.px
val endPaddingValues = windowInsets.only(WindowInsetsSides.End).asPaddingValues()
val sectionTextModifier = Modifier
.padding(horizontal = 16.dp)
.padding(top = 24.dp, bottom = 8.dp)
@ -80,17 +86,22 @@ fun ArtistOverview(
.background(colorPalette.background0)
.fillMaxSize()
.verticalScroll(scrollState)
.padding(LocalPlayerAwarePaddingValues.current)
.padding(windowInsets.only(WindowInsetsSides.Vertical).asPaddingValues())
) {
headerContent {
youtubeArtistPage?.radioEndpoint?.let { radioEndpoint ->
SecondaryTextButton(
text = "Start radio",
onClick = {
binder?.stopRadio()
binder?.playRadio(radioEndpoint)
}
)
Box(
modifier = Modifier
.padding(endPaddingValues)
) {
headerContent {
youtubeArtistPage?.radioEndpoint?.let { radioEndpoint ->
SecondaryTextButton(
text = "Start radio",
onClick = {
binder?.stopRadio()
binder?.playRadio(radioEndpoint)
}
)
}
}
}
@ -103,6 +114,7 @@ fun ArtistOverview(
horizontalArrangement = Arrangement.SpaceBetween,
modifier = Modifier
.fillMaxSize()
.padding(endPaddingValues)
) {
BasicText(
text = "Songs",
@ -144,6 +156,7 @@ fun ArtistOverview(
)
}
)
.padding(endPaddingValues)
)
}
}
@ -154,6 +167,7 @@ fun ArtistOverview(
horizontalArrangement = Arrangement.SpaceBetween,
modifier = Modifier
.fillMaxSize()
.padding(endPaddingValues)
) {
BasicText(
text = "Albums",
@ -172,6 +186,7 @@ fun ArtistOverview(
}
LazyRow(
contentPadding = endPaddingValues,
modifier = Modifier
.fillMaxWidth()
) {
@ -197,6 +212,7 @@ fun ArtistOverview(
horizontalArrangement = Arrangement.SpaceBetween,
modifier = Modifier
.fillMaxSize()
.padding(endPaddingValues)
) {
BasicText(
text = "Singles",
@ -215,6 +231,7 @@ fun ArtistOverview(
}
LazyRow(
contentPadding = endPaddingValues,
modifier = Modifier
.fillMaxWidth()
) {

View file

@ -14,7 +14,10 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import it.vfsfitvnm.vimusic.Database
import it.vfsfitvnm.vimusic.LocalPlayerAwarePaddingValues
import it.vfsfitvnm.vimusic.LocalPlayerAwareWindowInsets
import androidx.compose.foundation.layout.WindowInsetsSides
import androidx.compose.foundation.layout.asPaddingValues
import androidx.compose.foundation.layout.only
import it.vfsfitvnm.vimusic.LocalPlayerServiceBinder
import it.vfsfitvnm.vimusic.R
import it.vfsfitvnm.vimusic.enums.BuiltInPlaylist
@ -76,7 +79,8 @@ fun BuiltInPlaylistSongs(builtInPlaylist: BuiltInPlaylist) {
Box {
LazyColumn(
state = lazyListState,
contentPadding = LocalPlayerAwarePaddingValues.current,
contentPadding = LocalPlayerAwareWindowInsets.current
.only(WindowInsetsSides.Vertical + WindowInsetsSides.End).asPaddingValues(),
modifier = Modifier
.background(colorPalette.background0)
.fillMaxSize()

View file

@ -9,7 +9,10 @@ import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.WindowInsetsSides
import androidx.compose.foundation.layout.asPaddingValues
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.only
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
@ -21,7 +24,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.unit.dp
import it.vfsfitvnm.vimusic.Database
import it.vfsfitvnm.vimusic.LocalPlayerAwarePaddingValues
import it.vfsfitvnm.vimusic.LocalPlayerAwareWindowInsets
import it.vfsfitvnm.vimusic.R
import it.vfsfitvnm.vimusic.enums.AlbumSortBy
import it.vfsfitvnm.vimusic.enums.SortOrder
@ -77,7 +80,8 @@ fun HomeAlbums(
Box {
LazyColumn(
state = lazyListState,
contentPadding = LocalPlayerAwarePaddingValues.current,
contentPadding = LocalPlayerAwareWindowInsets.current
.only(WindowInsetsSides.Vertical + WindowInsetsSides.End).asPaddingValues(),
modifier = Modifier
.background(colorPalette.background0)
.fillMaxSize()

View file

@ -25,7 +25,10 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.unit.dp
import it.vfsfitvnm.vimusic.Database
import it.vfsfitvnm.vimusic.LocalPlayerAwarePaddingValues
import it.vfsfitvnm.vimusic.LocalPlayerAwareWindowInsets
import androidx.compose.foundation.layout.WindowInsetsSides
import androidx.compose.foundation.layout.asPaddingValues
import androidx.compose.foundation.layout.only
import it.vfsfitvnm.vimusic.R
import it.vfsfitvnm.vimusic.enums.ArtistSortBy
import it.vfsfitvnm.vimusic.enums.SortOrder
@ -82,7 +85,8 @@ fun HomeArtistList(
LazyVerticalGrid(
state = lazyGridState,
columns = GridCells.Adaptive(Dimensions.thumbnails.song * 2 + Dimensions.itemsVerticalPadding * 2),
contentPadding = LocalPlayerAwarePaddingValues.current,
contentPadding = LocalPlayerAwareWindowInsets.current
.only(WindowInsetsSides.Vertical + WindowInsetsSides.End).asPaddingValues(),
verticalArrangement = Arrangement.spacedBy(Dimensions.itemsVerticalPadding * 2),
horizontalArrangement = Arrangement.spacedBy(
space = Dimensions.itemsVerticalPadding * 2,

View file

@ -10,7 +10,10 @@ import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.WindowInsetsSides
import androidx.compose.foundation.layout.asPaddingValues
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.only
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.lazy.grid.GridCells
import androidx.compose.foundation.lazy.grid.GridItemSpan
@ -27,7 +30,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.unit.dp
import it.vfsfitvnm.vimusic.Database
import it.vfsfitvnm.vimusic.LocalPlayerAwarePaddingValues
import it.vfsfitvnm.vimusic.LocalPlayerAwareWindowInsets
import it.vfsfitvnm.vimusic.R
import it.vfsfitvnm.vimusic.enums.BuiltInPlaylist
import it.vfsfitvnm.vimusic.enums.PlaylistSortBy
@ -107,7 +110,8 @@ fun HomePlaylists(
LazyVerticalGrid(
state = lazyGridState,
columns = GridCells.Adaptive(Dimensions.thumbnails.song * 2 + Dimensions.itemsVerticalPadding * 2),
contentPadding = LocalPlayerAwarePaddingValues.current,
contentPadding = LocalPlayerAwareWindowInsets.current
.only(WindowInsetsSides.Vertical + WindowInsetsSides.End).asPaddingValues(),
verticalArrangement = Arrangement.spacedBy(Dimensions.itemsVerticalPadding * 2),
horizontalArrangement = Arrangement.spacedBy(
space = Dimensions.itemsVerticalPadding * 2,

View file

@ -28,7 +28,12 @@ import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import it.vfsfitvnm.vimusic.Database
import it.vfsfitvnm.vimusic.LocalPlayerAwarePaddingValues
import it.vfsfitvnm.vimusic.LocalPlayerAwareWindowInsets
import androidx.compose.foundation.layout.WindowInsetsSides
import androidx.compose.foundation.layout.asPaddingValues
import androidx.compose.foundation.layout.only
import androidx.compose.foundation.layout.asPaddingValues
import androidx.compose.foundation.layout.only
import it.vfsfitvnm.vimusic.LocalPlayerServiceBinder
import it.vfsfitvnm.vimusic.R
import it.vfsfitvnm.vimusic.enums.SongSortBy
@ -99,7 +104,8 @@ fun HomeSongs(
) {
LazyColumn(
state = lazyListState,
contentPadding = LocalPlayerAwarePaddingValues.current,
contentPadding = LocalPlayerAwareWindowInsets.current
.only(WindowInsetsSides.Vertical + WindowInsetsSides.End).asPaddingValues(),
) {
item(
key = "header",

View file

@ -10,9 +10,12 @@ import androidx.compose.foundation.gestures.snapping.rememberSnapFlingBehavior
import androidx.compose.foundation.layout.BoxWithConstraints
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.WindowInsetsSides
import androidx.compose.foundation.layout.asPaddingValues
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.only
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
@ -34,7 +37,7 @@ import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.dp
import it.vfsfitvnm.vimusic.Database
import it.vfsfitvnm.vimusic.LocalPlayerAwarePaddingValues
import it.vfsfitvnm.vimusic.LocalPlayerAwareWindowInsets
import it.vfsfitvnm.vimusic.LocalPlayerServiceBinder
import it.vfsfitvnm.vimusic.R
import it.vfsfitvnm.vimusic.savers.DetailedSongSaver
@ -87,6 +90,7 @@ fun QuickPicks(
val (colorPalette, typography) = LocalAppearance.current
val binder = LocalPlayerServiceBinder.current
val menuState = LocalMenuState.current
val windowInsets = LocalPlayerAwareWindowInsets.current
val trending by produceSaveableState(
initialValue = null,
@ -116,10 +120,6 @@ fun QuickPicks(
val playlistThumbnailSizeDp = 108.dp
val playlistThumbnailSizePx = playlistThumbnailSizeDp.px
val sectionTextModifier = Modifier
.padding(horizontal = 16.dp)
.padding(top = 24.dp, bottom = 8.dp)
val quickPicksLazyGridItemWidthFactor = 0.9f
val quickPicksLazyGridState = rememberLazyGridState()
val snapLayoutInfoProvider = remember(quickPicksLazyGridState) {
@ -133,6 +133,13 @@ fun QuickPicks(
val scrollState = rememberScrollState()
val endPaddingValues = windowInsets.only(WindowInsetsSides.End).asPaddingValues()
val sectionTextModifier = Modifier
.padding(horizontal = 16.dp)
.padding(top = 24.dp, bottom = 8.dp)
.padding(endPaddingValues)
BoxWithConstraints {
val itemInHorizontalGridWidth = maxWidth * quickPicksLazyGridItemWidthFactor
@ -141,15 +148,20 @@ fun QuickPicks(
.background(colorPalette.background0)
.fillMaxSize()
.verticalScroll(scrollState)
.padding(LocalPlayerAwarePaddingValues.current)
.padding(windowInsets.only(WindowInsetsSides.Vertical).asPaddingValues())
) {
Header(title = "Quick picks")
Header(
title = "Quick picks",
modifier = Modifier
.padding(endPaddingValues)
)
relatedPageResult?.getOrNull()?.let { related ->
LazyHorizontalGrid(
state = quickPicksLazyGridState,
rows = GridCells.Fixed(4),
flingBehavior = rememberSnapFlingBehavior(snapLayoutInfoProvider),
contentPadding = endPaddingValues,
modifier = Modifier
.fillMaxWidth()
.height((songThumbnailSizeDp + Dimensions.itemsVerticalPadding * 2) * 4)
@ -234,7 +246,7 @@ fun QuickPicks(
modifier = sectionTextModifier
)
LazyRow {
LazyRow(contentPadding = endPaddingValues) {
items(
items = albums,
key = Innertube.AlbumItem::key
@ -258,7 +270,7 @@ fun QuickPicks(
modifier = sectionTextModifier
)
LazyRow {
LazyRow(contentPadding = endPaddingValues) {
items(
items = artists,
key = Innertube.ArtistItem::key,
@ -284,7 +296,7 @@ fun QuickPicks(
.padding(top = 24.dp, bottom = 8.dp)
)
LazyRow {
LazyRow(contentPadding = endPaddingValues) {
items(
items = playlists,
key = Innertube.PlaylistItem::key,

View file

@ -24,7 +24,10 @@ import it.vfsfitvnm.reordering.draggedItem
import it.vfsfitvnm.reordering.rememberReorderingState
import it.vfsfitvnm.reordering.reorder
import it.vfsfitvnm.vimusic.Database
import it.vfsfitvnm.vimusic.LocalPlayerAwarePaddingValues
import it.vfsfitvnm.vimusic.LocalPlayerAwareWindowInsets
import androidx.compose.foundation.layout.WindowInsetsSides
import androidx.compose.foundation.layout.asPaddingValues
import androidx.compose.foundation.layout.only
import it.vfsfitvnm.vimusic.LocalPlayerServiceBinder
import it.vfsfitvnm.vimusic.R
import it.vfsfitvnm.vimusic.models.DetailedSong
@ -138,7 +141,8 @@ fun LocalPlaylistSongs(
Box {
ReorderingLazyColumn(
reorderingState = reorderingState,
contentPadding = LocalPlayerAwarePaddingValues.current,
contentPadding = LocalPlayerAwareWindowInsets.current
.only(WindowInsetsSides.Vertical + WindowInsetsSides.End).asPaddingValues(),
modifier = Modifier
.background(colorPalette.background0)
.fillMaxSize()

View file

@ -22,7 +22,10 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import com.valentinilk.shimmer.shimmer
import it.vfsfitvnm.vimusic.Database
import it.vfsfitvnm.vimusic.LocalPlayerAwarePaddingValues
import it.vfsfitvnm.vimusic.LocalPlayerAwareWindowInsets
import androidx.compose.foundation.layout.WindowInsetsSides
import androidx.compose.foundation.layout.asPaddingValues
import androidx.compose.foundation.layout.only
import it.vfsfitvnm.vimusic.LocalPlayerServiceBinder
import it.vfsfitvnm.vimusic.R
import it.vfsfitvnm.vimusic.models.Playlist
@ -171,7 +174,8 @@ fun PlaylistSongList(
Box {
LazyColumn(
state = lazyListState,
contentPadding = LocalPlayerAwarePaddingValues.current,
contentPadding = LocalPlayerAwareWindowInsets.current
.only(WindowInsetsSides.Vertical + WindowInsetsSides.End).asPaddingValues(),
modifier = Modifier
.background(colorPalette.background0)
.fillMaxSize()

View file

@ -18,7 +18,10 @@ import androidx.compose.ui.text.input.ImeAction
import androidx.compose.ui.text.input.TextFieldValue
import androidx.compose.ui.text.style.TextAlign
import it.vfsfitvnm.vimusic.Database
import it.vfsfitvnm.vimusic.LocalPlayerAwarePaddingValues
import it.vfsfitvnm.vimusic.LocalPlayerAwareWindowInsets
import androidx.compose.foundation.layout.WindowInsetsSides
import androidx.compose.foundation.layout.asPaddingValues
import androidx.compose.foundation.layout.only
import it.vfsfitvnm.vimusic.LocalPlayerServiceBinder
import it.vfsfitvnm.vimusic.models.DetailedSong
import it.vfsfitvnm.vimusic.savers.DetailedSongListSaver
@ -73,7 +76,8 @@ fun LocalSongSearch(
Box {
LazyColumn(
state = lazyListState,
contentPadding = LocalPlayerAwarePaddingValues.current,
contentPadding = LocalPlayerAwareWindowInsets.current
.only(WindowInsetsSides.Vertical + WindowInsetsSides.End).asPaddingValues(),
modifier = Modifier
.fillMaxSize()
) {

View file

@ -40,7 +40,10 @@ import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.core.net.toUri
import it.vfsfitvnm.vimusic.Database
import it.vfsfitvnm.vimusic.LocalPlayerAwarePaddingValues
import it.vfsfitvnm.vimusic.LocalPlayerAwareWindowInsets
import androidx.compose.foundation.layout.WindowInsetsSides
import androidx.compose.foundation.layout.asPaddingValues
import androidx.compose.foundation.layout.only
import it.vfsfitvnm.vimusic.R
import it.vfsfitvnm.vimusic.models.SearchQuery
import it.vfsfitvnm.vimusic.query
@ -121,7 +124,8 @@ fun OnlineSearch(
Box {
LazyColumn(
state = lazyListState,
contentPadding = LocalPlayerAwarePaddingValues.current,
contentPadding = LocalPlayerAwareWindowInsets.current
.only(WindowInsetsSides.Vertical + WindowInsetsSides.End).asPaddingValues(),
modifier = Modifier
.fillMaxSize()
) {

View file

@ -17,7 +17,10 @@ import androidx.compose.runtime.saveable.Saver
import androidx.compose.runtime.snapshotFlow
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import it.vfsfitvnm.vimusic.LocalPlayerAwarePaddingValues
import it.vfsfitvnm.vimusic.LocalPlayerAwareWindowInsets
import androidx.compose.foundation.layout.WindowInsetsSides
import androidx.compose.foundation.layout.asPaddingValues
import androidx.compose.foundation.layout.only
import it.vfsfitvnm.vimusic.savers.nullableSaver
import it.vfsfitvnm.vimusic.ui.components.ShimmerHost
import it.vfsfitvnm.vimusic.ui.components.themed.FloatingActionsContainerWithScrollToTop
@ -75,7 +78,8 @@ inline fun <T : Innertube.Item> ItemsPage(
Box {
LazyColumn(
state = lazyListState,
contentPadding = LocalPlayerAwarePaddingValues.current,
contentPadding = LocalPlayerAwareWindowInsets.current
.only(WindowInsetsSides.Vertical + WindowInsetsSides.End).asPaddingValues(),
modifier = modifier
.fillMaxSize()
) {

View file

@ -3,7 +3,10 @@ package it.vfsfitvnm.vimusic.ui.screens.settings
import androidx.compose.animation.ExperimentalAnimationApi
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.WindowInsetsSides
import androidx.compose.foundation.layout.asPaddingValues
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.only
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.text.BasicText
@ -12,7 +15,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalUriHandler
import it.vfsfitvnm.vimusic.BuildConfig
import it.vfsfitvnm.vimusic.LocalPlayerAwarePaddingValues
import it.vfsfitvnm.vimusic.LocalPlayerAwareWindowInsets
import it.vfsfitvnm.vimusic.ui.components.themed.Header
import it.vfsfitvnm.vimusic.ui.styling.LocalAppearance
import it.vfsfitvnm.vimusic.utils.secondary
@ -28,7 +31,11 @@ fun About() {
.background(colorPalette.background0)
.fillMaxSize()
.verticalScroll(rememberScrollState())
.padding(LocalPlayerAwarePaddingValues.current)
.padding(
LocalPlayerAwareWindowInsets.current
.only(WindowInsetsSides.Vertical + WindowInsetsSides.End)
.asPaddingValues()
)
) {
Header(title = "About") {
BasicText(

View file

@ -15,7 +15,10 @@ import androidx.compose.runtime.getValue
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import it.vfsfitvnm.vimusic.LocalPlayerAwarePaddingValues
import it.vfsfitvnm.vimusic.LocalPlayerAwareWindowInsets
import androidx.compose.foundation.layout.WindowInsetsSides
import androidx.compose.foundation.layout.asPaddingValues
import androidx.compose.foundation.layout.only
import it.vfsfitvnm.vimusic.enums.ColorPaletteMode
import it.vfsfitvnm.vimusic.enums.ColorPaletteName
import it.vfsfitvnm.vimusic.enums.ThumbnailRoundness
@ -48,7 +51,11 @@ fun AppearanceSettings() {
.background(colorPalette.background0)
.fillMaxSize()
.verticalScroll(rememberScrollState())
.padding(LocalPlayerAwarePaddingValues.current)
.padding(
LocalPlayerAwareWindowInsets.current
.only(WindowInsetsSides.Vertical + WindowInsetsSides.End)
.asPaddingValues()
)
) {
Header(title = "Appearance")

View file

@ -4,7 +4,10 @@ import android.text.format.Formatter
import androidx.compose.animation.ExperimentalAnimationApi
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.WindowInsetsSides
import androidx.compose.foundation.layout.asPaddingValues
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.only
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
@ -17,7 +20,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import coil.Coil
import coil.annotation.ExperimentalCoilApi
import it.vfsfitvnm.vimusic.LocalPlayerAwarePaddingValues
import it.vfsfitvnm.vimusic.LocalPlayerAwareWindowInsets
import it.vfsfitvnm.vimusic.LocalPlayerServiceBinder
import it.vfsfitvnm.vimusic.enums.CoilDiskCacheMaxSize
import it.vfsfitvnm.vimusic.enums.ExoPlayerDiskCacheMaxSize
@ -49,7 +52,11 @@ fun CacheSettings() {
.background(colorPalette.background0)
.fillMaxSize()
.verticalScroll(rememberScrollState())
.padding(LocalPlayerAwarePaddingValues.current)
.padding(
LocalPlayerAwareWindowInsets.current
.only(WindowInsetsSides.Vertical + WindowInsetsSides.End)
.asPaddingValues()
)
) {
Header(title = "Cache")
@ -64,7 +71,14 @@ fun CacheSettings() {
SettingsEntryGroupText(title = "IMAGE CACHE")
SettingsDescription(text = "${Formatter.formatShortFileSize(context, diskCacheSize)} used (${diskCacheSize * 100 / coilDiskCacheMaxSize.bytes.coerceAtLeast(1)}%)")
SettingsDescription(
text = "${
Formatter.formatShortFileSize(
context,
diskCacheSize
)
} used (${diskCacheSize * 100 / coilDiskCacheMaxSize.bytes.coerceAtLeast(1)}%)"
)
EnumValueSelectorSettingsEntry(
title = "Max size",

View file

@ -16,7 +16,10 @@ import androidx.compose.runtime.saveable.autoSaver
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import it.vfsfitvnm.vimusic.Database
import it.vfsfitvnm.vimusic.LocalPlayerAwarePaddingValues
import it.vfsfitvnm.vimusic.LocalPlayerAwareWindowInsets
import androidx.compose.foundation.layout.WindowInsetsSides
import androidx.compose.foundation.layout.asPaddingValues
import androidx.compose.foundation.layout.only
import it.vfsfitvnm.vimusic.checkpoint
import it.vfsfitvnm.vimusic.internal
import it.vfsfitvnm.vimusic.path
@ -90,7 +93,11 @@ fun DatabaseSettings() {
.background(colorPalette.background0)
.fillMaxSize()
.verticalScroll(rememberScrollState())
.padding(LocalPlayerAwarePaddingValues.current)
.padding(
LocalPlayerAwareWindowInsets.current
.only(WindowInsetsSides.Vertical + WindowInsetsSides.End)
.asPaddingValues()
)
) {
Header(title = "Database")

View file

@ -22,7 +22,10 @@ import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import it.vfsfitvnm.vimusic.LocalPlayerAwarePaddingValues
import it.vfsfitvnm.vimusic.LocalPlayerAwareWindowInsets
import androidx.compose.foundation.layout.WindowInsetsSides
import androidx.compose.foundation.layout.asPaddingValues
import androidx.compose.foundation.layout.only
import it.vfsfitvnm.vimusic.ui.components.themed.Header
import it.vfsfitvnm.vimusic.ui.styling.LocalAppearance
import it.vfsfitvnm.vimusic.utils.isIgnoringBatteryOptimizations
@ -51,7 +54,11 @@ fun OtherSettings() {
.background(colorPalette.background0)
.fillMaxSize()
.verticalScroll(rememberScrollState())
.padding(LocalPlayerAwarePaddingValues.current)
.padding(
LocalPlayerAwareWindowInsets.current
.only(WindowInsetsSides.Vertical + WindowInsetsSides.End)
.asPaddingValues()
)
) {
Header(title = "Other")

View file

@ -17,7 +17,10 @@ import androidx.compose.runtime.getValue
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import it.vfsfitvnm.vimusic.LocalPlayerAwarePaddingValues
import it.vfsfitvnm.vimusic.LocalPlayerAwareWindowInsets
import androidx.compose.foundation.layout.WindowInsetsSides
import androidx.compose.foundation.layout.asPaddingValues
import androidx.compose.foundation.layout.only
import it.vfsfitvnm.vimusic.LocalPlayerServiceBinder
import it.vfsfitvnm.vimusic.ui.components.themed.Header
import it.vfsfitvnm.vimusic.ui.styling.LocalAppearance
@ -46,7 +49,11 @@ fun PlayerSettings() {
.background(colorPalette.background0)
.fillMaxSize()
.verticalScroll(rememberScrollState())
.padding(LocalPlayerAwarePaddingValues.current)
.padding(
LocalPlayerAwareWindowInsets.current
.only(WindowInsetsSides.Vertical + WindowInsetsSides.End)
.asPaddingValues()
)
) {
Header(title = "Player & Audio")