Skip to content

Commit

Permalink
Add sample compositional local to demonstrate the issue
Browse files Browse the repository at this point in the history
  • Loading branch information
xxfast committed Mar 21, 2023
1 parent b165482 commit add79ab
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -11,12 +13,17 @@ import io.github.xxfast.nytimes.screens.home.HomeScreen
import platform.Foundation.NSHomeDirectory
import platform.UIKit.UIViewController

val LocalUnit: ProvidableCompositionLocal<Unit> = 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()
}
Expand Down

0 comments on commit add79ab

Please sign in to comment.