@expo/ui 0.1.1-alpha.7 → 0.1.1-alpha.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/android/build.gradle +3 -2
- package/android/src/main/java/expo/modules/ui/ExpoUIModule.kt +2 -0
- package/android/src/main/java/expo/modules/ui/ShapeView.kt +149 -0
- package/build/jetpack-compose/Shape/index.d.ts +48 -0
- package/build/jetpack-compose/Shape/index.d.ts.map +1 -0
- package/build/jetpack-compose/Shape/index.js +29 -0
- package/build/jetpack-compose/Shape/index.js.map +1 -0
- package/build/jetpack-compose/index.d.ts +1 -0
- package/build/jetpack-compose/index.d.ts.map +1 -1
- package/build/jetpack-compose/index.js +1 -0
- package/build/jetpack-compose/index.js.map +1 -1
- package/build/swift-ui/Button/index.d.ts +5 -4
- package/build/swift-ui/Button/index.d.ts.map +1 -1
- package/build/swift-ui/Button/index.js +10 -5
- package/build/swift-ui/Button/index.js.map +1 -1
- package/build/swift-ui/ContextMenu/utils.d.ts.map +1 -1
- package/build/swift-ui/ContextMenu/utils.js +14 -8
- package/build/swift-ui/ContextMenu/utils.js.map +1 -1
- package/build/swift-ui/Host/index.d.ts +9 -2
- package/build/swift-ui/Host/index.d.ts.map +1 -1
- package/build/swift-ui/Host/index.js +13 -7
- package/build/swift-ui/Host/index.js.map +1 -1
- package/build/swift-ui-primitives/DisclosureGroup.d.ts +7 -0
- package/build/swift-ui-primitives/DisclosureGroup.d.ts.map +1 -0
- package/build/swift-ui-primitives/DisclosureGroup.js +6 -0
- package/build/swift-ui-primitives/DisclosureGroup.js.map +1 -0
- package/build/swift-ui-primitives/Form.d.ts +9 -2
- package/build/swift-ui-primitives/Form.d.ts.map +1 -1
- package/build/swift-ui-primitives/Form.js.map +1 -1
- package/build/swift-ui-primitives/Image.d.ts +23 -0
- package/build/swift-ui-primitives/Image.d.ts.map +1 -0
- package/build/swift-ui-primitives/Image.js +13 -0
- package/build/swift-ui-primitives/Image.js.map +1 -0
- package/build/swift-ui-primitives/Layout.d.ts +27 -13
- package/build/swift-ui-primitives/Layout.d.ts.map +1 -1
- package/build/swift-ui-primitives/Layout.js +13 -2
- package/build/swift-ui-primitives/Layout.js.map +1 -1
- package/build/swift-ui-primitives/Spacer.d.ts +10 -0
- package/build/swift-ui-primitives/Spacer.d.ts.map +1 -0
- package/build/swift-ui-primitives/Spacer.js +6 -0
- package/build/swift-ui-primitives/Spacer.js.map +1 -0
- package/build/swift-ui-primitives/Text.d.ts +7 -2
- package/build/swift-ui-primitives/Text.d.ts.map +1 -1
- package/build/swift-ui-primitives/Text.js.map +1 -1
- package/build/swift-ui-primitives/index.d.ts +3 -0
- package/build/swift-ui-primitives/index.d.ts.map +1 -1
- package/build/swift-ui-primitives/index.js +3 -0
- package/build/swift-ui-primitives/index.js.map +1 -1
- package/build/swift-ui-primitives/types.d.ts +81 -0
- package/build/swift-ui-primitives/types.d.ts.map +1 -0
- package/build/swift-ui-primitives/types.js +2 -0
- package/build/swift-ui-primitives/types.js.map +1 -0
- package/expo-module.config.json +1 -1
- package/ios/BottomSheetView.swift +23 -5
- package/ios/Button/Button.swift +7 -3
- package/ios/Button/ButtonProps.swift +1 -1
- package/ios/DisclosureGroupView.swift +26 -0
- package/ios/ExpoUIModule.swift +4 -0
- package/ios/FormView.swift +7 -2
- package/ios/GroupView.swift +24 -0
- package/ios/HStackView.swift +37 -18
- package/ios/HostView.swift +33 -2
- package/ios/ImageView.swift +27 -0
- package/ios/List.swift +1 -1
- package/ios/Modifiers/CommonViewModifiers.swift +22 -0
- package/ios/Modifiers/View+FixedSizeModifiers.swift +15 -0
- package/ios/Modifiers/View+FrameModifiers.swift +80 -0
- package/ios/Modifiers/View+GestureModifiers.swift +23 -0
- package/ios/Modifiers/View+PaddingModifiers.swift +27 -0
- package/ios/SliderView.swift +1 -1
- package/ios/SpacerView.swift +20 -0
- package/ios/TextView.swift +7 -1
- package/ios/VStackView.swift +31 -18
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/{0.1.1-alpha.7/expo.modules.ui-0.1.1-alpha.7-sources.jar → 0.1.1-alpha.9/expo.modules.ui-0.1.1-alpha.9-sources.jar} +0 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/0.1.1-alpha.9/expo.modules.ui-0.1.1-alpha.9-sources.jar.md5 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/0.1.1-alpha.9/expo.modules.ui-0.1.1-alpha.9-sources.jar.sha1 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/0.1.1-alpha.9/expo.modules.ui-0.1.1-alpha.9-sources.jar.sha256 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/0.1.1-alpha.9/expo.modules.ui-0.1.1-alpha.9-sources.jar.sha512 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/0.1.1-alpha.9/expo.modules.ui-0.1.1-alpha.9.aar +0 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/0.1.1-alpha.9/expo.modules.ui-0.1.1-alpha.9.aar.md5 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/0.1.1-alpha.9/expo.modules.ui-0.1.1-alpha.9.aar.sha1 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/0.1.1-alpha.9/expo.modules.ui-0.1.1-alpha.9.aar.sha256 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/0.1.1-alpha.9/expo.modules.ui-0.1.1-alpha.9.aar.sha512 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/{0.1.1-alpha.7/expo.modules.ui-0.1.1-alpha.7.module → 0.1.1-alpha.9/expo.modules.ui-0.1.1-alpha.9.module} +29 -22
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/0.1.1-alpha.9/expo.modules.ui-0.1.1-alpha.9.module.md5 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/0.1.1-alpha.9/expo.modules.ui-0.1.1-alpha.9.module.sha1 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/0.1.1-alpha.9/expo.modules.ui-0.1.1-alpha.9.module.sha256 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/0.1.1-alpha.9/expo.modules.ui-0.1.1-alpha.9.module.sha512 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/{0.1.1-alpha.7/expo.modules.ui-0.1.1-alpha.7.pom → 0.1.1-alpha.9/expo.modules.ui-0.1.1-alpha.9.pom} +7 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/0.1.1-alpha.9/expo.modules.ui-0.1.1-alpha.9.pom.md5 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/0.1.1-alpha.9/expo.modules.ui-0.1.1-alpha.9.pom.sha1 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/0.1.1-alpha.9/expo.modules.ui-0.1.1-alpha.9.pom.sha256 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/0.1.1-alpha.9/expo.modules.ui-0.1.1-alpha.9.pom.sha512 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/maven-metadata.xml +4 -4
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/maven-metadata.xml.md5 +1 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/maven-metadata.xml.sha1 +1 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/maven-metadata.xml.sha256 +1 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/maven-metadata.xml.sha512 +1 -1
- package/package.json +3 -3
- package/src/jetpack-compose/Shape/index.tsx +71 -0
- package/src/jetpack-compose/index.tsx +1 -0
- package/src/swift-ui/Button/index.tsx +17 -8
- package/src/swift-ui/ContextMenu/utils.ts +20 -9
- package/src/swift-ui/Host/index.tsx +21 -10
- package/src/swift-ui-primitives/DisclosureGroup.tsx +17 -0
- package/src/swift-ui-primitives/Form.tsx +11 -2
- package/src/swift-ui-primitives/Image.tsx +49 -0
- package/src/swift-ui-primitives/Layout.tsx +58 -16
- package/src/swift-ui-primitives/Spacer.tsx +22 -0
- package/src/swift-ui-primitives/Text.tsx +8 -2
- package/src/swift-ui-primitives/index.tsx +3 -0
- package/src/swift-ui-primitives/types.ts +95 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/0.1.1-alpha.7/expo.modules.ui-0.1.1-alpha.7-sources.jar.md5 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/0.1.1-alpha.7/expo.modules.ui-0.1.1-alpha.7-sources.jar.sha1 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/0.1.1-alpha.7/expo.modules.ui-0.1.1-alpha.7-sources.jar.sha256 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/0.1.1-alpha.7/expo.modules.ui-0.1.1-alpha.7-sources.jar.sha512 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/0.1.1-alpha.7/expo.modules.ui-0.1.1-alpha.7.aar +0 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/0.1.1-alpha.7/expo.modules.ui-0.1.1-alpha.7.aar.md5 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/0.1.1-alpha.7/expo.modules.ui-0.1.1-alpha.7.aar.sha1 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/0.1.1-alpha.7/expo.modules.ui-0.1.1-alpha.7.aar.sha256 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/0.1.1-alpha.7/expo.modules.ui-0.1.1-alpha.7.aar.sha512 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/0.1.1-alpha.7/expo.modules.ui-0.1.1-alpha.7.module.md5 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/0.1.1-alpha.7/expo.modules.ui-0.1.1-alpha.7.module.sha1 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/0.1.1-alpha.7/expo.modules.ui-0.1.1-alpha.7.module.sha256 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/0.1.1-alpha.7/expo.modules.ui-0.1.1-alpha.7.module.sha512 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/0.1.1-alpha.7/expo.modules.ui-0.1.1-alpha.7.pom.md5 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/0.1.1-alpha.7/expo.modules.ui-0.1.1-alpha.7.pom.sha1 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/0.1.1-alpha.7/expo.modules.ui-0.1.1-alpha.7.pom.sha256 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/0.1.1-alpha.7/expo.modules.ui-0.1.1-alpha.7.pom.sha512 +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,22 @@
|
|
|
10
10
|
|
|
11
11
|
### 💡 Others
|
|
12
12
|
|
|
13
|
+
## 0.1.1-alpha.9 — 2025-06-08
|
|
14
|
+
|
|
15
|
+
### 🎉 New features
|
|
16
|
+
|
|
17
|
+
- Allowed custom children in SwiftUI Button. ([#37136](https://github.com/expo/expo/pull/37136) by [@kudo](https://github.com/kudo))
|
|
18
|
+
|
|
19
|
+
## 0.1.1-alpha.8 — 2025-06-04
|
|
20
|
+
|
|
21
|
+
### 🎉 New features
|
|
22
|
+
|
|
23
|
+
- [android] Add shape component. ([#36964](https://github.com/expo/expo/pull/36964) by [@aleqsio](https://github.com/aleqsio))
|
|
24
|
+
|
|
25
|
+
### 💡 Others
|
|
26
|
+
|
|
27
|
+
- Improved `@expo/ui/swift-ui-primitives` integrations. ([#36937](https://github.com/expo/expo/pull/36937), [#36938](https://github.com/expo/expo/pull/36938) by [@kudo](https://github.com/kudo))
|
|
28
|
+
|
|
13
29
|
## 0.1.1-alpha.7 — 2025-04-30
|
|
14
30
|
|
|
15
31
|
_This version does not introduce any user-facing changes._
|
package/android/build.gradle
CHANGED
|
@@ -12,13 +12,13 @@ apply plugin: 'expo-module-gradle-plugin'
|
|
|
12
12
|
apply plugin: 'org.jetbrains.kotlin.plugin.compose'
|
|
13
13
|
|
|
14
14
|
group = 'expo.modules.ui'
|
|
15
|
-
version = '0.1.1-alpha.
|
|
15
|
+
version = '0.1.1-alpha.9'
|
|
16
16
|
|
|
17
17
|
android {
|
|
18
18
|
namespace "expo.modules.ui"
|
|
19
19
|
defaultConfig {
|
|
20
20
|
versionCode 1
|
|
21
|
-
versionName "0.1.1-alpha.
|
|
21
|
+
versionName "0.1.1-alpha.9"
|
|
22
22
|
}
|
|
23
23
|
buildFeatures {
|
|
24
24
|
compose true
|
|
@@ -35,4 +35,5 @@ dependencies {
|
|
|
35
35
|
implementation 'androidx.lifecycle:lifecycle-runtime:2.8.7'
|
|
36
36
|
implementation 'androidx.fragment:fragment-ktx:1.8.5'
|
|
37
37
|
implementation 'androidx.compose.material3:material3-android:1.3.1'
|
|
38
|
+
implementation "androidx.graphics:graphics-shapes:1.0.1"
|
|
38
39
|
}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
package expo.modules.ui
|
|
2
|
+
|
|
3
|
+
import android.content.Context
|
|
4
|
+
import expo.modules.kotlin.views.ExpoComposeView
|
|
5
|
+
import androidx.compose.runtime.MutableState
|
|
6
|
+
import androidx.compose.runtime.mutableFloatStateOf
|
|
7
|
+
import androidx.compose.ui.graphics.Color
|
|
8
|
+
import expo.modules.kotlin.AppContext
|
|
9
|
+
import expo.modules.kotlin.views.ComposeProps
|
|
10
|
+
import androidx.compose.foundation.layout.Box
|
|
11
|
+
import androidx.compose.ui.Modifier
|
|
12
|
+
import androidx.compose.ui.draw.drawWithCache
|
|
13
|
+
import androidx.graphics.shapes.RoundedPolygon
|
|
14
|
+
import androidx.graphics.shapes.toPath
|
|
15
|
+
import androidx.compose.ui.graphics.asComposePath
|
|
16
|
+
import androidx.compose.foundation.layout.fillMaxSize
|
|
17
|
+
import androidx.compose.runtime.mutableIntStateOf
|
|
18
|
+
import androidx.compose.runtime.mutableStateOf
|
|
19
|
+
import androidx.compose.ui.geometry.Size
|
|
20
|
+
import androidx.compose.ui.graphics.Path
|
|
21
|
+
import androidx.graphics.shapes.CornerRounding
|
|
22
|
+
import androidx.graphics.shapes.circle
|
|
23
|
+
import androidx.graphics.shapes.pill
|
|
24
|
+
import androidx.graphics.shapes.pillStar
|
|
25
|
+
import androidx.graphics.shapes.rectangle
|
|
26
|
+
import androidx.graphics.shapes.star
|
|
27
|
+
import expo.modules.kotlin.types.Enumerable
|
|
28
|
+
import android.graphics.Color as GraphicsColor
|
|
29
|
+
|
|
30
|
+
enum class ShapeType(val value: String) : Enumerable {
|
|
31
|
+
STAR("star"),
|
|
32
|
+
PILL_STAR("pillStar"),
|
|
33
|
+
PILL("pill"),
|
|
34
|
+
CIRCLE("circle"),
|
|
35
|
+
RECTANGLE("rectangle"),
|
|
36
|
+
POLYGON("polygon")
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
data class ShapeProps(
|
|
40
|
+
val cornerRounding: MutableState<Float> = mutableFloatStateOf(0.0f),
|
|
41
|
+
val smoothing: MutableState<Float> = mutableFloatStateOf(0.0f),
|
|
42
|
+
val verticesCount: MutableState<Int> = mutableIntStateOf(6),
|
|
43
|
+
val innerRadius: MutableState<Float> = mutableFloatStateOf(0.0f),
|
|
44
|
+
val radius: MutableState<Float> = mutableFloatStateOf(0.0f),
|
|
45
|
+
val type: MutableState<ShapeType> = mutableStateOf(ShapeType.CIRCLE),
|
|
46
|
+
val color: MutableState<GraphicsColor?> = mutableStateOf(null),
|
|
47
|
+
) : ComposeProps
|
|
48
|
+
|
|
49
|
+
private fun Size.centerX() = this.width / 2
|
|
50
|
+
private fun Size.centerY() = this.height / 2
|
|
51
|
+
|
|
52
|
+
private fun createStarPath(size: Size, cornerRounding: Float, smoothing: Float, innerRadius: Float, radius: Float, verticesCount: Int): Path {
|
|
53
|
+
val rounding = CornerRounding(size.minDimension * cornerRounding, smoothing = smoothing)
|
|
54
|
+
return RoundedPolygon.star(
|
|
55
|
+
numVerticesPerRadius = verticesCount,
|
|
56
|
+
innerRadius = size.minDimension * 0.5f * innerRadius.coerceAtMost(radius - 0.001f).coerceAtLeast(0.001f),
|
|
57
|
+
radius = size.minDimension * 0.5f * radius.coerceAtLeast(0.002f),
|
|
58
|
+
centerX = size.centerX(),
|
|
59
|
+
centerY = size.centerY(),
|
|
60
|
+
rounding = rounding
|
|
61
|
+
).toPath().asComposePath()
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
private fun createPillStarPath(size: Size, cornerRounding: Float, smoothing: Float, innerRadius: Float, verticesCount: Int): Path {
|
|
65
|
+
val rounding = CornerRounding(size.minDimension * cornerRounding, smoothing = smoothing)
|
|
66
|
+
return RoundedPolygon.pillStar(
|
|
67
|
+
numVerticesPerRadius = verticesCount,
|
|
68
|
+
width = size.width / 2,
|
|
69
|
+
height = size.height / 2,
|
|
70
|
+
innerRadiusRatio = innerRadius.coerceAtMost(1f - 0.001f).coerceAtLeast(0.001f),
|
|
71
|
+
centerX = size.centerX(),
|
|
72
|
+
centerY = size.centerY(),
|
|
73
|
+
rounding = rounding
|
|
74
|
+
).toPath().asComposePath()
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
private fun createPillPath(size: Size, smoothing: Float): Path {
|
|
78
|
+
return RoundedPolygon.pill(
|
|
79
|
+
centerX = size.centerX(),
|
|
80
|
+
centerY = size.centerY(),
|
|
81
|
+
width = size.width,
|
|
82
|
+
height = size.height,
|
|
83
|
+
smoothing = smoothing
|
|
84
|
+
).toPath().asComposePath()
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
private fun createPolygonPath(size: Size, cornerRounding: Float, smoothing: Float, verticesCount: Int): Path {
|
|
88
|
+
val rounding = CornerRounding(size.minDimension * cornerRounding, smoothing = smoothing)
|
|
89
|
+
return RoundedPolygon(
|
|
90
|
+
numVertices = verticesCount.coerceAtLeast(3),
|
|
91
|
+
radius = size.minDimension / 2,
|
|
92
|
+
centerX = size.centerX(),
|
|
93
|
+
centerY = size.centerY(),
|
|
94
|
+
rounding = rounding,
|
|
95
|
+
).toPath().asComposePath()
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
private fun createCirclePath(size: Size, radius: Float, verticesCount: Int): Path {
|
|
99
|
+
return RoundedPolygon.circle(
|
|
100
|
+
centerX = size.centerX(),
|
|
101
|
+
centerY = size.centerY(),
|
|
102
|
+
radius = size.minDimension * 0.5f * radius.coerceAtLeast(0.002f),
|
|
103
|
+
numVertices = verticesCount.coerceAtLeast(3),
|
|
104
|
+
).toPath().asComposePath()
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
private fun createRectanglePath(size: Size, cornerRounding: Float, smoothing: Float): Path {
|
|
108
|
+
val rounding = CornerRounding(size.minDimension * cornerRounding, smoothing = smoothing)
|
|
109
|
+
return RoundedPolygon.rectangle(
|
|
110
|
+
centerX = size.centerX(),
|
|
111
|
+
centerY = size.centerY(),
|
|
112
|
+
rounding = rounding,
|
|
113
|
+
width = size.width,
|
|
114
|
+
height = size.height,
|
|
115
|
+
).toPath().asComposePath()
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
class ShapeView(context: Context, appContext: AppContext) : ExpoComposeView<ShapeProps>(context, appContext) {
|
|
119
|
+
override val props = ShapeProps()
|
|
120
|
+
init {
|
|
121
|
+
setContent {
|
|
122
|
+
val (smoothing) = props.smoothing
|
|
123
|
+
val (cornerRounding) = props.cornerRounding
|
|
124
|
+
val (innerRadius) = props.innerRadius
|
|
125
|
+
val (radius) = props.radius
|
|
126
|
+
val (shapeType) = props.type
|
|
127
|
+
val (verticesCount) = props.verticesCount
|
|
128
|
+
val (color) = props.color
|
|
129
|
+
Box(
|
|
130
|
+
modifier = Modifier
|
|
131
|
+
.drawWithCache {
|
|
132
|
+
val path = when (shapeType) {
|
|
133
|
+
ShapeType.STAR -> createStarPath(size = size, cornerRounding = cornerRounding, smoothing = smoothing, innerRadius = innerRadius, radius = radius, verticesCount = verticesCount)
|
|
134
|
+
ShapeType.PILL_STAR -> createPillStarPath(size = size, cornerRounding = cornerRounding, smoothing = smoothing, innerRadius = innerRadius, verticesCount = verticesCount)
|
|
135
|
+
ShapeType.PILL -> createPillPath(size = size, smoothing = smoothing)
|
|
136
|
+
ShapeType.CIRCLE -> createCirclePath(size = size, radius = radius, verticesCount = verticesCount)
|
|
137
|
+
ShapeType.RECTANGLE -> createRectanglePath(size = size, cornerRounding = cornerRounding, smoothing = smoothing)
|
|
138
|
+
ShapeType.POLYGON -> createPolygonPath(size = size, cornerRounding = cornerRounding, smoothing = smoothing, verticesCount = verticesCount)
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
onDrawBehind {
|
|
142
|
+
drawPath(path, color = color.composeOrNull ?: Color.Transparent)
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
.fillMaxSize()
|
|
146
|
+
)
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { ViewStyle } from 'react-native';
|
|
2
|
+
export type ShapeProps = {
|
|
3
|
+
/**
|
|
4
|
+
* Corner rounding percentage. Multiplied by the shorter dimension of the view to produce pixel values.
|
|
5
|
+
* @default 0.0
|
|
6
|
+
*/
|
|
7
|
+
cornerRounding?: number;
|
|
8
|
+
/**
|
|
9
|
+
* Number between `0.0` and `1.0` that determines how much each line between vertices is "smoothed".
|
|
10
|
+
* @default 0.0
|
|
11
|
+
*/
|
|
12
|
+
smoothing?: number;
|
|
13
|
+
/**
|
|
14
|
+
* Number of vertices. For `'POLYGON'` it must be at least `3.0`. For `'STAR'` and `'PILL_STAR'` it is a number of vertices for each of two radii (A 5-pointed star has 10 vertices.)
|
|
15
|
+
* @default 6.0
|
|
16
|
+
*/
|
|
17
|
+
verticesCount?: number;
|
|
18
|
+
/**
|
|
19
|
+
* Inner radius of star-related shapes (`'STAR'` and `'PILL_STAR'`). Multiplied by the shorter dimension of the view to produce pixel values.
|
|
20
|
+
* @default 1.0
|
|
21
|
+
*/
|
|
22
|
+
innerRadius?: number;
|
|
23
|
+
/**
|
|
24
|
+
* Radius of the circular shape. Multiplied by the shorter dimension of the view to produce pixel values.
|
|
25
|
+
* @default 1.0
|
|
26
|
+
*/
|
|
27
|
+
radius?: number;
|
|
28
|
+
/** Style of the component */
|
|
29
|
+
style?: ViewStyle;
|
|
30
|
+
/** Color of the shape */
|
|
31
|
+
color?: string;
|
|
32
|
+
};
|
|
33
|
+
declare function Star(props: ShapeProps): import("react").JSX.Element;
|
|
34
|
+
declare function PillStar(props: ShapeProps): import("react").JSX.Element;
|
|
35
|
+
declare function Pill(props: Pick<ShapeProps, 'smoothing' | 'style' | 'color'>): import("react").JSX.Element;
|
|
36
|
+
declare function Circle(props: Pick<ShapeProps, 'radius' | 'verticesCount' | 'style' | 'color'>): import("react").JSX.Element;
|
|
37
|
+
declare function Rectangle(props: Pick<ShapeProps, 'smoothing' | 'cornerRounding' | 'style' | 'color'>): import("react").JSX.Element;
|
|
38
|
+
declare function Polygon(props: Pick<ShapeProps, 'smoothing' | 'cornerRounding' | 'verticesCount' | 'style' | 'color'>): import("react").JSX.Element;
|
|
39
|
+
export declare const Shape: {
|
|
40
|
+
Star: typeof Star;
|
|
41
|
+
PillStar: typeof PillStar;
|
|
42
|
+
Pill: typeof Pill;
|
|
43
|
+
Circle: typeof Circle;
|
|
44
|
+
Rectangle: typeof Rectangle;
|
|
45
|
+
Polygon: typeof Polygon;
|
|
46
|
+
};
|
|
47
|
+
export {};
|
|
48
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/jetpack-compose/Shape/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,MAAM,MAAM,UAAU,GAAG;IACvB;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,6BAA6B;IAC7B,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,yBAAyB;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAIF,iBAAS,IAAI,CAAC,KAAK,EAAE,UAAU,+BAE9B;AAED,iBAAS,QAAQ,CAAC,KAAK,EAAE,UAAU,+BAElC;AAED,iBAAS,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,UAAU,EAAE,WAAW,GAAG,OAAO,GAAG,OAAO,CAAC,+BAErE;AAED,iBAAS,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,UAAU,EAAE,QAAQ,GAAG,eAAe,GAAG,OAAO,GAAG,OAAO,CAAC,+BAEtF;AAED,iBAAS,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,UAAU,EAAE,WAAW,GAAG,gBAAgB,GAAG,OAAO,GAAG,OAAO,CAAC,+BAE7F;AAED,iBAAS,OAAO,CACd,KAAK,EAAE,IAAI,CAAC,UAAU,EAAE,WAAW,GAAG,gBAAgB,GAAG,eAAe,GAAG,OAAO,GAAG,OAAO,CAAC,+BAG9F;AAED,eAAO,MAAM,KAAK;;;;;;;CAOjB,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { requireNativeView } from 'expo';
|
|
2
|
+
const ShapeNativeView = requireNativeView('ExpoUI', 'ShapeView');
|
|
3
|
+
function Star(props) {
|
|
4
|
+
return <ShapeNativeView {...props} style={props.style} type="star"/>;
|
|
5
|
+
}
|
|
6
|
+
function PillStar(props) {
|
|
7
|
+
return <ShapeNativeView {...props} style={props.style} type="pillStar"/>;
|
|
8
|
+
}
|
|
9
|
+
function Pill(props) {
|
|
10
|
+
return <ShapeNativeView {...props} style={props.style} type="pill"/>;
|
|
11
|
+
}
|
|
12
|
+
function Circle(props) {
|
|
13
|
+
return <ShapeNativeView {...props} style={props.style} type="circle"/>;
|
|
14
|
+
}
|
|
15
|
+
function Rectangle(props) {
|
|
16
|
+
return <ShapeNativeView {...props} style={props.style} type="rectangle"/>;
|
|
17
|
+
}
|
|
18
|
+
function Polygon(props) {
|
|
19
|
+
return <ShapeNativeView {...props} style={props.style} type="polygon"/>;
|
|
20
|
+
}
|
|
21
|
+
export const Shape = {
|
|
22
|
+
Star,
|
|
23
|
+
PillStar,
|
|
24
|
+
Pill,
|
|
25
|
+
Circle,
|
|
26
|
+
Rectangle,
|
|
27
|
+
Polygon,
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/jetpack-compose/Shape/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AAmCzC,MAAM,eAAe,GAA6B,iBAAiB,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;AAE3F,SAAS,IAAI,CAAC,KAAiB;IAC7B,OAAO,CAAC,eAAe,CAAC,IAAI,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,MAAM,EAAG,CAAC;AACxE,CAAC;AAED,SAAS,QAAQ,CAAC,KAAiB;IACjC,OAAO,CAAC,eAAe,CAAC,IAAI,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,UAAU,EAAG,CAAC;AAC5E,CAAC;AAED,SAAS,IAAI,CAAC,KAAwD;IACpE,OAAO,CAAC,eAAe,CAAC,IAAI,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,MAAM,EAAG,CAAC;AACxE,CAAC;AAED,SAAS,MAAM,CAAC,KAAuE;IACrF,OAAO,CAAC,eAAe,CAAC,IAAI,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAG,CAAC;AAC1E,CAAC;AAED,SAAS,SAAS,CAAC,KAA2E;IAC5F,OAAO,CAAC,eAAe,CAAC,IAAI,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,WAAW,EAAG,CAAC;AAC7E,CAAC;AAED,SAAS,OAAO,CACd,KAA6F;IAE7F,OAAO,CAAC,eAAe,CAAC,IAAI,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,SAAS,EAAG,CAAC;AAC3E,CAAC;AAED,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,IAAI;IACJ,QAAQ;IACR,IAAI;IACJ,MAAM;IACN,SAAS;IACT,OAAO;CACR,CAAC","sourcesContent":["import { requireNativeView } from 'expo';\nimport { ViewStyle } from 'react-native';\n\nexport type ShapeProps = {\n /**\n * Corner rounding percentage. Multiplied by the shorter dimension of the view to produce pixel values.\n * @default 0.0\n */\n cornerRounding?: number;\n /**\n * Number between `0.0` and `1.0` that determines how much each line between vertices is \"smoothed\".\n * @default 0.0\n */\n smoothing?: number;\n /**\n * Number of vertices. For `'POLYGON'` it must be at least `3.0`. For `'STAR'` and `'PILL_STAR'` it is a number of vertices for each of two radii (A 5-pointed star has 10 vertices.)\n * @default 6.0\n */\n verticesCount?: number;\n /**\n * Inner radius of star-related shapes (`'STAR'` and `'PILL_STAR'`). Multiplied by the shorter dimension of the view to produce pixel values.\n * @default 1.0\n */\n innerRadius?: number;\n /**\n * Radius of the circular shape. Multiplied by the shorter dimension of the view to produce pixel values.\n * @default 1.0\n */\n radius?: number;\n /** Style of the component */\n style?: ViewStyle;\n /** Color of the shape */\n color?: string;\n};\n\nconst ShapeNativeView: React.ComponentType<any> = requireNativeView('ExpoUI', 'ShapeView');\n\nfunction Star(props: ShapeProps) {\n return <ShapeNativeView {...props} style={props.style} type=\"star\" />;\n}\n\nfunction PillStar(props: ShapeProps) {\n return <ShapeNativeView {...props} style={props.style} type=\"pillStar\" />;\n}\n\nfunction Pill(props: Pick<ShapeProps, 'smoothing' | 'style' | 'color'>) {\n return <ShapeNativeView {...props} style={props.style} type=\"pill\" />;\n}\n\nfunction Circle(props: Pick<ShapeProps, 'radius' | 'verticesCount' | 'style' | 'color'>) {\n return <ShapeNativeView {...props} style={props.style} type=\"circle\" />;\n}\n\nfunction Rectangle(props: Pick<ShapeProps, 'smoothing' | 'cornerRounding' | 'style' | 'color'>) {\n return <ShapeNativeView {...props} style={props.style} type=\"rectangle\" />;\n}\n\nfunction Polygon(\n props: Pick<ShapeProps, 'smoothing' | 'cornerRounding' | 'verticesCount' | 'style' | 'color'>\n) {\n return <ShapeNativeView {...props} style={props.style} type=\"polygon\" />;\n}\n\nexport const Shape = {\n Star,\n PillStar,\n Pill,\n Circle,\n Rectangle,\n Polygon,\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/jetpack-compose/index.tsx"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/jetpack-compose/index.tsx"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/jetpack-compose/index.tsx"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC","sourcesContent":["export * from './Button';\nexport * from './ContextMenu';\nexport * from './DatePicker';\nexport * from './Picker';\nexport * from './Progress';\nexport * from './Slider';\nexport * from './Switch';\nexport * from './TextInput';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/jetpack-compose/index.tsx"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC","sourcesContent":["export * from './Button';\nexport * from './ContextMenu';\nexport * from './DatePicker';\nexport * from './Picker';\nexport * from './Progress';\nexport * from './Slider';\nexport * from './Switch';\nexport * from './TextInput';\nexport * from './Shape';\n"]}
|
|
@@ -30,6 +30,7 @@ export type ButtonProps = {
|
|
|
30
30
|
onPress?: () => void;
|
|
31
31
|
/**
|
|
32
32
|
* A string describing the system image to display in the button.
|
|
33
|
+
* This is only used if `children` is a string.
|
|
33
34
|
* Uses Material Icons on Android and SF Symbols on iOS.
|
|
34
35
|
*/
|
|
35
36
|
systemImage?: string;
|
|
@@ -43,9 +44,9 @@ export type ButtonProps = {
|
|
|
43
44
|
*/
|
|
44
45
|
variant?: ButtonVariant;
|
|
45
46
|
/**
|
|
46
|
-
* The text to display inside the button.
|
|
47
|
+
* The text or React node to display inside the button.
|
|
47
48
|
*/
|
|
48
|
-
children: string;
|
|
49
|
+
children: string | React.ReactNode;
|
|
49
50
|
/**
|
|
50
51
|
* Button color.
|
|
51
52
|
*/
|
|
@@ -60,13 +61,13 @@ export type ButtonProps = {
|
|
|
60
61
|
*/
|
|
61
62
|
export type NativeButtonProps = Omit<ButtonProps, 'role' | 'onPress' | 'children' | 'systemImage'> & {
|
|
62
63
|
buttonRole?: ButtonRole;
|
|
63
|
-
text: string;
|
|
64
|
+
text: string | undefined;
|
|
64
65
|
systemImage?: string;
|
|
65
66
|
} & ViewEvent<'onButtonPressed', void>;
|
|
66
67
|
/**
|
|
67
68
|
* @hidden
|
|
68
69
|
*/
|
|
69
|
-
export declare function transformButtonProps(props: ButtonProps): NativeButtonProps;
|
|
70
|
+
export declare function transformButtonProps(props: Omit<ButtonProps, 'children'>, text: string | undefined): NativeButtonProps;
|
|
70
71
|
/**
|
|
71
72
|
* `<Button>` component without a host view.
|
|
72
73
|
* You should use this with a `Host` component in ancestor.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/swift-ui/Button/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEpD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGxC;;;;;GAKG;AACH,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,QAAQ,GAAG,aAAa,CAAC;AAE9D;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,aAAa,GAErB,SAAS,GACT,UAAU,GACV,OAAO,GAEP,mBAAmB,GACnB,YAAY,GAEZ,cAAc,GACd,oBAAoB,GACpB,MAAM,GACN,MAAM,CAAC;AAEX,MAAM,MAAM,WAAW,GAAG;IACxB;;OA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CAClC,KAAK,EAAE,IAAI,CAAC,WAAW,EAAE,UAAU,CAAC,EACpC,IAAI,EAAE,MAAM,GAAG,SAAS,GACvB,iBAAiB,CASnB;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,WAAW,+BAOjD;AAED;;GAEG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,WAAW,GAAG;IAAE,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAA;CAAE,+BAO3E"}
|
|
@@ -5,13 +5,13 @@ const ButtonNativeView = requireNativeView('ExpoUI', 'Button');
|
|
|
5
5
|
/**
|
|
6
6
|
* @hidden
|
|
7
7
|
*/
|
|
8
|
-
export function transformButtonProps(props) {
|
|
9
|
-
const { role,
|
|
8
|
+
export function transformButtonProps(props, text) {
|
|
9
|
+
const { role, onPress, systemImage, ...restProps } = props;
|
|
10
10
|
return {
|
|
11
11
|
...restProps,
|
|
12
|
-
text
|
|
13
|
-
buttonRole: role,
|
|
12
|
+
text,
|
|
14
13
|
systemImage,
|
|
14
|
+
buttonRole: role,
|
|
15
15
|
onButtonPressed: onPress,
|
|
16
16
|
};
|
|
17
17
|
}
|
|
@@ -20,7 +20,12 @@ export function transformButtonProps(props) {
|
|
|
20
20
|
* You should use this with a `Host` component in ancestor.
|
|
21
21
|
*/
|
|
22
22
|
export function ButtonPrimitive(props) {
|
|
23
|
-
|
|
23
|
+
const { children, ...restProps } = props;
|
|
24
|
+
const text = typeof children === 'string' ? children : undefined;
|
|
25
|
+
if (text !== undefined) {
|
|
26
|
+
return <ButtonNativeView {...transformButtonProps(restProps, text)}/>;
|
|
27
|
+
}
|
|
28
|
+
return <ButtonNativeView {...transformButtonProps(restProps, text)}>{children}</ButtonNativeView>;
|
|
24
29
|
}
|
|
25
30
|
/**
|
|
26
31
|
* Displays a native button component.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/swift-ui/Button/index.tsx"],"names":[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E,MAAM,0BAA0B,GAAG,KAAK,CAAC,KAAK,IAAI,IAAI,CAAC;IACvD,OAAO,CACL,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,aAAa,CAAC,0BAA0B,CAAC,CAAC,0BAA0B,CAAC,CAC7F;MAAA,CAAC,eAAe,CAAC,IAAI,KAAK,CAAC,EAC7B;IAAA,EAAE,IAAI,CAAC,CACR,CAAC;AACJ,CAAC","sourcesContent":["import { requireNativeView } from 'expo';\nimport { StyleProp, ViewStyle } from 'react-native';\n\nimport { ViewEvent } from '../../types';\nimport { Host } from '../Host';\n\n/**\n * The role of the button.\n * - `default` - The default button role.\n * - `cancel` - A button that cancels the current operation.\n * - `destructive` - A button that deletes data or performs a destructive action.\n */\nexport type ButtonRole = 'default' | 'cancel' | 'destructive';\n\n/**\n * The built-in button styles available on iOS.\n *\n * Common styles:\n * - `default` - The default system button style.\n * - `bordered` - A button with a light fill. On Android, equivalent to `FilledTonalButton`.\n * - `borderless` - A button with no background or border. On Android, equivalent to `TextButton`.\n * - `borderedProminent` - A bordered button with a prominent appearance.\n * - `plain` - A button with no border or background and a less prominent text.\n * macOS-only styles:\n * - `accessoryBar` - A button style for accessory bars.\n * - `accessoryBarAction` - A button style for accessory bar actions.\n * - `card` - A button style for cards.\n * - `link` - A button style for links.\n */\nexport type ButtonVariant =\n // Common\n | 'default'\n | 'bordered'\n | 'plain'\n // Apple-only\n | 'borderedProminent'\n | 'borderless'\n // MacOS-only;\n | 'accessoryBar'\n | 'accessoryBarAction'\n | 'card'\n | 'link';\n\nexport type ButtonProps = {\n /**\n * A callback that is called when the button is pressed.\n */\n onPress?: () => void;\n /**\n * A string describing the system image to display in the button.\n * This is only used if `children` is a string.\n * Uses Material Icons on Android and SF Symbols on iOS.\n */\n systemImage?: string;\n /**\n * Indicated the role of the button.\n * @platform ios\n */\n role?: ButtonRole;\n /**\n * The button variant.\n */\n variant?: ButtonVariant;\n /**\n * The text or React node to display inside the button.\n */\n children: string | React.ReactNode;\n /**\n * Button color.\n */\n color?: string;\n /**\n * Disabled state of the button.\n */\n disabled?: boolean;\n};\n\n/**\n * @hidden\n */\nexport type NativeButtonProps = Omit<\n ButtonProps,\n 'role' | 'onPress' | 'children' | 'systemImage'\n> & {\n buttonRole?: ButtonRole;\n text: string | undefined;\n systemImage?: string;\n} & ViewEvent<'onButtonPressed', void>;\n\n// We have to work around the `role` and `onPress` props being reserved by React Native.\nconst ButtonNativeView: React.ComponentType<NativeButtonProps> = requireNativeView(\n 'ExpoUI',\n 'Button'\n);\n\n/**\n * @hidden\n */\nexport function transformButtonProps(\n props: Omit<ButtonProps, 'children'>,\n text: string | undefined\n): NativeButtonProps {\n const { role, onPress, systemImage, ...restProps } = props;\n return {\n ...restProps,\n text,\n systemImage,\n buttonRole: role,\n onButtonPressed: onPress,\n };\n}\n\n/**\n * `<Button>` component without a host view.\n * You should use this with a `Host` component in ancestor.\n */\nexport function ButtonPrimitive(props: ButtonProps) {\n const { children, ...restProps } = props;\n const text = typeof children === 'string' ? children : undefined;\n if (text !== undefined) {\n return <ButtonNativeView {...transformButtonProps(restProps, text)} />;\n }\n return <ButtonNativeView {...transformButtonProps(restProps, text)}>{children}</ButtonNativeView>;\n}\n\n/**\n * Displays a native button component.\n */\nexport function Button(props: ButtonProps & { style?: StyleProp<ViewStyle> }) {\n const useViewportSizeMeasurement = props.style == null;\n return (\n <Host style={props.style} matchContents useViewportSizeMeasurement={useViewportSizeMeasurement}>\n <ButtonPrimitive {...props} />\n </Host>\n );\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/swift-ui/ContextMenu/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0C,SAAS,EAAE,MAAM,OAAO,CAAC;AAG1E,OAAO,EAAE,sBAAsB,EAAE,aAAa,EAAyB,MAAM,SAAS,CAAC;AACvF,OAAO,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/swift-ui/ContextMenu/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0C,SAAS,EAAE,MAAM,OAAO,CAAC;AAG1E,OAAO,EAAE,sBAAsB,EAAE,aAAa,EAAyB,MAAM,SAAS,CAAC;AACvF,OAAO,EAIL,iBAAiB,EAElB,MAAM,WAAW,CAAC;AACnB,OAAO,EAA2B,WAAW,EAAE,MAAM,WAAW,CAAC;AACjE,OAAO,EAA2B,WAAW,EAAE,MAAM,WAAW,CAAC;AAGjE,KAAK,iBAAiB,GAAG;IACvB,MAAM,EAAE,iBAAiB,CAAC;CAC3B,GAAG,sBAAsB,CAAC;AAE3B,KAAK,iBAAiB,GAAG;IACvB,MAAM,EAAE,WAAW,CAAC;CACrB,GAAG,sBAAsB,CAAC;AAE3B,KAAK,iBAAiB,GAAG;IACvB,MAAM,EAAE,WAAW,CAAC;CACrB,GAAG,sBAAsB,CAAC;AAE3B,KAAK,cAAc,GAAG;IACpB,OAAO,EAAE;QACP,QAAQ,EAAE,WAAW,EAAE,CAAC;QACxB,MAAM,EAAE,iBAAiB,CAAC;KAC3B,CAAC;CACH,GAAG,sBAAsB,CAAC;AAE3B,MAAM,MAAM,WAAW,GACnB,iBAAiB,GACjB,iBAAiB,GACjB,iBAAiB,GACjB,cAAc,CAAC;AAInB,wBAAgB,+BAA+B,CAC7C,QAAQ,EAAE,SAAS,EACnB,gBAAgB,EAAE,aAAa,GAC9B,WAAW,EAAE,CAIf"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Children, isValidElement } from 'react';
|
|
2
2
|
import { Submenu } from './index';
|
|
3
|
-
import { Button, transformButtonProps } from '../Button';
|
|
4
|
-
import { Picker } from '../Picker';
|
|
5
|
-
import { Switch } from '../Switch';
|
|
3
|
+
import { Button, ButtonPrimitive, transformButtonProps, } from '../Button';
|
|
4
|
+
import { Picker, PickerPrimitive } from '../Picker';
|
|
5
|
+
import { Switch, SwitchPrimitive } from '../Switch';
|
|
6
6
|
// Maps the react children to NativeMenuElement[] which is used to render out the native menu
|
|
7
7
|
// TODO: Ideally we want to pass the children directly to the native side without having to do this
|
|
8
8
|
export function transformChildrenToElementArray(children, eventHandlersMap) {
|
|
@@ -14,15 +14,15 @@ function processChildElement(child, eventHandlersMap) {
|
|
|
14
14
|
if (!isValidElement(child))
|
|
15
15
|
return null;
|
|
16
16
|
const uuid = expo.uuidv4();
|
|
17
|
-
if (child.type === Button) {
|
|
17
|
+
if (child.type === Button || child.type === ButtonPrimitive) {
|
|
18
18
|
// @ts-expect-error TODO TS2345: Argument of type unknown is not assignable to parameter of type SubmenuProps
|
|
19
19
|
return createButtonElement(uuid, child.props, eventHandlersMap);
|
|
20
20
|
}
|
|
21
|
-
if (child.type === Switch) {
|
|
21
|
+
if (child.type === Switch || child.type === SwitchPrimitive) {
|
|
22
22
|
// @ts-expect-error TODO TS2345: Argument of type unknown is not assignable to parameter of type SubmenuProps
|
|
23
23
|
return createSwitchElement(uuid, child.props, eventHandlersMap);
|
|
24
24
|
}
|
|
25
|
-
if (child.type === Picker) {
|
|
25
|
+
if (child.type === Picker || child.type === PickerPrimitive) {
|
|
26
26
|
// @ts-expect-error TODO TS2345: Argument of type unknown is not assignable to parameter of type SubmenuProps
|
|
27
27
|
return createPickerElement(uuid, child.props, eventHandlersMap);
|
|
28
28
|
}
|
|
@@ -37,9 +37,12 @@ function createButtonElement(uuid, props, handlers) {
|
|
|
37
37
|
if (props.onPress) {
|
|
38
38
|
handlers[uuid] = { onPress: props.onPress };
|
|
39
39
|
}
|
|
40
|
+
if (typeof props.children !== 'string') {
|
|
41
|
+
throw new Error('ContextMenu Button only supports string children');
|
|
42
|
+
}
|
|
40
43
|
return {
|
|
41
44
|
contextMenuElementID: uuid,
|
|
42
|
-
button: transformButtonProps(props),
|
|
45
|
+
button: transformButtonProps(props, props.children),
|
|
43
46
|
};
|
|
44
47
|
}
|
|
45
48
|
function createSwitchElement(uuid, props, handlers) {
|
|
@@ -65,10 +68,13 @@ function createPickerElement(uuid, props, handlers) {
|
|
|
65
68
|
};
|
|
66
69
|
}
|
|
67
70
|
function createSubmenuElement(uuid, props, handlers) {
|
|
71
|
+
if (typeof props.button.props.children !== 'string') {
|
|
72
|
+
throw new Error('ContextMenu Submenu Button only supports string children');
|
|
73
|
+
}
|
|
68
74
|
return {
|
|
69
75
|
contextMenuElementID: uuid,
|
|
70
76
|
submenu: {
|
|
71
|
-
button: transformButtonProps(props.button.props),
|
|
77
|
+
button: transformButtonProps(props.button.props, props.button.props.children),
|
|
72
78
|
elements: transformChildrenToElementArray(props.children, handlers),
|
|
73
79
|
},
|
|
74
80
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/swift-ui/ContextMenu/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,cAAc,EAA2B,MAAM,OAAO,CAAC;AAG1E,OAAO,EAAyC,OAAO,EAAgB,MAAM,SAAS,CAAC;AACvF,OAAO,
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/swift-ui/ContextMenu/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,cAAc,EAA2B,MAAM,OAAO,CAAC;AAG1E,OAAO,EAAyC,OAAO,EAAgB,MAAM,SAAS,CAAC;AACvF,OAAO,EACL,MAAM,EACN,eAAe,EAGf,oBAAoB,GACrB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,MAAM,EAAE,eAAe,EAAe,MAAM,WAAW,CAAC;AACjE,OAAO,EAAE,MAAM,EAAE,eAAe,EAAe,MAAM,WAAW,CAAC;AA4BjE,6FAA6F;AAC7F,mGAAmG;AACnG,MAAM,UAAU,+BAA+B,CAC7C,QAAmB,EACnB,gBAA+B;IAE/B,OAAO,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC;SAC9B,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAA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EAAE,CAAC;QACpD,MAAM,IAAI,KAAK,CAAC,0DAA0D,CAAC,CAAC;IAC9E,CAAC;IACD,OAAO;QACL,oBAAoB,EAAE,IAAI;QAC1B,OAAO,EAAE;YACP,MAAM,EAAE,oBAAoB,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC;YAC7E,QAAQ,EAAE,+BAA+B,CAAC,KAAK,CAAC,QAAQ,EAAE,QAAQ,CAAC;SACpE;KACF,CAAC;AACJ,CAAC;AAED,SAAS,kBAAkB,CAAC,KAAmB;IAC7C,OAAO,KAAK,CAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,OAAO,CAAC,QAAQ,EAAE,CAAC;AACtD,CAAC","sourcesContent":["import { Children, isValidElement, ReactElement, ReactNode } from 'react';\nimport { NativeSyntheticEvent } from 'react-native';\n\nimport { ContextMenuElementBase, EventHandlers, Submenu, SubmenuProps } from './index';\nimport {\n Button,\n ButtonPrimitive,\n ButtonProps,\n NativeButtonProps,\n transformButtonProps,\n} from '../Button';\nimport { Picker, PickerPrimitive, PickerProps } from '../Picker';\nimport { Switch, SwitchPrimitive, SwitchProps } from '../Switch';\n\n// We use this slightly odd typing for the elements to make unpacking the elements easier on the native side\ntype ButtonMenuElement = {\n button: NativeButtonProps;\n} & ContextMenuElementBase;\n\ntype SwitchMenuElement = {\n switch: SwitchProps;\n} & ContextMenuElementBase;\n\ntype PickerMenuElement = {\n picker: PickerProps;\n} & ContextMenuElementBase;\n\ntype SubmenuElement = {\n submenu: {\n elements: MenuElement[];\n button: NativeButtonProps;\n };\n} & ContextMenuElementBase;\n\nexport type MenuElement =\n | ButtonMenuElement\n | SwitchMenuElement\n | PickerMenuElement\n | SubmenuElement;\n\n// Maps the react children to NativeMenuElement[] which is used to render out the native menu\n// TODO: Ideally we want to pass the children directly to the native side without having to do this\nexport function transformChildrenToElementArray(\n children: ReactNode,\n eventHandlersMap: EventHandlers\n): MenuElement[] {\n return Children.toArray(children)\n .map((child) => processChildElement(child, eventHandlersMap))\n .filter((el): el is MenuElement => el !== null);\n}\n\nfunction processChildElement(\n child: ReactNode,\n eventHandlersMap: EventHandlers\n): MenuElement | null {\n if (!isValidElement(child)) return null;\n\n const uuid = expo.uuidv4();\n\n if (child.type === Button || child.type === ButtonPrimitive) {\n // @ts-expect-error TODO TS2345: Argument of type unknown is not assignable to parameter of type SubmenuProps\n return createButtonElement(uuid, child.props, eventHandlersMap);\n }\n\n if (child.type === Switch || child.type === SwitchPrimitive) {\n // @ts-expect-error TODO TS2345: Argument of type unknown is not assignable to parameter of type SubmenuProps\n return createSwitchElement(uuid, child.props, eventHandlersMap);\n }\n\n if (child.type === Picker || child.type === PickerPrimitive) {\n // @ts-expect-error TODO TS2345: Argument of type unknown is not assignable to parameter of type SubmenuProps\n return createPickerElement(uuid, child.props, eventHandlersMap);\n }\n\n if (isSubmenuComponent(child)) {\n // @ts-expect-error TODO TS2345: Argument of type unknown is not assignable to parameter of type SubmenuProps\n return createSubmenuElement(uuid, child.props, eventHandlersMap);\n }\n\n console.warn('Unsupported child type in Menu: ', child.type);\n return null;\n}\n\nfunction createButtonElement(\n uuid: string,\n props: ButtonProps,\n handlers: EventHandlers\n): MenuElement {\n if (props.onPress) {\n handlers[uuid] = { onPress: props.onPress };\n }\n if (typeof props.children !== 'string') {\n throw new Error('ContextMenu Button only supports string children');\n }\n return {\n contextMenuElementID: uuid,\n button: transformButtonProps(props, props.children),\n };\n}\n\nfunction createSwitchElement(\n uuid: string,\n props: SwitchProps,\n handlers: EventHandlers\n): MenuElement {\n if (props.onValueChange) {\n handlers[uuid] = {\n onValueChange: ({ nativeEvent: { value } }: NativeSyntheticEvent<{ value: boolean }>) => {\n props.onValueChange?.(value);\n },\n };\n }\n\n return {\n contextMenuElementID: uuid,\n switch: props,\n };\n}\n\nfunction createPickerElement(\n uuid: string,\n props: PickerProps,\n handlers: EventHandlers\n): MenuElement {\n if (props.onOptionSelected) {\n handlers[uuid] = { onOptionSelected: props.onOptionSelected };\n }\n\n return {\n contextMenuElementID: uuid,\n picker: props,\n };\n}\n\nfunction createSubmenuElement(\n uuid: string,\n props: SubmenuProps,\n handlers: EventHandlers\n): MenuElement {\n if (typeof props.button.props.children !== 'string') {\n throw new Error('ContextMenu Submenu Button only supports string children');\n }\n return {\n contextMenuElementID: uuid,\n submenu: {\n button: transformButtonProps(props.button.props, props.button.props.children),\n elements: transformChildrenToElementArray(props.children, handlers),\n },\n };\n}\n\nfunction isSubmenuComponent(child: ReactElement): boolean {\n return child.type.toString() === Submenu.toString();\n}\n"]}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import { StyleProp, ViewStyle } from 'react-native';
|
|
1
|
+
import { StyleProp, ViewStyle, type ColorSchemeName } from 'react-native';
|
|
2
2
|
export type HostProps = {
|
|
3
3
|
/**
|
|
4
4
|
* When true, the host view will update its size in the React Native view tree to match the content's layout from SwiftUI.
|
|
5
5
|
* @default false
|
|
6
6
|
*/
|
|
7
|
-
matchContents?: boolean
|
|
7
|
+
matchContents?: boolean | {
|
|
8
|
+
vertical?: boolean;
|
|
9
|
+
horizontal?: boolean;
|
|
10
|
+
};
|
|
8
11
|
/**
|
|
9
12
|
* When true and no explicit size is provided, the host will use the viewport size as the proposed size for SwiftUI layout.
|
|
10
13
|
* This is particularly useful for SwiftUI views that need to fill their available space, such as `Form`.
|
|
@@ -21,6 +24,10 @@ export type HostProps = {
|
|
|
21
24
|
height: number;
|
|
22
25
|
};
|
|
23
26
|
}) => void;
|
|
27
|
+
/**
|
|
28
|
+
* The color scheme of the host view.
|
|
29
|
+
*/
|
|
30
|
+
colorScheme?: ColorSchemeName;
|
|
24
31
|
children: React.ReactNode;
|
|
25
32
|
style?: StyleProp<ViewStyle>;
|
|
26
33
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/swift-ui/Host/index.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/swift-ui/Host/index.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC;AAE1E,MAAM,MAAM,SAAS,GAAG;IACtB;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,GAAG;QAAE,QAAQ,CAAC,EAAE,OAAO,CAAC;QAAC,UAAU,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;IAEvE;;;;OAIG;IACH,0BAA0B,CAAC,EAAE,OAAO,CAAC;IAErC;;;OAGG;IACH,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE;QAAE,WAAW,EAAE;YAAE,KAAK,EAAE,MAAM,CAAC;YAAC,MAAM,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,KAAK,IAAI,CAAC;IAEtF;;OAEG;IACH,WAAW,CAAC,EAAE,eAAe,CAAC;IAE9B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;CAC9B,CAAC;AAIF;;GAEG;AACH,wBAAgB,IAAI,CAAC,KAAK,EAAE,SAAS,+BA0BpC"}
|
|
@@ -5,16 +5,22 @@ const HostNativeView = requireNativeView('ExpoUI', 'HostView');
|
|
|
5
5
|
* A hosting component for SwiftUI views.
|
|
6
6
|
*/
|
|
7
7
|
export function Host(props) {
|
|
8
|
-
const { matchContents,
|
|
8
|
+
const { matchContents, onLayoutContent, style, ...restProps } = props;
|
|
9
9
|
const [containerStyle, setContainerStyle] = useState(null);
|
|
10
|
-
return (<HostNativeView onLayoutContent={(e) => {
|
|
10
|
+
return (<HostNativeView style={[style, containerStyle]} onLayoutContent={(e) => {
|
|
11
11
|
onLayoutContent?.(e);
|
|
12
12
|
if (matchContents) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
const matchVertical = typeof matchContents === 'object' ? matchContents.vertical : matchContents;
|
|
14
|
+
const matchHorizontal = typeof matchContents === 'object' ? matchContents.horizontal : matchContents;
|
|
15
|
+
const newContainerStyle = {};
|
|
16
|
+
if (matchVertical) {
|
|
17
|
+
newContainerStyle.height = e.nativeEvent.height;
|
|
18
|
+
}
|
|
19
|
+
if (matchHorizontal) {
|
|
20
|
+
newContainerStyle.width = e.nativeEvent.width;
|
|
21
|
+
}
|
|
22
|
+
setContainerStyle(newContainerStyle);
|
|
17
23
|
}
|
|
18
|
-
}}
|
|
24
|
+
}} {...restProps}/>);
|
|
19
25
|
}
|
|
20
26
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/swift-ui/Host/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/swift-ui/Host/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAgCjC,MAAM,cAAc,GAAmC,iBAAiB,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;AAE/F;;GAEG;AACH,MAAM,UAAU,IAAI,CAAC,KAAgB;IACnC,MAAM,EAAE,aAAa,EAAE,eAAe,EAAE,KAAK,EAAE,GAAG,SAAS,EAAE,GAAG,KAAK,CAAC;IACtE,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,QAAQ,CAAmB,IAAI,CAAC,CAAC;IAC7E,OAAO,CACL,CAAC,cAAc,CACb,KAAK,CAAC,CAAC,CAAC,KAAK,EAAE,cAAc,CAAC,CAAC,CAC/B,eAAe,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE;YACrB,eAAe,EAAE,CAAC,CAAC,CAAC,CAAC;YACrB,IAAI,aAAa,EAAE,CAAC;gBAClB,MAAM,aAAa,GACjB,OAAO,aAAa,KAAK,QAAQ,CAAC,CAAC,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC,aAAa,CAAC;gBAC7E,MAAM,eAAe,GACnB,OAAO,aAAa,KAAK,QAAQ,CAAC,CAAC,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC,CAAC,aAAa,CAAC;gBAC/E,MAAM,iBAAiB,GAAc,EAAE,CAAC;gBACxC,IAAI,aAAa,EAAE,CAAC;oBAClB,iBAAiB,CAAC,MAAM,GAAG,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC;gBAClD,CAAC;gBACD,IAAI,eAAe,EAAE,CAAC;oBACpB,iBAAiB,CAAC,KAAK,GAAG,CAAC,CAAC,WAAW,CAAC,KAAK,CAAC;gBAChD,CAAC;gBACD,iBAAiB,CAAC,iBAAiB,CAAC,CAAC;YACvC,CAAC;QACH,CAAC,CAAC,CACF,IAAI,SAAS,CAAC,EACd,CACH,CAAC;AACJ,CAAC","sourcesContent":["import { requireNativeView } from 'expo';\nimport { useState } from 'react';\nimport { StyleProp, ViewStyle, type ColorSchemeName } from 'react-native';\n\nexport type HostProps = {\n /**\n * When true, the host view will update its size in the React Native view tree to match the content's layout from SwiftUI.\n * @default false\n */\n matchContents?: boolean | { vertical?: boolean; horizontal?: boolean };\n\n /**\n * When true and no explicit size is provided, the host will use the viewport size as the proposed size for SwiftUI layout.\n * This is particularly useful for SwiftUI views that need to fill their available space, such as `Form`.\n * @default false\n */\n useViewportSizeMeasurement?: boolean;\n\n /**\n * Callback function that is triggered when the SwiftUI content completes its layout.\n * Provides the current dimensions of the content, which may change as the content updates.\n */\n onLayoutContent?: (event: { nativeEvent: { width: number; height: number } }) => void;\n\n /**\n * The color scheme of the host view.\n */\n colorScheme?: ColorSchemeName;\n\n children: React.ReactNode;\n style?: StyleProp<ViewStyle>;\n};\n\nconst HostNativeView: React.ComponentType<HostProps> = requireNativeView('ExpoUI', 'HostView');\n\n/**\n * A hosting component for SwiftUI views.\n */\nexport function Host(props: HostProps) {\n const { matchContents, onLayoutContent, style, ...restProps } = props;\n const [containerStyle, setContainerStyle] = useState<ViewStyle | null>(null);\n return (\n <HostNativeView\n style={[style, containerStyle]}\n onLayoutContent={(e) => {\n onLayoutContent?.(e);\n if (matchContents) {\n const matchVertical =\n typeof matchContents === 'object' ? matchContents.vertical : matchContents;\n const matchHorizontal =\n typeof matchContents === 'object' ? matchContents.horizontal : matchContents;\n const newContainerStyle: ViewStyle = {};\n if (matchVertical) {\n newContainerStyle.height = e.nativeEvent.height;\n }\n if (matchHorizontal) {\n newContainerStyle.width = e.nativeEvent.width;\n }\n setContainerStyle(newContainerStyle);\n }\n }}\n {...restProps}\n />\n );\n}\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type CommonViewModifierProps } from './types';
|
|
2
|
+
export interface DisclosureGroupProps extends CommonViewModifierProps {
|
|
3
|
+
label: string;
|
|
4
|
+
children: React.ReactNode;
|
|
5
|
+
}
|
|
6
|
+
export declare function DisclosureGroup(props: DisclosureGroupProps): import("react").JSX.Element;
|
|
7
|
+
//# sourceMappingURL=DisclosureGroup.d.ts.map
|