From add79ab738c5bd2c18a01dc903e77e1fa5caf9a0 Mon Sep 17 00:00:00 2001 From: xxfast Date: Tue, 21 Mar 2023 15:27:09 +1100 Subject: [PATCH] Add sample compositional local to demonstrate the issue --- .../io/github/xxfast/nytimes/ios/compose/Application.kt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/ios-compose/src/iosMain/kotlin/io/github/xxfast/nytimes/ios/compose/Application.kt b/app/ios-compose/src/iosMain/kotlin/io/github/xxfast/nytimes/ios/compose/Application.kt index e831d31..f5ca160 100644 --- a/app/ios-compose/src/iosMain/kotlin/io/github/xxfast/nytimes/ios/compose/Application.kt +++ b/app/ios-compose/src/iosMain/kotlin/io/github/xxfast/nytimes/ios/compose/Application.kt @@ -2,6 +2,8 @@ package io.github.xxfast.nytimes.ios.compose import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.CompositionLocalProvider +import androidx.compose.runtime.ProvidableCompositionLocal +import androidx.compose.runtime.staticCompositionLocalOf import androidx.compose.ui.window.ComposeUIViewController import com.arkivanov.decompose.DefaultComponentContext import com.arkivanov.essenty.lifecycle.LifecycleRegistry @@ -11,12 +13,17 @@ import io.github.xxfast.nytimes.screens.home.HomeScreen import platform.Foundation.NSHomeDirectory import platform.UIKit.UIViewController +val LocalUnit: ProvidableCompositionLocal = staticCompositionLocalOf { } + fun Main(): UIViewController = ComposeUIViewController { val lifecycle = LifecycleRegistry() val rootComponentContext = DefaultComponentContext(lifecycle = lifecycle) appStorage = NSHomeDirectory() - CompositionLocalProvider(LocalComponentContext provides rootComponentContext) { + CompositionLocalProvider( + LocalComponentContext provides rootComponentContext, + LocalUnit provides Unit + ) { MaterialTheme { HomeScreen() }