Update gradle and compose

This commit is contained in:
Sylwester Zieliński
2021-12-23 13:59:54 +01:00
parent af11494e38
commit b842ff6551
12 changed files with 116 additions and 102 deletions

View File

@@ -1,42 +0,0 @@
package no.nordicsemi.android.theme.view
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import no.nordicsemi.android.material.you.RadioButton
import no.nordicsemi.android.material.you.RadioButtonItem
@Composable
fun <T> SelectItemRadioGroup(
currentItem: T,
items: List<RadioGroupItem<T>>,
onEvent: (RadioGroupItem<T>) -> Unit
) {
Row(
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.SpaceEvenly
) {
items.forEach {
SelectItemRadioButton(currentItem, it, onEvent)
}
}
}
@Composable
internal fun <T> SelectItemRadioButton(
selectedItem: T,
displayedItem: RadioGroupItem<T>,
onEvent: (RadioGroupItem<T>) -> Unit
) {
Row {
RadioButton(
RadioButtonItem(displayedItem.label, selectedItem == displayedItem.unit),
) {
onEvent(displayedItem)
}
}
}
data class RadioGroupItem<T>(val unit: T, val label: String)