-
Notifications
You must be signed in to change notification settings - Fork 180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add in predictive back snippets for NavHost and predictive back handler #394
Conversation
Here is the summary of changes. You are about to add 3 region tags.
This comment is generated by snippet-bot.
|
@googlebot hello |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I wasn't able to review before merging. Added a few comments and suggestions.
// [START android_compose_predictiveback_navhost] | ||
NavHost( | ||
navController = navController, | ||
startDestination = "home", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should use type safe routes. To do this declare:
@Serializable data object Home
@Serializable data object Settings
before the function.
Then to use it do startDestination = Home
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahhh, thanks for the tip of changing them to safe routes, Don!
) | ||
// [END android_compose_predictiveback_navhost] | ||
{ | ||
composable("home") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
composable<Home>
navController = navController, | ||
) | ||
} | ||
composable("settings") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
composable<Settings>
// code for progress | ||
boxScale = 1F - (1F * backEvent.progress) | ||
} | ||
// code for completion |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this have a completion state? From the looks of it, it should be boxScale = 0F
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, it should have a completion state. Added it into the #399 PR.
val navController = rememberNavController() | ||
|
||
// [START android_compose_predictiveback_navhost] | ||
NavHost( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure of the context in which this is being used but I think it's important to mention that NavHost
supports predictive back out of the box. There's nothing extra required, aside from defining the animations you want to use between destinations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we do mention NavHost supports PB out of the box. This snippets shows a custom in-app animations example for PB
* Added two snippets for showcasing how to do Masking and Clipping in Compose (#362) * Code snippet for Compose doc at https://developer.android.com/quick-guides/content/animate-text?hl=en (Animate text character-by-character). This commit slightly modifies (makes buildable in our repo) the existing code on the current DAC page. That code, in turn, was BNR's simplified version of Xoogler astamato's Medium article at https://medium.com/androiddevelopers/effective-state-management-for-textfield-in-compose-d6e5b070fbe5 * Code snippet for Compose doc at https://developer.android.com/quick-guides/content/animate-text?hl=en (Animate text character-by-character). This commit slightly modifies (makes buildable in our repo) the existing code on the current DAC page. That code, in turn, was BNR's simplified version of Xoogler astamato's Medium article at https://medium.com/androiddevelopers/effective-state-management-for-textfield-in-compose-d6e5b070fbe5 * Apply Spotless * Fix email input snippet * Migrate to use BasicSecureTextField. * Updated to use BasicSecureTextField. * Added clipping and faded edge examples * Apply Spotless * Clean up snippet * Clean up snippet --------- Co-authored-by: dmail <[email protected]> Co-authored-by: thedmail <[email protected]> Co-authored-by: riggaroo <[email protected]> * 🤖 Update Dependencies (#366) * Add Material Carousel (#363) * Add Carousel * Apply Spotless * add to components * Apply Spotless * Clean up landing screens, using Scaffold and list items. * Apply Spotless * Review comments --------- Co-authored-by: riggaroo <[email protected]> * Basic menu examples (#371) * basic menu examples * Make DropdownMenuWithDetails toggle expanded on click * Apply Spotless * Remove unneeded dependencies * Remove unneeded imports --------- Co-authored-by: jakeroseman <[email protected]> * Filter chip dropdown menu (#375) * Filter chip dropdown menu * Apply Spotless * Add example of date picker textfield opening picker dialog on click (#376) * Add example of date picker textfield opening picker dialog on click * Apply Spotless * Add auto advance pager snippets (#377) * Add auto advance pager snippets * Apply Spotless --------- Co-authored-by: jakeroseman <[email protected]> * Tooltip component examples (#373) * Tooltip component examples * Apply Spotless * Addressing PR comments * use LaunchedEffect to fix tooltip bug * Apply Spotless * Updated content descriptions --------- Co-authored-by: jakeroseman <[email protected]> * Add pull to refresh snippets (#378) * Add pull to refresh snippets * Apply Spotless * Remove LaunchedEffect workaround (#379) * Remove LaunchedEffect workaround for library bug * Apply Spotless * Changed single var to val --------- Co-authored-by: jakeroseman <[email protected]> * Navigation drawer examples (#380) * Basic navigation drawer examples * Add previews * Fix merge issue * Apply Spotless * rearrange functions * Narrowing the examples to just the example with nested items * Apply Spotless * refactoring as dismissable drawer * Fixing imports * refactor, new region tags * Renaming functions * Apply Spotless * Add horizontal padding to the drawer content * Apply Spotless * Make drawer content scrollable to make it work on small screens / landscape --------- Co-authored-by: jakeroseman <[email protected]> Co-authored-by: Jolanda Verhoef <[email protected]> * Snippets for keyboard input (#368) * Add a sample code for Keyboard Shortcuts Helper * Add a sample code for keyboard actions * Fix the issue on casting a Context object into Activity * Snippet for animated sorted list with add/remove buttons. (#381) * Snippet for animated sorted list with add/remove buttons. * Apply Spotless * Simplify adding an item to displayedItems * Use ViewModel to correctly extract business logic from UI --------- Co-authored-by: jakeroseman <[email protected]> Co-authored-by: Jolanda Verhoef <[email protected]> * Add basic segmented button examples (#383) * Add basic segmented button examples * Apply Spotless * Add region tags --------- Co-authored-by: jakeroseman <[email protected]> * Adding views snippets module with Generated Preview samples (#384) * Adding views snippets module with Generated Preview samples * fixup --------- Co-authored-by: Summers Pittman <[email protected]> * Adding top bar multi selection examples (#387) * Adding top bar multi selection examples * Apply Spotless * Remember some vals --------- Co-authored-by: jakeroseman <[email protected]> * Include AppScaffold in navigation Snippet (#385) * Animate image size on scroll (#390) * Add animate image size on scroll example * Add simple comments and rename some variables * Apply Spotless * Add region tags --------- Co-authored-by: jakeroseman <[email protected]> * Add basic HTML text styling example (#389) * Add basic HTML text styling example * Apply Spotless * Add region tags --------- Co-authored-by: jakeroseman <[email protected]> * 🤖 Update Dependencies (#391) * 🤖 Update Dependencies * Update compileSdk to 35 --------- Co-authored-by: Jolanda Verhoef <[email protected]> * add in predictive back snippets for NavHost and predictive back handler (#394) * add in predictive back snippets * Apply Spotless * add in basic predictivebackhandler composable example * Apply Spotless --------- Co-authored-by: trambui09 <[email protected]> * Add region tags to auto advance pager examples (#398) * Init Wear Tiles snippets (#400) * Init Wear Tiles snippets * Add snippet markers * Add manifest snippet markers * Rename manifest snippet markers * Create misc module, add broadcast receiver snippets (#397) * Create misc module, add broadcast receiver snippets * Apply Spotless * Add live search with FilterTextView example (#402) * Add live search with FilterTextView example * Apply Spotless --------- Co-authored-by: jakeroseman <[email protected]> * Add single option radio button example (#401) * Add single option radio button example * Apply Spotless * Apply Spotless --------- Co-authored-by: jakeroseman <[email protected]> * update to use type safe routes (#399) * Migrated relevant MotionCompose snippets into snippets (#411) * Migrated relevant MotionCompose snippets into snippets * Apply Spotless --------- Co-authored-by: riggaroo <[email protected]> --------- Co-authored-by: Rebecca Franks <[email protected]> Co-authored-by: dmail <[email protected]> Co-authored-by: thedmail <[email protected]> Co-authored-by: riggaroo <[email protected]> Co-authored-by: Jake Roseman <[email protected]> Co-authored-by: jakeroseman <[email protected]> Co-authored-by: Jolanda Verhoef <[email protected]> Co-authored-by: N. Shimizu <[email protected]> Co-authored-by: Hoyt Summers Pittman <[email protected]> Co-authored-by: Summers Pittman <[email protected]> Co-authored-by: Chiara Chiappini <[email protected]> Co-authored-by: Tram Bui <[email protected]> Co-authored-by: trambui09 <[email protected]> Co-authored-by: Michael Stillwell <[email protected]>
* Added two snippets for showcasing how to do Masking and Clipping in Compose (#362) * Code snippet for Compose doc at https://developer.android.com/quick-guides/content/animate-text?hl=en (Animate text character-by-character). This commit slightly modifies (makes buildable in our repo) the existing code on the current DAC page. That code, in turn, was BNR's simplified version of Xoogler astamato's Medium article at https://medium.com/androiddevelopers/effective-state-management-for-textfield-in-compose-d6e5b070fbe5 * Code snippet for Compose doc at https://developer.android.com/quick-guides/content/animate-text?hl=en (Animate text character-by-character). This commit slightly modifies (makes buildable in our repo) the existing code on the current DAC page. That code, in turn, was BNR's simplified version of Xoogler astamato's Medium article at https://medium.com/androiddevelopers/effective-state-management-for-textfield-in-compose-d6e5b070fbe5 * Apply Spotless * Fix email input snippet * Migrate to use BasicSecureTextField. * Updated to use BasicSecureTextField. * Added clipping and faded edge examples * Apply Spotless * Clean up snippet * Clean up snippet --------- Co-authored-by: dmail <[email protected]> Co-authored-by: thedmail <[email protected]> Co-authored-by: riggaroo <[email protected]> * 🤖 Update Dependencies (#366) * Add Material Carousel (#363) * Add Carousel * Apply Spotless * add to components * Apply Spotless * Clean up landing screens, using Scaffold and list items. * Apply Spotless * Review comments --------- Co-authored-by: riggaroo <[email protected]> * Basic menu examples (#371) * basic menu examples * Make DropdownMenuWithDetails toggle expanded on click * Apply Spotless * Remove unneeded dependencies * Remove unneeded imports --------- Co-authored-by: jakeroseman <[email protected]> * Filter chip dropdown menu (#375) * Filter chip dropdown menu * Apply Spotless * Add example of date picker textfield opening picker dialog on click (#376) * Add example of date picker textfield opening picker dialog on click * Apply Spotless * Add auto advance pager snippets (#377) * Add auto advance pager snippets * Apply Spotless --------- Co-authored-by: jakeroseman <[email protected]> * Tooltip component examples (#373) * Tooltip component examples * Apply Spotless * Addressing PR comments * use LaunchedEffect to fix tooltip bug * Apply Spotless * Updated content descriptions --------- Co-authored-by: jakeroseman <[email protected]> * Add pull to refresh snippets (#378) * Add pull to refresh snippets * Apply Spotless * Remove LaunchedEffect workaround (#379) * Remove LaunchedEffect workaround for library bug * Apply Spotless * Changed single var to val --------- Co-authored-by: jakeroseman <[email protected]> * Navigation drawer examples (#380) * Basic navigation drawer examples * Add previews * Fix merge issue * Apply Spotless * rearrange functions * Narrowing the examples to just the example with nested items * Apply Spotless * refactoring as dismissable drawer * Fixing imports * refactor, new region tags * Renaming functions * Apply Spotless * Add horizontal padding to the drawer content * Apply Spotless * Make drawer content scrollable to make it work on small screens / landscape --------- Co-authored-by: jakeroseman <[email protected]> Co-authored-by: Jolanda Verhoef <[email protected]> * Snippets for keyboard input (#368) * Add a sample code for Keyboard Shortcuts Helper * Add a sample code for keyboard actions * Fix the issue on casting a Context object into Activity * Snippet for animated sorted list with add/remove buttons. (#381) * Snippet for animated sorted list with add/remove buttons. * Apply Spotless * Simplify adding an item to displayedItems * Use ViewModel to correctly extract business logic from UI --------- Co-authored-by: jakeroseman <[email protected]> Co-authored-by: Jolanda Verhoef <[email protected]> * Add basic segmented button examples (#383) * Add basic segmented button examples * Apply Spotless * Add region tags --------- Co-authored-by: jakeroseman <[email protected]> * Adding views snippets module with Generated Preview samples (#384) * Adding views snippets module with Generated Preview samples * fixup --------- Co-authored-by: Summers Pittman <[email protected]> * Adding top bar multi selection examples (#387) * Adding top bar multi selection examples * Apply Spotless * Remember some vals --------- Co-authored-by: jakeroseman <[email protected]> * Include AppScaffold in navigation Snippet (#385) * Animate image size on scroll (#390) * Add animate image size on scroll example * Add simple comments and rename some variables * Apply Spotless * Add region tags --------- Co-authored-by: jakeroseman <[email protected]> * Add basic HTML text styling example (#389) * Add basic HTML text styling example * Apply Spotless * Add region tags --------- Co-authored-by: jakeroseman <[email protected]> * 🤖 Update Dependencies (#391) * 🤖 Update Dependencies * Update compileSdk to 35 --------- Co-authored-by: Jolanda Verhoef <[email protected]> * add in predictive back snippets for NavHost and predictive back handler (#394) * add in predictive back snippets * Apply Spotless * add in basic predictivebackhandler composable example * Apply Spotless --------- Co-authored-by: trambui09 <[email protected]> * Add region tags to auto advance pager examples (#398) * Init Wear Tiles snippets (#400) * Init Wear Tiles snippets * Add snippet markers * Add manifest snippet markers * Rename manifest snippet markers * Create misc module, add broadcast receiver snippets (#397) * Create misc module, add broadcast receiver snippets * Apply Spotless * Add live search with FilterTextView example (#402) * Add live search with FilterTextView example * Apply Spotless --------- Co-authored-by: jakeroseman <[email protected]> * Add single option radio button example (#401) * Add single option radio button example * Apply Spotless * Apply Spotless --------- Co-authored-by: jakeroseman <[email protected]> * update to use type safe routes (#399) * Migrated relevant MotionCompose snippets into snippets (#411) * Migrated relevant MotionCompose snippets into snippets * Apply Spotless --------- Co-authored-by: riggaroo <[email protected]> * Moving location permissions snippets to repo (#413) * Moving location permissions snippets to repo * Apply Spotless * rationalize class names * Fixing region tags --------- Co-authored-by: jakeroseman <[email protected]> --------- Co-authored-by: Rebecca Franks <[email protected]> Co-authored-by: dmail <[email protected]> Co-authored-by: thedmail <[email protected]> Co-authored-by: riggaroo <[email protected]> Co-authored-by: Jake Roseman <[email protected]> Co-authored-by: jakeroseman <[email protected]> Co-authored-by: Jolanda Verhoef <[email protected]> Co-authored-by: N. Shimizu <[email protected]> Co-authored-by: Hoyt Summers Pittman <[email protected]> Co-authored-by: Summers Pittman <[email protected]> Co-authored-by: Chiara Chiappini <[email protected]> Co-authored-by: Tram Bui <[email protected]> Co-authored-by: trambui09 <[email protected]> Co-authored-by: Michael Stillwell <[email protected]>
* Added two snippets for showcasing how to do Masking and Clipping in Compose (#362) * Code snippet for Compose doc at https://developer.android.com/quick-guides/content/animate-text?hl=en (Animate text character-by-character). This commit slightly modifies (makes buildable in our repo) the existing code on the current DAC page. That code, in turn, was BNR's simplified version of Xoogler astamato's Medium article at https://medium.com/androiddevelopers/effective-state-management-for-textfield-in-compose-d6e5b070fbe5 * Code snippet for Compose doc at https://developer.android.com/quick-guides/content/animate-text?hl=en (Animate text character-by-character). This commit slightly modifies (makes buildable in our repo) the existing code on the current DAC page. That code, in turn, was BNR's simplified version of Xoogler astamato's Medium article at https://medium.com/androiddevelopers/effective-state-management-for-textfield-in-compose-d6e5b070fbe5 * Apply Spotless * Fix email input snippet * Migrate to use BasicSecureTextField. * Updated to use BasicSecureTextField. * Added clipping and faded edge examples * Apply Spotless * Clean up snippet * Clean up snippet --------- Co-authored-by: dmail <[email protected]> Co-authored-by: thedmail <[email protected]> Co-authored-by: riggaroo <[email protected]> * 🤖 Update Dependencies (#366) * Add Material Carousel (#363) * Add Carousel * Apply Spotless * add to components * Apply Spotless * Clean up landing screens, using Scaffold and list items. * Apply Spotless * Review comments --------- Co-authored-by: riggaroo <[email protected]> * Basic menu examples (#371) * basic menu examples * Make DropdownMenuWithDetails toggle expanded on click * Apply Spotless * Remove unneeded dependencies * Remove unneeded imports --------- Co-authored-by: jakeroseman <[email protected]> * Filter chip dropdown menu (#375) * Filter chip dropdown menu * Apply Spotless * Add example of date picker textfield opening picker dialog on click (#376) * Add example of date picker textfield opening picker dialog on click * Apply Spotless * Add auto advance pager snippets (#377) * Add auto advance pager snippets * Apply Spotless --------- Co-authored-by: jakeroseman <[email protected]> * Tooltip component examples (#373) * Tooltip component examples * Apply Spotless * Addressing PR comments * use LaunchedEffect to fix tooltip bug * Apply Spotless * Updated content descriptions --------- Co-authored-by: jakeroseman <[email protected]> * Add pull to refresh snippets (#378) * Add pull to refresh snippets * Apply Spotless * Remove LaunchedEffect workaround (#379) * Remove LaunchedEffect workaround for library bug * Apply Spotless * Changed single var to val --------- Co-authored-by: jakeroseman <[email protected]> * Navigation drawer examples (#380) * Basic navigation drawer examples * Add previews * Fix merge issue * Apply Spotless * rearrange functions * Narrowing the examples to just the example with nested items * Apply Spotless * refactoring as dismissable drawer * Fixing imports * refactor, new region tags * Renaming functions * Apply Spotless * Add horizontal padding to the drawer content * Apply Spotless * Make drawer content scrollable to make it work on small screens / landscape --------- Co-authored-by: jakeroseman <[email protected]> Co-authored-by: Jolanda Verhoef <[email protected]> * Snippets for keyboard input (#368) * Add a sample code for Keyboard Shortcuts Helper * Add a sample code for keyboard actions * Fix the issue on casting a Context object into Activity * Snippet for animated sorted list with add/remove buttons. (#381) * Snippet for animated sorted list with add/remove buttons. * Apply Spotless * Simplify adding an item to displayedItems * Use ViewModel to correctly extract business logic from UI --------- Co-authored-by: jakeroseman <[email protected]> Co-authored-by: Jolanda Verhoef <[email protected]> * Add basic segmented button examples (#383) * Add basic segmented button examples * Apply Spotless * Add region tags --------- Co-authored-by: jakeroseman <[email protected]> * Adding views snippets module with Generated Preview samples (#384) * Adding views snippets module with Generated Preview samples * fixup --------- Co-authored-by: Summers Pittman <[email protected]> * Adding top bar multi selection examples (#387) * Adding top bar multi selection examples * Apply Spotless * Remember some vals --------- Co-authored-by: jakeroseman <[email protected]> * Include AppScaffold in navigation Snippet (#385) * Animate image size on scroll (#390) * Add animate image size on scroll example * Add simple comments and rename some variables * Apply Spotless * Add region tags --------- Co-authored-by: jakeroseman <[email protected]> * Add basic HTML text styling example (#389) * Add basic HTML text styling example * Apply Spotless * Add region tags --------- Co-authored-by: jakeroseman <[email protected]> * 🤖 Update Dependencies (#391) * 🤖 Update Dependencies * Update compileSdk to 35 --------- Co-authored-by: Jolanda Verhoef <[email protected]> * add in predictive back snippets for NavHost and predictive back handler (#394) * add in predictive back snippets * Apply Spotless * add in basic predictivebackhandler composable example * Apply Spotless --------- Co-authored-by: trambui09 <[email protected]> * Add region tags to auto advance pager examples (#398) * Init Wear Tiles snippets (#400) * Init Wear Tiles snippets * Add snippet markers * Add manifest snippet markers * Rename manifest snippet markers * Create misc module, add broadcast receiver snippets (#397) * Create misc module, add broadcast receiver snippets * Apply Spotless * Add live search with FilterTextView example (#402) * Add live search with FilterTextView example * Apply Spotless --------- Co-authored-by: jakeroseman <[email protected]> * Add single option radio button example (#401) * Add single option radio button example * Apply Spotless * Apply Spotless --------- Co-authored-by: jakeroseman <[email protected]> * update to use type safe routes (#399) * Migrated relevant MotionCompose snippets into snippets (#411) * Migrated relevant MotionCompose snippets into snippets * Apply Spotless --------- Co-authored-by: riggaroo <[email protected]> * Moving location permissions snippets to repo (#413) * Moving location permissions snippets to repo * Apply Spotless * rationalize class names * Fixing region tags --------- Co-authored-by: jakeroseman <[email protected]> * Use VerticalDivider in IntrinsicSnippets (#369) Co-authored-by: Rebecca Franks <[email protected]> --------- Co-authored-by: Rebecca Franks <[email protected]> Co-authored-by: dmail <[email protected]> Co-authored-by: thedmail <[email protected]> Co-authored-by: riggaroo <[email protected]> Co-authored-by: Jake Roseman <[email protected]> Co-authored-by: jakeroseman <[email protected]> Co-authored-by: Jolanda Verhoef <[email protected]> Co-authored-by: N. Shimizu <[email protected]> Co-authored-by: Hoyt Summers Pittman <[email protected]> Co-authored-by: Summers Pittman <[email protected]> Co-authored-by: Chiara Chiappini <[email protected]> Co-authored-by: Tram Bui <[email protected]> Co-authored-by: trambui09 <[email protected]> Co-authored-by: Michael Stillwell <[email protected]> Co-authored-by: David Mendoza <[email protected]>
Add in the predictive back snippets for NavHost implementation and the Predictive Back Handler for a navigation drawer