add word deleting
parent
cdc31e6f80
commit
286f6e315a
|
@ -11,10 +11,7 @@ import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
import androidx.compose.foundation.text.KeyboardOptions
|
import androidx.compose.foundation.text.KeyboardOptions
|
||||||
import androidx.compose.material.*
|
import androidx.compose.material.*
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.filled.ArrowBack
|
import androidx.compose.material.icons.filled.*
|
||||||
import androidx.compose.material.icons.filled.Check
|
|
||||||
import androidx.compose.material.icons.filled.Close
|
|
||||||
import androidx.compose.material.icons.filled.Search
|
|
||||||
import androidx.compose.runtime.*
|
import androidx.compose.runtime.*
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.ExperimentalComposeUiApi
|
import androidx.compose.ui.ExperimentalComposeUiApi
|
||||||
|
@ -38,7 +35,17 @@ import java.io.FileInputStream
|
||||||
|
|
||||||
val customRedColor = Color(0xFFB70D1B)
|
val customRedColor = Color(0xFFB70D1B)
|
||||||
|
|
||||||
|
fun supprimerMotDuGlossaire(mot: Mot) {
|
||||||
|
val listeMots = chargerDonneesDepuisFichier().toMutableList()
|
||||||
|
|
||||||
|
// Retirer le mot de la liste
|
||||||
|
listeMots.remove(mot)
|
||||||
|
|
||||||
|
// Sauvegarder la liste mise à jour
|
||||||
|
sauvegarderDonneesDansFichier(listeMots)
|
||||||
|
|
||||||
|
println("Mot supprimé avec succès : ${mot.nom}")
|
||||||
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun homePage(
|
fun homePage(
|
||||||
|
@ -629,14 +636,19 @@ fun glossaireDetailPage(glossaire: List<Mot>, onRetourClick: () -> Unit) {
|
||||||
modifier = Modifier.fillMaxSize()
|
modifier = Modifier.fillMaxSize()
|
||||||
) {
|
) {
|
||||||
items(filteredGlossaire) { mot ->
|
items(filteredGlossaire) { mot ->
|
||||||
GlossaireCard(mot)
|
GlossaireCard(mot, onSupprimerClick = { motASupprimer ->
|
||||||
|
supprimerMotDuGlossaire(motASupprimer)
|
||||||
|
//afficher à nouveau les mots du glossaire
|
||||||
|
filteredGlossaire = chargerDonneesDepuisFichier()
|
||||||
|
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun GlossaireCard(mot: Mot) {
|
fun GlossaireCard(mot: Mot, onSupprimerClick: (Mot) -> Unit) {
|
||||||
Card(
|
Card(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
|
@ -661,9 +673,24 @@ fun GlossaireCard(mot: Mot) {
|
||||||
Text(text = "Synonyme: ${mot.synonyme}")
|
Text(text = "Synonyme: ${mot.synonyme}")
|
||||||
Spacer(modifier = Modifier.height(4.dp))
|
Spacer(modifier = Modifier.height(4.dp))
|
||||||
Text(text = "Antonyme: ${mot.antonyme}")
|
Text(text = "Antonyme: ${mot.antonyme}")
|
||||||
|
|
||||||
|
// Ajouter le bouton de suppression
|
||||||
|
IconButton(
|
||||||
|
onClick = { onSupprimerClick(mot) },
|
||||||
|
modifier = Modifier
|
||||||
|
.align(Alignment.End)
|
||||||
|
.padding(top = 8.dp)
|
||||||
|
) {
|
||||||
|
Icon(
|
||||||
|
imageVector = Icons.Default.Delete,
|
||||||
|
contentDescription = "Supprimer",
|
||||||
|
tint = customRedColor
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@OptIn(ExperimentalMaterialApi::class)
|
@OptIn(ExperimentalMaterialApi::class)
|
||||||
@Composable
|
@Composable
|
||||||
|
|
Loading…
Reference in New Issue