|
1 | 1 | package com.yapp.common.yds |
2 | 2 |
|
3 | | -import androidx.compose.foundation.layout.Column |
4 | | -import androidx.compose.foundation.layout.Row |
5 | | -import androidx.compose.foundation.layout.padding |
| 3 | +import androidx.compose.foundation.layout.* |
6 | 4 | import androidx.compose.runtime.Composable |
7 | 5 | import androidx.compose.ui.Modifier |
8 | 6 | import androidx.compose.ui.unit.dp |
9 | 7 |
|
| 8 | +@OptIn(ExperimentalLayoutApi::class) |
10 | 9 | @Composable |
11 | | -fun YDSOption(types: List<String>, selectedType: String?, onTypeClicked: (String) -> Unit) { |
12 | | - val rowNum = 2 |
13 | | - Column { |
14 | | - repeat(types.size / rowNum) { row -> |
15 | | - Row { |
16 | | - repeat(rowNum) { index -> |
17 | | - val type = types[rowNum * row + index] |
18 | | - YDSChoiceButton( |
19 | | - text = type, |
20 | | - modifier = Modifier.padding(end = 12.dp, bottom = 12.dp), |
21 | | - state = if (selectedType == type) YdsButtonState.ENABLED else YdsButtonState.DISABLED, |
22 | | - onClick = { onTypeClicked(type) } |
23 | | - ) |
24 | | - } |
25 | | - } |
| 10 | +fun YDSOption( |
| 11 | + modifier: Modifier = Modifier, |
| 12 | + horizontalArrangement: Arrangement.Horizontal = Arrangement.spacedBy(12.dp), |
| 13 | + types: List<String>, |
| 14 | + selectedType: String?, |
| 15 | + onTypeClicked: (String) -> Unit |
| 16 | +) { |
| 17 | + FlowRow( |
| 18 | + modifier = modifier, |
| 19 | + horizontalArrangement = horizontalArrangement, |
| 20 | + ) { |
| 21 | + repeat(types.size) { index -> |
| 22 | + val type = types[index] |
| 23 | + YDSChoiceButton( |
| 24 | + text = type, |
| 25 | + modifier = Modifier.padding(bottom = 12.dp), |
| 26 | + state = if (selectedType == type) YdsButtonState.ENABLED else YdsButtonState.DISABLED, |
| 27 | + onClick = { onTypeClicked(type) } |
| 28 | + ) |
26 | 29 | } |
27 | 30 | } |
28 | 31 | } |
|
0 commit comments