@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
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
package expo.modules.ui.convertibles
|
|
2
|
+
|
|
3
|
+
import androidx.compose.ui.Alignment
|
|
4
|
+
import expo.modules.kotlin.types.Enumerable
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Generic alignment type that for modifier.clip()
|
|
8
|
+
*/
|
|
9
|
+
enum class AlignmentType(val value: String) : Enumerable {
|
|
10
|
+
TOP_START("topStart"),
|
|
11
|
+
TOP_CENTER("topCenter"),
|
|
12
|
+
TOP_END("topEnd"),
|
|
13
|
+
CENTER_START("centerStart"),
|
|
14
|
+
CENTER("center"),
|
|
15
|
+
CENTER_END("centerEnd"),
|
|
16
|
+
BOTTOM_START("bottomStart"),
|
|
17
|
+
BOTTOM_CENTER("bottomCenter"),
|
|
18
|
+
BOTTOM_END("bottomEnd"),
|
|
19
|
+
TOP("top"),
|
|
20
|
+
CENTER_VERTICALLY("centerVertically"),
|
|
21
|
+
BOTTOM("bottom"),
|
|
22
|
+
START("start"),
|
|
23
|
+
CENTER_HORIZONTALLY("centerHorizontally"),
|
|
24
|
+
END("end");
|
|
25
|
+
|
|
26
|
+
fun toAlignment(): Alignment? {
|
|
27
|
+
return when (this) {
|
|
28
|
+
TOP_START -> Alignment.TopStart
|
|
29
|
+
TOP_CENTER -> Alignment.TopCenter
|
|
30
|
+
TOP_END -> Alignment.TopEnd
|
|
31
|
+
CENTER_START -> Alignment.CenterStart
|
|
32
|
+
CENTER -> Alignment.Center
|
|
33
|
+
CENTER_END -> Alignment.CenterEnd
|
|
34
|
+
BOTTOM_START -> Alignment.BottomStart
|
|
35
|
+
BOTTOM_CENTER -> Alignment.BottomCenter
|
|
36
|
+
BOTTOM_END -> Alignment.BottomEnd
|
|
37
|
+
else -> null
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
fun toVerticalAlignment(): Alignment.Vertical? {
|
|
42
|
+
return when (this) {
|
|
43
|
+
TOP -> Alignment.Top
|
|
44
|
+
CENTER_VERTICALLY -> Alignment.CenterVertically
|
|
45
|
+
BOTTOM -> Alignment.Bottom
|
|
46
|
+
else -> null
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
fun toHorizontalAlignment(): Alignment.Horizontal? {
|
|
51
|
+
return when (this) {
|
|
52
|
+
START -> Alignment.Start
|
|
53
|
+
CENTER_HORIZONTALLY -> Alignment.CenterHorizontally
|
|
54
|
+
END -> Alignment.End
|
|
55
|
+
else -> null
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
enum class HorizontalAlignment(val value: String) : Enumerable {
|
|
61
|
+
START("start"),
|
|
62
|
+
END("end"),
|
|
63
|
+
CENTER("center");
|
|
64
|
+
|
|
65
|
+
fun toComposeAlignment(): Alignment.Horizontal {
|
|
66
|
+
return when (this) {
|
|
67
|
+
START -> Alignment.Start
|
|
68
|
+
END -> Alignment.End
|
|
69
|
+
CENTER -> Alignment.CenterHorizontally
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
enum class VerticalAlignment(val value: String) : Enumerable {
|
|
75
|
+
TOP("top"),
|
|
76
|
+
BOTTOM("bottom"),
|
|
77
|
+
CENTER("center");
|
|
78
|
+
|
|
79
|
+
fun toComposeAlignment(): Alignment.Vertical {
|
|
80
|
+
return when (this) {
|
|
81
|
+
TOP -> Alignment.Top
|
|
82
|
+
BOTTOM -> Alignment.Bottom
|
|
83
|
+
CENTER -> Alignment.CenterVertically
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
enum class ContentAlignment(val value: String) : Enumerable {
|
|
89
|
+
TOP_START("topStart"),
|
|
90
|
+
TOP_CENTER("topCenter"),
|
|
91
|
+
TOP_END("topEnd"),
|
|
92
|
+
CENTER_START("centerStart"),
|
|
93
|
+
CENTER("center"),
|
|
94
|
+
CENTER_END("centerEnd"),
|
|
95
|
+
BOTTOM_START("bottomStart"),
|
|
96
|
+
BOTTOM_CENTER("bottomCenter"),
|
|
97
|
+
BOTTOM_END("bottomEnd");
|
|
98
|
+
|
|
99
|
+
fun toComposeAlignment(): Alignment {
|
|
100
|
+
return when (this) {
|
|
101
|
+
TOP_START -> Alignment.TopStart
|
|
102
|
+
TOP_CENTER -> Alignment.TopCenter
|
|
103
|
+
TOP_END -> Alignment.TopEnd
|
|
104
|
+
CENTER_START -> Alignment.CenterStart
|
|
105
|
+
CENTER -> Alignment.Center
|
|
106
|
+
CENTER_END -> Alignment.CenterEnd
|
|
107
|
+
BOTTOM_START -> Alignment.BottomStart
|
|
108
|
+
BOTTOM_CENTER -> Alignment.BottomCenter
|
|
109
|
+
BOTTOM_END -> Alignment.BottomEnd
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
package expo.modules.ui.convertibles
|
|
2
|
+
|
|
3
|
+
import androidx.compose.foundation.layout.Arrangement
|
|
4
|
+
import androidx.compose.ui.unit.dp
|
|
5
|
+
import expo.modules.kotlin.records.Field
|
|
6
|
+
import expo.modules.kotlin.records.Record
|
|
7
|
+
import expo.modules.kotlin.types.Either
|
|
8
|
+
import expo.modules.kotlin.types.Enumerable
|
|
9
|
+
|
|
10
|
+
typealias HorizontalArrangement = Either<HorizontalArrangementDefault, HorizontalArrangementCustom>
|
|
11
|
+
|
|
12
|
+
enum class HorizontalArrangementDefault(val value: String) : Enumerable {
|
|
13
|
+
START("start"),
|
|
14
|
+
END("end"),
|
|
15
|
+
CENTER("center"),
|
|
16
|
+
SPACE_BETWEEN("spaceBetween"),
|
|
17
|
+
SPACE_AROUND("spaceAround"),
|
|
18
|
+
SPACE_EVENLY("spaceEvenly");
|
|
19
|
+
|
|
20
|
+
fun toComposeArrangement(): Arrangement.Horizontal {
|
|
21
|
+
return when (this) {
|
|
22
|
+
START -> Arrangement.Start
|
|
23
|
+
END -> Arrangement.End
|
|
24
|
+
CENTER -> Arrangement.Center
|
|
25
|
+
SPACE_BETWEEN -> Arrangement.SpaceBetween
|
|
26
|
+
SPACE_AROUND -> Arrangement.SpaceAround
|
|
27
|
+
SPACE_EVENLY -> Arrangement.SpaceEvenly
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
data class HorizontalArrangementCustom(
|
|
33
|
+
@Field val spacedBy: Int? = null
|
|
34
|
+
) : Record
|
|
35
|
+
|
|
36
|
+
fun HorizontalArrangement.toComposeArrangement(): Arrangement.Horizontal =
|
|
37
|
+
when {
|
|
38
|
+
`is`(HorizontalArrangementDefault::class) -> first().toComposeArrangement()
|
|
39
|
+
else -> second().spacedBy?.let { Arrangement.spacedBy(it.dp) } ?: Arrangement.Start
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
typealias VerticalArrangement = Either<VerticalArrangementDefault, VerticalArrangementCustom>
|
|
43
|
+
|
|
44
|
+
enum class VerticalArrangementDefault(val value: String) : Enumerable {
|
|
45
|
+
TOP("top"),
|
|
46
|
+
BOTTOM("bottom"),
|
|
47
|
+
CENTER("center"),
|
|
48
|
+
SPACE_BETWEEN("spaceBetween"),
|
|
49
|
+
SPACE_AROUND("spaceAround"),
|
|
50
|
+
SPACE_EVENLY("spaceEvenly");
|
|
51
|
+
|
|
52
|
+
fun toComposeArrangement(): Arrangement.Vertical {
|
|
53
|
+
return when (this) {
|
|
54
|
+
TOP -> Arrangement.Top
|
|
55
|
+
BOTTOM -> Arrangement.Bottom
|
|
56
|
+
CENTER -> Arrangement.Center
|
|
57
|
+
SPACE_BETWEEN -> Arrangement.SpaceBetween
|
|
58
|
+
SPACE_AROUND -> Arrangement.SpaceAround
|
|
59
|
+
SPACE_EVENLY -> Arrangement.SpaceEvenly
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
data class VerticalArrangementCustom(
|
|
65
|
+
@Field val spacedBy: Int? = null
|
|
66
|
+
) : Record
|
|
67
|
+
|
|
68
|
+
fun VerticalArrangement.toComposeArrangement(): Arrangement.Vertical =
|
|
69
|
+
when {
|
|
70
|
+
`is`(VerticalArrangementDefault::class) -> first().toComposeArrangement()
|
|
71
|
+
else -> second().spacedBy?.let { Arrangement.spacedBy(it.dp) } ?: Arrangement.Top
|
|
72
|
+
}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
package expo.modules.ui.icon
|
|
2
|
+
|
|
3
|
+
import android.content.Context
|
|
4
|
+
import android.graphics.Color
|
|
5
|
+
import android.graphics.drawable.BitmapDrawable
|
|
6
|
+
import android.graphics.drawable.Drawable
|
|
7
|
+
import android.net.Uri
|
|
8
|
+
import androidx.compose.foundation.layout.size
|
|
9
|
+
import androidx.compose.material3.Icon
|
|
10
|
+
import androidx.compose.runtime.Composable
|
|
11
|
+
import androidx.compose.runtime.LaunchedEffect
|
|
12
|
+
import androidx.compose.runtime.MutableState
|
|
13
|
+
import androidx.compose.runtime.getValue
|
|
14
|
+
import androidx.compose.runtime.mutableStateOf
|
|
15
|
+
import androidx.compose.runtime.remember
|
|
16
|
+
import androidx.compose.runtime.setValue
|
|
17
|
+
import androidx.compose.ui.Modifier
|
|
18
|
+
import androidx.compose.ui.geometry.Size
|
|
19
|
+
import androidx.compose.ui.graphics.asImageBitmap
|
|
20
|
+
import androidx.compose.ui.graphics.drawscope.DrawScope
|
|
21
|
+
import androidx.compose.ui.graphics.drawscope.drawIntoCanvas
|
|
22
|
+
import androidx.compose.ui.graphics.nativeCanvas
|
|
23
|
+
import androidx.compose.ui.graphics.painter.BitmapPainter
|
|
24
|
+
import androidx.compose.ui.graphics.painter.Painter
|
|
25
|
+
import androidx.compose.ui.graphics.vector.ImageVector
|
|
26
|
+
import androidx.compose.ui.graphics.vector.rememberVectorPainter
|
|
27
|
+
import androidx.compose.ui.unit.dp
|
|
28
|
+
import expo.modules.kotlin.AppContext
|
|
29
|
+
import expo.modules.kotlin.records.Field
|
|
30
|
+
import expo.modules.kotlin.records.Record
|
|
31
|
+
import expo.modules.kotlin.views.ComposableScope
|
|
32
|
+
import expo.modules.kotlin.views.ComposeProps
|
|
33
|
+
import expo.modules.kotlin.views.ExpoComposeView
|
|
34
|
+
import expo.modules.ui.ExpoUIModule
|
|
35
|
+
import expo.modules.ui.ModifierList
|
|
36
|
+
import expo.modules.ui.ModifierRegistry
|
|
37
|
+
import expo.modules.ui.compose
|
|
38
|
+
|
|
39
|
+
data class Source(
|
|
40
|
+
@Field val uri: String,
|
|
41
|
+
@Field val width: Int = 0,
|
|
42
|
+
@Field val height: Int = 0,
|
|
43
|
+
@Field val scale: Double = 1.0
|
|
44
|
+
) : Record
|
|
45
|
+
|
|
46
|
+
data class IconProps(
|
|
47
|
+
val source: MutableState<Source?> = mutableStateOf(null),
|
|
48
|
+
val tintColor: MutableState<Color?> = mutableStateOf(null),
|
|
49
|
+
val size: MutableState<Int?> = mutableStateOf(null),
|
|
50
|
+
val contentDescription: MutableState<String?> = mutableStateOf(null),
|
|
51
|
+
val modifiers: MutableState<ModifierList> = mutableStateOf(emptyList())
|
|
52
|
+
) : ComposeProps
|
|
53
|
+
|
|
54
|
+
class IconView(context: Context, appContext: AppContext) :
|
|
55
|
+
ExpoComposeView<IconProps>(context, appContext) {
|
|
56
|
+
|
|
57
|
+
override val props = IconProps()
|
|
58
|
+
|
|
59
|
+
private val iconLoader by lazy {
|
|
60
|
+
val module = appContext.registry.getModule<ExpoUIModule>()
|
|
61
|
+
val okHttpClient = requireNotNull(module?.okHttpClient) { "ExpoUIModule.okHttpClient is not initialized" }
|
|
62
|
+
VectorIconLoader(
|
|
63
|
+
context = context,
|
|
64
|
+
okHttpClient = okHttpClient
|
|
65
|
+
)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
@Composable
|
|
69
|
+
override fun ComposableScope.Content() {
|
|
70
|
+
val (source) = props.source
|
|
71
|
+
val (tint) = props.tintColor
|
|
72
|
+
val (iconSize) = props.size
|
|
73
|
+
val (contentDescription) = props.contentDescription
|
|
74
|
+
val (modifiers) = props.modifiers
|
|
75
|
+
|
|
76
|
+
var imageVector by remember { mutableStateOf<ImageVector?>(null) }
|
|
77
|
+
var drawable by remember { mutableStateOf<Drawable?>(null) }
|
|
78
|
+
|
|
79
|
+
// Load icon from URI asynchronously
|
|
80
|
+
LaunchedEffect(source) {
|
|
81
|
+
imageVector = null
|
|
82
|
+
drawable = null
|
|
83
|
+
|
|
84
|
+
val uriString = source?.let { resolveUri(it) }
|
|
85
|
+
if (uriString != null) {
|
|
86
|
+
// loadFromUri is already a suspend function that handles dispatchers
|
|
87
|
+
val result = iconLoader.loadFromUri(uriString)
|
|
88
|
+
imageVector = result.imageVector
|
|
89
|
+
drawable = result.drawable
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// Convert to Painter (prioritize ImageVector over Drawable)
|
|
94
|
+
val painter = imageVector?.let { rememberVectorPainter(it) }
|
|
95
|
+
?: rememberDrawableAsPainter(drawable)
|
|
96
|
+
|
|
97
|
+
// Render icon if painter available
|
|
98
|
+
if (painter != null) {
|
|
99
|
+
Icon(
|
|
100
|
+
painter = painter,
|
|
101
|
+
contentDescription = contentDescription,
|
|
102
|
+
tint = tint?.compose ?: androidx.compose.ui.graphics.Color.Unspecified,
|
|
103
|
+
modifier = Modifier
|
|
104
|
+
.then(iconSize?.let { Modifier.size(it.dp) } ?: Modifier)
|
|
105
|
+
.then(ModifierRegistry.applyModifiers(modifiers, appContext, this@Content, globalEventDispatcher))
|
|
106
|
+
)
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Resolve Source to URI string, handling resource IDs and local resources.
|
|
112
|
+
*/
|
|
113
|
+
private fun resolveUri(source: Source): String? {
|
|
114
|
+
val stringUri = source.uri
|
|
115
|
+
return try {
|
|
116
|
+
val uri = Uri.parse(stringUri)
|
|
117
|
+
|
|
118
|
+
// If no scheme, try to resolve as local resource
|
|
119
|
+
if (uri.scheme == null) {
|
|
120
|
+
ResourceIdHelper.getResourceUri(context, stringUri)?.toString()
|
|
121
|
+
} else {
|
|
122
|
+
stringUri
|
|
123
|
+
}
|
|
124
|
+
} catch (e: Exception) {
|
|
125
|
+
// Fallback to resource ID helper
|
|
126
|
+
ResourceIdHelper.getResourceUri(context, stringUri)?.toString()
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
@Composable
|
|
131
|
+
private fun rememberDrawableAsPainter(drawable: Drawable?): Painter? {
|
|
132
|
+
return remember(drawable) {
|
|
133
|
+
when (drawable) {
|
|
134
|
+
null -> null
|
|
135
|
+
is BitmapDrawable -> BitmapPainter(drawable.bitmap.asImageBitmap())
|
|
136
|
+
else -> DrawablePainter(drawable.mutate())
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
private class DrawablePainter(
|
|
142
|
+
private val drawable: Drawable
|
|
143
|
+
) : Painter() {
|
|
144
|
+
override val intrinsicSize: Size
|
|
145
|
+
get() = Size(
|
|
146
|
+
drawable.intrinsicWidth.toFloat().takeIf { it > 0 } ?: Size.Unspecified.width,
|
|
147
|
+
drawable.intrinsicHeight.toFloat().takeIf { it > 0 } ?: Size.Unspecified.height
|
|
148
|
+
)
|
|
149
|
+
|
|
150
|
+
override fun DrawScope.onDraw() {
|
|
151
|
+
drawIntoCanvas { canvas ->
|
|
152
|
+
with(drawable) {
|
|
153
|
+
setBounds(0, 0, size.width.toInt(), size.height.toInt())
|
|
154
|
+
draw(canvas.nativeCanvas)
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
package expo.modules.ui.icon
|
|
2
|
+
|
|
3
|
+
import android.annotation.SuppressLint
|
|
4
|
+
import android.content.Context
|
|
5
|
+
import android.net.Uri
|
|
6
|
+
import com.facebook.react.views.imagehelper.ResourceDrawableIdHelper
|
|
7
|
+
import java.util.Locale
|
|
8
|
+
|
|
9
|
+
internal object ResourceIdHelper {
|
|
10
|
+
private val idMap = mutableMapOf<String, Int>()
|
|
11
|
+
|
|
12
|
+
@SuppressLint("DiscouragedApi")
|
|
13
|
+
private fun getResourceRawId(context: Context, name: String): Int {
|
|
14
|
+
if (name.isEmpty()) {
|
|
15
|
+
return -1
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
val normalizedName = name.lowercase(Locale.ROOT).replace("-", "_")
|
|
19
|
+
synchronized(this) {
|
|
20
|
+
val id = idMap[normalizedName]
|
|
21
|
+
if (id != null) {
|
|
22
|
+
return id
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return context
|
|
26
|
+
.resources
|
|
27
|
+
.getIdentifier(normalizedName, "raw", context.packageName)
|
|
28
|
+
.also {
|
|
29
|
+
idMap[normalizedName] = it
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
fun getResourceUri(context: Context, name: String): Uri? {
|
|
35
|
+
val drawableUri = ResourceDrawableIdHelper.getResourceDrawableUri(context, name)
|
|
36
|
+
if (drawableUri != Uri.EMPTY) {
|
|
37
|
+
return drawableUri
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
val resId = getResourceRawId(context, name)
|
|
41
|
+
return if (resId > 0) {
|
|
42
|
+
Uri.Builder().scheme("res").path(resId.toString()).build()
|
|
43
|
+
} else {
|
|
44
|
+
null
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|