This is a sample Android application demonstrating how to pass data back when navigating between screens in Jetpack Compose.
The application showcases a pattern for passing data back from a dialog or screen to the previous screen in the navigation stack. This is accomplished using:
- BackArgumentHolder - A wrapper around SavedStateHandle that provides type-safe access to data
- Navigation with Arguments - Using extensions to pass data back to previous screens
- Compose Navigation - Utilizing Jetpack Compose's navigation components
- Main Screen - Shows a list of comments and a button to add new comments
- Comment Screen - Allows users to enter and submit a new comment
- Navigation - Handles the flow between screens and passing data back
This pattern can be useful in various scenarios:
- When you need to return a result from a form screen
- When implementing dialog-like pure screens that need to return data
- For implementing back navigation with state preservation