Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions ui/components/src/main/kotlin/com/getcode/ui/components/Modal.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.getcode.ui.components
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ColumnScope
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.navigationBars
Expand All @@ -21,6 +22,11 @@ import com.getcode.theme.CodeTheme
fun Modal(
modifier: Modifier = Modifier,
backgroundColor: Color = CodeTheme.colors.brandContainer,
contentPadding: PaddingValues = PaddingValues(
horizontal = CodeTheme.dimens.inset,
vertical = CodeTheme.dimens.grid.x2
),
horizontalAlignment: Alignment.Horizontal = Alignment.CenterHorizontally,
verticalArrangement: Arrangement.Vertical = Arrangement.spacedBy(CodeTheme.dimens.grid.x2),
content: @Composable ColumnScope.() -> Unit
) {
Expand All @@ -36,9 +42,9 @@ fun Modal(
modifier = Modifier
.fillMaxWidth()
.wrapContentHeight()
.padding(horizontal = CodeTheme.dimens.inset, vertical = CodeTheme.dimens.grid.x2)
.padding(contentPadding)
.windowInsetsPadding(WindowInsets.navigationBars),
horizontalAlignment = Alignment.CenterHorizontally,
horizontalAlignment = horizontalAlignment,
verticalArrangement = verticalArrangement,
) {
content()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import androidx.compose.foundation.background
import androidx.compose.foundation.clickable

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
Expand Down Expand Up @@ -72,6 +73,14 @@ fun BottomBarContainer(
) {
val scope = rememberCoroutineScope()
val bottomBarMessage by barMessages.bottomBar.collectAsStateWithLifecycle()
// The manager clears the message immediately on close (see onClose) so other
// screens don't re-show it. Retain the last non-null message so the exit
// transition still has content to render, otherwise the bar blanks out and
// the slide-out animation isn't visible.
var exitingMessage by remember { mutableStateOf(bottomBarMessage) }
LaunchedEffect(bottomBarMessage) {
if (bottomBarMessage != null) exitingMessage = bottomBarMessage
}
val bottomBarVisibleState = remember(bottomBarMessage?.id) { MutableTransitionState(false) }
var bottomBarMessageDismissId by remember { mutableLongStateOf(0L) }
val animationScale by rememberAnimationScale()
Expand Down Expand Up @@ -171,7 +180,7 @@ fun BottomBarContainer(
scope.launch { onClose(selection, false) }
}
BottomBarView(
bottomBarMessage = bottomBarMessage,
bottomBarMessage = exitingMessage,
onShown = onShown,
onClose = closeWith,
onBackPressed = { closeWith(SelectedBottomBarAction(-1)) }
Expand Down Expand Up @@ -205,6 +214,13 @@ fun BottomBarView(
) {
Modal(
backgroundColor = bottomBarMessage.type.backgroundColor(),
contentPadding = PaddingValues(
top = CodeTheme.dimens.inset,
start = CodeTheme.dimens.inset,
end = CodeTheme.dimens.inset,
),
horizontalAlignment = Alignment.Start,
verticalArrangement = Arrangement.spacedBy(CodeTheme.dimens.grid.x3),
) {
if (bottomBarMessage.title.isNotEmpty()) {
CompositionLocalProvider(LocalContentColor provides White) {
Expand All @@ -213,12 +229,12 @@ fun BottomBarView(
verticalArrangement = Arrangement.spacedBy(CodeTheme.dimens.grid.x2)
) {
Text(
style = CodeTheme.typography.textMedium,
style = CodeTheme.typography.textLarge,
text = bottomBarMessage.title
)
if (bottomBarMessage.subtitle.isNotEmpty()) {
Text(
style = CodeTheme.typography.textSmall,
style = CodeTheme.typography.caption,
text = bottomBarMessage.subtitle,
color = LocalContentColor.current.copy(alpha = 0.8f)
)
Expand Down
Loading