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
5 changes: 2 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 @@ -7,17 +7,16 @@ import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.ui.Modifier
import com.ivancorrales.basicjetpackcompose.ui.theme.IntroTheme
import es.fpsumma.dam2.intro.ui.theme.IntroTheme
import es.fpsumma.dam2.intro.ui.screens.CounterScreen

class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
IntroTheme(){
IntroTheme(darkTheme = true){
Surface(
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colorScheme.background
) {
CounterScreen()
}
Expand Down
74 changes: 46 additions & 28 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 @@ -5,51 +5,69 @@ import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.Refresh

import androidx.compose.material3.*
import androidx.compose.material3.darkColorScheme
import androidx.compose.runtime.*
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
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 android.content.res.Configuration.UI_MODE_NIGHT_YES
import es.fpsumma.dam2.intro.ui.theme.Green2
import es.fpsumma.dam2.intro.ui.theme.IntroTheme


@Composable
fun CounterScreen() {
var count by remember { mutableStateOf(0) }
fun CounterScreen(modifier: Modifier = Modifier) {
var count by rememberSaveable { mutableStateOf(5) }
Column(
modifier = Modifier
.fillMaxSize()
.padding(24.dp),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.spacedBy(16.dp)
) {
Text("Hola mi amig@!", style = MaterialTheme.typography.headlineMedium)
Text("Contador: $count", style = MaterialTheme.typography.titleLarge)
Row(horizontalArrangement = Arrangement.spacedBy(12.dp)) {
Button(
onClick = { count++ },
colors = ButtonDefaults.buttonColors(
containerColor = Green2,
),
modifier = Modifier.semantics { contentDescription = "Incrementar" }
) { Text("+") }

Column(
modifier = Modifier
.fillMaxSize()
.padding(24.dp),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.spacedBy(16.dp)
) {
Text("Hola mi amig@!", style = MaterialTheme.typography.headlineMedium)
Text("Contador: $count", style = MaterialTheme.typography.titleLarge)
Row(horizontalArrangement = Arrangement.spacedBy(12.dp)) {
Button(
onClick = {},
modifier = Modifier.semantics { contentDescription = "Incrementar" }
) { Text("+1") }
FilledTonalButton(
onClick = {
if (count == 0) {
count = 0;
} else {
count--
}
},
modifier = Modifier.semantics { contentDescription = "Decrementar" }
) { Text("-") }

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

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

@Preview(showBackground = true)
@Composable
private fun CounterPreview() {
CounterScreen()
IntroTheme(darkTheme = true){
Surface {
CounterScreen()
}
}
}
10 changes: 8 additions & 2 deletions app/src/main/java/es/fpsumma/dam2/intro/ui/theme/Color.kt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.ivancorrales.basicjetpackcompose.ui.theme
package es.fpsumma.dam2.intro.ui.theme

import androidx.compose.ui.graphics.Color

Expand All @@ -8,4 +8,10 @@ val Pink80 = Color(0xFFEFB8C8)

val Purple40 = Color(0xFF6650a4)
val PurpleGrey40 = Color(0xFF625b71)
val Pink40 = Color(0xFF7D5260)
val Pink40 = Color(0xFF7D5260)

val Green = Color(0xFF009106)

val Green2 = Color(0xFF006505)

val Green3 = Color(0xFF004804)
23 changes: 15 additions & 8 deletions app/src/main/java/es/fpsumma/dam2/intro/ui/theme/Theme.kt
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
package com.ivancorrales.basicjetpackcompose.ui.theme
package es.fpsumma.dam2.intro.ui.theme

import android.app.Activity
import android.os.Build
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.material3.ColorScheme
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.darkColorScheme
import androidx.compose.material3.dynamicDarkColorScheme
import androidx.compose.material3.dynamicLightColorScheme
import androidx.compose.material3.lightColorScheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.Color
import androidx.compose.runtime.SideEffect
import androidx.compose.ui.graphics.toArgb
import androidx.compose.ui.platform.LocalContext
import com.ivancorrales.basicjetpackcompose.ui.theme.LightColorScheme
import androidx.compose.ui.platform.LocalView
import androidx.core.view.ViewCompat

private val DarkColorScheme = darkColorScheme(
primary = Purple80,
Expand All @@ -21,9 +21,9 @@ private val DarkColorScheme = darkColorScheme(
)

private val LightColorScheme = lightColorScheme(
primary = Purple40,
secondary = PurpleGrey40,
tertiary = Pink40
primary = Green,
secondary = Green2,
tertiary = Green3,
)

@Composable
Expand All @@ -40,6 +40,13 @@ fun IntroTheme(
darkTheme -> DarkColorScheme
else -> LightColorScheme
}
val view = LocalView.current
if (!view.isInEditMode) {
SideEffect {
(view.context as Activity).window.statusBarColor = colorScheme.primary.toArgb()
ViewCompat.getWindowInsetsController(view)?.isAppearanceLightStatusBars = darkTheme
}
}

MaterialTheme(
colorScheme = colorScheme,
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/es/fpsumma/dam2/intro/ui/theme/Type.kt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.ivancorrales.basicjetpackcompose.ui.theme
package es.fpsumma.dam2.intro.ui.theme

import androidx.compose.material3.Typography
import androidx.compose.ui.text.TextStyle
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

</androidx.constraintlayout.widget.ConstraintLayout>
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[versions]
agp = "8.12.3"
agp = "8.13.0"
kotlin = "2.0.21"
coreKtx = "1.17.0"
junit = "4.13.2"
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Wed Oct 15 11:01:44 CEST 2025
#Wed Oct 22 11:12:45 CEST 2025
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists