File tree Expand file tree Collapse file tree 3 files changed +17
-5
lines changed
compose-multiplatform-common/src
commonMain/kotlin/com/huanshankeji/compose/layout
jsMain/kotlin/com/huanshankeji/compose/layout
jvmMain/kotlin/com/huanshankeji/compose/layout Expand file tree Collapse file tree 3 files changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -6,5 +6,7 @@ import com.huanshankeji.compose.ui.ModifierOrAttrs
66
77expect abstract class BoxElement : Element
88
9+ expect interface BoxScope
10+
911@Composable
10- expect fun Box (modifierOrAttrs : ModifierOrAttrs <BoxElement > = null, content : @Composable () -> Unit )
12+ expect fun Box (modifierOrAttrs : ModifierOrAttrs <BoxElement > = null, content : @Composable BoxScope . () -> Unit )
Original file line number Diff line number Diff line change @@ -4,10 +4,18 @@ import androidx.compose.runtime.Composable
44import com.huanshankeji.compose.ui.ModifierOrAttrs
55import com.huanshankeji.compose.ui.toAttrs
66import org.jetbrains.compose.web.dom.Div
7+ import org.jetbrains.compose.web.dom.ElementScope
78import org.w3c.dom.HTMLDivElement
89
910actual typealias BoxElement = HTMLDivElement
1011
12+ // actual typealias BoxScope = ElementScope<HTMLDivElement>
13+ actual interface BoxScope {
14+ val htmlDivElementScope: ElementScope <HTMLDivElement >
15+
16+ class Impl (override val htmlDivElementScope : ElementScope <HTMLDivElement >) : BoxScope
17+ }
18+
1119@Composable
12- actual fun Box (modifierOrAttrs : ModifierOrAttrs <BoxElement >, content : @Composable () -> Unit ) =
13- Div (modifierOrAttrs.toAttrs()) { content() }
20+ actual fun Box (modifierOrAttrs : ModifierOrAttrs <BoxElement >, content : @Composable BoxScope . () -> Unit ) =
21+ Div (modifierOrAttrs.toAttrs()) { BoxScope . Impl ( this ). content() }
Original file line number Diff line number Diff line change @@ -7,6 +7,8 @@ import com.huanshankeji.compose.ui.toModifier
77
88actual abstract class BoxElement : Element ()
99
10+ actual typealias BoxScope = androidx.compose.foundation.layout.BoxScope
11+
1012@Composable
11- actual fun Box (modifierOrAttrs : ModifierOrAttrs <BoxElement >, content : @Composable () -> Unit ) =
12- androidx.compose.foundation.layout.Box (modifierOrAttrs.toModifier()) { content() }
13+ actual fun Box (modifierOrAttrs : ModifierOrAttrs <BoxElement >, content : @Composable BoxScope . () -> Unit ) =
14+ androidx.compose.foundation.layout.Box (modifierOrAttrs.toModifier(), content = content)
You can’t perform that action at this time.
0 commit comments