Skip to content

Commit 5a0d284

Browse files
authored
fix(ui): restore BottomBar padding after Modal migration (#1170)
* fix(ui): restore BottomBar padding after Modal migration PR #1128 migrated BottomBarContainer to the shared Modal composable but inherited Modal's own layout defaults, changing how the bar renders: - top inset padding was halved (inset -> grid.x2) - an extra bottom gap was added (grid.x2, on top of the button's own padding) - item spacing tightened (grid.x3 -> grid.x2) - title/subtitle became center-aligned instead of start-aligned Parameterize Modal with contentPadding and horizontalAlignment (defaults unchanged, so other callers like ReceivedFundsConfirmation are unaffected) and pass the original BottomBarView values from BottomBarContainer. * fix(ui): use textLarge for BottomBar title and caption for message * fix(ui): keep BottomBar content during exit so slide-out animation is visible The manager clears the active message immediately on close (so other screens don't re-show it), which set bottomBarMessage to null before the AnimatedContent exit transition finished. BottomBarView early-returns on a null message, so the outgoing frame rendered nothing and the bar appeared to vanish instantly instead of sliding out. Retain the last non-null message and render that during the transition so the slide-out animation is visible.
1 parent 1b8a7fb commit 5a0d284

2 files changed

Lines changed: 27 additions & 5 deletions

File tree

‎ui/components/src/main/kotlin/com/getcode/ui/components/Modal.kt‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package com.getcode.ui.components
33
import androidx.compose.foundation.layout.Arrangement
44
import androidx.compose.foundation.layout.Column
55
import androidx.compose.foundation.layout.ColumnScope
6+
import androidx.compose.foundation.layout.PaddingValues
67
import androidx.compose.foundation.layout.WindowInsets
78
import androidx.compose.foundation.layout.fillMaxWidth
89
import androidx.compose.foundation.layout.navigationBars
@@ -21,6 +22,11 @@ import com.getcode.theme.CodeTheme
2122
fun Modal(
2223
modifier: Modifier = Modifier,
2324
backgroundColor: Color = CodeTheme.colors.brandContainer,
25+
contentPadding: PaddingValues = PaddingValues(
26+
horizontal = CodeTheme.dimens.inset,
27+
vertical = CodeTheme.dimens.grid.x2
28+
),
29+
horizontalAlignment: Alignment.Horizontal = Alignment.CenterHorizontally,
2430
verticalArrangement: Arrangement.Vertical = Arrangement.spacedBy(CodeTheme.dimens.grid.x2),
2531
content: @Composable ColumnScope.() -> Unit
2632
) {
@@ -36,9 +42,9 @@ fun Modal(
3642
modifier = Modifier
3743
.fillMaxWidth()
3844
.wrapContentHeight()
39-
.padding(horizontal = CodeTheme.dimens.inset, vertical = CodeTheme.dimens.grid.x2)
45+
.padding(contentPadding)
4046
.windowInsetsPadding(WindowInsets.navigationBars),
41-
horizontalAlignment = Alignment.CenterHorizontally,
47+
horizontalAlignment = horizontalAlignment,
4248
verticalArrangement = verticalArrangement,
4349
) {
4450
content()

‎ui/components/src/main/kotlin/com/getcode/ui/components/bars/BottomBarContainer.kt‎

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import androidx.compose.foundation.background
1313
import androidx.compose.foundation.clickable
1414

1515
import androidx.compose.foundation.layout.Arrangement
16+
import androidx.compose.foundation.layout.PaddingValues
1617
import androidx.compose.foundation.layout.Box
1718
import androidx.compose.foundation.layout.Column
1819
import androidx.compose.foundation.layout.Row
@@ -72,6 +73,14 @@ fun BottomBarContainer(
7273
) {
7374
val scope = rememberCoroutineScope()
7475
val bottomBarMessage by barMessages.bottomBar.collectAsStateWithLifecycle()
76+
// The manager clears the message immediately on close (see onClose) so other
77+
// screens don't re-show it. Retain the last non-null message so the exit
78+
// transition still has content to render, otherwise the bar blanks out and
79+
// the slide-out animation isn't visible.
80+
var exitingMessage by remember { mutableStateOf(bottomBarMessage) }
81+
LaunchedEffect(bottomBarMessage) {
82+
if (bottomBarMessage != null) exitingMessage = bottomBarMessage
83+
}
7584
val bottomBarVisibleState = remember(bottomBarMessage?.id) { MutableTransitionState(false) }
7685
var bottomBarMessageDismissId by remember { mutableLongStateOf(0L) }
7786
val animationScale by rememberAnimationScale()
@@ -171,7 +180,7 @@ fun BottomBarContainer(
171180
scope.launch { onClose(selection, false) }
172181
}
173182
BottomBarView(
174-
bottomBarMessage = bottomBarMessage,
183+
bottomBarMessage = exitingMessage,
175184
onShown = onShown,
176185
onClose = closeWith,
177186
onBackPressed = { closeWith(SelectedBottomBarAction(-1)) }
@@ -205,6 +214,13 @@ fun BottomBarView(
205214
) {
206215
Modal(
207216
backgroundColor = bottomBarMessage.type.backgroundColor(),
217+
contentPadding = PaddingValues(
218+
top = CodeTheme.dimens.inset,
219+
start = CodeTheme.dimens.inset,
220+
end = CodeTheme.dimens.inset,
221+
),
222+
horizontalAlignment = Alignment.Start,
223+
verticalArrangement = Arrangement.spacedBy(CodeTheme.dimens.grid.x3),
208224
) {
209225
if (bottomBarMessage.title.isNotEmpty()) {
210226
CompositionLocalProvider(LocalContentColor provides White) {
@@ -213,12 +229,12 @@ fun BottomBarView(
213229
verticalArrangement = Arrangement.spacedBy(CodeTheme.dimens.grid.x2)
214230
) {
215231
Text(
216-
style = CodeTheme.typography.textMedium,
232+
style = CodeTheme.typography.textLarge,
217233
text = bottomBarMessage.title
218234
)
219235
if (bottomBarMessage.subtitle.isNotEmpty()) {
220236
Text(
221-
style = CodeTheme.typography.textSmall,
237+
style = CodeTheme.typography.caption,
222238
text = bottomBarMessage.subtitle,
223239
color = LocalContentColor.current.copy(alpha = 0.8f)
224240
)

0 commit comments

Comments
 (0)