better dialog
This commit is contained in:
parent
dd922b0b38
commit
46f95c9481
2 changed files with 30 additions and 5 deletions
|
@ -42,6 +42,7 @@ import androidx.lifecycle.viewmodel.compose.viewModel
|
||||||
import fr.uparis.diamantkennel.memorisationapplication.data.SetOfQuestions
|
import fr.uparis.diamantkennel.memorisationapplication.data.SetOfQuestions
|
||||||
import fr.uparis.diamantkennel.memorisationapplication.data.SetQuestions
|
import fr.uparis.diamantkennel.memorisationapplication.data.SetQuestions
|
||||||
import fr.uparis.diamantkennel.memorisationapplication.ui.ActionHome
|
import fr.uparis.diamantkennel.memorisationapplication.ui.ActionHome
|
||||||
|
import fr.uparis.diamantkennel.memorisationapplication.ui.ActionImport
|
||||||
import fr.uparis.diamantkennel.memorisationapplication.ui.ErrorsAjout
|
import fr.uparis.diamantkennel.memorisationapplication.ui.ErrorsAjout
|
||||||
import fr.uparis.diamantkennel.memorisationapplication.ui.HomeViewModel
|
import fr.uparis.diamantkennel.memorisationapplication.ui.HomeViewModel
|
||||||
|
|
||||||
|
@ -210,8 +211,7 @@ fun ImportDialog(
|
||||||
dismiss: () -> Unit,
|
dismiss: () -> Unit,
|
||||||
model: HomeViewModel
|
model: HomeViewModel
|
||||||
) {
|
) {
|
||||||
val radioOptions = listOf("Locale", "Internet")
|
val (selectedOption, onOptionSelected) = remember { mutableStateOf(ActionImport.FILE) }
|
||||||
val (selectedOption, onOptionSelected) = remember { mutableStateOf(radioOptions[0]) }
|
|
||||||
|
|
||||||
var lien by remember { mutableStateOf("") }
|
var lien by remember { mutableStateOf("") }
|
||||||
|
|
||||||
|
@ -221,7 +221,7 @@ fun ImportDialog(
|
||||||
text = {
|
text = {
|
||||||
Column {
|
Column {
|
||||||
Column(Modifier.selectableGroup()) {
|
Column(Modifier.selectableGroup()) {
|
||||||
radioOptions.forEach { text ->
|
ActionImport.values().forEach { text ->
|
||||||
Row(
|
Row(
|
||||||
Modifier
|
Modifier
|
||||||
.selectable(
|
.selectable(
|
||||||
|
@ -230,22 +230,36 @@ fun ImportDialog(
|
||||||
role = Role.RadioButton
|
role = Role.RadioButton
|
||||||
)
|
)
|
||||||
.padding(horizontal = 16.dp),
|
.padding(horizontal = 16.dp),
|
||||||
verticalAlignment = Alignment.CenterVertically
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
) {
|
) {
|
||||||
RadioButton(
|
RadioButton(
|
||||||
selected = (text == selectedOption),
|
selected = (text == selectedOption),
|
||||||
onClick = null
|
onClick = null
|
||||||
)
|
)
|
||||||
Text(
|
Text(
|
||||||
text = text,
|
text = text.toString(),
|
||||||
style = MaterialTheme.typography.bodyLarge,
|
style = MaterialTheme.typography.bodyLarge,
|
||||||
modifier = Modifier.padding(start = 16.dp)
|
modifier = Modifier.padding(start = 16.dp)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (text == ActionImport.FILE) {
|
||||||
|
Button(
|
||||||
|
enabled = selectedOption == ActionImport.FILE,
|
||||||
|
modifier = Modifier.padding(start = 16.dp),
|
||||||
|
onClick = { /*TODO*/ }
|
||||||
|
) {
|
||||||
|
Text(
|
||||||
|
text = "Explorateur",
|
||||||
|
style = MaterialTheme.typography.labelSmall
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
OutlinedTextField(
|
OutlinedTextField(
|
||||||
|
enabled = selectedOption == ActionImport.INTERNET,
|
||||||
value = lien,
|
value = lien,
|
||||||
onValueChange = { newTextValue -> lien = newTextValue },
|
onValueChange = { newTextValue -> lien = newTextValue },
|
||||||
label = { Text(text = "Lien") }
|
label = { Text(text = "Lien") }
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
package fr.uparis.diamantkennel.memorisationapplication.ui
|
||||||
|
|
||||||
|
enum class ActionImport {
|
||||||
|
FILE, INTERNET;
|
||||||
|
|
||||||
|
override fun toString() = when (this) {
|
||||||
|
FILE -> "Locale"
|
||||||
|
INTERNET -> "Internet"
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Reference in a new issue