Skip to content

Commit

Permalink
Fix CollapsedPlayerView UI being obsecured by navigation buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
mr3y-the-programmer committed Feb 15, 2024
1 parent 7043931 commit 8c14519
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
13 changes: 8 additions & 5 deletions app/src/main/kotlin/com/mr3y/podcaster/ui/screens/HomeScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import androidx.compose.foundation.layout.BoxWithConstraints
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.asPaddingValues
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
Expand Down Expand Up @@ -53,6 +54,7 @@ import androidx.navigation.compose.rememberNavController
import com.kiwi.navigationcompose.typed.createRoutePattern
import com.kiwi.navigationcompose.typed.navigate
import com.mr3y.podcaster.LocalStrings
import com.mr3y.podcaster.ui.components.plus
import com.mr3y.podcaster.ui.navigation.Destinations
import com.mr3y.podcaster.ui.navigation.PodcasterNavGraph
import com.mr3y.podcaster.ui.presenter.PodcasterAppState
Expand Down Expand Up @@ -157,7 +159,8 @@ fun HomeScreen(
val density = LocalDensity.current
val expandedPlayerViewHeight = maxHeight
val collapsedPlayerViewHeight = 104.dp
val collapsedPlayerViewOffset = with(density) { expandedPlayerViewHeight.toPx() - collapsedPlayerViewHeight.toPx() }
val collapsedPlayerViewBottomInsets = WindowInsets.navigationBars
val collapsedPlayerViewOffset = with(density) { expandedPlayerViewHeight.toPx() - collapsedPlayerViewHeight.toPx() - collapsedPlayerViewBottomInsets.getBottom(this) }

val anchors = DraggableAnchors {
PlayerViewState.Expanded at 0f
Expand Down Expand Up @@ -191,16 +194,16 @@ fun HomeScreen(
}
}
}
val playerViewBottomInsets = WindowInsets.navigationBars

PodcasterNavGraph(
navController = navController,
onNavDrawerClick = {
scope.launch { drawerState.open() }
},
appState = appState,
userPreferences = userPreferences,
contentPadding = PaddingValues(bottom = if (currentlyPlayingEpisode != null) collapsedPlayerViewHeight else 0.dp),
excludedWindowInsets = if (currentlyPlayingEpisode != null) playerViewBottomInsets else null,
contentPadding = PaddingValues(bottom = if (currentlyPlayingEpisode != null) collapsedPlayerViewHeight else 0.dp) + collapsedPlayerViewBottomInsets.asPaddingValues(density),
excludedWindowInsets = if (currentlyPlayingEpisode != null) collapsedPlayerViewBottomInsets else null,
)
currentlyPlayingEpisode?.let { activeEpisode ->
val isCollapsed = state.targetValue == PlayerViewState.Collapsed
Expand Down Expand Up @@ -231,7 +234,7 @@ fun HomeScreen(
onResume = appState::resume,
onPause = appState::pause,
progress = trackProgress,
contentWindowInsets = playerViewBottomInsets,
contentWindowInsets = collapsedPlayerViewBottomInsets,
containerColor = containerColor,
)
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,13 @@ import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.WindowInsets
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.navigationBars
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.windowInsetsPadding
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.CornerSize
Expand Down Expand Up @@ -343,8 +342,8 @@ fun CollapsedPlayerView(
) {
Column(
modifier = Modifier
.fillMaxWidth()
.windowInsetsPadding(contentWindowInsets),
.padding(contentWindowInsets.asPaddingValues())
.fillMaxWidth(),
) {
Row(
verticalAlignment = Alignment.CenterVertically,
Expand Down Expand Up @@ -399,7 +398,6 @@ fun CollapsedPlayerView(
val progressColor = MaterialTheme.colorScheme.primaryTertiary
Box(
modifier = Modifier
.padding(bottom = 8.dp)
.fillMaxWidth()
.height(8.dp)
.background(MaterialTheme.colorScheme.inverseSurface.copy(alpha = 0.45f))
Expand Down

0 comments on commit 8c14519

Please sign in to comment.