first refactor
parent
4a6f055473
commit
ef3ba67abe
|
@ -13,12 +13,7 @@ import androidx.compose.material.*
|
|||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.*
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.material.icons.filled.ArrowBack
|
||||
import androidx.compose.material.icons.filled.Check
|
||||
import androidx.compose.material.icons.filled.Close
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.ExperimentalComposeUiApi
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.res.painterResource
|
||||
|
@ -28,14 +23,15 @@ import androidx.compose.ui.unit.dp
|
|||
import androidx.compose.ui.window.*
|
||||
import kotlinx.serialization.encodeToString
|
||||
import kotlinx.serialization.json.Json
|
||||
import java.awt.FileDialog
|
||||
import java.awt.Frame
|
||||
import java.io.File
|
||||
import java.io.IOException
|
||||
import org.apache.poi.ss.usermodel.CellType
|
||||
import org.apache.poi.ss.usermodel.Workbook
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook
|
||||
import java.awt.FileDialog
|
||||
import java.awt.Frame
|
||||
import java.io.File
|
||||
import java.io.FileInputStream
|
||||
import java.io.FileWriter
|
||||
import java.io.IOException
|
||||
|
||||
val customRedColor = Color(0xFFB70D1B)
|
||||
|
||||
|
@ -123,8 +119,7 @@ fun homePage(
|
|||
fun compareResults(
|
||||
motsGlossaire: List<Mot>,
|
||||
motsCode: List<String>,
|
||||
onRetourClick: () -> Unit,
|
||||
navigationIcon: @Composable () -> Unit = { Icon(Icons.Filled.ArrowBack, contentDescription = null) }
|
||||
onRetourClick: () -> Unit
|
||||
|
||||
) {
|
||||
Column(
|
||||
|
@ -531,6 +526,7 @@ fun glossairePage(
|
|||
onAjouterMotClick: () -> Unit,
|
||||
onImporterClick: () -> Unit,
|
||||
onExporterClick: () -> Unit,
|
||||
onVoirGlossaireClick: () -> Unit,
|
||||
onRetourClick: () -> Unit
|
||||
) {
|
||||
|
||||
|
@ -611,13 +607,12 @@ fun glossairePage(
|
|||
}
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalComposeUiApi::class)
|
||||
@Composable
|
||||
fun glossaireDetailPage(glossaire: List<Mot>, onRetourClick: () -> Unit) {
|
||||
var searchQuery by remember { mutableStateOf("") }
|
||||
var sortOption by remember { mutableStateOf("Nom ↑") }
|
||||
|
||||
var filteredGlossaire by remember { mutableStateOf<List<Mot>>(glossaire) }
|
||||
var filteredGlossaire by remember { mutableStateOf(glossaire) }
|
||||
|
||||
val menuExpanded = remember { mutableStateOf(false) }
|
||||
|
||||
|
@ -745,7 +740,7 @@ fun glossaireDetailPage(glossaire: List<Mot>, onRetourClick: () -> Unit) {
|
|||
modifier = Modifier.fillMaxSize()
|
||||
) {
|
||||
items(filteredGlossaire) { mot ->
|
||||
GlossaireCard(mot, onSupprimerClick = { motASupprimer ->
|
||||
glossaireCard(mot, onSupprimerClick = { motASupprimer ->
|
||||
supprimerMotDuGlossaire(motASupprimer)
|
||||
//afficher à nouveau les mots du glossaire
|
||||
filteredGlossaire = chargerDonneesDepuisFichier()
|
||||
|
@ -757,11 +752,12 @@ fun glossaireDetailPage(glossaire: List<Mot>, onRetourClick: () -> Unit) {
|
|||
}
|
||||
|
||||
@Composable
|
||||
fun GlossaireCard(mot: Mot, onSupprimerClick: (Mot) -> Unit) {
|
||||
fun glossaireCard(mot: Mot, onSupprimerClick: (Mot) -> Unit) {
|
||||
Card(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(8.dp),
|
||||
|
||||
elevation = 8.dp
|
||||
) {
|
||||
Column(
|
||||
|
@ -822,8 +818,8 @@ fun resetFields(
|
|||
@Composable
|
||||
fun formulairePage(onAnnulerClick: () -> Unit) {
|
||||
// State to track whether to show the snackbar
|
||||
val ChampsObligatoireSnackbarVisibleState = remember { mutableStateOf(false) }
|
||||
val ExisteDejaSnackbarVisibleState = remember { mutableStateOf(false) }
|
||||
val champsObligatoireSnackbarVisibleState = remember { mutableStateOf(false) }
|
||||
val existeDejaSnackbarVisibleState = remember { mutableStateOf(false) }
|
||||
|
||||
val nom = remember { mutableStateOf("") }
|
||||
val description = remember { mutableStateOf("") }
|
||||
|
@ -957,7 +953,7 @@ fun formulairePage(onAnnulerClick: () -> Unit) {
|
|||
// Validation du formulaire
|
||||
if (nom.value.isBlank() || contextePrincipal.value.isBlank()) {
|
||||
// Show the snackbar when validation fails
|
||||
ChampsObligatoireSnackbarVisibleState.value = true
|
||||
champsObligatoireSnackbarVisibleState.value = true
|
||||
return@Button
|
||||
}
|
||||
|
||||
|
@ -966,7 +962,7 @@ fun formulairePage(onAnnulerClick: () -> Unit) {
|
|||
// Vérifier si le mot existe déjà dans le glossaire
|
||||
if (listeMots.any { it.nom.equals(nom.value, ignoreCase = true) }) {
|
||||
println("Le mot '${nom.value}' existe déjà dans le glossaire. Ajout annulé.")
|
||||
ExisteDejaSnackbarVisibleState.value = true
|
||||
existeDejaSnackbarVisibleState.value = true
|
||||
return@Button
|
||||
}
|
||||
|
||||
|
@ -995,11 +991,11 @@ fun formulairePage(onAnnulerClick: () -> Unit) {
|
|||
}
|
||||
|
||||
// Show the snackbar when the state is true
|
||||
if (ChampsObligatoireSnackbarVisibleState.value) {
|
||||
if (champsObligatoireSnackbarVisibleState.value) {
|
||||
Snackbar(
|
||||
modifier = Modifier.padding(16.dp),
|
||||
action = {
|
||||
Button(onClick = { ChampsObligatoireSnackbarVisibleState.value = false }) {
|
||||
Button(onClick = { champsObligatoireSnackbarVisibleState.value = false }) {
|
||||
Text("OK")
|
||||
}
|
||||
}
|
||||
|
@ -1007,11 +1003,11 @@ fun formulairePage(onAnnulerClick: () -> Unit) {
|
|||
Text("Les champs 'Mot' et 'Contexte principal' sont obligatoires.")
|
||||
}
|
||||
}
|
||||
if (ExisteDejaSnackbarVisibleState.value) {
|
||||
if (existeDejaSnackbarVisibleState.value) {
|
||||
Snackbar(
|
||||
modifier = Modifier.padding(16.dp),
|
||||
action = {
|
||||
Button(onClick = { ExisteDejaSnackbarVisibleState.value = false }) {
|
||||
Button(onClick = { existeDejaSnackbarVisibleState.value = false }) {
|
||||
Text("OK")
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue