Skip to content
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 some navigation sample #33

Open
hmshohrab opened this issue Dec 26, 2024 · 0 comments
Open

Add some navigation sample #33

hmshohrab opened this issue Dec 26, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@hmshohrab
Copy link

hmshohrab commented Dec 26, 2024

Add some navigation samples like below

@Serializable
data object LoginRoute

fun NavController.navigateToLogin(
    navOptions: NavOptionsBuilder.() -> Unit = {}
) {
    navigate(route = LoginRoute) {
        navOptions()
    }
}
@OptIn(KoinExperimentalAPI::class)
fun NavGraphBuilder.loginScreen(
    navController: NavController,
    showBackButton: Boolean,
    onRenameBookClick: (BookItem) -> Unit,
    onDeleteBookClick: (BookItem) -> Unit,
    onBackClick: () -> Unit
) {
    composable<LoginRoute> {
        val viewModel = koinViewModel<AuthVM>()

        TopCenterContainer {
            ScaffoldWithSnackbar {
                LoginScreenIndex(
                    authVM = viewModel,
                    navigateToMain = {
                        navController.navigateToMain {
                            popUpTo(LoginRoute) {
                                inclusive = true
                            }
                        }
                    })
            }

        }
    }
}
@hmshohrab hmshohrab added the enhancement New feature or request label Dec 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants