Created
February 11, 2025 18:10
-
-
Save vitoksmile/c11e0d462c764324ee7d3f63a9007888 to your computer and use it in GitHub Desktop.
ComposeHints
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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