@@ -2,13 +2,16 @@ package com.getcode.view.main.getKin
2
2
3
3
import androidx.compose.foundation.Image
4
4
import androidx.compose.foundation.background
5
+ import androidx.compose.foundation.layout.Arrangement
5
6
import androidx.compose.foundation.layout.Column
6
7
import androidx.compose.foundation.layout.Row
7
8
import androidx.compose.foundation.layout.Spacer
8
9
import androidx.compose.foundation.layout.fillMaxHeight
10
+ import androidx.compose.foundation.layout.fillMaxSize
9
11
import androidx.compose.foundation.layout.fillMaxWidth
10
12
import androidx.compose.foundation.layout.height
11
13
import androidx.compose.foundation.layout.padding
14
+ import androidx.compose.foundation.layout.requiredHeight
12
15
import androidx.compose.foundation.layout.size
13
16
import androidx.compose.material.Snackbar
14
17
import androidx.compose.material.SnackbarHost
@@ -33,7 +36,6 @@ import androidx.compose.ui.res.painterResource
33
36
import androidx.compose.ui.res.stringResource
34
37
import androidx.compose.ui.text.style.TextDecoration
35
38
import androidx.compose.ui.unit.dp
36
- import androidx.constraintlayout.compose.ConstraintLayout
37
39
import com.getcode.R
38
40
import com.getcode.manager.TopBarManager
39
41
import com.getcode.navigation.core.LocalCodeNavigator
@@ -45,9 +47,9 @@ import com.getcode.navigation.screens.RequestTip
45
47
import com.getcode.theme.BrandLight
46
48
import com.getcode.theme.BrandMuted
47
49
import com.getcode.theme.CodeTheme
50
+ import com.getcode.theme.Success
48
51
import com.getcode.theme.White
49
52
import com.getcode.theme.White05
50
- import com.getcode.theme.Success
51
53
import com.getcode.ui.components.CodeCircularProgressIndicator
52
54
import com.getcode.ui.components.CodeScaffold
53
55
import com.getcode.ui.components.showSnackbar
@@ -152,129 +154,16 @@ fun GetKinSheet(
152
154
}
153
155
}
154
156
) { padding ->
155
- ConstraintLayout (
157
+ Column (
156
158
modifier = Modifier
157
- .fillMaxWidth()
158
- .fillMaxHeight()
159
+ .fillMaxSize()
159
160
.padding(horizontal = CodeTheme .dimens.inset)
160
161
.then(Modifier .padding(padding)),
162
+ verticalArrangement = Arrangement .SpaceBetween
161
163
) {
162
- val (topSection, bottomSection) = createRefs()
163
-
164
- Column (
165
- modifier = Modifier
166
- .fillMaxWidth()
167
- .constrainAs(topSection) {
168
- top.linkTo(parent.top)
169
- start.linkTo(parent.start)
170
- end.linkTo(parent.end)
171
- },
172
- ) {
173
- Image (
174
- painter = painterResource(R .drawable.ic_graphic_wallet),
175
- contentDescription = " " ,
176
- modifier = Modifier .padding(vertical = CodeTheme .dimens.grid.x2),
177
- )
178
- Text (
179
- text = stringResource(R .string.title_getKin),
180
- style = CodeTheme .typography.h1,
181
- modifier = Modifier .padding(vertical = CodeTheme .dimens.grid.x3),
182
- )
183
- Text (
184
- text = stringResource(R .string.subtitle_getKin),
185
- style = CodeTheme .typography.body1,
186
- modifier = Modifier .padding(vertical = CodeTheme .dimens.grid.x2),
187
- )
188
- }
189
-
190
- val x10 = CodeTheme .dimens.grid.x15
191
- Column (
192
- modifier = Modifier
193
- .fillMaxWidth()
194
- .padding(top = x10)
195
- .constrainAs(bottomSection) {
196
- top.linkTo(topSection.bottom)
197
- start.linkTo(parent.start)
198
- end.linkTo(parent.end)
199
- },
200
- ) {
201
- Column {
202
- for (item in items) {
203
- if (! item.isVisible) {
204
- continue
205
- }
206
-
207
- Spacer (
208
- modifier = Modifier
209
- .fillMaxWidth()
210
- .height(1 .dp)
211
- .background(White05 ),
212
- )
213
-
214
- Row (
215
- modifier = Modifier
216
- .addIf(
217
- item.isStrikeThrough.not (),
218
- ) {
219
- Modifier .rememberedClickable { item.onClick() }
220
- }
221
- .padding(
222
- vertical = CodeTheme .dimens.grid.x4,
223
- horizontal = CodeTheme .dimens.grid.x2
224
- ),
225
- verticalAlignment = Alignment .CenterVertically ,
226
- ) {
227
- Image (
228
- modifier = Modifier .size(CodeTheme .dimens.staticGrid.x5),
229
- painter = if (item.isActive) painterResource(id = item.imageResId) else painterResource(
230
- id = item.inactiveImageResId
231
- ),
232
- contentDescription = " " ,
233
- )
234
- Column (
235
- modifier = Modifier
236
- .padding(start = CodeTheme .dimens.grid.x3)
237
- .weight(1f ),
238
- ) {
239
- Text (
240
- text = item.titleText,
241
- color = if (item.isActive) Color .White else BrandLight ,
242
- style = CodeTheme .typography.body2.copy(
243
- textDecoration = if (item.isStrikeThrough) TextDecoration .LineThrough else CodeTheme .typography.button.textDecoration,
244
- ),
245
- )
246
- item.subtitleText?.let {
247
- Text (
248
- modifier = Modifier .padding(top = CodeTheme .dimens.grid.x1),
249
- text = it,
250
- style = CodeTheme .typography.caption,
251
- color = BrandLight
252
- )
253
- }
254
- }
255
-
256
- if (item.isLoading) {
257
- CodeCircularProgressIndicator (
258
- strokeWidth = CodeTheme .dimens.thickBorder,
259
- color = White ,
260
- modifier = Modifier
261
- .size(CodeTheme .dimens.grid.x3)
262
- .align(Alignment .CenterVertically ),
263
- )
264
- } else {
265
- Spacer (modifier = Modifier .weight(1f ))
266
- }
267
- }
268
- }
269
- }
270
-
271
- Spacer (
272
- modifier = Modifier
273
- .fillMaxWidth()
274
- .height(1 .dp)
275
- .background(White05 ),
276
- )
277
- }
164
+ Header ()
165
+ Items (items)
166
+ Spacer (modifier = Modifier .requiredHeight(CodeTheme .dimens.grid.x12))
278
167
}
279
168
}
280
169
@@ -290,3 +179,108 @@ fun GetKinSheet(
290
179
}
291
180
}
292
181
}
182
+
183
+ @Composable
184
+ private fun Header () {
185
+ Column (modifier = Modifier .fillMaxWidth()) {
186
+ Image (
187
+ painter = painterResource(R .drawable.ic_graphic_wallet),
188
+ contentDescription = " " ,
189
+ modifier = Modifier .padding(vertical = CodeTheme .dimens.grid.x2),
190
+ )
191
+ Text (
192
+ text = stringResource(R .string.title_getKin),
193
+ style = CodeTheme .typography.h1,
194
+ modifier = Modifier .padding(vertical = CodeTheme .dimens.grid.x3),
195
+ )
196
+ Text (
197
+ text = stringResource(R .string.subtitle_getKin),
198
+ style = CodeTheme .typography.body1,
199
+ modifier = Modifier .padding(vertical = CodeTheme .dimens.grid.x2),
200
+ )
201
+ }
202
+ }
203
+
204
+ @Composable
205
+ private fun Items (items : List <GetKinItem >) {
206
+ Column (modifier = Modifier .fillMaxWidth()) {
207
+ Column {
208
+ items
209
+ .filter { it.isVisible }
210
+ .onEach { item ->
211
+ Spacer (
212
+ modifier = Modifier
213
+ .fillMaxWidth()
214
+ .height(1 .dp)
215
+ .background(White05 ),
216
+ )
217
+ GetKinItemRow (item = item)
218
+ }
219
+ }
220
+
221
+ Spacer (
222
+ modifier = Modifier
223
+ .fillMaxWidth()
224
+ .height(1 .dp)
225
+ .background(White05 ),
226
+ )
227
+ }
228
+ }
229
+
230
+ @Composable
231
+ private fun GetKinItemRow (modifier : Modifier = Modifier , item : GetKinItem ) {
232
+ Row (
233
+ modifier = modifier
234
+ .addIf(
235
+ item.isStrikeThrough.not (),
236
+ ) {
237
+ Modifier .rememberedClickable { item.onClick() }
238
+ }
239
+ .padding(
240
+ vertical = CodeTheme .dimens.grid.x4,
241
+ horizontal = CodeTheme .dimens.grid.x2
242
+ ),
243
+ verticalAlignment = Alignment .CenterVertically ,
244
+ ) {
245
+ Image (
246
+ modifier = Modifier .size(CodeTheme .dimens.staticGrid.x5),
247
+ painter = if (item.isActive) painterResource(id = item.imageResId) else painterResource(
248
+ id = item.inactiveImageResId
249
+ ),
250
+ contentDescription = " " ,
251
+ )
252
+ Column (
253
+ modifier = Modifier
254
+ .padding(start = CodeTheme .dimens.grid.x3)
255
+ .weight(1f ),
256
+ ) {
257
+ Text (
258
+ text = item.titleText,
259
+ color = if (item.isActive) Color .White else BrandLight ,
260
+ style = CodeTheme .typography.body2.copy(
261
+ textDecoration = if (item.isStrikeThrough) TextDecoration .LineThrough else CodeTheme .typography.button.textDecoration,
262
+ ),
263
+ )
264
+ item.subtitleText?.let {
265
+ Text (
266
+ modifier = Modifier .padding(top = CodeTheme .dimens.grid.x1),
267
+ text = it,
268
+ style = CodeTheme .typography.caption,
269
+ color = BrandLight
270
+ )
271
+ }
272
+ }
273
+
274
+ if (item.isLoading) {
275
+ CodeCircularProgressIndicator (
276
+ strokeWidth = CodeTheme .dimens.thickBorder,
277
+ color = White ,
278
+ modifier = Modifier
279
+ .size(CodeTheme .dimens.grid.x3)
280
+ .align(Alignment .CenterVertically ),
281
+ )
282
+ } else {
283
+ Spacer (modifier = Modifier .weight(1f ))
284
+ }
285
+ }
286
+ }
0 commit comments