Skip to content

Commit

Permalink
extract locale text
Browse files Browse the repository at this point in the history
  • Loading branch information
Souleymane Sidibe committed Aug 20, 2021
1 parent 97dbc90 commit 667c040
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ import androidx.compose.material.icons.filled.Delete
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.input.ImeAction
import androidx.compose.ui.text.input.KeyboardType
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.navigation.NavHostController
import com.soulesidibe.todoapp.R
import com.soulesidibe.todoapp.model.TodoViewModel
import com.soulesidibe.todoapp.viewmodel.TodoDetailViewModel
import com.soulesidibe.todoapp.viewmodel.ViewState
Expand Down Expand Up @@ -53,7 +55,7 @@ private fun CreateTodoAppBar(
) {
TopAppBar(
title = {
Text(text = "Add a todo")
Text(text = stringResource(R.string.str_toolbar_title))
},
actions = {
CreateTodoToolbarActions(todoId, onRemove)
Expand Down Expand Up @@ -129,7 +131,7 @@ private fun CreateTodo(
.fillMaxHeight()
.fillMaxWidth()
) {
Text(text = "Veuillez fournir un titre a votre todo.")
Text(text = stringResource(R.string.str_add_todo_explanation))
Spacer(modifier = Modifier.height(8.dp))

val onClick: () -> Unit = {
Expand Down Expand Up @@ -208,9 +210,9 @@ private fun CreateTodoSubmitButton(

Button(modifier = modifier, onClick = onClick, enabled = !loadingState) {
val label = if (todoState is ViewState.Success) {
"Modifier"
stringResource(R.string.btn_edit_todo)
} else {
"Ajouter"
stringResource(R.string.btn_add_todo)
}
Text(text = label, textAlign = TextAlign.Center)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ import androidx.compose.material.icons.filled.Add
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Alignment.Companion.Center
import androidx.compose.ui.Alignment.Companion.CenterHorizontally
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.layout.layoutId
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontStyle
import androidx.compose.ui.text.font.FontWeight
Expand Down Expand Up @@ -123,7 +123,7 @@ fun TodosEmptyView(onAdd: () -> Unit) {
Box(
modifier = Modifier
.fillMaxWidth()
.fillMaxHeight(), contentAlignment = Alignment.Center
.fillMaxHeight(), contentAlignment = Center
) {

Column {
Expand All @@ -134,11 +134,11 @@ fun TodosEmptyView(onAdd: () -> Unit) {
contentDescription = "Empty todo list"
)
Spacer(modifier = Modifier.height(8.dp))
Text(text = "Vous n'avez pas encore de todo :(", color = Color.Gray)
Text(text = stringResource(R.string.str_no_todos), color = Color.Gray)
Spacer(modifier = Modifier.height(16.dp))

Text(
text = "Ajouter un nouveau todo",
text = stringResource(R.string.str_add_todo),
color = Color.Gray,
modifier = Modifier
.clickable { onAdd() }
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
<resources>
<string name="app_name">Todo App</string>
<string name="str_no_todos">Vous n\'avez pas encore de todo :(</string>
<string name="str_add_todo">Ajouter un nouveau todo</string>
<string name="btn_edit_todo">Modifier</string>
<string name="btn_add_todo">Ajouter</string>
<string name="str_add_todo_explanation">Veuillez fournir un titre a votre todo.</string>
<string name="str_toolbar_title">Add a todo</string>
</resources>

0 comments on commit 667c040

Please sign in to comment.