Skip to content

Commit

Permalink
#3 - Events in Compose
Browse files Browse the repository at this point in the history
  • Loading branch information
jhg3410 committed Jan 29, 2023
1 parent 252c7be commit e3b74de
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
package jik.compose.basicstatecodelab

import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.padding
import androidx.compose.material.Button
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp

@Composable
fun WaterCounter(modifier: Modifier = Modifier) {
val count = 0
Text(
text = "You've had $count glasses",
modifier = modifier.padding(16.dp)
)
Column(modifier = modifier.padding(16.dp)) {
var count = 0
Text(text = "You've had $count glasses")
Button(onClick = { count++ }, modifier = Modifier.padding(top = 8.dp)) {
Text(text = "Add one")
}
}
}

0 comments on commit e3b74de

Please sign in to comment.