Avanzando en primer ejercicio

This commit is contained in:
Salatiel Genol 2023-03-24 15:50:45 +01:00
parent 35a4bb1547
commit 42e2855620
4 changed files with 62 additions and 10 deletions

View File

@ -49,12 +49,12 @@ android {
dependencies { dependencies {
implementation 'androidx.core:core-ktx:1.9.0' implementation 'androidx.core:core-ktx:1.9.0'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.0' implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.1'
implementation 'androidx.activity:activity-compose:1.6.1' implementation 'androidx.activity:activity-compose:1.7.0'
implementation "androidx.compose.ui:ui:$compose_ui_version" implementation "androidx.compose.ui:ui:$compose_ui_version"
implementation "androidx.compose.ui:ui-tooling-preview:$compose_ui_version" implementation "androidx.compose.ui:ui-tooling-preview:$compose_ui_version"
implementation 'androidx.compose.material:material:1.3.1' implementation 'androidx.compose.material:material:1.4.0'
implementation "androidx.lifecycle:lifecycle-viewmodel-compose:2.6.0" implementation "androidx.lifecycle:lifecycle-viewmodel-compose:2.6.1"
implementation "androidx.navigation:navigation-compose:2.5.3" implementation "androidx.navigation:navigation-compose:2.5.3"
testImplementation 'junit:junit:4.13.2' testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5' androidTestImplementation 'androidx.test.ext:junit:1.1.5'

View File

@ -1,9 +1,60 @@
package ies.teis.genol_salatiel_ex2tdist.ui.exerciseOne package ies.teis.genol_salatiel_ex2tdist.ui.exerciseOne
import androidx.compose.material.Text import androidx.compose.foundation.layout.Column
import androidx.compose.runtime.Composable import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material.*
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
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
@Preview
@Composable @Composable
fun ExerciseOneCompose() { fun ExerciseOneCompose() {
Text(text = "1") val viewModel: ExerciseOneViewModel = viewModel()
Scaffold(topBar = {
TopAppBar(title = {
Text(text = "Contadores", modifier = Modifier.padding(horizontal = 10.dp))
})
}) {
if (!viewModel.showLazy) {
InputCount(Modifier.padding(paddingValues = it))
} else {
ButtonsCounter()
}
}
}
@Composable
fun InputCount(modifier: Modifier = Modifier) {
var inputState by remember { mutableStateOf("") }
Column(
Modifier
.padding(top = 45.dp)
.fillMaxSize(),
horizontalAlignment = Alignment.CenterHorizontally
) {
OutlinedTextField(
value = inputState,
onValueChange = { inputState = it },
placeholder = { Text(text = "Número de contadores:")},
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number)
)
Button(onClick = { /*TODO*/ }) {
Text(text = "Mostrar")
}
}
}
@Composable
fun ButtonsCounter() {
} }

View File

@ -37,6 +37,7 @@ class LauncherActivity : ComponentActivity() {
modifier = Modifier.fillMaxSize(), modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colors.background color = MaterialTheme.colors.background
) { ) {
/* Los colores de los botones cambian intencionadamente */
LauncherNavController() LauncherNavController()
} }
} }
@ -81,14 +82,14 @@ fun ExerciseList(navController: NavController) {
label = stringResource(R.string.launcher_button_two), label = stringResource(R.string.launcher_button_two),
{ navController.navigate(route = LauncherModel.ExerciseTwo.path) } { navController.navigate(route = LauncherModel.ExerciseTwo.path) }
) )
LauncherButton( /* LauncherButton(
label = stringResource(R.string.launcher_button_three), label = stringResource(R.string.launcher_button_three),
{ navController.navigate(route = LauncherModel.ExerciseThree.path) } { navController.navigate(route = LauncherModel.ExerciseThree.path) }
) )
LauncherButton( LauncherButton(
label = stringResource(R.string.launcher_button_four), label = stringResource(R.string.launcher_button_four),
{ navController.navigate(route = LauncherModel.ExerciseFour.path) } { navController.navigate(route = LauncherModel.ExerciseFour.path) }
) )*/
} }
} }

0
gradlew vendored Executable file → Normal file
View File