Skip to content

Commit

Permalink
#3 - State in Compose
Browse files Browse the repository at this point in the history
  • Loading branch information
jhg3410 committed Jan 29, 2023
1 parent 11e62cb commit 252c7be
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,9 @@ class MainActivity : ComponentActivity() {
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colors.background
) {
Greeting("Android")
WellnessScreen()
}
}
}
}
}

@Composable
fun Greeting(name: String) {
Text(text = "Hello $name!")
}

@Preview(showBackground = true)
@Composable
fun DefaultPreview() {
BasicStateCodelabTheme {
Greeting("Android")
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package jik.compose.basicstatecodelab

import androidx.compose.foundation.layout.padding
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)
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package jik.compose.basicstatecodelab

import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier


@Composable
fun WellnessScreen(modifier: Modifier = Modifier) {
WaterCounter(modifier)
}

0 comments on commit 252c7be

Please sign in to comment.