Skip to content

Commit

Permalink
#3 - Restore state in Compose
Browse files Browse the repository at this point in the history
  • Loading branch information
jhg3410 committed Jan 31, 2023
1 parent a791948 commit db52f65
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.material.Button
import androidx.compose.material.Text
import androidx.compose.runtime.*
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp

@Composable
fun WaterCounter(modifier: Modifier = Modifier) {
Column(modifier = modifier.padding(16.dp)) {
var count by remember { mutableStateOf(0) }
var count by rememberSaveable { mutableStateOf(0) }
if (count > 0) {
Text("You've had $count glasses.")
}
Expand Down

0 comments on commit db52f65

Please sign in to comment.