@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
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
@file:OptIn(ExperimentalMaterial3ExpressiveApi::class)
|
|
2
|
+
|
|
1
3
|
package expo.modules.ui
|
|
2
4
|
|
|
3
5
|
import android.graphics.Color
|
|
@@ -11,26 +13,41 @@ import androidx.compose.foundation.clickable
|
|
|
11
13
|
import androidx.compose.foundation.layout.fillMaxHeight
|
|
12
14
|
import androidx.compose.foundation.layout.fillMaxSize
|
|
13
15
|
import androidx.compose.foundation.layout.fillMaxWidth
|
|
16
|
+
import androidx.compose.foundation.layout.height
|
|
14
17
|
import androidx.compose.foundation.layout.offset
|
|
15
18
|
import androidx.compose.foundation.layout.padding
|
|
16
19
|
import androidx.compose.foundation.layout.size
|
|
20
|
+
import androidx.compose.foundation.layout.width
|
|
21
|
+
import androidx.compose.foundation.layout.wrapContentHeight
|
|
22
|
+
import androidx.compose.foundation.layout.wrapContentWidth
|
|
23
|
+
import androidx.compose.foundation.selection.selectable
|
|
24
|
+
import androidx.compose.foundation.shape.CircleShape
|
|
25
|
+
import androidx.compose.foundation.shape.CutCornerShape
|
|
26
|
+
import androidx.compose.foundation.shape.RoundedCornerShape
|
|
27
|
+
import androidx.compose.material3.ExperimentalMaterial3ExpressiveApi
|
|
28
|
+
import androidx.compose.material3.toShape
|
|
29
|
+
import androidx.compose.runtime.Composable
|
|
17
30
|
import androidx.compose.ui.Modifier
|
|
18
31
|
import androidx.compose.ui.draw.alpha
|
|
19
32
|
import androidx.compose.ui.draw.blur
|
|
20
33
|
import androidx.compose.ui.draw.clip
|
|
21
34
|
import androidx.compose.ui.draw.rotate
|
|
22
35
|
import androidx.compose.ui.draw.shadow
|
|
36
|
+
import androidx.compose.ui.graphics.RectangleShape
|
|
23
37
|
import androidx.compose.ui.unit.dp
|
|
24
38
|
import androidx.compose.ui.zIndex
|
|
25
39
|
import expo.modules.kotlin.AppContext
|
|
26
40
|
import expo.modules.kotlin.records.Field
|
|
27
41
|
import expo.modules.kotlin.records.Record
|
|
28
42
|
import expo.modules.kotlin.records.recordFromMap
|
|
43
|
+
import expo.modules.kotlin.types.Enumerable
|
|
29
44
|
import expo.modules.kotlin.views.ComposableScope
|
|
45
|
+
import expo.modules.ui.convertibles.AlignmentType
|
|
30
46
|
|
|
31
47
|
typealias ModifierType = Map<String, Any?>
|
|
32
48
|
typealias ModifierList = List<ModifierType>
|
|
33
|
-
typealias
|
|
49
|
+
typealias ModifierEventDispatcher = (String, Map<String, Any?>) -> Unit
|
|
50
|
+
typealias ModifierFactory = @Composable (ModifierType, ComposableScope?, AppContext?, ModifierEventDispatcher) -> Modifier
|
|
34
51
|
|
|
35
52
|
// region Modifier Params
|
|
36
53
|
|
|
@@ -62,6 +79,22 @@ internal data class FillMaxHeightParams(
|
|
|
62
79
|
@Field val fraction: Float = 1.0f
|
|
63
80
|
) : Record
|
|
64
81
|
|
|
82
|
+
internal data class WidthParams(
|
|
83
|
+
@Field val width: Int = 0
|
|
84
|
+
) : Record
|
|
85
|
+
|
|
86
|
+
internal data class HeightParams(
|
|
87
|
+
@Field val height: Int = 0
|
|
88
|
+
) : Record
|
|
89
|
+
|
|
90
|
+
internal data class WrapContentWidthParams(
|
|
91
|
+
@Field val alignment: AlignmentType? = null
|
|
92
|
+
) : Record
|
|
93
|
+
|
|
94
|
+
internal data class WrapContentHeightParams(
|
|
95
|
+
@Field val alignment: AlignmentType? = null
|
|
96
|
+
) : Record
|
|
97
|
+
|
|
65
98
|
internal data class OffsetParams(
|
|
66
99
|
@Field val x: Int = 0,
|
|
67
100
|
@Field val y: Int = 0
|
|
@@ -105,12 +138,38 @@ internal data class WeightParams(
|
|
|
105
138
|
@Field val weight: Float = 1f
|
|
106
139
|
) : Record
|
|
107
140
|
|
|
141
|
+
internal data class AlignParams(
|
|
142
|
+
@Field val alignment: AlignmentType? = null
|
|
143
|
+
) : Record
|
|
144
|
+
|
|
108
145
|
internal data class TestIDParams(
|
|
109
146
|
@Field val testID: String? = null
|
|
110
147
|
) : Record
|
|
111
148
|
|
|
149
|
+
internal enum class BuiltinShapeType(val value: String) : Enumerable {
|
|
150
|
+
RECTANGLE("rectangle"),
|
|
151
|
+
CIRCLE("circle"),
|
|
152
|
+
ROUNDED_CORNER("roundedCorner"),
|
|
153
|
+
CUT_CORNER("cutCorner"),
|
|
154
|
+
MATERIAL("material")
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
internal data class BuiltinShapeRecord(
|
|
158
|
+
@Field val type: BuiltinShapeType = BuiltinShapeType.RECTANGLE,
|
|
159
|
+
@Field val radius: Float? = null,
|
|
160
|
+
@Field val topStart: Float? = null,
|
|
161
|
+
@Field val topEnd: Float? = null,
|
|
162
|
+
@Field val bottomStart: Float? = null,
|
|
163
|
+
@Field val bottomEnd: Float? = null,
|
|
164
|
+
@Field val name: MaterialShapeType? = null
|
|
165
|
+
) : Record
|
|
166
|
+
|
|
112
167
|
internal data class ClipParams(
|
|
113
|
-
@Field val shape:
|
|
168
|
+
@Field val shape: BuiltinShapeRecord? = null
|
|
169
|
+
) : Record
|
|
170
|
+
|
|
171
|
+
internal data class SelectableParams(
|
|
172
|
+
@Field val selected: Boolean = false
|
|
114
173
|
) : Record
|
|
115
174
|
|
|
116
175
|
// endregion
|
|
@@ -124,7 +183,7 @@ internal data class ClipParams(
|
|
|
124
183
|
*
|
|
125
184
|
* Usage in Native:
|
|
126
185
|
* ```kotlin
|
|
127
|
-
* modifier = ModifierRegistry.applyModifiers(props.modifiers, appContext, composableScope)
|
|
186
|
+
* modifier = ModifierRegistry.applyModifiers(props.modifiers, appContext, composableScope, globalEventDispatcher)
|
|
128
187
|
* ```
|
|
129
188
|
* ```
|
|
130
189
|
*/
|
|
@@ -150,15 +209,17 @@ object ModifierRegistry {
|
|
|
150
209
|
/**
|
|
151
210
|
* Applies an array of modifier configs to build a Compose Modifier chain.
|
|
152
211
|
*/
|
|
212
|
+
@Composable
|
|
153
213
|
fun applyModifiers(
|
|
154
214
|
modifiers: List<ModifierType>?,
|
|
155
215
|
appContext: AppContext,
|
|
156
|
-
scope: ComposableScope
|
|
216
|
+
scope: ComposableScope,
|
|
217
|
+
eventDispatcher: ModifierEventDispatcher
|
|
157
218
|
): Modifier {
|
|
158
219
|
if (modifiers.isNullOrEmpty()) return Modifier
|
|
159
220
|
return modifiers.fold(Modifier as Modifier) { acc, config ->
|
|
160
221
|
val type = config["\$type"] as? String ?: return@fold acc
|
|
161
|
-
val modifier = modifierFactories[type]?.invoke(config, scope, appContext) ?: Modifier
|
|
222
|
+
val modifier = modifierFactories[type]?.invoke(config, scope, appContext, eventDispatcher) ?: Modifier
|
|
162
223
|
acc.then(modifier)
|
|
163
224
|
}
|
|
164
225
|
}
|
|
@@ -179,12 +240,12 @@ object ModifierRegistry {
|
|
|
179
240
|
|
|
180
241
|
private fun registerBuiltInModifiers() {
|
|
181
242
|
// Padding modifiers
|
|
182
|
-
register("paddingAll") { map, _, _ ->
|
|
243
|
+
register("paddingAll") { map, _, _, _ ->
|
|
183
244
|
val params = recordFromMap<PaddingAllParams>(map)
|
|
184
245
|
Modifier.padding(params.all.dp)
|
|
185
246
|
}
|
|
186
247
|
|
|
187
|
-
register("padding") { map, _, _ ->
|
|
248
|
+
register("padding") { map, _, _, _ ->
|
|
188
249
|
val params = recordFromMap<PaddingParams>(map)
|
|
189
250
|
Modifier.padding(
|
|
190
251
|
params.start.dp,
|
|
@@ -195,75 +256,99 @@ object ModifierRegistry {
|
|
|
195
256
|
}
|
|
196
257
|
|
|
197
258
|
// Size modifiers
|
|
198
|
-
register("size") { map, _, _ ->
|
|
259
|
+
register("size") { map, _, _, _ ->
|
|
199
260
|
val params = recordFromMap<SizeParams>(map)
|
|
200
261
|
Modifier.size(params.width.dp, params.height.dp)
|
|
201
262
|
}
|
|
202
263
|
|
|
203
|
-
register("fillMaxSize") { map, _, _ ->
|
|
264
|
+
register("fillMaxSize") { map, _, _, _ ->
|
|
204
265
|
val params = recordFromMap<FillMaxSizeParams>(map)
|
|
205
266
|
Modifier.fillMaxSize(fraction = params.fraction)
|
|
206
267
|
}
|
|
207
268
|
|
|
208
|
-
register("fillMaxWidth") { map, _, _ ->
|
|
269
|
+
register("fillMaxWidth") { map, _, _, _ ->
|
|
209
270
|
val params = recordFromMap<FillMaxWidthParams>(map)
|
|
210
271
|
Modifier.fillMaxWidth(fraction = params.fraction)
|
|
211
272
|
}
|
|
212
273
|
|
|
213
|
-
register("fillMaxHeight") { map, _, _ ->
|
|
274
|
+
register("fillMaxHeight") { map, _, _, _ ->
|
|
214
275
|
val params = recordFromMap<FillMaxHeightParams>(map)
|
|
215
276
|
Modifier.fillMaxHeight(fraction = params.fraction)
|
|
216
277
|
}
|
|
217
278
|
|
|
279
|
+
register("width") { map, _, _, _ ->
|
|
280
|
+
val params = recordFromMap<WidthParams>(map)
|
|
281
|
+
Modifier.width(params.width.dp)
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
register("height") { map, _, _, _ ->
|
|
285
|
+
val params = recordFromMap<HeightParams>(map)
|
|
286
|
+
Modifier.height(params.height.dp)
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
register("wrapContentWidth") { map, _, _, _ ->
|
|
290
|
+
val params = recordFromMap<WrapContentWidthParams>(map)
|
|
291
|
+
params.alignment?.toHorizontalAlignment()?.let { alignment ->
|
|
292
|
+
Modifier.wrapContentWidth(align = alignment)
|
|
293
|
+
} ?: Modifier.wrapContentWidth()
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
register("wrapContentHeight") { map, _, _, _ ->
|
|
297
|
+
val params = recordFromMap<WrapContentHeightParams>(map)
|
|
298
|
+
params.alignment?.toVerticalAlignment()?.let { alignment ->
|
|
299
|
+
Modifier.wrapContentHeight(align = alignment)
|
|
300
|
+
} ?: Modifier.wrapContentHeight()
|
|
301
|
+
}
|
|
302
|
+
|
|
218
303
|
// Position modifiers
|
|
219
|
-
register("offset") { map, _, _ ->
|
|
304
|
+
register("offset") { map, _, _, _ ->
|
|
220
305
|
val params = recordFromMap<OffsetParams>(map)
|
|
221
306
|
Modifier.offset(params.x.dp, params.y.dp)
|
|
222
307
|
}
|
|
223
308
|
|
|
224
309
|
// Appearance modifiers
|
|
225
|
-
register("background") { map, _, _ ->
|
|
310
|
+
register("background") { map, _, _, _ ->
|
|
226
311
|
val params = recordFromMap<BackgroundParams>(map)
|
|
227
312
|
params.color?.let { color ->
|
|
228
313
|
Modifier.background(color.compose)
|
|
229
314
|
} ?: Modifier
|
|
230
315
|
}
|
|
231
316
|
|
|
232
|
-
register("border") { map, _, _ ->
|
|
317
|
+
register("border") { map, _, _, _ ->
|
|
233
318
|
val params = recordFromMap<BorderParams>(map)
|
|
234
319
|
params.borderColor?.let { borderColor ->
|
|
235
320
|
Modifier.border(BorderStroke(params.borderWidth.dp, borderColor.compose))
|
|
236
321
|
} ?: Modifier
|
|
237
322
|
}
|
|
238
323
|
|
|
239
|
-
register("shadow") { map, _, _ ->
|
|
324
|
+
register("shadow") { map, _, _, _ ->
|
|
240
325
|
val params = recordFromMap<ShadowParams>(map)
|
|
241
326
|
Modifier.shadow(params.elevation.dp)
|
|
242
327
|
}
|
|
243
328
|
|
|
244
|
-
register("alpha") { map, _, _ ->
|
|
329
|
+
register("alpha") { map, _, _, _ ->
|
|
245
330
|
val params = recordFromMap<AlphaParams>(map)
|
|
246
331
|
Modifier.alpha(params.alpha)
|
|
247
332
|
}
|
|
248
333
|
|
|
249
|
-
register("blur") { map, _, _ ->
|
|
334
|
+
register("blur") { map, _, _, _ ->
|
|
250
335
|
val params = recordFromMap<BlurParams>(map)
|
|
251
336
|
Modifier.blur(params.radius.dp)
|
|
252
337
|
}
|
|
253
338
|
|
|
254
339
|
// Transform modifiers
|
|
255
|
-
register("rotate") { map, _, _ ->
|
|
340
|
+
register("rotate") { map, _, _, _ ->
|
|
256
341
|
val params = recordFromMap<RotateParams>(map)
|
|
257
342
|
Modifier.rotate(params.degrees)
|
|
258
343
|
}
|
|
259
344
|
|
|
260
|
-
register("zIndex") { map, _, _ ->
|
|
345
|
+
register("zIndex") { map, _, _, _ ->
|
|
261
346
|
val params = recordFromMap<ZIndexParams>(map)
|
|
262
347
|
Modifier.zIndex(params.index)
|
|
263
348
|
}
|
|
264
349
|
|
|
265
350
|
// Animation modifiers
|
|
266
|
-
register("animateContentSize") { map, _, _ ->
|
|
351
|
+
register("animateContentSize") { map, _, _, _ ->
|
|
267
352
|
val params = recordFromMap<AnimateContentSizeParams>(map)
|
|
268
353
|
Modifier.animateContentSize(
|
|
269
354
|
spring(dampingRatio = params.dampingRatio, stiffness = params.stiffness)
|
|
@@ -271,7 +356,7 @@ object ModifierRegistry {
|
|
|
271
356
|
}
|
|
272
357
|
|
|
273
358
|
// Scope-dependent modifiers
|
|
274
|
-
register("weight") { map, scope, _ ->
|
|
359
|
+
register("weight") { map, scope, _, _ ->
|
|
275
360
|
val params = recordFromMap<WeightParams>(map)
|
|
276
361
|
scope?.rowScope?.run {
|
|
277
362
|
Modifier.weight(params.weight)
|
|
@@ -280,32 +365,85 @@ object ModifierRegistry {
|
|
|
280
365
|
} ?: Modifier
|
|
281
366
|
}
|
|
282
367
|
|
|
283
|
-
register("
|
|
368
|
+
register("align") { map, scope, _, _ ->
|
|
369
|
+
val params = recordFromMap<AlignParams>(map)
|
|
370
|
+
scope?.boxScope?.run {
|
|
371
|
+
params.alignment?.toAlignment()?.let { alignment -> Modifier.align(alignment) }
|
|
372
|
+
} ?: scope?.rowScope?.run {
|
|
373
|
+
params.alignment?.toVerticalAlignment()?.let { alignment -> Modifier.align(alignment) }
|
|
374
|
+
} ?: scope?.columnScope?.run {
|
|
375
|
+
params.alignment?.toHorizontalAlignment()?.let { alignment -> Modifier.align(alignment) }
|
|
376
|
+
} ?: Modifier
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
register("matchParentSize") { _, scope, _, _ ->
|
|
284
380
|
scope?.boxScope?.run {
|
|
285
381
|
Modifier.matchParentSize()
|
|
286
382
|
} ?: Modifier
|
|
287
383
|
}
|
|
288
384
|
|
|
289
385
|
// Utility modifiers
|
|
290
|
-
register("testID") { map, _, _ ->
|
|
386
|
+
register("testID") { map, _, _, _ ->
|
|
291
387
|
val params = recordFromMap<TestIDParams>(map)
|
|
292
388
|
params.testID?.let { testID ->
|
|
293
389
|
Modifier.applyTestTag(testID)
|
|
294
390
|
} ?: Modifier
|
|
295
391
|
}
|
|
296
392
|
|
|
297
|
-
register("clip") { map, _, _ ->
|
|
393
|
+
register("clip") { map, _, _, _ ->
|
|
298
394
|
val params = recordFromMap<ClipParams>(map)
|
|
299
|
-
params.shape?.let {
|
|
300
|
-
|
|
301
|
-
|
|
395
|
+
params.shape?.let { shape ->
|
|
396
|
+
val composeShape = when (shape.type) {
|
|
397
|
+
BuiltinShapeType.RECTANGLE -> RectangleShape
|
|
398
|
+
BuiltinShapeType.CIRCLE -> CircleShape
|
|
399
|
+
BuiltinShapeType.ROUNDED_CORNER -> {
|
|
400
|
+
val hasPerCorner = shape.topStart != null || shape.topEnd != null || shape.bottomStart != null || shape.bottomEnd != null
|
|
401
|
+
if (hasPerCorner) {
|
|
402
|
+
RoundedCornerShape(
|
|
403
|
+
topStart = (shape.topStart ?: 0f).dp,
|
|
404
|
+
topEnd = (shape.topEnd ?: 0f).dp,
|
|
405
|
+
bottomStart = (shape.bottomStart ?: 0f).dp,
|
|
406
|
+
bottomEnd = (shape.bottomEnd ?: 0f).dp
|
|
407
|
+
)
|
|
408
|
+
} else {
|
|
409
|
+
RoundedCornerShape((shape.radius ?: 0f).dp)
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
BuiltinShapeType.CUT_CORNER -> {
|
|
413
|
+
val hasPerCorner = shape.topStart != null || shape.topEnd != null || shape.bottomStart != null || shape.bottomEnd != null
|
|
414
|
+
if (hasPerCorner) {
|
|
415
|
+
CutCornerShape(
|
|
416
|
+
topStart = (shape.topStart ?: 0f).dp,
|
|
417
|
+
topEnd = (shape.topEnd ?: 0f).dp,
|
|
418
|
+
bottomStart = (shape.bottomStart ?: 0f).dp,
|
|
419
|
+
bottomEnd = (shape.bottomEnd ?: 0f).dp
|
|
420
|
+
)
|
|
421
|
+
} else {
|
|
422
|
+
CutCornerShape((shape.radius ?: 0f).dp)
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
BuiltinShapeType.MATERIAL -> {
|
|
426
|
+
shape.name?.toRoundedPolygon()?.toShape()
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
composeShape?.let {
|
|
430
|
+
Modifier.clip(it)
|
|
302
431
|
}
|
|
303
432
|
} ?: Modifier
|
|
304
433
|
}
|
|
305
434
|
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
435
|
+
register("clickable") { _, _, _, eventDispatcher ->
|
|
436
|
+
Modifier.clickable {
|
|
437
|
+
eventDispatcher("clickable", emptyMap())
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
register("selectable") { map, _, _, eventDispatcher ->
|
|
442
|
+
val params = recordFromMap<SelectableParams>(map)
|
|
443
|
+
Modifier.selectable(
|
|
444
|
+
selected = params.selected,
|
|
445
|
+
onClick = { eventDispatcher("selectable", emptyMap()) }
|
|
446
|
+
)
|
|
309
447
|
}
|
|
310
448
|
}
|
|
311
449
|
}
|
|
@@ -88,7 +88,7 @@ fun FunctionalComposableScope.PickerContent(
|
|
|
88
88
|
@Composable
|
|
89
89
|
fun SegmentedComposable() {
|
|
90
90
|
SingleChoiceSegmentedButtonRow(
|
|
91
|
-
modifier = ModifierRegistry.applyModifiers(props.modifiers, appContext, composableScope)
|
|
91
|
+
modifier = ModifierRegistry.applyModifiers(props.modifiers, appContext, composableScope, globalEventDispatcher)
|
|
92
92
|
) {
|
|
93
93
|
options.forEachIndexed { index, label ->
|
|
94
94
|
SegmentedButton(
|
|
@@ -99,7 +99,7 @@ fun FunctionalComposableScope.PickerContent(
|
|
|
99
99
|
onClick = {
|
|
100
100
|
onOptionSelected(PickerOptionSelectedEvent(index, label))
|
|
101
101
|
},
|
|
102
|
-
modifier = ModifierRegistry.applyModifiers(props.modifiers, appContext, composableScope),
|
|
102
|
+
modifier = ModifierRegistry.applyModifiers(props.modifiers, appContext, composableScope, globalEventDispatcher),
|
|
103
103
|
selected = index == selectedIndex,
|
|
104
104
|
label = { Text(label) },
|
|
105
105
|
colors = SegmentedButtonDefaults.colors(
|
|
@@ -41,7 +41,7 @@ fun FunctionalComposableScope.ProgressContent(props: ProgressProps) {
|
|
|
41
41
|
val progress = props.progress
|
|
42
42
|
val color = props.color
|
|
43
43
|
val colors = props.elementColors
|
|
44
|
-
val modifier = ModifierRegistry.applyModifiers(props.modifiers, appContext, composableScope)
|
|
44
|
+
val modifier = ModifierRegistry.applyModifiers(props.modifiers, appContext, composableScope, globalEventDispatcher)
|
|
45
45
|
|
|
46
46
|
when (props.variant) {
|
|
47
47
|
ProgressVariant.LINEAR -> {
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
@file:OptIn(ExperimentalMaterial3ExpressiveApi::class)
|
|
2
|
+
|
|
3
|
+
package expo.modules.ui
|
|
4
|
+
|
|
5
|
+
import androidx.compose.material3.ExperimentalMaterial3ExpressiveApi
|
|
6
|
+
import androidx.compose.material3.pulltorefresh.PullToRefreshBox
|
|
7
|
+
import androidx.compose.material3.pulltorefresh.PullToRefreshDefaults
|
|
8
|
+
import androidx.compose.material3.pulltorefresh.rememberPullToRefreshState
|
|
9
|
+
import androidx.compose.runtime.Composable
|
|
10
|
+
import expo.modules.kotlin.views.ComposableScope
|
|
11
|
+
import expo.modules.kotlin.views.ComposeProps
|
|
12
|
+
import expo.modules.kotlin.views.FunctionalComposableScope
|
|
13
|
+
|
|
14
|
+
data class PullToRefreshBoxProps(
|
|
15
|
+
val isRefreshing: Boolean = false,
|
|
16
|
+
val modifiers: ModifierList = emptyList(),
|
|
17
|
+
val loadingIndicatorModifiers: ModifierList = emptyList()
|
|
18
|
+
) : ComposeProps
|
|
19
|
+
|
|
20
|
+
@Composable
|
|
21
|
+
fun FunctionalComposableScope.PullToRefreshBoxContent(props: PullToRefreshBoxProps, onRefresh: () -> Unit) {
|
|
22
|
+
val isRefreshing = props.isRefreshing
|
|
23
|
+
val pullToRefreshState = rememberPullToRefreshState()
|
|
24
|
+
|
|
25
|
+
PullToRefreshBox(
|
|
26
|
+
isRefreshing = isRefreshing,
|
|
27
|
+
onRefresh = { onRefresh() },
|
|
28
|
+
state = pullToRefreshState,
|
|
29
|
+
indicator = {
|
|
30
|
+
PullToRefreshDefaults.LoadingIndicator(
|
|
31
|
+
isRefreshing = isRefreshing,
|
|
32
|
+
state = pullToRefreshState,
|
|
33
|
+
modifier = ModifierRegistry.applyModifiers(props.loadingIndicatorModifiers, appContext, composableScope, globalEventDispatcher)
|
|
34
|
+
)
|
|
35
|
+
},
|
|
36
|
+
modifier = ModifierRegistry.applyModifiers(props.modifiers, appContext, composableScope, globalEventDispatcher)
|
|
37
|
+
) {
|
|
38
|
+
Children(ComposableScope())
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
package expo.modules.ui
|
|
2
|
+
|
|
3
|
+
import android.annotation.SuppressLint
|
|
4
|
+
import android.content.Context
|
|
5
|
+
import android.view.View
|
|
6
|
+
import android.view.ViewGroup
|
|
7
|
+
import androidx.compose.foundation.rememberScrollState
|
|
8
|
+
import androidx.compose.foundation.verticalScroll
|
|
9
|
+
import androidx.compose.runtime.Composable
|
|
10
|
+
import androidx.compose.runtime.MutableState
|
|
11
|
+
import androidx.compose.runtime.mutableStateOf
|
|
12
|
+
import androidx.compose.ui.Modifier
|
|
13
|
+
import androidx.compose.ui.viewinterop.AndroidView
|
|
14
|
+
import com.facebook.react.ReactRootView
|
|
15
|
+
import expo.modules.kotlin.AppContext
|
|
16
|
+
import expo.modules.kotlin.views.ComposableScope
|
|
17
|
+
import expo.modules.kotlin.views.ComposeProps
|
|
18
|
+
import expo.modules.kotlin.views.ExpoComposeView
|
|
19
|
+
import expo.modules.kotlin.views.RNHostViewInterface
|
|
20
|
+
import expo.modules.kotlin.views.ShadowNodeProxy
|
|
21
|
+
import java.lang.ref.WeakReference
|
|
22
|
+
|
|
23
|
+
internal data class RNHostProps(
|
|
24
|
+
val matchContents: MutableState<Boolean?> = mutableStateOf(null),
|
|
25
|
+
val verticalScrollEnabled: MutableState<Boolean?> = mutableStateOf(null),
|
|
26
|
+
val modifiers: MutableState<ModifierList> = mutableStateOf(emptyList())
|
|
27
|
+
) : ComposeProps
|
|
28
|
+
|
|
29
|
+
@SuppressLint("ViewConstructor")
|
|
30
|
+
internal class RNHostView(context: Context, appContext: AppContext) :
|
|
31
|
+
ExpoComposeView<RNHostProps>(context, appContext), RNHostViewInterface {
|
|
32
|
+
override val props = RNHostProps()
|
|
33
|
+
override var matchContents: Boolean = false
|
|
34
|
+
get() = props.matchContents.value ?: false
|
|
35
|
+
|
|
36
|
+
private val container = RNHostContainerView(context, WeakReference(shadowNodeProxy))
|
|
37
|
+
|
|
38
|
+
@Composable
|
|
39
|
+
override fun ComposableScope.Content() {
|
|
40
|
+
val (verticalScrollEnabled) = props.verticalScrollEnabled
|
|
41
|
+
val (modifiers) = props.modifiers
|
|
42
|
+
|
|
43
|
+
AndroidView(
|
|
44
|
+
factory = {
|
|
45
|
+
container
|
|
46
|
+
},
|
|
47
|
+
modifier = ModifierRegistry.applyModifiers(modifiers, appContext, this@Content, globalEventDispatcher)
|
|
48
|
+
.then(if (verticalScrollEnabled == true) Modifier.verticalScroll(rememberScrollState()) else Modifier)
|
|
49
|
+
)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
override fun addView(child: View, index: Int, params: ViewGroup.LayoutParams) {
|
|
53
|
+
container.addView(child, index, params)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
|
|
57
|
+
super.onMeasure(widthMeasureSpec, heightMeasureSpec)
|
|
58
|
+
container.measure(widthMeasureSpec, heightMeasureSpec)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
override fun onLayout(
|
|
62
|
+
changed: Boolean,
|
|
63
|
+
left: Int,
|
|
64
|
+
top: Int,
|
|
65
|
+
right: Int,
|
|
66
|
+
bottom: Int
|
|
67
|
+
) {
|
|
68
|
+
super.onLayout(changed, left, top, right, bottom)
|
|
69
|
+
val offsetX = paddingLeft
|
|
70
|
+
val offsetY = paddingRight
|
|
71
|
+
container.layout(offsetX, offsetY, offsetX + width, offsetY + height)
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
internal class RNHostContainerView(context: Context, private val shadowNodeProxy: WeakReference<ShadowNodeProxy>) : ReactRootView(context) {
|
|
76
|
+
var matchContents = false
|
|
77
|
+
|
|
78
|
+
override fun onLayout(changed: Boolean, left: Int, top: Int, right: Int, bottom: Int) {
|
|
79
|
+
super.onLayout(changed, left, top, right, bottom)
|
|
80
|
+
if (matchContents && childCount > 1) {
|
|
81
|
+
val subview = getChildAt(0)
|
|
82
|
+
shadowNodeProxy.get()?.setViewSize(subview.width.toDouble(), subview.height.toDouble())
|
|
83
|
+
} else {
|
|
84
|
+
shadowNodeProxy.get()?.setViewSize(width.toDouble(), height.toDouble())
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
package expo.modules.ui
|
|
2
|
+
|
|
3
|
+
import androidx.compose.material3.RadioButton
|
|
4
|
+
import androidx.compose.runtime.Composable
|
|
5
|
+
import expo.modules.kotlin.views.ComposeProps
|
|
6
|
+
import expo.modules.kotlin.views.FunctionalComposableScope
|
|
7
|
+
|
|
8
|
+
data class RadioButtonProps(
|
|
9
|
+
val selected: Boolean = false,
|
|
10
|
+
val nativeClickable: Boolean = true,
|
|
11
|
+
val modifiers: ModifierList = emptyList()
|
|
12
|
+
) : ComposeProps
|
|
13
|
+
|
|
14
|
+
@Composable
|
|
15
|
+
fun FunctionalComposableScope.RadioButtonContent(
|
|
16
|
+
props: RadioButtonProps,
|
|
17
|
+
onNativeClick: () -> Unit
|
|
18
|
+
) {
|
|
19
|
+
RadioButton(
|
|
20
|
+
selected = props.selected,
|
|
21
|
+
onClick = if (props.nativeClickable) {
|
|
22
|
+
{ onNativeClick() }
|
|
23
|
+
} else {
|
|
24
|
+
null
|
|
25
|
+
},
|
|
26
|
+
modifier = ModifierRegistry.applyModifiers(props.modifiers, appContext, composableScope, globalEventDispatcher)
|
|
27
|
+
)
|
|
28
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
@file:OptIn(ExperimentalMaterial3Api::class)
|
|
2
|
+
|
|
3
|
+
package expo.modules.ui
|
|
4
|
+
|
|
5
|
+
import androidx.compose.foundation.text.input.rememberTextFieldState
|
|
6
|
+
import androidx.compose.material3.ExpandedFullScreenSearchBar
|
|
7
|
+
import androidx.compose.material3.ExperimentalMaterial3Api
|
|
8
|
+
import androidx.compose.material3.SearchBar
|
|
9
|
+
import androidx.compose.material3.SearchBarDefaults
|
|
10
|
+
import androidx.compose.material3.rememberSearchBarState
|
|
11
|
+
import androidx.compose.runtime.Composable
|
|
12
|
+
import expo.modules.kotlin.views.ComposableScope
|
|
13
|
+
import expo.modules.kotlin.views.ComposeProps
|
|
14
|
+
import expo.modules.kotlin.views.FunctionalComposableScope
|
|
15
|
+
|
|
16
|
+
data class SearchBarProps(
|
|
17
|
+
val modifiers: ModifierList = emptyList()
|
|
18
|
+
) : ComposeProps
|
|
19
|
+
|
|
20
|
+
@Composable
|
|
21
|
+
fun FunctionalComposableScope.SearchBarContent(props: SearchBarProps, onSearch: (GenericEventPayload1<String>) -> Unit) {
|
|
22
|
+
val searchBarState = rememberSearchBarState()
|
|
23
|
+
val textFieldState = rememberTextFieldState()
|
|
24
|
+
|
|
25
|
+
val inputField =
|
|
26
|
+
@Composable {
|
|
27
|
+
SearchBarDefaults.InputField(
|
|
28
|
+
searchBarState = searchBarState,
|
|
29
|
+
textFieldState = textFieldState,
|
|
30
|
+
onSearch = { value -> onSearch.invoke(GenericEventPayload1(value)) },
|
|
31
|
+
placeholder = {
|
|
32
|
+
Children(ComposableScope(), filter = { isSlotWithName(it, "placeholder") })
|
|
33
|
+
}
|
|
34
|
+
)
|
|
35
|
+
}
|
|
36
|
+
SearchBar(
|
|
37
|
+
state = searchBarState,
|
|
38
|
+
inputField = inputField,
|
|
39
|
+
modifier = ModifierRegistry.applyModifiers(props.modifiers, appContext, composableScope, globalEventDispatcher)
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
val expandedFullScreenSearchBarView = findChildSlotView(view, "expandedFullScreenSearchBar")
|
|
43
|
+
expandedFullScreenSearchBarView?.let { slotView ->
|
|
44
|
+
ExpandedFullScreenSearchBar(
|
|
45
|
+
state = searchBarState,
|
|
46
|
+
inputField = inputField
|
|
47
|
+
) {
|
|
48
|
+
ExpandedFullScreenSearchBarView(ComposableScope(), slotView)
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
@Composable
|
|
54
|
+
private fun ExpandedFullScreenSearchBarView(composableScope: ComposableScope, view: SlotView) {
|
|
55
|
+
with(composableScope) {
|
|
56
|
+
with(view) {
|
|
57
|
+
Content()
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|