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.Close
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.MutableState
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.Alignment
|
||||
|
@ -205,11 +206,11 @@ fun exportToCSV(csvFilePath: String) {
|
|||
fun importFile(cheminFichier: String) {
|
||||
val fileExtension = File(cheminFichier).extension.lowercase()
|
||||
|
||||
when {
|
||||
fileExtension == "csv" -> {
|
||||
when (fileExtension) {
|
||||
"csv" -> {
|
||||
importCSVFile(cheminFichier)
|
||||
}
|
||||
fileExtension == "xlsx" -> {
|
||||
"xlsx" -> {
|
||||
importXLSXFile(cheminFichier)
|
||||
}
|
||||
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)
|
||||
@Composable
|
||||
|
@ -525,13 +543,7 @@ fun formulairePage(onAnnulerClick: () -> Unit) {
|
|||
Button(
|
||||
onClick = {
|
||||
openDialog.value = false
|
||||
nom.value = ""
|
||||
description.value = ""
|
||||
contextePrincipal.value = ""
|
||||
contexte2.value = ""
|
||||
lieA.value = ""
|
||||
synonyme.value = ""
|
||||
antonyme.value = ""
|
||||
resetFields(nom, description, contextePrincipal, contexte2, lieA, synonyme, antonyme)
|
||||
|
||||
},
|
||||
colors = ButtonDefaults.buttonColors(
|
||||
|
@ -657,13 +669,7 @@ fun formulairePage(onAnnulerClick: () -> Unit) {
|
|||
openDialog.value = true
|
||||
|
||||
// Réinitialiser les champs après l'ajout
|
||||
nom.value = ""
|
||||
description.value = ""
|
||||
contextePrincipal.value = ""
|
||||
contexte2.value = ""
|
||||
lieA.value = ""
|
||||
synonyme.value = ""
|
||||
antonyme.value = ""
|
||||
resetFields(nom, description, contextePrincipal, contexte2, lieA, synonyme, antonyme)
|
||||
|
||||
},
|
||||
colors = ButtonDefaults.buttonColors(
|
||||
|
|
Loading…
Reference in New Issue