Skip to content

Instantly share code, notes, and snippets.

@walnashgit
Created May 6, 2021 15:23
Show Gist options
  • Save walnashgit/1f300d4745483cdbd6277b67cdc5b2a8 to your computer and use it in GitHub Desktop.
Save walnashgit/1f300d4745483cdbd6277b67cdc5b2a8 to your computer and use it in GitHub Desktop.
@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