Skip to content
This repository was archived by the owner on Mar 6, 2024. It is now read-only.

Commit a47c467

Browse files
committed
Support surface component on desktop
1 parent 3f67c25 commit a47c467

File tree

36 files changed

+147
-21
lines changed

36 files changed

+147
-21
lines changed

componentbox/src/jvmMain/kotlin/com/dropbox/componentbox/material/Inflate.kt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ package com.dropbox.componentbox.material
33
import androidx.compose.runtime.Composable
44
import com.dropbox.componentbox.foundation.Component
55
import com.dropbox.componentbox.foundation.Context
6+
import com.dropbox.componentbox.material.box.Inflate
7+
import com.dropbox.componentbox.material.button.Inflate
8+
import com.dropbox.componentbox.material.column.Inflate
9+
import com.dropbox.componentbox.material.drawable.Inflate
10+
import com.dropbox.componentbox.material.row.Inflate
11+
import com.dropbox.componentbox.material.text.Inflate
612

713
// This module targets JS
814
// Until material and foundation are supported on JS
@@ -11,4 +17,15 @@ import com.dropbox.componentbox.foundation.Context
1117

1218
@Composable
1319
actual fun Component.Inflate(context: Context?) {
20+
when (this) {
21+
is Component.Box -> Inflate(context)
22+
is Component.Button -> Inflate(context)
23+
is Component.Column -> Inflate(context)
24+
is Component.Drawable -> Inflate(context)
25+
is Component.Row -> Inflate(context)
26+
is Component.Switch -> TODO()
27+
is Component.Text -> Inflate(context)
28+
is Component.Vector -> TODO()
29+
is Component.Surface -> Inflate(context)
30+
}
1431
}

desktop/src/jvmMain/kotlin/com/dropbox/componentbox/store/reducers/component/helpers/componentId.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@ internal fun Component?.componentId() = when (this) {
1111
is Component.Switch -> this.id
1212
is Component.Text -> this.id
1313
is Component.Vector -> this.id
14+
is Component.Surface -> this.id
1415
else -> null
1516
}

desktop/src/jvmMain/kotlin/com/dropbox/componentbox/store/reducers/component/helpers/getComponentChildren.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ internal fun Component.getComponentChildren(): MutableList<Component>? {
99
is Component.Button -> component.components
1010
is Component.Column -> component.components
1111
is Component.Row -> component.components
12+
is Component.Surface -> component.components
1213
else -> null
1314
}
1415
}

desktop/src/jvmMain/kotlin/com/dropbox/componentbox/store/reducers/component/helpers/setComponentChildren.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ internal fun Component?.setComponentChildren(children: MutableList<Component>) {
99
is Component.Button -> components = children
1010
is Component.Column -> components = children
1111
is Component.Row -> components = children
12+
is Component.Surface -> components = children
1213
else -> {}
1314
}
1415
}

desktop/src/jvmMain/kotlin/com/dropbox/componentbox/store/reducers/component/main/setBackground.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ private fun Component?.setBackground(background: String): Component? {
2626
is Component.Switch -> modifier?.background = background
2727
is Component.Text -> modifier?.background = background
2828
is Component.Vector -> modifier?.background = background
29+
is Component.Surface -> modifier?.background = background
2930
else -> {}
3031
}
3132
}

desktop/src/jvmMain/kotlin/com/dropbox/componentbox/store/reducers/component/main/setFillMaxHeight.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ private fun Component?.setFillMaxHeight(fillMaxHeight: Boolean): Component? {
2626
is Component.Switch -> modifier?.fillMaxHeight = fillMaxHeight
2727
is Component.Text -> modifier?.fillMaxHeight = fillMaxHeight
2828
is Component.Vector -> modifier?.fillMaxHeight = fillMaxHeight
29+
is Component.Surface -> modifier?.fillMaxHeight = fillMaxHeight
2930
else -> {}
3031
}
3132
}

desktop/src/jvmMain/kotlin/com/dropbox/componentbox/store/reducers/component/main/setFillMaxSize.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ private fun Component?.setFillMaxSize(fillMaxSize: Boolean): Component? {
2626
is Component.Switch -> modifier?.fillMaxSize = fillMaxSize
2727
is Component.Text -> modifier?.fillMaxSize = fillMaxSize
2828
is Component.Vector -> modifier?.fillMaxSize = fillMaxSize
29+
is Component.Surface -> modifier?.fillMaxSize = fillMaxSize
2930
else -> {}
3031
}
3132
}

desktop/src/jvmMain/kotlin/com/dropbox/componentbox/store/reducers/component/main/setFillMaxWidth.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ private fun Component?.setFillMaxWidth(fillMaxWidth: Boolean): Component? {
2626
is Component.Switch -> modifier?.fillMaxWidth = fillMaxWidth
2727
is Component.Text -> modifier?.fillMaxWidth = fillMaxWidth
2828
is Component.Vector -> modifier?.fillMaxWidth = fillMaxWidth
29+
is Component.Surface -> modifier?.fillMaxWidth = fillMaxWidth
2930
else -> {}
3031
}
3132
}

desktop/src/jvmMain/kotlin/com/dropbox/componentbox/store/reducers/component/main/setHeight.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ private fun Component?.setHeight(height: Int): Component? {
2626
is Component.Switch -> modifier?.height = height
2727
is Component.Text -> modifier?.height = height
2828
is Component.Vector -> modifier?.height = height
29+
is Component.Surface -> modifier?.height = height
2930
else -> {}
3031
}
3132
}

desktop/src/jvmMain/kotlin/com/dropbox/componentbox/store/reducers/component/main/setMargin.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ private fun Component?.setMargin(margin: Margin): Component? {
3030
is Component.Switch -> modifier?.margin = margin.copy()
3131
is Component.Text -> modifier?.margin = margin.copy()
3232
is Component.Vector -> modifier?.margin = margin.copy()
33+
is Component.Surface -> modifier?.margin = margin.copy()
3334
else -> {}
3435
}
3536
}

0 commit comments

Comments
 (0)