Skip to content
This repository has been archived by the owner on Mar 18, 2024. It is now read-only.

Commit

Permalink
Improve sliding panel
Browse files Browse the repository at this point in the history
  • Loading branch information
AnkitSuda committed Nov 19, 2022
1 parent b9cb436 commit 21080b6
Show file tree
Hide file tree
Showing 2 changed files with 282 additions and 252 deletions.
10 changes: 8 additions & 2 deletions app/src/main/java/com/ankitsuda/rebound/ui/main/MainScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import androidx.compose.material.icons.filled.*
import androidx.compose.material.icons.outlined.*
import androidx.compose.runtime.*
import androidx.compose.runtime.livedata.observeAsState
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.vector.ImageVector
Expand Down Expand Up @@ -108,7 +109,9 @@ private fun MainLayout(
initial = AppSettings.defValues()
)

val panelHidden = currentWorkoutId == NONE_WORKOUT_ID
val panelHidden by rememberSaveable(currentWorkoutId) {
mutableStateOf(currentWorkoutId == NONE_WORKOUT_ID)
}

var dialogContent: @Composable () -> Unit by remember {
mutableStateOf({})
Expand All @@ -134,6 +137,10 @@ private fun MainLayout(
swipeableState = swipeableState
)

LaunchedEffect(key1 = panelHidden) {
swipeableState.animateTo(if (panelHidden) 0 else 1)
}

ReboundThemeWrapper(themeState = themeState) {
NavigatorHost {
CompositionLocalProvider(
Expand All @@ -160,7 +167,6 @@ private fun MainLayout(
) {
val navigator = LocalNavigator.current
MainScreenScaffold(
modifier = Modifier,
panelHidden = panelHidden,
swipeableState = swipeableState,
bottomBar = {
Expand Down
Loading

0 comments on commit 21080b6

Please sign in to comment.