Vaibhav Jaiswal
06/27/2024, 1:18 PMdiscardSavedState
param
Code in ThreadVaibhav Jaiswal
06/27/2024, 1:19 PMobject MedialApp {
private val deeplink = MutableStateFlow<String?>(null)
/**
* Call from iOS
*/
fun setUpDeeplink(deeplink: String?) {
this.deeplink.update { deeplink }
}
@OptIn(ExperimentalDecomposeApi::class, ExperimentalComposeApi::class)
fun viewController(): UIViewController {
return ComposeUIViewController(
configure = {
onFocusBehavior = OnFocusBehavior.DoNothing
opaque = false
},
) {
val permissionController = remember { PermissionsController() }
val deeplink by this.deeplink.collectAsState()
val backDispatcher = BackDispatcher()
val rootComponent = RootComponentImpl(
componentContext = DefaultComponentContext(
lifecycle = ApplicationLifecycle(),
backHandler = backDispatcher
),
deeplink = deeplink,
permissionController = permissionController
)
PredictiveBackGestureOverlay(
backDispatcher = backDispatcher, // Use the same BackDispatcher as above
backIcon = { progress, _ ->
PredictiveBackGestureIcon(
imageVector = Icons.Default.ArrowBack,
progress = progress,
)
},
modifier = Modifier.fillMaxSize(),
) {
MedialApp(
component = rootComponent,
modifier = Modifier.fillMaxSize()
)
}
}
}
}
Arkadii Ivanov
06/27/2024, 1:21 PMVaibhav Jaiswal
06/27/2024, 1:26 PMArkadii Ivanov
06/27/2024, 1:27 PMVaibhav Jaiswal
06/27/2024, 1:27 PMArkadii Ivanov
06/27/2024, 1:35 PMVaibhav Jaiswal
06/27/2024, 1:38 PMArkadii Ivanov
06/27/2024, 1:39 PMVaibhav Jaiswal
06/27/2024, 1:40 PMVaibhav Jaiswal
06/29/2024, 10:48 AMArkadii Ivanov
06/29/2024, 10:58 AMDefaultComponentContext
on the Swift side. I would also create the RootComponent
on the Swift side, as there might be iOS specific dependencies.