Skip to content

Instantly share code, notes, and snippets.

@vitoksmile
Created February 11, 2025 18:10
Show Gist options
  • Save vitoksmile/c11e0d462c764324ee7d3f63a9007888 to your computer and use it in GitHub Desktop.
Save vitoksmile/c11e0d462c764324ee7d3f63a9007888 to your computer and use it in GitHub Desktop.
ComposeHints
val coroutineScope = rememberCoroutineScope()
val hintController = rememberHintController()
// Now we can dismiss all pending hints from a hint itself
val topAppBarHint = rememberHintContainer {
OutlinedButton(
onClick = {
hintController.dismiss()
}
) { Text("Hint for TopAppBar") }
}
// Show 1 hint
BottomNavigationItem(
onClick = {
coroutineScope.launch {
hintController.show(bottomNavigationHintAnchor)
scaffoldState.snackbarHostState.showSnackbar("One hint was shown")
}
},
)
// Show many hints sequentially
Button(
onClick = {
coroutineScope.launch {
hintController.show(
topAppBarActionHintAnchor,
actionHintAnchor,
bottomNavigationHintAnchor,
)
scaffoldState.snackbarHostState.showSnackbar("Many hints were shown")
}
},
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment