Skip to content

Commit

Permalink
chore: update ios link launch
Browse files Browse the repository at this point in the history
  • Loading branch information
aanorbel committed Sep 11, 2024
1 parent 697b30b commit 7c1dc71
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
14 changes: 12 additions & 2 deletions composeApp/src/iosMain/kotlin/org/ooni/probe/MainViewController.kt
Original file line number Diff line number Diff line change
@@ -1,22 +1,32 @@
package org.ooni.probe

import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.ui.window.ComposeUIViewController
import kotlinx.coroutines.flow.SharedFlow
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.launch
import org.ooni.probe.data.models.DeepLink
import org.ooni.probe.di.Dependencies
import platform.UIKit.UIViewController

fun mainViewController(
dependencies: Dependencies,
deepLinkFlow: SharedFlow<DeepLink>,
deepLinkFlow: MutableSharedFlow<DeepLink?>,
): UIViewController {
return ComposeUIViewController {
val deepLink by deepLinkFlow.collectAsState(null)
App(
dependencies = dependencies,
deepLink = deepLink,
)
LaunchedEffect(deepLink) {
deepLink?.let {
// Reset the deepLinkFlow after processing the deep link
launch {
deepLinkFlow.emit(null)
}
}
}
}
}
8 changes: 4 additions & 4 deletions iosApp/iosApp/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import composeApp

struct ComposeView: UIViewControllerRepresentable {
let dependencies: Dependencies
let deepLinkFlow: Kotlinx_coroutines_coreSharedFlow
let deepLinkFlow: Kotlinx_coroutines_coreMutableSharedFlow

init(dependencies: Dependencies, deepLinkFlow: Kotlinx_coroutines_coreSharedFlow) {
init(dependencies: Dependencies, deepLinkFlow: Kotlinx_coroutines_coreMutableSharedFlow) {
self.dependencies = dependencies
self.deepLinkFlow = deepLinkFlow
}
Expand All @@ -20,9 +20,9 @@ struct ComposeView: UIViewControllerRepresentable {

struct ContentView: View {
let dependencies: Dependencies
let deepLinkFlow: Kotlinx_coroutines_coreSharedFlow
let deepLinkFlow: Kotlinx_coroutines_coreMutableSharedFlow

init(dependencies: Dependencies, deepLinkFlow: Kotlinx_coroutines_coreSharedFlow) {
init(dependencies: Dependencies, deepLinkFlow: Kotlinx_coroutines_coreMutableSharedFlow) {
self.dependencies = dependencies
self.deepLinkFlow = deepLinkFlow
}
Expand Down

0 comments on commit 7c1dc71

Please sign in to comment.