Skip to content

Commit 3115f44

Browse files
committed
Bridge parent CompositionLocals into Tao window scenes
Capture the outer currentCompositionLocalContext in TaoDecoratedWindowAdapter and re-provide it inside the fresh ComposeScene Tao opens per window so themes (Jewel/Material), density, layout direction and user-provided locals flow across the scene boundary — matching Dialog/Popup behavior and removing the need to wrap content with IntUiTheme twice when using NucleusBackend.Tao. Rename SingleInstance.kt to match its single top-level declaration.
1 parent 876aa26 commit 3115f44

2 files changed

Lines changed: 13 additions & 17 deletions

File tree

nucleus-application/src/main/kotlin/dev/nucleusframework/application/SingleInstance.kt renamed to nucleus-application/src/main/kotlin/dev/nucleusframework/application/SingleInstanceRestoreBus.kt

File renamed without changes.

nucleus-application/src/main/kotlin/dev/nucleusframework/application/internal/TaoDecoratedWindowAdapter.kt

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package dev.nucleusframework.application.internal
22

33
import androidx.compose.runtime.Composable
44
import androidx.compose.runtime.CompositionLocalProvider
5+
import androidx.compose.runtime.currentCompositionLocalContext
56
import androidx.compose.runtime.derivedStateOf
67
import androidx.compose.runtime.remember
78
import androidx.compose.ui.graphics.painter.Painter
@@ -17,9 +18,6 @@ import dev.nucleusframework.application.ObserveSingleInstanceRestore
1718
import dev.nucleusframework.application.TaoNucleusApplicationScope
1819
import dev.nucleusframework.application.TaoNucleusWindow
1920
import dev.nucleusframework.window.DecoratedWindowState
20-
import dev.nucleusframework.window.LocalIsDarkTheme
21-
import dev.nucleusframework.window.styling.LocalDecoratedWindowStyle
22-
import dev.nucleusframework.window.styling.LocalTitleBarStyle
2321
import dev.nucleusframework.window.tao.TaoDecoratedWindowScope
2422
import dev.nucleusframework.window.tao.DecoratedWindow as TaoDecoratedWindow
2523

@@ -47,12 +45,11 @@ internal object TaoDecoratedWindowAdapter {
4745
content: @Composable NucleusDecoratedWindowScope.() -> Unit,
4846
) {
4947
// Tao opens a fresh ComposeScene per window; CompositionLocals from
50-
// the outer scope don't propagate across scenes. Capture the styling
51-
// locals here so wrapping `NucleusDecoratedWindowTheme` outside the
52-
// DecoratedWindow works the same on both backends.
53-
val outerIsDark = LocalIsDarkTheme.current
54-
val outerWindowStyle = LocalDecoratedWindowStyle.current
55-
val outerTitleBarStyle = LocalTitleBarStyle.current
48+
// the outer scope don't propagate across scenes. Capture the full
49+
// local context so every local (theme, density, layout direction,
50+
// user-provided locals, …) flows into the new scene — matching how
51+
// Compose's own Dialog/Popup bridge across scene boundaries.
52+
val outerLocals = currentCompositionLocalContext
5653

5754
with(scope.taoScope) {
5855
TaoDecoratedWindow(
@@ -83,14 +80,13 @@ internal object TaoDecoratedWindowAdapter {
8380
TaoNucleusDecoratedWindowScope(taoScope, nucleusWindow)
8481
}
8582
ObserveSingleInstanceRestore(nucleusWindow)
86-
CompositionLocalProvider(
87-
LocalNucleusBackend provides NucleusBackend.Tao,
88-
LocalNucleusWindow provides nucleusWindow,
89-
LocalIsDarkTheme provides outerIsDark,
90-
LocalDecoratedWindowStyle provides outerWindowStyle,
91-
LocalTitleBarStyle provides outerTitleBarStyle,
92-
) {
93-
nucleusScope.content()
83+
CompositionLocalProvider(outerLocals) {
84+
CompositionLocalProvider(
85+
LocalNucleusBackend provides NucleusBackend.Tao,
86+
LocalNucleusWindow provides nucleusWindow,
87+
) {
88+
nucleusScope.content()
89+
}
9490
}
9591
}
9692
}

0 commit comments

Comments
 (0)