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

🔧 [Compose Multiplatform] Fixed navigation to work properly on both iOS and Android. #1010

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ private fun KaigiNavHost(
displayFeatures: PersistentList<DisplayFeature>,
modifier: Modifier = Modifier,
navController: NavHostController = rememberNavController(),
mainNestedNavController: NavHostController = rememberNavController(),
externalNavController: ExternalNavController = rememberExternalNavController(),
) {
SharedTransitionLayout(modifier = modifier) {
Expand All @@ -144,9 +145,10 @@ private fun KaigiNavHost(
startDestination = mainScreenRoute,
) {
mainScreen(
windowSize,
navController,
externalNavController,
windowSize = windowSize,
navController = navController,
mainNestedNavController = mainNestedNavController,
externalNavController = externalNavController,
)
sessionScreens(
onNavigationIconClick = navController::popBackStack,
Expand Down Expand Up @@ -197,12 +199,14 @@ private fun KaigiNavHost(
private fun NavGraphBuilder.mainScreen(
windowSize: WindowSizeClass,
navController: NavHostController,
mainNestedNavController: NavHostController,
@Suppress("UnusedParameter")
externalNavController: ExternalNavController,
) {
mainScreen(
windowSize = windowSize,
mainNestedGraphStateHolder = KaigiAppMainNestedGraphStateHolder(),
mainNestedNavController = mainNestedNavController,
mainNestedGraph = { mainNestedNavController, contentPadding ->
nestedSessionScreens(
modifier = Modifier,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,11 +197,13 @@ private fun KaigiNavHost(
onLicenseScreenRequest: () -> Unit,
onAccessCalendarIsDenied: () -> Unit,
navController: NavHostController = rememberNavController(),
mainNestedNavController: NavHostController = rememberNavController(),
) {
NavHostWithSharedAxisX(navController = navController, startDestination = mainScreenRoute) {
mainScreen(
windowSize = windowSize,
navController = navController,
mainNestedNavController = mainNestedNavController,
externalNavController = externalNavController,
onLicenseScreenRequest = onLicenseScreenRequest,
)
Expand Down Expand Up @@ -257,12 +259,14 @@ private fun KaigiNavHost(
private fun NavGraphBuilder.mainScreen(
windowSize: WindowSizeClass,
navController: NavHostController,
mainNestedNavController: NavHostController,
externalNavController: ExternalNavController,
onLicenseScreenRequest: () -> Unit,
) {
mainScreen(
windowSize = windowSize,
mainNestedGraphStateHolder = KaigiAppMainNestedGraphStateHolder(),
mainNestedNavController = mainNestedNavController,
mainNestedGraph = { mainNestedNavController, contentPadding ->
nestedSessionScreens(
modifier = Modifier,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp
import androidx.navigation.NavController
import androidx.navigation.NavGraphBuilder
import androidx.navigation.NavHostController
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.currentBackStackEntryAsState
import androidx.navigation.compose.rememberNavController
import conference_app_2024.core.designsystem.generated.resources.ic_fav_off
import conference_app_2024.core.designsystem.generated.resources.ic_fav_on
import conference_app_2024.core.designsystem.generated.resources.ic_info_off
Expand Down Expand Up @@ -73,6 +73,7 @@ const val mainScreenRoute = "main"
fun NavGraphBuilder.mainScreen(
windowSize: WindowSizeClass,
mainNestedGraphStateHolder: MainNestedGraphStateHolder,
mainNestedNavController: NavHostController,
mainNestedGraph: NavGraphBuilder.(mainNestedNavController: NavController, PaddingValues) -> Unit,
) {
composable(mainScreenRoute) {
Expand All @@ -82,6 +83,7 @@ fun NavGraphBuilder.mainScreen(
MainScreen(
windowSize = windowSize,
mainNestedGraphStateHolder = mainNestedGraphStateHolder,
mainNestedNavController = mainNestedNavController,
mainNestedNavGraph = mainNestedGraph,
)
}
Expand All @@ -108,6 +110,7 @@ enum class NavigationType {
fun MainScreen(
windowSize: WindowSizeClass,
mainNestedGraphStateHolder: MainNestedGraphStateHolder,
mainNestedNavController: NavHostController,
mainNestedNavGraph: NavGraphBuilder.(NavController, PaddingValues) -> Unit,
eventFlow: EventFlow<MainScreenEvent> = rememberEventFlow(),
uiState: MainScreenUiState = mainScreenPresenter(eventFlow),
Expand Down Expand Up @@ -139,6 +142,7 @@ fun MainScreen(
navigationType = navigationType,
routeToTab = mainNestedGraphStateHolder::routeToTab,
onTabSelected = mainNestedGraphStateHolder::onTabSelected,
mainNestedNavController = mainNestedNavController,
mainNestedNavGraph = mainNestedNavGraph,
)
}
Expand Down Expand Up @@ -201,11 +205,10 @@ fun MainScreen(
navigationType: NavigationType,
routeToTab: String.() -> MainScreenTab?,
onTabSelected: (NavController, MainScreenTab) -> Unit,
mainNestedNavController: NavHostController,
mainNestedNavGraph: NavGraphBuilder.(NavController, PaddingValues) -> Unit,
modifier: Modifier = Modifier,
) {
val mainNestedNavController = rememberNavController()

val navBackStackEntryRoute =
mainNestedNavController.currentBackStackEntryAsState().value?.destination?.route

Expand Down
Loading