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) } val (selectedOption, onOptionSelected) = remember { mutableStateOf(ActionImport.FILE) }
var lien by remember { mutableStateOf("") } var lien by remember { mutableStateOf("") }
var ctx = LocalContext.current val ctx = LocalContext.current
val filePickerLauncher = rememberLauncherForActivityResult( val filePickerLauncher = rememberLauncherForActivityResult(
ActivityResultContracts.StartActivityForResult() ActivityResultContracts.StartActivityForResult()
) { result -> ) { result ->
if (result.resultCode == Activity.RESULT_OK) { if (result.resultCode == Activity.RESULT_OK) {
val uri = result.data?.data 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), modifier = Modifier.padding(padding),
horizontalAlignment = Alignment.CenterHorizontally horizontalAlignment = Alignment.CenterHorizontally
) { ) {
showList(model, questions, currentSelection) ShowQuestionList(model, questions, currentSelection)
Row(modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.Center) { Row(modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.Center) {
Button( Button(
@ -93,19 +93,23 @@ fun ModifySetScreen(
} }
@Composable @Composable
fun showList(model: ModifySetViewModel, questions: List<Question>, currentSelection: Question?) { fun ShowQuestionList(
model: ModifySetViewModel,
questions: List<Question>,
currentSelection: Question?
) {
LazyColumn( LazyColumn(
Modifier.fillMaxHeight(0.6f) Modifier.fillMaxHeight(0.6f)
) { ) {
itemsIndexed(questions) { index, item -> itemsIndexed(questions) { index, item ->
listItem(index, item, currentSelection, model::updateSelection) ListItem(index, item, currentSelection, model::updateSelection)
} }
} }
} }
@OptIn(ExperimentalMaterial3Api::class) @OptIn(ExperimentalMaterial3Api::class)
@Composable @Composable
fun listItem( fun ListItem(
index: Int, index: Int,
question: Question, question: Question,
currentSelection: Question?, currentSelection: Question?,

View file

@ -1,5 +1,5 @@
package fr.uparis.diamantkennel.memorisationapplication.ui package fr.uparis.diamantkennel.memorisationapplication.ui
enum class ActionHome { 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 selected = mutableStateOf<SetQuestions?>(null)
var creation = mutableStateOf(false) var creation = mutableStateOf(false)
var modification = mutableStateOf(false)
var importation = mutableStateOf(false) var importation = mutableStateOf(false)
var deletionSelect = mutableStateOf(false) var deletionSelect = mutableStateOf(false)
var deletionDB = mutableStateOf(false) var deletionDB = mutableStateOf(false)
@ -81,12 +80,6 @@ class HomeViewModel(application: Application) : AndroidViewModel(application) {
importation.value = true importation.value = true
} }
ActionHome.MODIFIER -> {
if (selected.value != null) {
modification.value = true
}
}
ActionHome.DELETION_SELECT -> { ActionHome.DELETION_SELECT -> {
if (selected.value != null) { if (selected.value != null) {
deletionSelect.value = true deletionSelect.value = true
@ -133,10 +126,6 @@ class HomeViewModel(application: Application) : AndroidViewModel(application) {
deletionDB.value = false deletionDB.value = false
} }
fun dismissModification() {
modification.value = false
}
fun dismissImportation() { fun dismissImportation() {
importation.value = false importation.value = false
} }