@@ -4,6 +4,7 @@ import androidx.compose.animation.core.tween
44import androidx.compose.animation.fadeIn
55import androidx.compose.animation.scaleIn
66import androidx.compose.foundation.Image
7+ import androidx.compose.foundation.layout.Arrangement
78import androidx.compose.foundation.layout.Box
89import androidx.compose.foundation.layout.Column
910import androidx.compose.foundation.layout.PaddingValues
@@ -15,7 +16,6 @@ import androidx.compose.material.Text
1516import androidx.compose.runtime.Composable
1617import androidx.compose.ui.Alignment
1718import androidx.compose.ui.Modifier
18- import androidx.compose.ui.draw.clip
1919import androidx.compose.ui.graphics.painter.Painter
2020import androidx.compose.ui.layout.Layout
2121import androidx.compose.ui.layout.layoutId
@@ -24,101 +24,99 @@ import androidx.compose.ui.res.stringResource
2424import androidx.compose.ui.tooling.preview.Preview
2525import androidx.compose.ui.unit.Dp
2626import androidx.compose.ui.unit.dp
27+ import androidx.compose.ui.util.fastForEach
2728import com.getcode.R
2829import com.getcode.theme.CodeTheme
2930import com.getcode.ui.components.Badge
3031import com.getcode.ui.components.Row
3132import com.getcode.ui.components.chat.ChatNodeDefaults
3233import com.getcode.ui.utils.heightOrZero
33- import com.getcode.ui.utils.rememberedClickable
34+ import com.getcode.ui.utils.unboundedClickable
3435import com.getcode.ui.utils.widthOrZero
35- import com.getcode.view.main.home.HomeBottomSheet
36+ import com.getcode.view.main.home.HomeAction
3637import com.getcode.view.main.home.HomeUiModel
3738
3839@Preview
3940@Composable
4041internal fun HomeBottom (
4142 modifier : Modifier = Modifier ,
4243 state : HomeUiModel = HomeUiModel (),
43- onPress : (homeBottomSheet: HomeBottomSheet ) -> Unit = {},
44+ onPress : (homeBottomSheet: HomeAction ) -> Unit = {},
4445) {
4546 Row (
4647 modifier = Modifier
4748 .fillMaxWidth()
4849 .then(modifier),
4950 verticalAlignment = Alignment .Bottom ,
50- contentPadding = PaddingValues (horizontal = CodeTheme .dimens.grid.x3) ,
51+ horizontalArrangement = Arrangement . SpaceAround ,
5152 ) {
52- BottomBarAction (
53- label = if (state.tipCardOnHomeScreen.enabled) {
54- stringResource(R .string.title_tipCard)
55- } else {
56- stringResource(R .string.title_getCash)
57- },
58- contentPadding = PaddingValues (
59- start = CodeTheme .dimens.grid.x3,
60- end = CodeTheme .dimens.grid.x3,
61- top = CodeTheme .dimens.grid.x1,
62- bottom = CodeTheme .dimens.grid.x2,
63- ),
64- imageSize = CodeTheme .dimens.grid.x7,
65- painter = if (state.tipCardOnHomeScreen.enabled) {
66- painterResource(R .drawable.ic_tip_card)
67- } else {
68- painterResource(R .drawable.ic_wallet)
69- },
70- onClick = {
71- if (state.tipCardOnHomeScreen.enabled) {
72- onPress(HomeBottomSheet .TIP_CARD )
73- } else {
74- onPress(HomeBottomSheet .GET_KIN )
53+ state.actions.fastForEach { action ->
54+ when (action) {
55+ HomeAction .GIVE_KIN -> {
56+ BottomBarAction (
57+ modifier = Modifier .weight(1f ),
58+ label = stringResource(R .string.action_give),
59+ painter = painterResource(R .drawable.ic_kin_white_small),
60+ onClick = { onPress(action) }
61+ )
7562 }
76- },
77- )
78- Spacer (modifier = Modifier .weight(1f ))
79- BottomBarAction (
80- label = stringResource(R .string.action_giveKin),
81- contentPadding = PaddingValues (
82- horizontal = CodeTheme .dimens.grid.x3,
83- vertical = CodeTheme .dimens.grid.x2
84- ),
85- imageSize = CodeTheme .dimens.grid.x10,
86- painter = painterResource(R .drawable.ic_kin_white),
87- onClick = { onPress(HomeBottomSheet .GIVE_KIN ) }
88- )
89- Spacer (modifier = Modifier .weight(1f ))
90- BottomBarAction (
91- label = stringResource(R .string.action_balance),
92- contentPadding = PaddingValues (
93- horizontal = CodeTheme .dimens.grid.x2,
94- ),
95- imageSize = CodeTheme .dimens.grid.x9,
96- painter = painterResource(R .drawable.ic_history),
97- onClick = { onPress(HomeBottomSheet .BALANCE ) },
98- badge = {
99- Badge (
100- modifier = Modifier .padding(top = 2 .dp, end = 2 .dp),
101- count = state.chatUnreadCount,
102- color = ChatNodeDefaults .UnreadIndicator ,
103- enterTransition = scaleIn(
104- animationSpec = tween(
105- durationMillis = 300 ,
106- delayMillis = 1000
107- )
108- ) + fadeIn()
109- )
63+ HomeAction .GET_KIN -> {
64+ BottomBarAction (
65+ modifier = Modifier .weight(1f ),
66+ label = stringResource(R .string.action_receive),
67+ painter = painterResource(R .drawable.ic_wallet),
68+ onClick = { onPress(action) },
69+ )
70+ }
71+ HomeAction .BALANCE -> {
72+ BottomBarAction (
73+ modifier = Modifier .weight(1f ),
74+ label = stringResource(R .string.action_balance),
75+ painter = painterResource(R .drawable.ic_balance),
76+ contentPadding = PaddingValues (
77+ top = CodeTheme .dimens.grid.x2,
78+ bottom = CodeTheme .dimens.grid.x3
79+ ),
80+ imageSize = CodeTheme .dimens.staticGrid.x6,
81+ onClick = { onPress(HomeAction .BALANCE ) },
82+ badge = {
83+ Badge (
84+ modifier = Modifier .padding(top = 2 .dp, end = 2 .dp),
85+ count = state.chatUnreadCount,
86+ color = ChatNodeDefaults .UnreadIndicator ,
87+ enterTransition = scaleIn(
88+ animationSpec = tween(
89+ durationMillis = 300 ,
90+ delayMillis = 1000
91+ )
92+ ) + fadeIn()
93+ )
94+ }
95+ )
96+ }
97+ HomeAction .TIP_CARD -> {
98+ BottomBarAction (
99+ modifier = Modifier .weight(1f ),
100+ label = stringResource(R .string.action_receive),
101+ painter = painterResource(R .drawable.ic_tip_card),
102+ onClick = { onPress(action) },
103+ )
104+ }
105+ else -> Unit
110106 }
111- )
107+ }
112108 }
113109}
114110
115111@Composable
116112private fun BottomBarAction (
117113 modifier : Modifier = Modifier ,
118114 label : String ,
119- contentPadding : PaddingValues = PaddingValues (),
115+ contentPadding : PaddingValues = PaddingValues (
116+ vertical = CodeTheme .dimens.grid.x2
117+ ),
120118 painter : Painter ,
121- imageSize : Dp ,
119+ imageSize : Dp = CodeTheme .dimens.staticGrid.x8 ,
122120 badge : @Composable () -> Unit = { },
123121 onClick : () -> Unit ,
124122) {
@@ -127,8 +125,7 @@ private fun BottomBarAction(
127125 content = {
128126 Column (
129127 modifier = Modifier
130- .clip(CodeTheme .shapes.medium)
131- .rememberedClickable { onClick() }
128+ .unboundedClickable { onClick() }
132129 .layoutId(" action" ),
133130 horizontalAlignment = Alignment .CenterHorizontally
134131 ) {
0 commit comments