Remove code duplication
parent
4b44267bda
commit
9c9906df16
|
@ -7,6 +7,7 @@ import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.filled.Check
|
import androidx.compose.material.icons.filled.Check
|
||||||
import androidx.compose.material.icons.filled.Close
|
import androidx.compose.material.icons.filled.Close
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.runtime.MutableState
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
|
@ -205,11 +206,11 @@ fun exportToCSV(csvFilePath: String) {
|
||||||
fun importFile(cheminFichier: String) {
|
fun importFile(cheminFichier: String) {
|
||||||
val fileExtension = File(cheminFichier).extension.lowercase()
|
val fileExtension = File(cheminFichier).extension.lowercase()
|
||||||
|
|
||||||
when {
|
when (fileExtension) {
|
||||||
fileExtension == "csv" -> {
|
"csv" -> {
|
||||||
importCSVFile(cheminFichier)
|
importCSVFile(cheminFichier)
|
||||||
}
|
}
|
||||||
fileExtension == "xlsx" -> {
|
"xlsx" -> {
|
||||||
importXLSXFile(cheminFichier)
|
importXLSXFile(cheminFichier)
|
||||||
}
|
}
|
||||||
else -> {
|
else -> {
|
||||||
|
@ -494,6 +495,23 @@ fun glossairePage(
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun resetFields(
|
||||||
|
nom: MutableState<String>,
|
||||||
|
description: MutableState<String>,
|
||||||
|
contextePrincipal: MutableState<String>,
|
||||||
|
contexte2: MutableState<String>,
|
||||||
|
lieA: MutableState<String>,
|
||||||
|
synonyme: MutableState<String>,
|
||||||
|
antonyme: MutableState<String>
|
||||||
|
) {
|
||||||
|
nom.value = ""
|
||||||
|
description.value = ""
|
||||||
|
contextePrincipal.value = ""
|
||||||
|
contexte2.value = ""
|
||||||
|
lieA.value = ""
|
||||||
|
synonyme.value = ""
|
||||||
|
antonyme.value = ""
|
||||||
|
}
|
||||||
|
|
||||||
@OptIn(ExperimentalMaterialApi::class)
|
@OptIn(ExperimentalMaterialApi::class)
|
||||||
@Composable
|
@Composable
|
||||||
|
@ -525,13 +543,7 @@ fun formulairePage(onAnnulerClick: () -> Unit) {
|
||||||
Button(
|
Button(
|
||||||
onClick = {
|
onClick = {
|
||||||
openDialog.value = false
|
openDialog.value = false
|
||||||
nom.value = ""
|
resetFields(nom, description, contextePrincipal, contexte2, lieA, synonyme, antonyme)
|
||||||
description.value = ""
|
|
||||||
contextePrincipal.value = ""
|
|
||||||
contexte2.value = ""
|
|
||||||
lieA.value = ""
|
|
||||||
synonyme.value = ""
|
|
||||||
antonyme.value = ""
|
|
||||||
|
|
||||||
},
|
},
|
||||||
colors = ButtonDefaults.buttonColors(
|
colors = ButtonDefaults.buttonColors(
|
||||||
|
@ -657,13 +669,7 @@ fun formulairePage(onAnnulerClick: () -> Unit) {
|
||||||
openDialog.value = true
|
openDialog.value = true
|
||||||
|
|
||||||
// Réinitialiser les champs après l'ajout
|
// Réinitialiser les champs après l'ajout
|
||||||
nom.value = ""
|
resetFields(nom, description, contextePrincipal, contexte2, lieA, synonyme, antonyme)
|
||||||
description.value = ""
|
|
||||||
contextePrincipal.value = ""
|
|
||||||
contexte2.value = ""
|
|
||||||
lieA.value = ""
|
|
||||||
synonyme.value = ""
|
|
||||||
antonyme.value = ""
|
|
||||||
|
|
||||||
},
|
},
|
||||||
colors = ButtonDefaults.buttonColors(
|
colors = ButtonDefaults.buttonColors(
|
||||||
|
|
Loading…
Reference in New Issue