Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .kotlin/errors/errors-1761115146673.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
kotlin version: 2.0.21
error message: The daemon has terminated unexpectedly on startup attempt #1 with error code: 0. The daemon process output:
1. Kotlin compile daemon is ready

1 change: 1 addition & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ dependencies {
implementation(libs.material)
implementation(libs.androidx.activity)
implementation(libs.androidx.constraintlayout)
implementation(libs.androidx.compose.foundation.layout)
testImplementation(libs.junit)
androidTestImplementation(libs.androidx.junit)
androidTestImplementation(libs.androidx.espresso.core)
Expand Down
51 changes: 51 additions & 0 deletions app/src/main/java/es/fpsumma/dam2/intro/ui/components/NameField.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package es.fpsumma.dam2.intro.ui.components


import android.R
import android.R.attr.name
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.text.KeyboardActions
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.input.ImeAction

import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp






@Composable
fun NameField(
value: R.string,
onValueChange=string,
) {
OutlinedTextField(
value = name,
onValueChange = { name = it },
label = { Text("Tu nombre") },
isError = error != null,
supportingText = { if (error != null) Text(error!!) },
singleLine = true,
keyboardOptions = KeyboardOptions(imeAction = ImeAction.Done),
keyboardActions = KeyboardActions(onDone = { submit() }),
modifier = Modifier.fillMaxWidth()
)

}




Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package es.fpsumma.dam2.intro.ui.screens


import androidx.compose.foundation.layout.*
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.Refresh
Expand All @@ -8,15 +9,21 @@ import androidx.compose.material3.*
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.contentDescription
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.res.stringResource
import es.fpsumma.dam2.intro.R


@Composable
fun CounterScreen() {
var count by remember { mutableStateOf(0) }
var count by remember { mutableStateOf(5) }
val buttonWidth = (100 + count * 10).dp


Column(
modifier = Modifier
Expand All @@ -25,31 +32,48 @@ fun CounterScreen() {
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.spacedBy(16.dp)
) {
Text("Hola mi amig@!", style = MaterialTheme.typography.headlineMedium)

Text(stringResource(R.string.saludos), style = MaterialTheme.typography.headlineMedium)
Text("Contador: $count", style = MaterialTheme.typography.titleLarge)
Row(horizontalArrangement = Arrangement.spacedBy(12.dp)) {
Button(
onClick = {},
onClick = {count++},
colors= ButtonDefaults.buttonColors(
containerColor = Color.Green,
contentColor = Color.Red
),

modifier = Modifier.semantics { contentDescription = "Incrementar" }


) { Text("+1") }

FilledTonalButton(
onClick = {},
onClick = {count--},
modifier = Modifier.semantics { contentDescription = "Decrementar" }
) { Text("-1") }

IconButton(
onClick = {},
onClick = {count = 0},
modifier = Modifier.size(48.dp)
) {
Icon(Icons.Outlined.Refresh, contentDescription = "Reiniciar contador")
}

Button(
onClick = {count = 10},
modifier = Modifier.width(buttonWidth).semantics { contentDescription = "Incrementar" }


)
{ }
}
}
}

@Preview(showBackground = true)
@Composable
private fun CounterPreview() {

CounterScreen()
}
2 changes: 1 addition & 1 deletion app/src/main/java/es/fpsumma/dam2/intro/ui/theme/Theme.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ private val LightColorScheme = lightColorScheme(

@Composable
fun IntroTheme(
darkTheme: Boolean = false,
darkTheme: Boolean = true,
dynamicColor: Boolean = true,
content: @Composable () -> Unit
) {
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<resources>
<string name="app_name">Intro</string>
<string name="saludos">Buenos Dias!</string>
</resources>
2 changes: 2 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ appcompat = "1.7.1"
material = "1.13.0"
activity = "1.11.0"
constraintlayout = "2.2.1"
foundationLayout = "1.9.4"

[libraries]
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
Expand All @@ -32,6 +33,7 @@ androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version
material = { group = "com.google.android.material", name = "material", version.ref = "material" }
androidx-activity = { group = "androidx.activity", name = "activity", version.ref = "activity" }
androidx-constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "constraintlayout" }
androidx-compose-foundation-layout = { group = "androidx.compose.foundation", name = "foundation-layout", version.ref = "foundationLayout" }

[plugins]
android-application = { id = "com.android.application", version.ref = "agp" }
Expand Down