strings madness
This commit is contained in:
parent
e7c511f5e4
commit
4329f3f91d
5 changed files with 88 additions and 48 deletions
|
@ -135,13 +135,13 @@ private fun ActionRow(context: Context, model: HomeViewModel, navController: Nav
|
|||
Button(
|
||||
enabled = selection != null,
|
||||
onClick = { navController.navigate("$MODIFY_SET/${selection?.idSet}") }) {
|
||||
Text(text = context.getString(R.string.main_button_modify))
|
||||
Text(text = context.getString(R.string.modify))
|
||||
}
|
||||
|
||||
Spacer(modifier = Modifier.padding(2.dp))
|
||||
|
||||
Button(onClick = { model.doAction(ActionHome.IMPORTATION) }) {
|
||||
Text(text = context.getString(R.string.main_button_import))
|
||||
Text(text = context.getString(R.string.importation))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -151,17 +151,25 @@ private fun ActionRow(context: Context, model: HomeViewModel, navController: Nav
|
|||
fun CreationDialog(
|
||||
dismiss: () -> Unit, model: HomeViewModel = viewModel()
|
||||
) {
|
||||
val context = LocalContext.current
|
||||
val sujet by model.sujet
|
||||
|
||||
AlertDialog(onDismissRequest = dismiss, title = { Text(text = "Créer un sujet") }, text = {
|
||||
OutlinedTextField(
|
||||
sujet, label = { Text("Nouveau sujet") }, onValueChange = model::onSujetChange
|
||||
)
|
||||
}, confirmButton = {
|
||||
Button(onClick = model::addSet, content = { Text("Ajouter") })
|
||||
}, dismissButton = {
|
||||
Button(onClick = dismiss, content = { Text("Annuler") })
|
||||
})
|
||||
AlertDialog(
|
||||
onDismissRequest = dismiss,
|
||||
title = { Text(text = context.getString(R.string.create_subject)) },
|
||||
text = {
|
||||
OutlinedTextField(
|
||||
sujet,
|
||||
label = { Text(context.getString(R.string.new_subject)) },
|
||||
onValueChange = model::onSujetChange
|
||||
)
|
||||
},
|
||||
confirmButton = {
|
||||
Button(onClick = model::addSet, content = { Text(context.getString(R.string.add)) })
|
||||
},
|
||||
dismissButton = {
|
||||
Button(onClick = dismiss, content = { Text(context.getString(R.string.cancel)) })
|
||||
})
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class, DelicateCoroutinesApi::class)
|
||||
|
@ -171,6 +179,7 @@ fun ImportDialog(
|
|||
) {
|
||||
val (selectedOption, onOptionSelected) = remember { mutableStateOf(ActionImport.FILE) }
|
||||
|
||||
val context = LocalContext.current
|
||||
var lien by remember { mutableStateOf("") }
|
||||
val ctx = LocalContext.current
|
||||
|
||||
|
@ -184,7 +193,7 @@ fun ImportDialog(
|
|||
}
|
||||
|
||||
AlertDialog(onDismissRequest = dismiss,
|
||||
title = { Text(text = "Importer un jeu de question") },
|
||||
title = { Text(text = context.getString(R.string.import_set_qestions)) },
|
||||
text = {
|
||||
Column {
|
||||
Column(Modifier.selectableGroup()) {
|
||||
|
@ -218,7 +227,7 @@ fun ImportDialog(
|
|||
)
|
||||
}) {
|
||||
Text(
|
||||
text = "Explorateur",
|
||||
text = context.getString(R.string.explorer),
|
||||
style = MaterialTheme.typography.labelSmall
|
||||
)
|
||||
}
|
||||
|
@ -230,30 +239,30 @@ fun ImportDialog(
|
|||
OutlinedTextField(enabled = selectedOption == ActionImport.INTERNET,
|
||||
value = lien,
|
||||
onValueChange = { newTextValue -> lien = newTextValue },
|
||||
label = { Text(text = "Lien") })
|
||||
label = { Text(text = context.getString(R.string.link)) })
|
||||
}
|
||||
},
|
||||
confirmButton = {
|
||||
Button(onClick = { GlobalScope.launch { model.import(ctx, lien) } },
|
||||
content = { Text("Importer") })
|
||||
content = { Text(context.getString(R.string.importation)) })
|
||||
},
|
||||
dismissButton = {
|
||||
Button(onClick = dismiss, content = { Text("Annuler") })
|
||||
Button(onClick = dismiss, content = { Text(context.getString(R.string.cancel)) })
|
||||
})
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun ErrorDialog(errMsg: String, dismiss: () -> Unit) = AlertDialog(onDismissRequest = dismiss,
|
||||
title = { Text(text = "Erreur") },
|
||||
title = { Text(text = LocalContext.current.getString(R.string.error)) },
|
||||
text = { Text(text = errMsg) },
|
||||
confirmButton = { Button(onClick = dismiss) { Text(text = "Ok") } })
|
||||
confirmButton = { Button(onClick = dismiss) { Text(text = LocalContext.current.getString(R.string.ok)) } })
|
||||
|
||||
@Composable
|
||||
fun DeletionDialog(dismiss: () -> Unit, confirm: () -> Unit) =
|
||||
AlertDialog(onDismissRequest = dismiss,
|
||||
title = { Text(text = "Supprimer un jeu de question") },
|
||||
text = { Text(text = "Voulez-vous supprimer ce jeu de question ?") },
|
||||
confirmButton = { Button(onClick = confirm) { Text(text = "Ok") } })
|
||||
title = { Text(text = LocalContext.current.getString(R.string.delete_set_questions)) },
|
||||
text = { Text(text = LocalContext.current.getString(R.string.delete_set_qestions_desc)) },
|
||||
confirmButton = { Button(onClick = confirm) { Text(text = LocalContext.current.getString(R.string.ok)) } })
|
||||
|
||||
@Composable
|
||||
fun ShowList(
|
||||
|
|
|
@ -72,13 +72,13 @@ fun ModifySetScreen(
|
|||
Button(
|
||||
enabled = currentSelection != null,
|
||||
onClick = { action = ActionModifySet.MODIFICATION }) {
|
||||
Text(text = context.getString(R.string.modify_button_modify))
|
||||
Text(text = context.getString(R.string.modify))
|
||||
}
|
||||
|
||||
Spacer(modifier = Modifier.padding(2.dp))
|
||||
|
||||
Button(onClick = { action = ActionModifySet.AJOUT }) {
|
||||
Text(text = context.getString(R.string.modify_button_add))
|
||||
Text(text = context.getString(R.string.add))
|
||||
}
|
||||
|
||||
Spacer(modifier = Modifier.padding(2.dp))
|
||||
|
@ -149,6 +149,8 @@ fun AjoutModifDialog(
|
|||
confirm: (String, String) -> Unit,
|
||||
dismiss: () -> Unit
|
||||
) {
|
||||
val context = LocalContext.current
|
||||
|
||||
var enonce by remember {
|
||||
mutableStateOf(
|
||||
if (type == ActionModifySet.MODIFICATION) {
|
||||
|
@ -172,9 +174,9 @@ fun AjoutModifDialog(
|
|||
title = {
|
||||
Text(
|
||||
text = if (selection != null) {
|
||||
"Mettre à jour la question"
|
||||
context.getString(R.string.update_question)
|
||||
} else {
|
||||
"Ajouter une question"
|
||||
context.getString(R.string.add_question)
|
||||
}
|
||||
)
|
||||
},
|
||||
|
@ -184,14 +186,14 @@ fun AjoutModifDialog(
|
|||
OutlinedTextField(
|
||||
value = enonce,
|
||||
onValueChange = { enonce = it },
|
||||
label = { Text(text = "Question") })
|
||||
label = { Text(text = context.getString(R.string.question)) })
|
||||
}
|
||||
|
||||
Row {
|
||||
OutlinedTextField(
|
||||
value = reponse,
|
||||
onValueChange = { reponse = it },
|
||||
label = { Text(text = "Réponse") })
|
||||
label = { Text(text = context.getString(R.string.reponse)) })
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -199,18 +201,18 @@ fun AjoutModifDialog(
|
|||
Button(onClick = {
|
||||
confirm(enonce, reponse)
|
||||
dismiss()
|
||||
}) { Text(text = "Ok") }
|
||||
}) { Text(text = context.getString(R.string.ok)) }
|
||||
})
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun RemoveDialog(confirm: () -> Unit, dismiss: () -> Unit) =
|
||||
AlertDialog(onDismissRequest = dismiss,
|
||||
title = { Text(text = "Supprimer la question") },
|
||||
text = { Text(text = "Voulez-vous supprimer la question ?") },
|
||||
title = { Text(text = LocalContext.current.getString(R.string.delete_question)) },
|
||||
text = { Text(text = LocalContext.current.getString(R.string.delete_question_desc)) },
|
||||
confirmButton = {
|
||||
Button(onClick = {
|
||||
confirm()
|
||||
dismiss()
|
||||
}) { Text(text = "Ok") }
|
||||
}) { Text(text = LocalContext.current.getString(R.string.ok)) }
|
||||
})
|
||||
|
|
|
@ -20,6 +20,7 @@ import androidx.compose.runtime.getValue
|
|||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
|
@ -40,6 +41,8 @@ fun PlayScreen(
|
|||
// First update the list of questions
|
||||
model.updateQuestionList(idSet)
|
||||
|
||||
val context = LocalContext.current
|
||||
|
||||
val question by model.currentQuestion
|
||||
val reponse by model.proposedAnswer
|
||||
val correction by model.evaluatedAnswer
|
||||
|
@ -51,8 +54,8 @@ fun PlayScreen(
|
|||
model.sbUpdate()
|
||||
snackbarHostState.showSnackbar(
|
||||
when (correction!!) {
|
||||
AnswerType.GOOD -> "Bonnne réponse !"
|
||||
AnswerType.BAD -> "Mauvaise réponse !"
|
||||
AnswerType.GOOD -> context.getString(R.string.good_answer)
|
||||
AnswerType.BAD -> context.getString(R.string.bad_answer)
|
||||
}, duration = SnackbarDuration.Short
|
||||
)
|
||||
model.resetAfterSb()
|
||||
|
@ -74,7 +77,7 @@ fun PlayScreen(
|
|||
) {
|
||||
if (question == null) {
|
||||
Row(modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.Center) {
|
||||
Text("Ce set n'a aucune question", fontSize = 30.sp)
|
||||
Text(context.getString(R.string.no_question), fontSize = 30.sp)
|
||||
}
|
||||
} else {
|
||||
Text(text = question!!.enonce, fontSize = 30.sp, textAlign = TextAlign.Center)
|
||||
|
@ -83,7 +86,7 @@ fun PlayScreen(
|
|||
|
||||
OutlinedTextField(
|
||||
value = reponse,
|
||||
label = { Text(text = "Réponse") },
|
||||
label = { Text(text = context.getString(R.string.reponse)) },
|
||||
onValueChange = model::updateAnswer
|
||||
)
|
||||
|
||||
|
@ -97,13 +100,13 @@ fun PlayScreen(
|
|||
enabled = reponse.isNotBlank() && correction == null,
|
||||
onClick = model::checkAnswer
|
||||
) {
|
||||
Text(text = "Répondre")
|
||||
Text(text = context.getString(R.string.to_answer))
|
||||
}
|
||||
|
||||
Button(
|
||||
enabled = model.isDelayElapsed(),
|
||||
onClick = { giveup = true }) {
|
||||
Text(text = "Voir réponse")
|
||||
Text(text = context.getString(R.string.see_answer))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -112,7 +115,7 @@ fun PlayScreen(
|
|||
|
||||
Button(
|
||||
onClick = { navController.navigate("$MODIFY_SET/$idSet") }) {
|
||||
Text(text = "Modifier le set")
|
||||
Text(text = context.getString(R.string.modify_set))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -120,8 +123,8 @@ fun PlayScreen(
|
|||
@Composable
|
||||
fun SolutionDialog(reponse: String, next: () -> Unit) =
|
||||
AlertDialog(onDismissRequest = next,
|
||||
title = { Text(text = "Solution") },
|
||||
title = { Text(text = LocalContext.current.getString(R.string.solution)) },
|
||||
text = { Text(text = reponse) },
|
||||
confirmButton = {
|
||||
Button(onClick = next) { Text(text = "Ok") }
|
||||
Button(onClick = next) { Text(text = LocalContext.current.getString(R.string.ok)) }
|
||||
})
|
||||
|
|
|
@ -49,9 +49,9 @@ fun SettingsScreen(padding: PaddingValues, model: SettingsViewModel = viewModel(
|
|||
@Composable
|
||||
fun DeletionDBDialog(confirm: () -> Unit, dismiss: () -> Unit) =
|
||||
AlertDialog(onDismissRequest = dismiss,
|
||||
title = { Text(text = "Supprimer la base de données") },
|
||||
text = { Text(text = "Voulez-vous supprimer la base de données ?") },
|
||||
title = { Text(text = LocalContext.current.getString(R.string.delete_db)) },
|
||||
text = { Text(text = LocalContext.current.getString(R.string.delete_db_desc)) },
|
||||
confirmButton = {
|
||||
Button(onClick = confirm) { Text(text = "Oui") }
|
||||
Button(onClick = confirm) { Text(text = LocalContext.current.getString(R.string.yes)) }
|
||||
},
|
||||
dismissButton = { Button(onClick = dismiss) { Text(text = "Non") } })
|
||||
dismissButton = { Button(onClick = dismiss) { Text(text = LocalContext.current.getString(R.string.no)) } })
|
||||
|
|
|
@ -3,14 +3,40 @@
|
|||
<string name="home_button">Page principale</string>
|
||||
<string name="settings_button">Paramètres</string>
|
||||
<string name="main_button_create">Créer</string>
|
||||
<string name="main_button_modify">Modifier</string>
|
||||
<string name="main_button_import">Importer</string>
|
||||
<string name="main_button_deletebase">Supprimer base</string>
|
||||
<string name="main_button_delete">Supprimer sélection</string>
|
||||
<string name="main_button_start">Lancer</string>
|
||||
<string name="error_bad_entry">Erreur : entrée invalide</string>
|
||||
<string name="error_duplicate">Erreur : doublon</string>
|
||||
<string name="modify_button_add">Ajouter</string>
|
||||
<string name="modify_button_modify">Modifier</string>
|
||||
<string name="modify">Modifier</string>
|
||||
<string name="modify_button_delete">Supprimer</string>
|
||||
<string name="create_subject">Créer un sujet</string>
|
||||
<string name="new_subject">Nouveau sujet</string>
|
||||
<string name="add">Ajouter</string>
|
||||
<string name="cancel">Annuler</string>
|
||||
<string name="import_set_qestions">Importer un jeu de question</string>
|
||||
<string name="explorer">Explorateur</string>
|
||||
<string name="link">Lien</string>
|
||||
<string name="importation">Importer</string>
|
||||
<string name="error">Erreur</string>
|
||||
<string name="delete_set_questions">Supprimer un jeu de question</string>
|
||||
<string name="delete_set_qestions_desc">Voulez-vous supprimer ce jeu de question ?</string>
|
||||
<string name="ok">Ok</string>
|
||||
<string name="update_question">Mettre à jour la question</string>
|
||||
<string name="add_question">Ajouter une question</string>
|
||||
<string name="question">Question</string>
|
||||
<string name="reponse">Réponse</string>
|
||||
<string name="delete_question">Supprimer la question</string>
|
||||
<string name="delete_question_desc">Voulez-vous supprimer la question ?</string>
|
||||
<string name="good_answer">Bonnne réponse !</string>
|
||||
<string name="bad_answer">Mauvaise réponse !</string>
|
||||
<string name="no_question">Ce set n\'a aucune question</string>
|
||||
<string name="to_answer">Répondre</string>
|
||||
<string name="see_answer">Voir réponse</string>
|
||||
<string name="modify_set">Modifier le set</string>
|
||||
<string name="solution">Solution</string>
|
||||
<string name="delete_db">Supprimer la base de données</string>
|
||||
<string name="delete_db_desc">Voulez-vous supprimer la base de données ?</string>
|
||||
<string name="yes">Oui</string>
|
||||
<string name="no">Non</string>
|
||||
</resources>
|
||||
|
|
Reference in a new issue