Added JSON saving of Glossaire
parent
12255f2986
commit
9a911e9352
|
@ -42,3 +42,7 @@ bin/
|
|||
### Mac OS ###
|
||||
.DS_Store
|
||||
.run/*
|
||||
|
||||
/glossaire.json
|
||||
```
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ dependencies {
|
|||
// With compose.desktop.common you will also lose @Preview functionality
|
||||
implementation(compose.desktop.currentOs)
|
||||
implementation(kotlin("stdlib"))
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.3.0")
|
||||
implementation("mysql:mysql-connector-java:8.0.23")
|
||||
implementation("org.jetbrains.compose.material:material:1.0.0-beta-02")
|
||||
implementation("org.jetbrains.compose.ui:ui:1.0.0-beta-02")
|
||||
|
|
|
@ -23,6 +23,13 @@ import androidx.compose.ui.graphics.Color
|
|||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.window.*
|
||||
import database.DatabaseManager
|
||||
import kotlinx.serialization.json.JsonObject
|
||||
import kotlinx.serialization.json.buildJsonObject
|
||||
import kotlinx.serialization.json.put
|
||||
import java.io.File
|
||||
import java.io.FileWriter
|
||||
import java.io.IOException
|
||||
|
||||
|
||||
val connection = DatabaseManager.getConnection()
|
||||
val customRedColor = Color(0xFFB70D1B)
|
||||
|
@ -326,9 +333,9 @@ fun glossairePage(
|
|||
}
|
||||
|
||||
|
||||
|
||||
@Composable
|
||||
fun FormulairePage(onAnnulerClick: () -> Unit) {
|
||||
|
||||
MaterialTheme {
|
||||
Column(
|
||||
modifier = Modifier.padding(16.dp),
|
||||
|
@ -423,19 +430,47 @@ fun FormulairePage(onAnnulerClick: () -> Unit) {
|
|||
colors = ButtonDefaults.buttonColors(
|
||||
backgroundColor = customRedColor,
|
||||
contentColor = Color.White
|
||||
)) {
|
||||
)
|
||||
) {
|
||||
Icon(imageVector = Icons.Default.Close, contentDescription = null)
|
||||
Text("Annuler")
|
||||
}
|
||||
Button(onClick = { /* Action de validation */ },
|
||||
Button(
|
||||
onClick = {
|
||||
// Validation du formulaire
|
||||
|
||||
// Create a JsonObject to represent your Mot
|
||||
val motJson = buildJsonObject {
|
||||
put("nom", nom.value)
|
||||
put("description", description.value)
|
||||
put("contextePrincipal", contextePrincipal.value)
|
||||
put("contexte2", contexte2.value)
|
||||
put("lieA", lieA.value)
|
||||
put("synonyme", synonyme.value)
|
||||
put("antonyme", antonyme.value)
|
||||
}
|
||||
|
||||
// Append the JsonObject to the glossaire.json file
|
||||
try {
|
||||
FileWriter("glossaire.json", true).use { fileWriter ->
|
||||
fileWriter.appendLine(motJson.toString())
|
||||
}
|
||||
} catch (e: IOException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
|
||||
// Reste de la logique de validation ou de navigation
|
||||
},
|
||||
colors = ButtonDefaults.buttonColors(
|
||||
backgroundColor = customRedColor,
|
||||
contentColor = Color.White
|
||||
)) {
|
||||
)
|
||||
) {
|
||||
Icon(imageVector = Icons.Default.Check, contentDescription = null)
|
||||
Text("Valider")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue