Extraidos textos

This commit is contained in:
Salatiel Genol Rodríguez 2023-03-24 17:52:16 +01:00
parent 49aef16922
commit 4b1d224620
2 changed files with 14 additions and 7 deletions

View File

@ -17,10 +17,11 @@ import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.input.KeyboardType
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.lifecycle.viewmodel.compose.viewModel
import ies.teis.genol_salatiel_ex2tdist.R
@Composable
fun ExerciseOneCompose() {
@ -30,7 +31,7 @@ fun ExerciseOneCompose() {
TopAppBar(title = {
Row() {
Text(
text = "Contadores",
text = stringResource(R.string.ej1_contadores),
modifier = Modifier
.padding(horizontal = 10.dp)
.weight(1f)
@ -38,7 +39,7 @@ fun ExerciseOneCompose() {
if (viewModel.counters.isNotEmpty()) {
Icon(
Icons.Default.Refresh,
contentDescription = "Reload the app",
contentDescription = stringResource(R.string.ej1_reload),
modifier = Modifier
.padding(horizontal = 15.dp)
.clickable { viewModel.resetAll() }
@ -86,11 +87,11 @@ fun InputCount(
OutlinedTextField(
value = inputState,
onValueChange = { inputState = it },
placeholder = { Text(text = "Número de contadores:") },
placeholder = { Text(text = stringResource(R.string.ej1_num_contadores)) },
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number)
)
Button(onClick = { onClick(inputState.toInt()) }) {
Text(text = "Mostrar")
Text(text = stringResource(R.string.ej1_mostrar))
}
}
@ -136,13 +137,13 @@ fun ButtonCounter(
verticalAlignment = Alignment.CenterVertically
) {
Button(onClick = onIncrement) {
Text(text = "Incrementar")
Text(text = stringResource(R.string.ej1_incrementar))
}
Text(text = valor.toString())
Button(onClick = onDecrement) {
Text(text = "Decrementar")
Text(text = stringResource(R.string.ej1_decrementar))
}
}
}

View File

@ -5,4 +5,10 @@
<string name="launcher_button_two">Exercise Two</string>
<string name="launcher_button_three">Exercise Three</string>
<string name="launcher_button_four">Exercise Four</string>
<string name="ej1_contadores">Contadores</string>
<string name="ej1_reload">Reload the app</string>
<string name="ej1_num_contadores">Número de contadores:</string>
<string name="ej1_mostrar">Mostrar</string>
<string name="ej1_incrementar">Incrementar</string>
<string name="ej1_decrementar">Decrementar</string>
</resources>