This commit is contained in:
Mylloon 2024-01-04 01:01:18 +01:00
parent a20b894571
commit 678582b562
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
4 changed files with 12 additions and 19 deletions

View file

@ -200,14 +200,14 @@ fun ImportDialog(
val (selectedOption, onOptionSelected) = remember { mutableStateOf(ActionImport.FILE) }
var lien by remember { mutableStateOf("") }
var ctx = LocalContext.current
val ctx = LocalContext.current
val filePickerLauncher = rememberLauncherForActivityResult(
ActivityResultContracts.StartActivityForResult()
) { result ->
if (result.resultCode == Activity.RESULT_OK) {
val uri = result.data?.data
lien = uri?.let { it.toString() } ?: lien
lien = uri?.toString() ?: lien
}
}

View file

@ -66,7 +66,7 @@ fun ModifySetScreen(
modifier = Modifier.padding(padding),
horizontalAlignment = Alignment.CenterHorizontally
) {
showList(model, questions, currentSelection)
ShowQuestionList(model, questions, currentSelection)
Row(modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.Center) {
Button(
@ -93,19 +93,23 @@ fun ModifySetScreen(
}
@Composable
fun showList(model: ModifySetViewModel, questions: List<Question>, currentSelection: Question?) {
fun ShowQuestionList(
model: ModifySetViewModel,
questions: List<Question>,
currentSelection: Question?
) {
LazyColumn(
Modifier.fillMaxHeight(0.6f)
) {
itemsIndexed(questions) { index, item ->
listItem(index, item, currentSelection, model::updateSelection)
ListItem(index, item, currentSelection, model::updateSelection)
}
}
}
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun listItem(
fun ListItem(
index: Int,
question: Question,
currentSelection: Question?,

View file

@ -1,5 +1,5 @@
package fr.uparis.diamantkennel.memorisationapplication.ui
enum class ActionHome {
CREATION, IMPORTATION, MODIFIER, DELETION_SELECT, DELETION_DB
}
CREATION, IMPORTATION, DELETION_SELECT, DELETION_DB
}

View file

@ -28,7 +28,6 @@ class HomeViewModel(application: Application) : AndroidViewModel(application) {
var selected = mutableStateOf<SetQuestions?>(null)
var creation = mutableStateOf(false)
var modification = mutableStateOf(false)
var importation = mutableStateOf(false)
var deletionSelect = mutableStateOf(false)
var deletionDB = mutableStateOf(false)
@ -81,12 +80,6 @@ class HomeViewModel(application: Application) : AndroidViewModel(application) {
importation.value = true
}
ActionHome.MODIFIER -> {
if (selected.value != null) {
modification.value = true
}
}
ActionHome.DELETION_SELECT -> {
if (selected.value != null) {
deletionSelect.value = true
@ -133,10 +126,6 @@ class HomeViewModel(application: Application) : AndroidViewModel(application) {
deletionDB.value = false
}
fun dismissModification() {
modification.value = false
}
fun dismissImportation() {
importation.value = false
}