Skip to content

Commit

Permalink
🔧 The class hosting the ExternalNavController was changed from KaigiN…
Browse files Browse the repository at this point in the history
…avHost to KaigiApp.

And I moved the process of opening the settings app to ExternalNavController.
  • Loading branch information
Corvus400 committed Sep 1, 2024
1 parent d6911cb commit 9806779
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ import platform.Foundation.NSDate
import platform.Foundation.NSURL
import platform.Foundation.dateWithTimeIntervalSince1970
import platform.UIKit.UIApplication
import platform.UIKit.UIApplicationOpenSettingsURLString
import platform.UIKit.UIViewController
import platform.darwin.NSObject

Expand Down Expand Up @@ -145,6 +146,7 @@ fun KaigiApp(
snackbarHostState: SnackbarHostState,
onLicenseScreenRequest: () -> Unit,
modifier: Modifier = Modifier,
externalNavController: ExternalNavController = rememberExternalNavController(),
) {
val eventFlow = rememberEventFlow<IosComposeKaigiAppEvent>()
val uiState = iosComposeKaigiAppPresenter(events = eventFlow)
Expand All @@ -157,7 +159,7 @@ fun KaigiApp(
LaunchedEffect(uiState.shouldGoToSettingsApp) {
if (uiState.shouldGoToSettingsApp) {
eventFlow.tryEmit(IosComposeKaigiAppEvent.SettingsAppNavigated)
openSettingsApp()
externalNavController.navigateToSettingsApp()
}
}

Expand All @@ -173,6 +175,7 @@ fun KaigiApp(

KaigiNavHost(
windowSize = windowSize,
externalNavController = externalNavController,
onLicenseScreenRequest = onLicenseScreenRequest,
onAccessCalendarIsDenied = {
eventFlow.tryEmit(
Expand All @@ -190,10 +193,10 @@ fun KaigiApp(
@Composable
private fun KaigiNavHost(
windowSize: WindowSizeClass,
externalNavController: ExternalNavController,
onLicenseScreenRequest: () -> Unit,
onAccessCalendarIsDenied: () -> Unit,
navController: NavHostController = rememberNavController(),
externalNavController: ExternalNavController = rememberExternalNavController(),
) {
NavHostWithSharedAxisX(navController = navController, startDestination = mainScreenRoute) {
mainScreen(
Expand Down Expand Up @@ -370,7 +373,7 @@ private fun rememberExternalNavController(): ExternalNavController {
}
}

private class ExternalNavController(
class ExternalNavController(
private val shareNavigator: ShareNavigator,
private val coroutineScope: CoroutineScope,
) {
Expand Down Expand Up @@ -443,6 +446,13 @@ private class ExternalNavController(
}
}

fun navigateToSettingsApp() {
val settingsUrl = NSURL.URLWithString(UIApplicationOpenSettingsURLString)
if (settingsUrl != null) {
UIApplication.sharedApplication.openURL(settingsUrl)
}
}

fun onShareClick(timetableItem: TimetableItem) {
shareNavigator.share(
"[${timetableItem.room.name.currentLangTitle}] ${timetableItem.startsTimeString} - ${timetableItem.endsTimeString}\n" +
Expand Down

This file was deleted.

0 comments on commit 9806779

Please sign in to comment.