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
2 changes: 0 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Intro">
<activity
android:name=".MainActivity"
android:exported="true"
android:label="@string/app_name"
android:theme="@style/Theme.Intro">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/java/es/fpsumma/dam2/intro/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
IntroTheme(){
IntroTheme() {
Surface(
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colorScheme.background
) {
CounterScreen()
}
}
}
}
}
}
}
34 changes: 22 additions & 12 deletions app/src/main/java/es/fpsumma/dam2/intro/ui/screens/CounterScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,53 +3,63 @@ 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

import androidx.compose.material3.*
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
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 es.fpsumma.dam2.intro.R
import androidx.compose.ui.graphics.Color

@Composable
fun CounterScreen() {
var count by remember { mutableStateOf(0) }

var count by remember { mutableStateOf(5) }
var BigButton = (100 + count * 100).dp
Column(
modifier = Modifier
.fillMaxSize()
.padding(24.dp),
.padding(25.dp),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.spacedBy(16.dp)
verticalArrangement = Arrangement.spacedBy(25.dp)
) {
Text("Hola mi amig@!", style = MaterialTheme.typography.headlineMedium)
Text(text = stringResource(id = R.string.texto))
Text("Contador: $count", style = MaterialTheme.typography.titleLarge)
Row(horizontalArrangement = Arrangement.spacedBy(12.dp)) {
Row(horizontalArrangement = Arrangement.spacedBy(25.dp)) {
Button(
onClick = {},
onClick = { if (count < 10) count++ },
modifier = Modifier.semantics { contentDescription = "Incrementar" }
) { Text("+1") }

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

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

Button(
onClick = { count = 10},
colors = ButtonDefaults.buttonColors(containerColor = Color.Green, // Color de fondo del botón
),
modifier = Modifier.width(BigButton).semantics() { contentDescription = "Creciente y decreciente" }
) { Text("") }
}
}
}


@Preview(showBackground = true)
@Composable
private fun CounterPreview() {
CounterScreen()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,4 @@ fun InputDemoScreen() {

@Preview(showBackground = true)
@Composable
private fun InputDemoPreview() { InputDemoScreen() }
private fun InputDemoPreview() { InputDemoScreen() }
2 changes: 1 addition & 1 deletion app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<color name="purple_200">#FFBB86FC</color>
<color name="purple_500">#FF6200EE</color>
<color name="purple_700">#FF3700B3</color>
Expand Down
5 changes: 3 additions & 2 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>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<string name="app_name">Introducción</string>
<string name="texto">Hola mi amig@</string>
</resources>