Skip to content

Commit 11145ef

Browse files
committed
style(ui/components): give BottomBar's a little bounce
show scrim in various places Signed-off-by: Brandon McAnsh <[email protected]>
1 parent 155547c commit 11145ef

File tree

8 files changed

+56
-24
lines changed

8 files changed

+56
-24
lines changed

apps/flipcash/app/src/main/kotlin/com/flipcash/app/HomeViewModel.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class HomeViewModel @Inject constructor(
3535
positiveText = resources.getString(R.string.action_logIn),
3636
tertiaryText = resources.getString(R.string.action_cancel),
3737
isDismissible = false,
38+
showScrim = true,
3839
onPositive = {
3940
viewModelScope.launch {
4041
delay(150) // wait for dismiss

apps/flipcash/features/balance/src/main/kotlin/com/flipcash/app/balance/internal/BalanceViewModel.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ internal class BalanceViewModel @Inject constructor(
6767
BottomBarManager.BottomBarMessage(
6868
title = title,
6969
subtitle = resources.getString(R.string.prompt_description_cancelTransfer),
70+
showScrim = true,
7071
positiveText = resources.getString(R.string.action_cancelTransfer),
7172
onPositive = { dispatchEvent(Event.CancelTransfer(vault = metadata.creator)) },
7273
negativeText = resources.getString(R.string.action_nevermind)

apps/flipcash/features/login/src/main/kotlin/com/flipcash/app/login/accesskey/AccessKeyScreen.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ internal fun AccessKeyScreenContent(viewModel: LoginAccessKeyViewModel, onComple
219219
title = context.getString(R.string.prompt_title_wroteThemDown),
220220
subtitle = context
221221
.getString(R.string.prompt_description_wroteThemDown),
222+
showScrim = true,
222223
positiveText = context
223224
.getString(R.string.action_yesWroteThemDown),
224225
negativeText = "",
@@ -298,6 +299,7 @@ internal fun AccessKeyScreenContent(viewModel: LoginAccessKeyViewModel, onComple
298299
title = context.getString(R.string.prompt_title_exitAccountCreation),
299300
subtitle = context
300301
.getString(R.string.prompt_description_exitAccountCreation),
302+
showScrim = true,
301303
positiveText = context.getString(R.string.action_exit),
302304
negativeText = "",
303305
tertiaryText = context.getString(R.string.action_cancel),

apps/flipcash/features/menu/src/main/kotlin/com/flipcash/app/menu/internal/MenuScreenViewModel.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ internal class MenuScreenViewModel @Inject constructor(
122122
BottomBarManager.BottomBarMessage(
123123
title = resources.getString(R.string.prompt_title_logout),
124124
subtitle = resources.getString(R.string.prompt_description_logout),
125+
showScrim = true,
125126
positiveText = resources.getString(R.string.action_logout),
126127
tertiaryText = resources.getString(R.string.action_cancel),
127128
onPositive = {

apps/flipcash/features/myaccount/src/main/kotlin/com/flipcash/app/myaccount/internal/MyAccountScreenViewModel.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ internal class MyAccountScreenViewModel @Inject constructor(
9595
BottomBarManager.showMessage(
9696
BottomBarManager.BottomBarMessage(
9797
title = resources.getString(R.string.prompt_title_deleteAccount),
98+
showScrim = true,
9899
subtitle = resources.getString(R.string.prompt_description_deleteAccount),
99100
positiveText = resources.getString(R.string.action_deleteAccount),
100101
tertiaryText = resources.getString(R.string.action_cancel),
@@ -144,6 +145,7 @@ internal class MyAccountScreenViewModel @Inject constructor(
144145
BottomBarManager.BottomBarMessage(
145146
title = resources.getString(R.string.prompt_title_viewAccessKey),
146147
subtitle = resources.getString(R.string.prompt_description_viewAccessKey),
148+
showScrim = true,
147149
positiveText = resources.getString(R.string.action_viewAccessKey),
148150
negativeText = resources.getString(R.string.action_cancel),
149151
onPositive = { dispatchEvent(Event.OnViewAccessKey) },

apps/flipcash/features/withdrawal/src/main/kotlin/com/flipcash/app/withdrawal/WithdrawalViewModel.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,7 @@ internal class WithdrawalViewModel @Inject constructor(
343343
BottomBarManager.BottomBarMessage(
344344
title = resources.getString(R.string.prompt_title_confirmWithdrawal),
345345
subtitle = resources.getString(R.string.prompt_description_confirmWithdrawal),
346+
showScrim = true,
346347
actions = buildList {
347348
add(
348349
BottomBarAction(

apps/flipcash/features/withdrawal/src/main/kotlin/com/flipcash/app/withdrawal/internal/confirmation/WithdrawalConfirmationScreen.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ internal fun WithdrawalConfirmationScreen(viewModel: WithdrawalViewModel) {
6161
title = resources.getString(R.string.success_title_withdrawalComplete),
6262
subtitle = resources.getString(R.string.success_description_withdrawalComplete),
6363
showCancel = false,
64+
showScrim = true,
6465
type = BottomBarManager.BottomBarMessageType.SUCCESS,
6566
actions = listOf(
6667
BottomBarAction(

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

Lines changed: 47 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
package com.getcode.ui.components.bars
22

33
import androidx.activity.compose.BackHandler
4+
import androidx.compose.animation.AnimatedContent
45
import androidx.compose.animation.AnimatedVisibility
56
import androidx.compose.animation.core.MutableTransitionState
7+
import androidx.compose.animation.core.Spring
68
import androidx.compose.animation.core.animateFloatAsState
9+
import androidx.compose.animation.core.spring
710
import androidx.compose.animation.core.tween
11+
import androidx.compose.animation.fadeIn
812
import androidx.compose.animation.slideInVertically
913
import androidx.compose.animation.slideOutVertically
14+
import androidx.compose.animation.togetherWith
1015
import androidx.compose.foundation.background
1116
import androidx.compose.foundation.interaction.MutableInteractionSource
1217
import androidx.compose.foundation.layout.Arrangement
@@ -34,6 +39,7 @@ import androidx.compose.runtime.setValue
3439
import androidx.compose.ui.Alignment
3540
import androidx.compose.ui.Modifier
3641
import androidx.compose.ui.draw.alpha
42+
import androidx.compose.ui.draw.clipToBounds
3743
import androidx.compose.ui.graphics.Color
3844
import androidx.compose.ui.res.stringResource
3945
import androidx.compose.ui.text.style.TextAlign
@@ -121,22 +127,37 @@ fun BottomBarContainer(barMessages: BarMessages) {
121127
}
122128
}
123129

124-
AnimatedVisibility(
125-
modifier = Modifier.fillMaxSize(),
126-
visibleState = bottomBarVisibleState,
127-
enter = slideInVertically(
128-
initialOffsetY = { it / 2 },
129-
animationSpec = tween(300.scaled(animationScale).toInt())
130-
),
131-
exit = slideOutVertically(
132-
targetOffsetY = { it },
133-
animationSpec = tween(300.scaled(animationScale).toInt())
134-
),
135-
) {
136-
val closeWith: (fromAction: Boolean) -> Unit = { fromAction ->
137-
scope.launch { onClose(fromAction) }
130+
AnimatedContent(
131+
modifier = Modifier.fillMaxSize()
132+
.clipToBounds(),
133+
targetState = bottomBarVisibleState.targetState,
134+
transitionSpec = {
135+
slideInVertically(
136+
initialOffsetY = { it / 2 },
137+
animationSpec = spring(
138+
dampingRatio = Spring.DampingRatioLowBouncy,
139+
stiffness = Spring.StiffnessMediumLow
140+
)
141+
) togetherWith slideOutVertically(
142+
targetOffsetY = { it },
143+
animationSpec = spring(
144+
dampingRatio = Spring.DampingRatioNoBouncy,
145+
stiffness = Spring.StiffnessLow
146+
)
147+
)
148+
},
149+
label = "BottomBarAnimation"
150+
) { isVisible ->
151+
if (isVisible) {
152+
val closeWith: (fromAction: Boolean) -> Unit = { fromAction ->
153+
scope.launch { onClose(fromAction) }
154+
}
155+
BottomBarView(
156+
bottomBarMessage = bottomBarMessage,
157+
onClose = closeWith,
158+
onBackPressed = { closeWith(false) }
159+
)
138160
}
139-
BottomBarView(bottomBarMessage = bottomBarMessage, closeWith, onBackPressed = { closeWith(false)})
140161
}
141162
}
142163

@@ -153,19 +174,12 @@ fun BottomBarView(
153174
}
154175

155176
Box(
177+
modifier = Modifier.fillMaxWidth(),
156178
contentAlignment = Alignment.BottomCenter
157179
) {
158180
Column(
159181
modifier = Modifier
160-
.background(
161-
when (bottomBarMessage.type) {
162-
BottomBarManager.BottomBarMessageType.DESTRUCTIVE -> CodeTheme.colors.bannerError
163-
BottomBarManager.BottomBarMessageType.REMOTE_SEND -> CodeTheme.colors.brandLight
164-
BottomBarManager.BottomBarMessageType.THEMED -> CodeTheme.colors.brand
165-
BottomBarManager.BottomBarMessageType.WARNING -> CodeTheme.colors.bannerWarning
166-
BottomBarManager.BottomBarMessageType.SUCCESS -> CodeTheme.colors.bannerSuccess
167-
}
168-
)
182+
.background(bottomBarMessage.type.backgroundColor())
169183
.padding(top = CodeTheme.dimens.inset)
170184
.padding(horizontal = CodeTheme.dimens.inset)
171185
.windowInsetsPadding(WindowInsets.navigationBars),
@@ -238,4 +252,13 @@ fun BottomBarView(
238252
}
239253
}
240254
}
255+
}
256+
257+
@Composable
258+
private fun BottomBarManager.BottomBarMessageType.backgroundColor(): Color = when (this) {
259+
BottomBarManager.BottomBarMessageType.DESTRUCTIVE -> CodeTheme.colors.bannerError
260+
BottomBarManager.BottomBarMessageType.REMOTE_SEND -> CodeTheme.colors.brandLight
261+
BottomBarManager.BottomBarMessageType.THEMED -> CodeTheme.colors.brand
262+
BottomBarManager.BottomBarMessageType.WARNING -> CodeTheme.colors.bannerWarning
263+
BottomBarManager.BottomBarMessageType.SUCCESS -> CodeTheme.colors.bannerSuccess
241264
}

0 commit comments

Comments
 (0)