@expo/ui 55.0.0-preview.6 → 55.0.0
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 +20 -0
- package/android/build.gradle +27 -8
- package/android/src/main/java/expo/modules/ui/BasicAlertDialogView.kt +26 -0
- package/android/src/main/java/expo/modules/ui/BottomSheetView.kt +12 -37
- package/android/src/main/java/expo/modules/ui/CardView.kt +72 -0
- package/android/src/main/java/expo/modules/ui/CarouselView.kt +2 -5
- package/android/src/main/java/expo/modules/ui/ComposeViews.kt +91 -130
- package/android/src/main/java/expo/modules/ui/DatePickerView.kt +2 -2
- package/android/src/main/java/expo/modules/ui/DividerView.kt +1 -1
- package/android/src/main/java/expo/modules/ui/DockedSearchBarView.kt +53 -0
- package/android/src/main/java/expo/modules/ui/ExpoUIModule.kt +136 -17
- package/android/src/main/java/expo/modules/ui/FilterChipView.kt +59 -0
- package/android/src/main/java/expo/modules/ui/HorizontalFloatingToolbarView.kt +63 -0
- package/android/src/main/java/expo/modules/ui/LazyColumnView.kt +95 -0
- package/android/src/main/java/expo/modules/ui/ListItemView.kt +89 -0
- package/android/src/main/java/expo/modules/ui/MaterialShapes.kt +77 -0
- package/android/src/main/java/expo/modules/ui/ModifierRegistry.kt +168 -30
- package/android/src/main/java/expo/modules/ui/PickerView.kt +2 -2
- package/android/src/main/java/expo/modules/ui/ProgressView.kt +1 -1
- package/android/src/main/java/expo/modules/ui/PullToRefreshBoxView.kt +40 -0
- package/android/src/main/java/expo/modules/ui/RNHostView.kt +87 -0
- package/android/src/main/java/expo/modules/ui/RadioButtonView.kt +28 -0
- package/android/src/main/java/expo/modules/ui/SearchBarView.kt +60 -0
- package/android/src/main/java/expo/modules/ui/ShapeView.kt +36 -5
- package/android/src/main/java/expo/modules/ui/SliderView.kt +1 -1
- package/android/src/main/java/expo/modules/ui/SlotView.kt +53 -0
- package/android/src/main/java/expo/modules/ui/SpacerView.kt +15 -0
- package/android/src/main/java/expo/modules/ui/SurfaceView.kt +36 -0
- package/android/src/main/java/expo/modules/ui/SwitchView.kt +24 -4
- package/android/src/main/java/expo/modules/ui/TextButtonView.kt +33 -0
- package/android/src/main/java/expo/modules/ui/TextInputView.kt +1 -2
- package/android/src/main/java/expo/modules/ui/TextView.kt +194 -0
- package/android/src/main/java/expo/modules/ui/ToggleButtonView.kt +96 -0
- package/android/src/main/java/expo/modules/ui/Utils.kt +6 -0
- package/android/src/main/java/expo/modules/ui/button/Button.kt +1 -1
- package/android/src/main/java/expo/modules/ui/button/IconButton.kt +2 -6
- package/android/src/main/java/expo/modules/ui/convertibles/Alignment.kt +112 -0
- package/android/src/main/java/expo/modules/ui/convertibles/Arrangement.kt +72 -0
- package/android/src/main/java/expo/modules/ui/icon/IconView.kt +159 -0
- package/android/src/main/java/expo/modules/ui/icon/ResourceIdHelper.kt +47 -0
- package/android/src/main/java/expo/modules/ui/icon/VectorIconLoader.kt +369 -0
- package/android/src/main/java/expo/modules/ui/menu/ContextMenu.kt +1 -1
- package/build/jetpack-compose/AlertDialog/index.d.ts.map +1 -1
- package/build/jetpack-compose/BasicAlertDialog/index.d.ts +22 -0
- package/build/jetpack-compose/BasicAlertDialog/index.d.ts.map +1 -0
- package/build/jetpack-compose/Button/index.d.ts.map +1 -1
- package/build/jetpack-compose/Card/index.d.ts +40 -0
- package/build/jetpack-compose/Card/index.d.ts.map +1 -0
- package/build/jetpack-compose/Carousel/index.d.ts.map +1 -1
- package/build/jetpack-compose/Chip/index.d.ts +0 -4
- package/build/jetpack-compose/Chip/index.d.ts.map +1 -1
- package/build/jetpack-compose/ContextMenu/index.d.ts.map +1 -1
- package/build/jetpack-compose/DatePicker/index.d.ts +1 -12
- package/build/jetpack-compose/DatePicker/index.d.ts.map +1 -1
- package/build/jetpack-compose/Divider/index.d.ts.map +1 -1
- package/build/jetpack-compose/DockedSearchBar/index.d.ts +30 -0
- package/build/jetpack-compose/DockedSearchBar/index.d.ts.map +1 -0
- package/build/jetpack-compose/ExpoUIModule.d.ts +2 -0
- package/build/jetpack-compose/ExpoUIModule.d.ts.map +1 -0
- package/build/jetpack-compose/FilterChip/index.d.ts +49 -0
- package/build/jetpack-compose/FilterChip/index.d.ts.map +1 -0
- package/build/jetpack-compose/HorizontalFloatingToolbar/index.d.ts +41 -0
- package/build/jetpack-compose/HorizontalFloatingToolbar/index.d.ts.map +1 -0
- package/build/jetpack-compose/Icon/index.d.ts +112 -0
- package/build/jetpack-compose/Icon/index.d.ts.map +1 -0
- package/build/jetpack-compose/IconButton/index.d.ts +0 -4
- package/build/jetpack-compose/IconButton/index.d.ts.map +1 -1
- package/build/jetpack-compose/LazyColumn/index.d.ts +55 -0
- package/build/jetpack-compose/LazyColumn/index.d.ts.map +1 -0
- package/build/jetpack-compose/ListItem/index.d.ts +81 -0
- package/build/jetpack-compose/ListItem/index.d.ts.map +1 -0
- package/build/jetpack-compose/MaterialSymbolsAssetsTransformer.fx.d.ts +2 -0
- package/build/jetpack-compose/MaterialSymbolsAssetsTransformer.fx.d.ts.map +1 -0
- package/build/jetpack-compose/ModalBottomSheet/index.d.ts +34 -0
- package/build/jetpack-compose/ModalBottomSheet/index.d.ts.map +1 -0
- package/build/jetpack-compose/Picker/index.d.ts +0 -6
- package/build/jetpack-compose/Picker/index.d.ts.map +1 -1
- package/build/jetpack-compose/Progress/index.d.ts.map +1 -1
- package/build/jetpack-compose/PullToRefreshBox/index.d.ts +31 -0
- package/build/jetpack-compose/PullToRefreshBox/index.d.ts.map +1 -0
- package/build/jetpack-compose/RNHostView/index.d.ts +28 -0
- package/build/jetpack-compose/RNHostView/index.d.ts.map +1 -0
- package/build/jetpack-compose/RadioButton/index.d.ts +20 -0
- package/build/jetpack-compose/RadioButton/index.d.ts.map +1 -0
- package/build/jetpack-compose/SearchBar/index.d.ts +47 -0
- package/build/jetpack-compose/SearchBar/index.d.ts.map +1 -0
- package/build/jetpack-compose/Shape/index.d.ts +29 -2
- package/build/jetpack-compose/Shape/index.d.ts.map +1 -1
- package/build/jetpack-compose/Slider/index.d.ts +1 -9
- package/build/jetpack-compose/Slider/index.d.ts.map +1 -1
- package/build/jetpack-compose/Spacer/index.d.ts +22 -0
- package/build/jetpack-compose/Spacer/index.d.ts.map +1 -0
- package/build/jetpack-compose/Surface/index.d.ts +44 -0
- package/build/jetpack-compose/Surface/index.d.ts.map +1 -0
- package/build/jetpack-compose/Switch/index.d.ts +17 -9
- package/build/jetpack-compose/Switch/index.d.ts.map +1 -1
- package/build/jetpack-compose/Text/index.d.ts +182 -0
- package/build/jetpack-compose/Text/index.d.ts.map +1 -0
- package/build/jetpack-compose/TextButton/index.d.ts +29 -0
- package/build/jetpack-compose/TextButton/index.d.ts.map +1 -0
- package/build/jetpack-compose/TextInput/index.d.ts.map +1 -1
- package/build/jetpack-compose/ToggleButton/index.d.ts +54 -0
- package/build/jetpack-compose/ToggleButton/index.d.ts.map +1 -0
- package/build/jetpack-compose/index.d.ts +20 -1
- package/build/jetpack-compose/index.d.ts.map +1 -1
- package/build/jetpack-compose/layout.d.ts +16 -19
- package/build/jetpack-compose/layout.d.ts.map +1 -1
- package/build/jetpack-compose/modifiers/createModifier.d.ts +18 -0
- package/build/jetpack-compose/modifiers/createModifier.d.ts.map +1 -0
- package/build/jetpack-compose/modifiers/index.d.ts +133 -41
- package/build/jetpack-compose/modifiers/index.d.ts.map +1 -1
- package/build/jetpack-compose/modifiers/utils.d.ts +15 -0
- package/build/jetpack-compose/modifiers/utils.d.ts.map +1 -0
- package/build/swift-ui/ConfirmationDialog/index.d.ts +47 -0
- package/build/swift-ui/ConfirmationDialog/index.d.ts.map +1 -0
- package/build/swift-ui/ScrollView/index.d.ts +16 -0
- package/build/swift-ui/ScrollView/index.d.ts.map +1 -0
- package/build/swift-ui/index.d.ts +2 -0
- package/build/swift-ui/index.d.ts.map +1 -1
- package/build/swift-ui/modifiers/index.d.ts +12 -3
- package/build/swift-ui/modifiers/index.d.ts.map +1 -1
- package/expo-module.config.json +2 -1
- package/ios/ColorPickerView.swift +2 -2
- package/ios/ConfirmationDialog/ConfirmationDialog.swift +65 -0
- package/ios/ConfirmationDialog/ConfirmationDialogComponents.swift +26 -0
- package/ios/ConfirmationDialog/ConfirmationDialogProps.swift +15 -0
- package/ios/Convertibles/VisibilityOptions.swift +19 -0
- package/ios/ExpoUIModule.swift +5 -0
- package/ios/Modifiers/ForegroundStyleModifier.swift +124 -0
- package/ios/Modifiers/PresentationModifiers.swift +1 -18
- package/ios/Modifiers/ViewModifierRegistry.swift +30 -121
- package/ios/ScrollViewComponent.swift +23 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.0/expo.modules.ui-55.0.0-sources.jar +0 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.0/expo.modules.ui-55.0.0-sources.jar.md5 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.0/expo.modules.ui-55.0.0-sources.jar.sha1 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.0/expo.modules.ui-55.0.0-sources.jar.sha256 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.0/expo.modules.ui-55.0.0-sources.jar.sha512 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.0/expo.modules.ui-55.0.0.aar +0 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.0/expo.modules.ui-55.0.0.aar.md5 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.0/expo.modules.ui-55.0.0.aar.sha1 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.0/expo.modules.ui-55.0.0.aar.sha256 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.0/expo.modules.ui-55.0.0.aar.sha512 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/{55.0.0-preview.6/expo.modules.ui-55.0.0-preview.6.module → 55.0.0/expo.modules.ui-55.0.0.module} +46 -28
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.0/expo.modules.ui-55.0.0.module.md5 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.0/expo.modules.ui-55.0.0.module.sha1 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.0/expo.modules.ui-55.0.0.module.sha256 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.0/expo.modules.ui-55.0.0.module.sha512 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/{55.0.0-preview.6/expo.modules.ui-55.0.0-preview.6.pom → 55.0.0/expo.modules.ui-55.0.0.pom} +36 -7
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.0/expo.modules.ui-55.0.0.pom.md5 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.0/expo.modules.ui-55.0.0.pom.sha1 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.0/expo.modules.ui-55.0.0.pom.sha256 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.0/expo.modules.ui-55.0.0.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 +5 -3
- package/src/jetpack-compose/AlertDialog/index.tsx +11 -1
- package/src/jetpack-compose/BasicAlertDialog/index.tsx +51 -0
- package/src/jetpack-compose/Button/index.tsx +13 -1
- package/src/jetpack-compose/Card/index.tsx +62 -0
- package/src/jetpack-compose/Carousel/index.tsx +7 -1
- package/src/jetpack-compose/Chip/index.tsx +14 -7
- package/src/jetpack-compose/ContextMenu/index.tsx +5 -2
- package/src/jetpack-compose/DatePicker/index.tsx +5 -5
- package/src/jetpack-compose/Divider/index.tsx +13 -2
- package/src/jetpack-compose/DockedSearchBar/index.tsx +78 -0
- package/src/jetpack-compose/ExpoUIModule.ts +3 -0
- package/src/jetpack-compose/FilterChip/index.tsx +89 -0
- package/src/jetpack-compose/HorizontalFloatingToolbar/index.tsx +90 -0
- package/src/jetpack-compose/Icon/index.tsx +144 -0
- package/src/jetpack-compose/IconButton/index.tsx +5 -5
- package/src/jetpack-compose/LazyColumn/index.tsx +82 -0
- package/src/jetpack-compose/ListItem/index.tsx +129 -0
- package/src/jetpack-compose/MaterialSymbolsAssetsTransformer.fx.ts +22 -0
- package/src/jetpack-compose/ModalBottomSheet/index.tsx +61 -0
- package/src/jetpack-compose/Picker/index.tsx +6 -5
- package/src/jetpack-compose/Progress/index.tsx +14 -4
- package/src/jetpack-compose/PullToRefreshBox/index.tsx +66 -0
- package/src/jetpack-compose/RNHostView/index.tsx +56 -0
- package/src/jetpack-compose/RadioButton/index.tsx +48 -0
- package/src/jetpack-compose/SearchBar/index.tsx +96 -0
- package/src/jetpack-compose/Shape/index.tsx +65 -22
- package/src/jetpack-compose/Slider/index.tsx +6 -5
- package/src/jetpack-compose/Spacer/index.tsx +43 -0
- package/src/jetpack-compose/Surface/index.tsx +66 -0
- package/src/jetpack-compose/Switch/index.tsx +43 -8
- package/src/jetpack-compose/Text/index.tsx +274 -0
- package/src/jetpack-compose/TextButton/index.tsx +55 -0
- package/src/jetpack-compose/TextInput/index.tsx +5 -4
- package/src/jetpack-compose/ToggleButton/index.tsx +83 -0
- package/src/jetpack-compose/index.ts +21 -1
- package/src/jetpack-compose/layout.tsx +55 -70
- package/src/jetpack-compose/modifiers/createModifier.ts +27 -0
- package/src/jetpack-compose/modifiers/index.ts +204 -83
- package/src/jetpack-compose/modifiers/utils.ts +30 -0
- package/src/swift-ui/ConfirmationDialog/index.tsx +98 -0
- package/src/swift-ui/ScrollView/index.tsx +34 -0
- package/src/swift-ui/index.tsx +2 -0
- package/src/swift-ui/modifiers/index.ts +19 -3
- package/src/ts-declarations/react-native-assets.d.ts +31 -0
- package/build/jetpack-compose/BottomSheet/index.d.ts +0 -21
- package/build/jetpack-compose/BottomSheet/index.d.ts.map +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.0-preview.6/expo.modules.ui-55.0.0-preview.6-sources.jar +0 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.0-preview.6/expo.modules.ui-55.0.0-preview.6-sources.jar.md5 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.0-preview.6/expo.modules.ui-55.0.0-preview.6-sources.jar.sha1 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.0-preview.6/expo.modules.ui-55.0.0-preview.6-sources.jar.sha256 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.0-preview.6/expo.modules.ui-55.0.0-preview.6-sources.jar.sha512 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.0-preview.6/expo.modules.ui-55.0.0-preview.6.aar +0 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.0-preview.6/expo.modules.ui-55.0.0-preview.6.aar.md5 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.0-preview.6/expo.modules.ui-55.0.0-preview.6.aar.sha1 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.0-preview.6/expo.modules.ui-55.0.0-preview.6.aar.sha256 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.0-preview.6/expo.modules.ui-55.0.0-preview.6.aar.sha512 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.0-preview.6/expo.modules.ui-55.0.0-preview.6.module.md5 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.0-preview.6/expo.modules.ui-55.0.0-preview.6.module.sha1 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.0-preview.6/expo.modules.ui-55.0.0-preview.6.module.sha256 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.0-preview.6/expo.modules.ui-55.0.0-preview.6.module.sha512 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.0-preview.6/expo.modules.ui-55.0.0-preview.6.pom.md5 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.0-preview.6/expo.modules.ui-55.0.0-preview.6.pom.sha1 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.0-preview.6/expo.modules.ui-55.0.0-preview.6.pom.sha256 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.0-preview.6/expo.modules.ui-55.0.0-preview.6.pom.sha512 +0 -1
- package/src/jetpack-compose/BottomSheet/index.tsx +0 -46
|
@@ -12,6 +12,8 @@ import androidx.compose.ui.graphics.Shape
|
|
|
12
12
|
import androidx.compose.ui.graphics.asComposePath
|
|
13
13
|
import androidx.compose.ui.unit.Density
|
|
14
14
|
import androidx.compose.ui.unit.LayoutDirection
|
|
15
|
+
import androidx.compose.foundation.shape.RoundedCornerShape
|
|
16
|
+
import androidx.compose.ui.unit.dp
|
|
15
17
|
import androidx.graphics.shapes.CornerRounding
|
|
16
18
|
import androidx.graphics.shapes.RoundedPolygon
|
|
17
19
|
import androidx.graphics.shapes.circle
|
|
@@ -33,15 +35,24 @@ enum class ShapeType(val value: String) : Enumerable {
|
|
|
33
35
|
PILL("pill"),
|
|
34
36
|
CIRCLE("circle"),
|
|
35
37
|
RECTANGLE("rectangle"),
|
|
36
|
-
POLYGON("polygon")
|
|
38
|
+
POLYGON("polygon"),
|
|
39
|
+
ROUNDED_CORNER("roundedCorner")
|
|
37
40
|
}
|
|
38
41
|
|
|
42
|
+
data class CornerRadii(
|
|
43
|
+
@Field val topStart: Float = 0f,
|
|
44
|
+
@Field val topEnd: Float = 0f,
|
|
45
|
+
@Field val bottomStart: Float = 0f,
|
|
46
|
+
@Field val bottomEnd: Float = 0f
|
|
47
|
+
) : Record
|
|
48
|
+
|
|
39
49
|
data class ShapeProps(
|
|
40
50
|
val cornerRounding: Float = 0.0f,
|
|
41
51
|
val smoothing: Float = 0.0f,
|
|
42
52
|
val verticesCount: Int = 6,
|
|
43
53
|
val innerRadius: Float = 0.0f,
|
|
44
54
|
val radius: Float = 0.0f,
|
|
55
|
+
val cornerRadii: CornerRadii? = null,
|
|
45
56
|
val type: ShapeType = ShapeType.CIRCLE,
|
|
46
57
|
val color: GraphicsColor? = null,
|
|
47
58
|
val modifiers: ModifierList = emptyList()
|
|
@@ -116,6 +127,21 @@ private fun createRectanglePath(size: Size, cornerRounding: Float, smoothing: Fl
|
|
|
116
127
|
).toPath().asComposePath()
|
|
117
128
|
}
|
|
118
129
|
|
|
130
|
+
private fun createRoundedCornerPath(size: Size, cornerRadii: CornerRadii?, density: Density): Path {
|
|
131
|
+
val radii = cornerRadii ?: CornerRadii()
|
|
132
|
+
val shape = RoundedCornerShape(
|
|
133
|
+
topStart = radii.topStart.dp,
|
|
134
|
+
topEnd = radii.topEnd.dp,
|
|
135
|
+
bottomStart = radii.bottomStart.dp,
|
|
136
|
+
bottomEnd = radii.bottomEnd.dp
|
|
137
|
+
)
|
|
138
|
+
return when (val outline = shape.createOutline(size, LayoutDirection.Ltr, density)) {
|
|
139
|
+
is Outline.Rectangle -> Path().apply { addRect(outline.rect) }
|
|
140
|
+
is Outline.Rounded -> Path().apply { addRoundRect(outline.roundRect) }
|
|
141
|
+
is Outline.Generic -> outline.path
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
119
145
|
data class ShapeRecord(
|
|
120
146
|
@Field
|
|
121
147
|
val cornerRounding: Float = 0.0f,
|
|
@@ -128,10 +154,12 @@ data class ShapeRecord(
|
|
|
128
154
|
@Field
|
|
129
155
|
val radius: Float = 0.0f,
|
|
130
156
|
@Field
|
|
157
|
+
val cornerRadii: CornerRadii? = null,
|
|
158
|
+
@Field
|
|
131
159
|
val type: ShapeType = ShapeType.CIRCLE
|
|
132
160
|
) : Record
|
|
133
161
|
|
|
134
|
-
fun pathFromShapeRecord(record: ShapeRecord, size: Size): Path {
|
|
162
|
+
fun pathFromShapeRecord(record: ShapeRecord, size: Size, density: Density): Path {
|
|
135
163
|
return runCatching {
|
|
136
164
|
when (record.type) {
|
|
137
165
|
ShapeType.STAR -> createStarPath(size = size, cornerRounding = record.cornerRounding, smoothing = record.smoothing, innerRadius = record.innerRadius, radius = record.radius, verticesCount = record.verticesCount)
|
|
@@ -140,6 +168,7 @@ fun pathFromShapeRecord(record: ShapeRecord, size: Size): Path {
|
|
|
140
168
|
ShapeType.CIRCLE -> createCirclePath(size = size, radius = record.radius, verticesCount = record.verticesCount)
|
|
141
169
|
ShapeType.RECTANGLE -> createRectanglePath(size = size, cornerRounding = record.cornerRounding, smoothing = record.smoothing)
|
|
142
170
|
ShapeType.POLYGON -> createPolygonPath(size = size, cornerRounding = record.cornerRounding, smoothing = record.smoothing, verticesCount = record.verticesCount)
|
|
171
|
+
ShapeType.ROUNDED_CORNER -> createRoundedCornerPath(size = size, cornerRadii = record.cornerRadii, density = density)
|
|
143
172
|
}
|
|
144
173
|
}.getOrNull() ?: Path()
|
|
145
174
|
}
|
|
@@ -148,7 +177,7 @@ fun shapeFromShapeRecord(shapeRecord: ShapeRecord?): Shape? {
|
|
|
148
177
|
if (shapeRecord == null) return null
|
|
149
178
|
return object : Shape {
|
|
150
179
|
override fun createOutline(size: Size, layoutDirection: LayoutDirection, density: Density): Outline {
|
|
151
|
-
val path = pathFromShapeRecord(shapeRecord, size)
|
|
180
|
+
val path = pathFromShapeRecord(shapeRecord, size, density)
|
|
152
181
|
return Outline.Generic(path)
|
|
153
182
|
}
|
|
154
183
|
}
|
|
@@ -157,7 +186,7 @@ fun shapeFromShapeRecord(shapeRecord: ShapeRecord?): Shape? {
|
|
|
157
186
|
@Composable
|
|
158
187
|
fun FunctionalComposableScope.ShapeContent(props: ShapeProps) {
|
|
159
188
|
Box(
|
|
160
|
-
modifier = ModifierRegistry.applyModifiers(props.modifiers, appContext, composableScope)
|
|
189
|
+
modifier = ModifierRegistry.applyModifiers(props.modifiers, appContext, composableScope, globalEventDispatcher)
|
|
161
190
|
.drawWithCache {
|
|
162
191
|
val path = pathFromShapeRecord(
|
|
163
192
|
ShapeRecord(
|
|
@@ -165,10 +194,12 @@ fun FunctionalComposableScope.ShapeContent(props: ShapeProps) {
|
|
|
165
194
|
smoothing = props.smoothing,
|
|
166
195
|
innerRadius = props.innerRadius,
|
|
167
196
|
radius = props.radius,
|
|
197
|
+
cornerRadii = props.cornerRadii,
|
|
168
198
|
type = props.type,
|
|
169
199
|
verticesCount = props.verticesCount
|
|
170
200
|
),
|
|
171
|
-
size
|
|
201
|
+
size,
|
|
202
|
+
this
|
|
172
203
|
)
|
|
173
204
|
|
|
174
205
|
onDrawBehind {
|
|
@@ -59,6 +59,6 @@ fun FunctionalComposableScope.SliderContent(props: SliderProps) {
|
|
|
59
59
|
activeTickColor = colors.activeTickColor.compose,
|
|
60
60
|
inactiveTickColor = colors.inactiveTickColor.compose
|
|
61
61
|
),
|
|
62
|
-
modifier = ModifierRegistry.applyModifiers(props.modifiers, appContext, composableScope)
|
|
62
|
+
modifier = ModifierRegistry.applyModifiers(props.modifiers, appContext, composableScope, globalEventDispatcher)
|
|
63
63
|
)
|
|
64
64
|
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
package expo.modules.ui
|
|
2
|
+
|
|
3
|
+
import android.annotation.SuppressLint
|
|
4
|
+
import android.content.Context
|
|
5
|
+
import android.view.ViewGroup
|
|
6
|
+
import androidx.compose.runtime.Composable
|
|
7
|
+
import androidx.compose.runtime.MutableState
|
|
8
|
+
import androidx.compose.runtime.mutableStateOf
|
|
9
|
+
import androidx.core.view.size
|
|
10
|
+
import expo.modules.kotlin.AppContext
|
|
11
|
+
import expo.modules.kotlin.viewevent.EventDispatcher
|
|
12
|
+
import expo.modules.kotlin.views.ComposableScope
|
|
13
|
+
import expo.modules.kotlin.views.ComposeProps
|
|
14
|
+
import expo.modules.kotlin.views.ExpoComposeView
|
|
15
|
+
|
|
16
|
+
data class SlotProps(
|
|
17
|
+
val slotName: MutableState<String> = mutableStateOf("")
|
|
18
|
+
) : ComposeProps
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* A generic slot marker view that can be used to mark children for specific slots.
|
|
22
|
+
* This view is not rendered directly but used as a marker to identify which children
|
|
23
|
+
* should be placed in which composable slots.
|
|
24
|
+
*/
|
|
25
|
+
@SuppressLint("ViewConstructor")
|
|
26
|
+
class SlotView(context: Context, appContext: AppContext) :
|
|
27
|
+
ExpoComposeView<SlotProps>(context, appContext) {
|
|
28
|
+
override val props = SlotProps()
|
|
29
|
+
internal val onSlotEvent by EventDispatcher<Unit>()
|
|
30
|
+
|
|
31
|
+
@Composable
|
|
32
|
+
override fun ComposableScope.Content() {
|
|
33
|
+
Children(this)
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
fun isSlotWithName(view: ExpoComposeView<*>, slotName: String): Boolean {
|
|
38
|
+
return view is SlotView && view.props.slotName.value == slotName
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
fun isSlotView(view: ExpoComposeView<*>): Boolean {
|
|
42
|
+
return view is SlotView
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
fun findChildSlotView(viewGroup: ViewGroup, slotName: String): SlotView? {
|
|
46
|
+
for (index in 0..<viewGroup.size) {
|
|
47
|
+
val child = viewGroup.getChildAt(index) as? SlotView
|
|
48
|
+
if (child != null && child.props.slotName.value == slotName) {
|
|
49
|
+
return child
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return null
|
|
53
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
package expo.modules.ui
|
|
2
|
+
|
|
3
|
+
import androidx.compose.foundation.layout.Spacer
|
|
4
|
+
import androidx.compose.runtime.Composable
|
|
5
|
+
import expo.modules.kotlin.views.ComposeProps
|
|
6
|
+
import expo.modules.kotlin.views.FunctionalComposableScope
|
|
7
|
+
|
|
8
|
+
data class SpacerProps(
|
|
9
|
+
val modifiers: ModifierList = emptyList()
|
|
10
|
+
) : ComposeProps
|
|
11
|
+
|
|
12
|
+
@Composable
|
|
13
|
+
fun FunctionalComposableScope.SpacerContent(props: SpacerProps) {
|
|
14
|
+
Spacer(modifier = ModifierRegistry.applyModifiers(props.modifiers, appContext, composableScope, globalEventDispatcher))
|
|
15
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
package expo.modules.ui
|
|
2
|
+
|
|
3
|
+
import android.graphics.Color
|
|
4
|
+
import androidx.compose.material3.MaterialTheme
|
|
5
|
+
import androidx.compose.material3.Surface
|
|
6
|
+
import androidx.compose.material3.contentColorFor
|
|
7
|
+
import androidx.compose.runtime.Composable
|
|
8
|
+
import androidx.compose.ui.unit.dp
|
|
9
|
+
import expo.modules.kotlin.views.ComposableScope
|
|
10
|
+
import expo.modules.kotlin.views.ComposeProps
|
|
11
|
+
import expo.modules.kotlin.views.FunctionalComposableScope
|
|
12
|
+
|
|
13
|
+
data class SurfaceProps(
|
|
14
|
+
val color: Color? = null,
|
|
15
|
+
val contentColor: Color? = null,
|
|
16
|
+
val tonalElevation: Float = 0f,
|
|
17
|
+
val shadowElevation: Float = 0f,
|
|
18
|
+
val modifiers: ModifierList = emptyList()
|
|
19
|
+
) : ComposeProps
|
|
20
|
+
|
|
21
|
+
@Composable
|
|
22
|
+
fun FunctionalComposableScope.SurfaceContent(props: SurfaceProps) {
|
|
23
|
+
val modifier = ModifierRegistry.applyModifiers(props.modifiers, appContext, composableScope, globalEventDispatcher)
|
|
24
|
+
val color = props.color?.compose ?: MaterialTheme.colorScheme.surface
|
|
25
|
+
val contentColor = props.contentColor?.compose ?: contentColorFor(color)
|
|
26
|
+
|
|
27
|
+
Surface(
|
|
28
|
+
modifier = modifier,
|
|
29
|
+
color = color,
|
|
30
|
+
contentColor = contentColor,
|
|
31
|
+
tonalElevation = props.tonalElevation.dp,
|
|
32
|
+
shadowElevation = props.shadowElevation.dp
|
|
33
|
+
) {
|
|
34
|
+
Children(ComposableScope())
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -9,6 +9,7 @@ import androidx.compose.runtime.Composable
|
|
|
9
9
|
import androidx.compose.ui.Modifier
|
|
10
10
|
import expo.modules.kotlin.records.Field
|
|
11
11
|
import expo.modules.kotlin.records.Record
|
|
12
|
+
import expo.modules.kotlin.views.ComposableScope
|
|
12
13
|
import expo.modules.kotlin.views.ComposeProps
|
|
13
14
|
import expo.modules.kotlin.views.FunctionalComposableScope
|
|
14
15
|
import java.io.Serializable
|
|
@@ -57,11 +58,18 @@ data class SwitchProps(
|
|
|
57
58
|
) : ComposeProps
|
|
58
59
|
|
|
59
60
|
@Composable
|
|
60
|
-
fun SwitchComposable(
|
|
61
|
+
fun SwitchComposable(
|
|
62
|
+
checked: Boolean,
|
|
63
|
+
onCheckedChange: ((Boolean) -> Unit)?,
|
|
64
|
+
colors: SwitchColors,
|
|
65
|
+
modifier: Modifier = Modifier,
|
|
66
|
+
thumbContent: (@Composable () -> Unit)? = null
|
|
67
|
+
) {
|
|
61
68
|
Switch(
|
|
62
69
|
checked = checked,
|
|
63
70
|
onCheckedChange = onCheckedChange,
|
|
64
71
|
modifier = modifier,
|
|
72
|
+
thumbContent = thumbContent,
|
|
65
73
|
colors = SwitchDefaults.colors(
|
|
66
74
|
// For some reason the default way of passing colors using `compose` results in a transparent view
|
|
67
75
|
checkedThumbColor = colors.checkedThumbColor.composeOrNull
|
|
@@ -99,10 +107,11 @@ fun ThemedHybridSwitch(
|
|
|
99
107
|
checked: Boolean,
|
|
100
108
|
onCheckedChange: ((Boolean) -> Unit)?,
|
|
101
109
|
colors: SwitchColors,
|
|
102
|
-
modifier: Modifier = Modifier
|
|
110
|
+
modifier: Modifier = Modifier,
|
|
111
|
+
thumbContent: (@Composable () -> Unit)? = null
|
|
103
112
|
) {
|
|
104
113
|
when (variant) {
|
|
105
|
-
"switch" -> SwitchComposable(checked, onCheckedChange, colors, modifier)
|
|
114
|
+
"switch" -> SwitchComposable(checked, onCheckedChange, colors, modifier, thumbContent)
|
|
106
115
|
else -> CheckboxComposable(checked, onCheckedChange, colors, modifier)
|
|
107
116
|
}
|
|
108
117
|
}
|
|
@@ -112,11 +121,22 @@ fun FunctionalComposableScope.SwitchContent(
|
|
|
112
121
|
props: SwitchProps,
|
|
113
122
|
onValueChange: (ValueChangeEvent) -> Unit
|
|
114
123
|
) {
|
|
124
|
+
val thumbContentSlotView = findChildSlotView(view, "thumbContent")
|
|
125
|
+
|
|
115
126
|
ThemedHybridSwitch(
|
|
116
127
|
props.variant,
|
|
117
128
|
props.value,
|
|
118
129
|
{ newChecked -> onValueChange(ValueChangeEvent(newChecked)) },
|
|
119
130
|
props.elementColors,
|
|
120
|
-
ModifierRegistry.applyModifiers(props.modifiers, appContext, composableScope)
|
|
131
|
+
ModifierRegistry.applyModifiers(props.modifiers, appContext, composableScope, globalEventDispatcher),
|
|
132
|
+
thumbContent = thumbContentSlotView?.let {
|
|
133
|
+
{
|
|
134
|
+
with(ComposableScope()) {
|
|
135
|
+
with(it) {
|
|
136
|
+
Content()
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
121
141
|
)
|
|
122
142
|
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
package expo.modules.ui
|
|
2
|
+
|
|
3
|
+
import android.graphics.Color
|
|
4
|
+
import androidx.compose.material3.Text
|
|
5
|
+
import androidx.compose.material3.TextButton
|
|
6
|
+
import androidx.compose.runtime.Composable
|
|
7
|
+
import expo.modules.kotlin.views.ComposeProps
|
|
8
|
+
import expo.modules.kotlin.views.FunctionalComposableScope
|
|
9
|
+
import expo.modules.ui.button.ButtonPressedEvent
|
|
10
|
+
|
|
11
|
+
data class TextButtonProps(
|
|
12
|
+
val text: String = "",
|
|
13
|
+
val color: Color? = null,
|
|
14
|
+
val disabled: Boolean = false,
|
|
15
|
+
val modifiers: ModifierList = emptyList()
|
|
16
|
+
) : ComposeProps
|
|
17
|
+
|
|
18
|
+
@Composable
|
|
19
|
+
fun FunctionalComposableScope.TextButtonContent(
|
|
20
|
+
props: TextButtonProps,
|
|
21
|
+
onButtonPressed: (ButtonPressedEvent) -> Unit
|
|
22
|
+
) {
|
|
23
|
+
TextButton(
|
|
24
|
+
onClick = { onButtonPressed(ButtonPressedEvent()) },
|
|
25
|
+
enabled = !props.disabled,
|
|
26
|
+
modifier = ModifierRegistry.applyModifiers(props.modifiers, appContext, composableScope, globalEventDispatcher)
|
|
27
|
+
) {
|
|
28
|
+
Text(
|
|
29
|
+
text = props.text,
|
|
30
|
+
color = props.color.composeOrNull ?: androidx.compose.ui.graphics.Color.Unspecified
|
|
31
|
+
)
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -7,7 +7,6 @@ import androidx.compose.material3.TextField
|
|
|
7
7
|
import androidx.compose.runtime.Composable
|
|
8
8
|
import androidx.compose.runtime.MutableState
|
|
9
9
|
import androidx.compose.runtime.mutableStateOf
|
|
10
|
-
import androidx.compose.ui.Modifier
|
|
11
10
|
import androidx.compose.ui.text.input.KeyboardCapitalization
|
|
12
11
|
import androidx.compose.ui.text.input.KeyboardType
|
|
13
12
|
import expo.modules.kotlin.AppContext
|
|
@@ -83,7 +82,7 @@ class TextInputView(context: Context, appContext: AppContext) :
|
|
|
83
82
|
autoCorrectEnabled = props.autocorrection.value,
|
|
84
83
|
capitalization = props.autoCapitalize.value.autoCapitalize()
|
|
85
84
|
),
|
|
86
|
-
modifier = ModifierRegistry.applyModifiers(props.modifiers.value, appContext, this@Content)
|
|
85
|
+
modifier = ModifierRegistry.applyModifiers(props.modifiers.value, appContext, this@Content, globalEventDispatcher)
|
|
87
86
|
)
|
|
88
87
|
}
|
|
89
88
|
}
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
package expo.modules.ui
|
|
2
|
+
|
|
3
|
+
import android.graphics.Color
|
|
4
|
+
import androidx.compose.material3.MaterialTheme
|
|
5
|
+
import androidx.compose.material3.Text
|
|
6
|
+
import androidx.compose.runtime.Composable
|
|
7
|
+
import androidx.compose.ui.text.TextStyle
|
|
8
|
+
import androidx.compose.ui.text.font.FontStyle
|
|
9
|
+
import androidx.compose.ui.text.font.FontWeight
|
|
10
|
+
import androidx.compose.ui.text.style.TextAlign
|
|
11
|
+
import androidx.compose.ui.text.style.TextDecoration
|
|
12
|
+
import androidx.compose.ui.text.style.TextOverflow
|
|
13
|
+
import androidx.compose.ui.unit.sp
|
|
14
|
+
import expo.modules.kotlin.types.Enumerable
|
|
15
|
+
import expo.modules.kotlin.views.ComposeProps
|
|
16
|
+
import expo.modules.kotlin.views.FunctionalComposableScope
|
|
17
|
+
|
|
18
|
+
enum class TextFontWeight(val value: String) : Enumerable {
|
|
19
|
+
NORMAL("normal"),
|
|
20
|
+
BOLD("bold"),
|
|
21
|
+
W100("100"),
|
|
22
|
+
W200("200"),
|
|
23
|
+
W300("300"),
|
|
24
|
+
W400("400"),
|
|
25
|
+
W500("500"),
|
|
26
|
+
W600("600"),
|
|
27
|
+
W700("700"),
|
|
28
|
+
W800("800"),
|
|
29
|
+
W900("900");
|
|
30
|
+
|
|
31
|
+
fun toComposeFontWeight(): FontWeight {
|
|
32
|
+
return when (this) {
|
|
33
|
+
NORMAL -> FontWeight.Normal
|
|
34
|
+
BOLD -> FontWeight.Bold
|
|
35
|
+
W100 -> FontWeight.W100
|
|
36
|
+
W200 -> FontWeight.W200
|
|
37
|
+
W300 -> FontWeight.W300
|
|
38
|
+
W400 -> FontWeight.W400
|
|
39
|
+
W500 -> FontWeight.W500
|
|
40
|
+
W600 -> FontWeight.W600
|
|
41
|
+
W700 -> FontWeight.W700
|
|
42
|
+
W800 -> FontWeight.W800
|
|
43
|
+
W900 -> FontWeight.W900
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
enum class TextFontStyle(val value: String) : Enumerable {
|
|
49
|
+
NORMAL("normal"),
|
|
50
|
+
ITALIC("italic");
|
|
51
|
+
|
|
52
|
+
fun toComposeFontStyle(): FontStyle {
|
|
53
|
+
return when (this) {
|
|
54
|
+
NORMAL -> FontStyle.Normal
|
|
55
|
+
ITALIC -> FontStyle.Italic
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
enum class TextAlignType(val value: String) : Enumerable {
|
|
61
|
+
LEFT("left"),
|
|
62
|
+
RIGHT("right"),
|
|
63
|
+
CENTER("center"),
|
|
64
|
+
JUSTIFY("justify"),
|
|
65
|
+
START("start"),
|
|
66
|
+
END("end");
|
|
67
|
+
|
|
68
|
+
fun toComposeTextAlign(): TextAlign {
|
|
69
|
+
return when (this) {
|
|
70
|
+
LEFT -> TextAlign.Left
|
|
71
|
+
RIGHT -> TextAlign.Right
|
|
72
|
+
CENTER -> TextAlign.Center
|
|
73
|
+
JUSTIFY -> TextAlign.Justify
|
|
74
|
+
START -> TextAlign.Start
|
|
75
|
+
END -> TextAlign.End
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
enum class TextDecorationType(val value: String) : Enumerable {
|
|
81
|
+
NONE("none"),
|
|
82
|
+
UNDERLINE("underline"),
|
|
83
|
+
LINE_THROUGH("lineThrough");
|
|
84
|
+
|
|
85
|
+
fun toComposeTextDecoration(): TextDecoration {
|
|
86
|
+
return when (this) {
|
|
87
|
+
NONE -> TextDecoration.None
|
|
88
|
+
UNDERLINE -> TextDecoration.Underline
|
|
89
|
+
LINE_THROUGH -> TextDecoration.LineThrough
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
enum class TextOverflowType(val value: String) : Enumerable {
|
|
95
|
+
CLIP("clip"),
|
|
96
|
+
ELLIPSIS("ellipsis"),
|
|
97
|
+
VISIBLE("visible");
|
|
98
|
+
|
|
99
|
+
fun toComposeTextOverflow(): TextOverflow {
|
|
100
|
+
return when (this) {
|
|
101
|
+
CLIP -> TextOverflow.Clip
|
|
102
|
+
ELLIPSIS -> TextOverflow.Ellipsis
|
|
103
|
+
VISIBLE -> TextOverflow.Visible
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
enum class TypographyStyle(val value: String) : Enumerable {
|
|
109
|
+
DISPLAY_LARGE("displayLarge"),
|
|
110
|
+
DISPLAY_MEDIUM("displayMedium"),
|
|
111
|
+
DISPLAY_SMALL("displaySmall"),
|
|
112
|
+
HEADLINE_LARGE("headlineLarge"),
|
|
113
|
+
HEADLINE_MEDIUM("headlineMedium"),
|
|
114
|
+
HEADLINE_SMALL("headlineSmall"),
|
|
115
|
+
TITLE_LARGE("titleLarge"),
|
|
116
|
+
TITLE_MEDIUM("titleMedium"),
|
|
117
|
+
TITLE_SMALL("titleSmall"),
|
|
118
|
+
BODY_LARGE("bodyLarge"),
|
|
119
|
+
BODY_MEDIUM("bodyMedium"),
|
|
120
|
+
BODY_SMALL("bodySmall"),
|
|
121
|
+
LABEL_LARGE("labelLarge"),
|
|
122
|
+
LABEL_MEDIUM("labelMedium"),
|
|
123
|
+
LABEL_SMALL("labelSmall");
|
|
124
|
+
|
|
125
|
+
@Composable
|
|
126
|
+
fun toTextStyle(): TextStyle {
|
|
127
|
+
val typography = MaterialTheme.typography
|
|
128
|
+
return when (this) {
|
|
129
|
+
DISPLAY_LARGE -> typography.displayLarge
|
|
130
|
+
DISPLAY_MEDIUM -> typography.displayMedium
|
|
131
|
+
DISPLAY_SMALL -> typography.displaySmall
|
|
132
|
+
HEADLINE_LARGE -> typography.headlineLarge
|
|
133
|
+
HEADLINE_MEDIUM -> typography.headlineMedium
|
|
134
|
+
HEADLINE_SMALL -> typography.headlineSmall
|
|
135
|
+
TITLE_LARGE -> typography.titleLarge
|
|
136
|
+
TITLE_MEDIUM -> typography.titleMedium
|
|
137
|
+
TITLE_SMALL -> typography.titleSmall
|
|
138
|
+
BODY_LARGE -> typography.bodyLarge
|
|
139
|
+
BODY_MEDIUM -> typography.bodyMedium
|
|
140
|
+
BODY_SMALL -> typography.bodySmall
|
|
141
|
+
LABEL_LARGE -> typography.labelLarge
|
|
142
|
+
LABEL_MEDIUM -> typography.labelMedium
|
|
143
|
+
LABEL_SMALL -> typography.labelSmall
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
data class TextProps(
|
|
149
|
+
val text: String = "",
|
|
150
|
+
val color: Color? = null,
|
|
151
|
+
val typography: TypographyStyle? = null,
|
|
152
|
+
val fontSize: Float? = null,
|
|
153
|
+
val fontWeight: TextFontWeight? = null,
|
|
154
|
+
val fontStyle: TextFontStyle? = null,
|
|
155
|
+
val textAlign: TextAlignType? = null,
|
|
156
|
+
val textDecoration: TextDecorationType? = null,
|
|
157
|
+
val letterSpacing: Float? = null,
|
|
158
|
+
val lineHeight: Float? = null,
|
|
159
|
+
val overflow: TextOverflowType? = null,
|
|
160
|
+
val softWrap: Boolean? = null,
|
|
161
|
+
val maxLines: Int? = null,
|
|
162
|
+
val minLines: Int? = null,
|
|
163
|
+
val modifiers: ModifierList = emptyList()
|
|
164
|
+
) : ComposeProps
|
|
165
|
+
|
|
166
|
+
@Composable
|
|
167
|
+
fun FunctionalComposableScope.TextContent(props: TextProps) {
|
|
168
|
+
// Start with typography style if provided, otherwise use default
|
|
169
|
+
val baseStyle = props.typography?.toTextStyle() ?: TextStyle.Default
|
|
170
|
+
|
|
171
|
+
// Merge base style with custom properties
|
|
172
|
+
val mergedStyle = baseStyle.merge(
|
|
173
|
+
TextStyle(
|
|
174
|
+
fontSize = props.fontSize?.sp ?: androidx.compose.ui.unit.TextUnit.Unspecified,
|
|
175
|
+
fontWeight = props.fontWeight?.toComposeFontWeight(),
|
|
176
|
+
fontStyle = props.fontStyle?.toComposeFontStyle(),
|
|
177
|
+
textDecoration = props.textDecoration?.toComposeTextDecoration(),
|
|
178
|
+
letterSpacing = props.letterSpacing?.sp ?: androidx.compose.ui.unit.TextUnit.Unspecified,
|
|
179
|
+
lineHeight = props.lineHeight?.sp ?: androidx.compose.ui.unit.TextUnit.Unspecified
|
|
180
|
+
)
|
|
181
|
+
)
|
|
182
|
+
|
|
183
|
+
Text(
|
|
184
|
+
text = props.text,
|
|
185
|
+
modifier = ModifierRegistry.applyModifiers(props.modifiers, appContext, composableScope, globalEventDispatcher),
|
|
186
|
+
color = colorToComposeColor(props.color),
|
|
187
|
+
textAlign = props.textAlign?.toComposeTextAlign(),
|
|
188
|
+
overflow = props.overflow?.toComposeTextOverflow() ?: TextOverflow.Clip,
|
|
189
|
+
softWrap = props.softWrap ?: true,
|
|
190
|
+
maxLines = props.maxLines ?: Int.MAX_VALUE,
|
|
191
|
+
minLines = props.minLines ?: 1,
|
|
192
|
+
style = mergedStyle
|
|
193
|
+
)
|
|
194
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
@file:OptIn(ExperimentalMaterial3ExpressiveApi::class)
|
|
2
|
+
|
|
3
|
+
package expo.modules.ui
|
|
4
|
+
|
|
5
|
+
import android.graphics.Color
|
|
6
|
+
import androidx.compose.foundation.layout.RowScope
|
|
7
|
+
import androidx.compose.material3.ExperimentalMaterial3ExpressiveApi
|
|
8
|
+
import androidx.compose.material3.FilledIconToggleButton
|
|
9
|
+
import androidx.compose.material3.IconToggleButton
|
|
10
|
+
import androidx.compose.material3.OutlinedIconToggleButton
|
|
11
|
+
import androidx.compose.material3.Text
|
|
12
|
+
import androidx.compose.material3.ToggleButton
|
|
13
|
+
import androidx.compose.material3.ToggleButtonDefaults
|
|
14
|
+
import androidx.compose.runtime.Composable
|
|
15
|
+
import expo.modules.kotlin.records.Field
|
|
16
|
+
import expo.modules.kotlin.records.Record
|
|
17
|
+
import expo.modules.kotlin.views.ComposeProps
|
|
18
|
+
import expo.modules.kotlin.views.FunctionalComposableScope
|
|
19
|
+
|
|
20
|
+
data class ToggleButtonProps(
|
|
21
|
+
val checked: Boolean = false,
|
|
22
|
+
val text: String? = null,
|
|
23
|
+
val variant: String = "default",
|
|
24
|
+
val color: Color? = null,
|
|
25
|
+
val disabled: Boolean = false,
|
|
26
|
+
val modifiers: ModifierList = emptyList()
|
|
27
|
+
) : ComposeProps
|
|
28
|
+
|
|
29
|
+
data class ToggleButtonValueChangeEvent(
|
|
30
|
+
@Field val checked: Boolean = false
|
|
31
|
+
) : Record
|
|
32
|
+
|
|
33
|
+
@Composable
|
|
34
|
+
fun FunctionalComposableScope.ToggleButtonContent(
|
|
35
|
+
props: ToggleButtonProps,
|
|
36
|
+
onCheckedChange: (ToggleButtonValueChangeEvent) -> Unit
|
|
37
|
+
) {
|
|
38
|
+
val modifier = ModifierRegistry.applyModifiers(props.modifiers, appContext, composableScope, globalEventDispatcher)
|
|
39
|
+
|
|
40
|
+
val scope = this
|
|
41
|
+
|
|
42
|
+
val content: @Composable () -> Unit = {
|
|
43
|
+
when {
|
|
44
|
+
props.text != null -> Text(text = props.text)
|
|
45
|
+
else -> scope.Children(composableScope)
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// RowScope content for ToggleButton
|
|
50
|
+
val rowContent: @Composable RowScope.() -> Unit = {
|
|
51
|
+
when {
|
|
52
|
+
props.text != null -> Text(text = props.text)
|
|
53
|
+
else -> scope.Children(composableScope)
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
when (props.variant) {
|
|
58
|
+
"icon" -> {
|
|
59
|
+
IconToggleButton(
|
|
60
|
+
checked = props.checked,
|
|
61
|
+
onCheckedChange = { onCheckedChange(ToggleButtonValueChangeEvent(it)) },
|
|
62
|
+
enabled = !props.disabled,
|
|
63
|
+
modifier = modifier,
|
|
64
|
+
content = content
|
|
65
|
+
)
|
|
66
|
+
}
|
|
67
|
+
"filledIcon" -> {
|
|
68
|
+
FilledIconToggleButton(
|
|
69
|
+
checked = props.checked,
|
|
70
|
+
onCheckedChange = { onCheckedChange(ToggleButtonValueChangeEvent(it)) },
|
|
71
|
+
enabled = !props.disabled,
|
|
72
|
+
modifier = modifier,
|
|
73
|
+
content = content
|
|
74
|
+
)
|
|
75
|
+
}
|
|
76
|
+
"outlinedIcon" -> {
|
|
77
|
+
OutlinedIconToggleButton(
|
|
78
|
+
checked = props.checked,
|
|
79
|
+
onCheckedChange = { onCheckedChange(ToggleButtonValueChangeEvent(it)) },
|
|
80
|
+
enabled = !props.disabled,
|
|
81
|
+
modifier = modifier,
|
|
82
|
+
content = content
|
|
83
|
+
)
|
|
84
|
+
}
|
|
85
|
+
else -> {
|
|
86
|
+
ToggleButton(
|
|
87
|
+
checked = props.checked,
|
|
88
|
+
onCheckedChange = { onCheckedChange(ToggleButtonValueChangeEvent(it)) },
|
|
89
|
+
enabled = !props.disabled,
|
|
90
|
+
modifier = modifier,
|
|
91
|
+
colors = ToggleButtonDefaults.toggleButtonColors(),
|
|
92
|
+
content = rowContent
|
|
93
|
+
)
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
@@ -4,6 +4,8 @@ import android.graphics.Color
|
|
|
4
4
|
import android.os.Build
|
|
5
5
|
import android.util.Log
|
|
6
6
|
import androidx.compose.ui.graphics.vector.ImageVector
|
|
7
|
+
import expo.modules.kotlin.records.Field
|
|
8
|
+
import expo.modules.kotlin.records.Record
|
|
7
9
|
|
|
8
10
|
fun colorToComposeColorOrNull(color: Color?): androidx.compose.ui.graphics.Color? {
|
|
9
11
|
return color?.let {
|
|
@@ -39,3 +41,7 @@ fun getImageVector(icon: String?): ImageVector? {
|
|
|
39
41
|
return null
|
|
40
42
|
}
|
|
41
43
|
}
|
|
44
|
+
|
|
45
|
+
data class GenericEventPayload1<T>(
|
|
46
|
+
@Field val value: T
|
|
47
|
+
) : Record
|
|
@@ -174,7 +174,7 @@ fun FunctionalComposableScope.ButtonContent(
|
|
|
174
174
|
// Also fire the button pressed event
|
|
175
175
|
onButtonPressed(ButtonPressedEvent())
|
|
176
176
|
},
|
|
177
|
-
modifier = ModifierRegistry.applyModifiers(props.modifiers, appContext, composableScope),
|
|
177
|
+
modifier = ModifierRegistry.applyModifiers(props.modifiers, appContext, composableScope, globalEventDispatcher),
|
|
178
178
|
shape = shapeFromShapeRecord(props.shape)
|
|
179
179
|
) {
|
|
180
180
|
Row(verticalAlignment = Alignment.CenterVertically) {
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
package expo.modules.ui.button
|
|
2
2
|
|
|
3
|
-
import androidx.compose.foundation.layout.Box
|
|
4
|
-
import androidx.compose.foundation.layout.fillMaxSize
|
|
5
3
|
import androidx.compose.material3.ButtonDefaults
|
|
6
4
|
import androidx.compose.material3.FilledTonalIconButton
|
|
7
5
|
import androidx.compose.material3.IconButton
|
|
@@ -102,11 +100,9 @@ fun FunctionalComposableScope.IconButtonContent(
|
|
|
102
100
|
colors,
|
|
103
101
|
disabled ?: false,
|
|
104
102
|
onPress = { onButtonPressed(ButtonPressedEvent()) },
|
|
105
|
-
modifier = ModifierRegistry.applyModifiers(props.modifiers, appContext, composableScope),
|
|
103
|
+
modifier = ModifierRegistry.applyModifiers(props.modifiers, appContext, composableScope, globalEventDispatcher),
|
|
106
104
|
shape = shapeFromShapeRecord(props.shape)
|
|
107
105
|
) {
|
|
108
|
-
|
|
109
|
-
Children(ComposableScope())
|
|
110
|
-
}
|
|
106
|
+
Children(ComposableScope())
|
|
111
107
|
}
|
|
112
108
|
}
|