Skip to content

Commit e524543

Browse files
new : RadioGroup Strict variants
1 parent a762534 commit e524543

1 file changed

Lines changed: 81 additions & 0 deletions

File tree

  • compose/src/main/java/com/streamliners/compose/comp/select

compose/src/main/java/com/streamliners/compose/comp/select/RadioGroup.kt

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,27 @@ fun RadioGroup(
4949
)
5050
}
5151

52+
@Composable
53+
fun RadioGroupStrict(
54+
modifier: Modifier = Modifier,
55+
title: String? = null,
56+
state: MutableState<String>,
57+
options: List<String>,
58+
enabled: Boolean = true,
59+
layout: Layout = Layout.Column
60+
) {
61+
RadioGroup(
62+
modifier = modifier,
63+
title = title,
64+
selection = state.value,
65+
onSelectionChange = { state.value = it },
66+
options = options,
67+
labelExtractor = { it },
68+
enabled = enabled,
69+
layout = layout
70+
)
71+
}
72+
5273
@Composable
5374
fun RadioGroup(
5475
modifier: Modifier = Modifier,
@@ -71,6 +92,28 @@ fun RadioGroup(
7192
)
7293
}
7394

95+
@Composable
96+
fun RadioGroupStrict(
97+
modifier: Modifier = Modifier,
98+
title: String? = null,
99+
selection: String,
100+
onSelectionChange: (String) -> Unit,
101+
options: List<String>,
102+
enabled: Boolean = true,
103+
layout: Layout = Layout.Column
104+
) {
105+
RadioGroup(
106+
modifier = modifier,
107+
title = title,
108+
selection = selection,
109+
onSelectionChange = onSelectionChange,
110+
options = options,
111+
labelExtractor = { it },
112+
enabled = enabled,
113+
layout = layout
114+
)
115+
}
116+
74117
@Composable
75118
fun <T> RadioGroup(
76119
modifier: Modifier = Modifier,
@@ -93,6 +136,28 @@ fun <T> RadioGroup(
93136
)
94137
}
95138

139+
@Composable
140+
fun <T> RadioGroupStrict(
141+
modifier: Modifier = Modifier,
142+
title: String? = null,
143+
state: MutableState<T>,
144+
options: List<T>,
145+
labelExtractor: (T) -> String,
146+
enabled: Boolean = true,
147+
layout: Layout = Layout.Column
148+
) {
149+
RadioGroup(
150+
modifier = modifier,
151+
title = title,
152+
selection = state.value,
153+
onSelectionChange = { state.value = it },
154+
options = options,
155+
labelExtractor = labelExtractor,
156+
enabled = enabled,
157+
layout = layout
158+
)
159+
}
160+
96161
@Composable
97162
fun <T> RadioGroup(
98163
modifier: Modifier = Modifier,
@@ -136,6 +201,22 @@ fun <T> RadioGroup(
136201
}
137202
}
138203

204+
@Composable
205+
fun <T> RadioGroupStrict(
206+
modifier: Modifier = Modifier,
207+
title: String? = null,
208+
selection: T,
209+
onSelectionChange: (T) -> Unit,
210+
options: List<T>,
211+
labelExtractor: (T) -> String,
212+
enabled: Boolean = true,
213+
layout: Layout = Layout.Column
214+
) {
215+
RadioGroup(
216+
modifier, title, selection, onSelectionChange, options, labelExtractor, enabled, layout
217+
)
218+
}
219+
139220
@Composable
140221
fun LabelledRadioButton(
141222
label: String,

0 commit comments

Comments
 (0)