Skip to content

Instantly share code, notes, and snippets.

@walnashgit
Created May 6, 2021
Embed
What would you like to do?
@Composable
fun Favorite(modifier: Modifier = Modifier, viewModel: MainViewModel) {
viewModel.setCurrentScreen(Screens.HomeScreens.Favorite)
val clickCount by viewModel.clickCount.observeAsState()
var click = clickCount?: 0
Column(
modifier = modifier.fillMaxSize(),
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally
) {
Text(text = "Favorite.", style = MaterialTheme.typography.h4)
Button(
onClick = {
click++
viewModel.updateClick(click)
}
) {
Text("clicked: $click")
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment