11package com.getcode.view.main.home.components
22
33import androidx.compose.foundation.Image
4+ import androidx.compose.foundation.layout.Box
45import androidx.compose.foundation.layout.Column
6+ import androidx.compose.foundation.layout.PaddingValues
7+ import androidx.compose.foundation.layout.Spacer
58import androidx.compose.foundation.layout.fillMaxWidth
6- import androidx.compose.foundation.layout.height
79import androidx.compose.foundation.layout.padding
8- import androidx.compose.foundation.layout.width
9- import androidx.compose.foundation.shape.RoundedCornerShape
10- import androidx.compose.material.MaterialTheme
10+ import androidx.compose.foundation.layout.size
1111import androidx.compose.material.Text
1212import androidx.compose.runtime.Composable
1313import androidx.compose.ui.Alignment
1414import androidx.compose.ui.Modifier
1515import androidx.compose.ui.draw.clip
16+ import androidx.compose.ui.graphics.painter.Painter
1617import androidx.compose.ui.res.painterResource
1718import androidx.compose.ui.res.stringResource
1819import androidx.compose.ui.tooling.preview.Preview
19- import androidx.compose.ui.unit.dp
20- import androidx.constraintlayout.compose.ConstraintLayout
20+ import androidx.compose.ui.unit.Dp
2121import com.getcode.R
2222import com.getcode.theme.CodeTheme
2323import com.getcode.util.rememberedClickable
24+ import com.getcode.view.components.Badge
25+ import com.getcode.view.components.Row
26+ import com.getcode.view.components.chat.ChatNodeDefaults
2427import com.getcode.view.main.home.HomeBottomSheet
28+ import com.getcode.view.main.home.HomeUiModel
2529
2630@Preview
2731@Composable
2832internal fun HomeBottom (
2933 modifier : Modifier = Modifier ,
34+ state : HomeUiModel = HomeUiModel (),
3035 onPress : (homeBottomSheet: HomeBottomSheet ) -> Unit = {},
3136) {
32- ConstraintLayout (modifier = modifier.fillMaxWidth()) {
33- val (button1, button2, button3) = createRefs()
34-
35- Column (modifier = Modifier
36- .constrainAs(button2) {
37- centerHorizontallyTo(parent)
38- bottom.linkTo(parent.bottom)
39- }
40- .clip(
41- RoundedCornerShape (10 .dp)
42- )
43- .rememberedClickable { onPress(HomeBottomSheet .GIVE_KIN ) },
44- horizontalAlignment = Alignment .CenterHorizontally
45- ) {
46- Image (
47- modifier = Modifier
48- .padding(horizontal = 15 .dp)
49- .padding(vertical = 11 .dp)
50- .height(51 .dp)
51- .width(51 .dp),
52- painter = painterResource(
53- R .drawable.ic_kin_white
54- ),
55- contentDescription = stringResource(R .string.action_giveKin),
56- )
57- Text (
58- text = stringResource(R .string.action_giveKin),
59- style = CodeTheme .typography.body2
60- )
61- }
37+ Row (
38+ modifier = Modifier
39+ .fillMaxWidth()
40+ .then(modifier),
41+ verticalAlignment = Alignment .Bottom ,
42+ contentPadding = PaddingValues (horizontal = CodeTheme .dimens.grid.x3),
43+ ) {
44+ BottomBarAction (
45+ label = stringResource(R .string.title_getKin),
46+ contentPadding = PaddingValues (
47+ start = CodeTheme .dimens.grid.x3,
48+ end = CodeTheme .dimens.grid.x3,
49+ top = CodeTheme .dimens.grid.x1,
50+ bottom = CodeTheme .dimens.grid.x2,
51+ ),
52+ imageSize = CodeTheme .dimens.grid.x6,
53+ painter = painterResource(R .drawable.ic_wallet),
54+ onClick = { onPress(HomeBottomSheet .GET_KIN ) }
55+ )
56+ Spacer (modifier = Modifier .weight(1f ))
57+ BottomBarAction (
58+ label = stringResource(R .string.action_giveKin),
59+ contentPadding = PaddingValues (
60+ horizontal = CodeTheme .dimens.grid.x3,
61+ vertical = CodeTheme .dimens.grid.x2
62+ ),
63+ imageSize = CodeTheme .dimens.grid.x10,
64+ painter = painterResource(R .drawable.ic_kin_white),
65+ onClick = { onPress(HomeBottomSheet .GIVE_KIN ) }
66+ )
67+ Spacer (modifier = Modifier .weight(1f ))
68+ BottomBarAction (
69+ label = stringResource(R .string.action_balance),
70+ contentPadding = PaddingValues (
71+ horizontal = CodeTheme .dimens.grid.x2,
72+ ),
73+ imageSize = CodeTheme .dimens.grid.x9,
74+ painter = painterResource(R .drawable.ic_history),
75+ onClick = { onPress(HomeBottomSheet .BALANCE ) },
76+ badge = { Badge (count = state.chatUnreadCount, color = ChatNodeDefaults .UnreadIndicator ) }
77+ )
78+ }
79+ }
6280
63- Column (modifier = Modifier
64- .constrainAs(button1) {
65- start.linkTo(parent.start)
66- bottom.linkTo(parent.bottom)
67- }
68- .padding(start = 15 .dp)
69- .clip(
70- RoundedCornerShape (10 .dp, 10 .dp, 10 .dp, 10 .dp)
71- )
72- .rememberedClickable {
73- onPress(HomeBottomSheet .GET_KIN )
74- },
81+ @Composable
82+ private fun BottomBarAction (
83+ modifier : Modifier = Modifier ,
84+ label : String ,
85+ contentPadding : PaddingValues = PaddingValues (),
86+ painter : Painter ,
87+ imageSize : Dp ,
88+ badge : @Composable () -> Unit = { },
89+ onClick : () -> Unit ,
90+ ) {
91+ Box (modifier = modifier) {
92+ Column (
93+ modifier = Modifier
94+ .align(Alignment .Center )
95+ .clip(CodeTheme .shapes.medium)
96+ .rememberedClickable { onClick() },
7597 horizontalAlignment = Alignment .CenterHorizontally
7698 ) {
7799 Image (
78100 modifier = Modifier
79- .padding(horizontal = 15 .dp)
80- .padding(bottom = 8 .dp, top = 5 .dp)
81- .height(32 .dp)
82- .width(32 .dp),
83- painter = painterResource(
84- R .drawable.ic_wallet
85- ),
86- contentDescription = stringResource(R .string.title_getKin),
101+ .padding(contentPadding)
102+ .size(imageSize),
103+ painter = painter,
104+ contentDescription = null ,
87105 )
88106 Text (
89- text = stringResource( R .string.title_getKin) ,
107+ text = label ,
90108 style = CodeTheme .typography.body2
91109 )
92110 }
93-
94- Column (modifier = Modifier
95- .constrainAs(button3) {
96- end.linkTo(parent.end)
97- bottom.linkTo(parent.bottom)
98- }
99- .padding(end = 15 .dp)
100- .clip(
101- RoundedCornerShape (10 .dp, 10 .dp, 10 .dp, 10 .dp)
102- )
103- .rememberedClickable { onPress(HomeBottomSheet .BALANCE ) },
104- horizontalAlignment = Alignment .CenterHorizontally
105- ) {
106- Image (
107- modifier = Modifier
108- .padding(horizontal = 10 .dp)
109- .height(44 .dp)
110- .width(44 .dp),
111- painter = painterResource(
112- R .drawable.ic_history
113- ),
114- contentDescription = stringResource(R .string.action_balance),
115- )
116- Text (
117- text = stringResource(R .string.action_balance),
118- style = CodeTheme .typography.body2
119- )
111+ Box (modifier = Modifier .align(Alignment .TopEnd )) {
112+ badge()
120113 }
121114 }
122115}
0 commit comments