Improve dialogs and update accompanist

This commit is contained in:
Syer10
2022-03-03 14:49:03 -05:00
parent a2247cfa1e
commit 6c32c59579
2 changed files with 26 additions and 19 deletions

View File

@@ -9,9 +9,9 @@ xmlUtil = "0.84.0"
# Compose # Compose
voyager = "1.0.0-beta16" voyager = "1.0.0-beta16"
accompanist = "0.20.1" accompanist = "0.24.4"
kamel = "0.3.0" kamel = "0.3.0"
materialDialogs = "0.6.4" materialDialogs = "0.6.6"
# Android # Android
core = "1.7.0" core = "1.7.0"

View File

@@ -32,7 +32,6 @@ import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.defaultMinSize import androidx.compose.foundation.layout.defaultMinSize
import androidx.compose.foundation.layout.fillMaxHeight import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
@@ -274,15 +273,19 @@ fun <T> ChoiceDialog(
title(title) title(title)
Box { Box {
val listState = rememberLazyListState() val listState = rememberLazyListState()
LazyColumn(Modifier.fillMaxSize(), listState) { LazyColumn(Modifier.defaultMinSize(minHeight = 64.dp).fillMaxWidth(), listState) {
items(items) { (value, text) -> items(items) { (value, text) ->
Row( Row(
modifier = Modifier.requiredHeight(48.dp).fillMaxWidth().clickable( modifier = Modifier
onClick = { .requiredHeight(48.dp)
onSelected(value) .fillMaxWidth()
state.hide() .clickable(
} onClick = {
), onSelected(value)
state.hide()
}
)
.padding(horizontal = 8.dp),
verticalAlignment = Alignment.CenterVertically verticalAlignment = Alignment.CenterVertically
) { ) {
RadioButton( RadioButton(
@@ -333,18 +336,22 @@ fun <T> MultiSelectDialog(
title(title) title(title)
val listState = rememberLazyListState() val listState = rememberLazyListState()
Box { Box {
LazyColumn(Modifier.fillMaxSize(), listState) { LazyColumn(Modifier.defaultMinSize(minHeight = 64.dp).fillMaxWidth(), listState) {
items(items) { (value, text) -> items(items) { (value, text) ->
Row( Row(
modifier = Modifier.requiredHeight(48.dp).fillMaxWidth().clickable( modifier = Modifier
onClick = { .requiredHeight(48.dp)
if (value in checked) { .fillMaxWidth()
checked -= value .clickable(
} else { onClick = {
checked += value if (value in checked) {
checked -= value
} else {
checked += value
}
} }
} )
), .padding(horizontal = 8.dp),
verticalAlignment = Alignment.CenterVertically verticalAlignment = Alignment.CenterVertically
) { ) {
Checkbox( Checkbox(