@expo/ui 55.0.2 → 55.0.3

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.
Files changed (193) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/android/build.gradle +2 -2
  3. package/android/src/main/java/expo/modules/ui/AnimatedVisibilityView.kt +130 -0
  4. package/android/src/main/java/expo/modules/ui/CardView.kt +138 -34
  5. package/android/src/main/java/expo/modules/ui/CheckboxView.kt +98 -0
  6. package/android/src/main/java/expo/modules/ui/ChipView.kt +267 -142
  7. package/android/src/main/java/expo/modules/ui/DatePickerView.kt +258 -70
  8. package/android/src/main/java/expo/modules/ui/ExpoUIModule.kt +204 -57
  9. package/android/src/main/java/expo/modules/ui/ModifierRegistry.kt +44 -1
  10. package/android/src/main/java/expo/modules/ui/ProgressView.kt +189 -89
  11. package/android/src/main/java/expo/modules/ui/RadioButtonView.kt +3 -7
  12. package/android/src/main/java/expo/modules/ui/SegmentedButtonView.kt +115 -0
  13. package/android/src/main/java/expo/modules/ui/SegmentedControlView.kt +35 -0
  14. package/android/src/main/java/expo/modules/ui/SliderView.kt +70 -12
  15. package/android/src/main/java/expo/modules/ui/SwitchView.kt +53 -161
  16. package/android/src/main/java/expo/modules/ui/ToggleButtonView.kt +95 -57
  17. package/android/src/main/java/expo/modules/ui/button/Button.kt +117 -158
  18. package/android/src/main/java/expo/modules/ui/button/FloatingActionButton.kt +92 -0
  19. package/android/src/main/java/expo/modules/ui/button/IconButton.kt +73 -86
  20. package/android/src/main/java/expo/modules/ui/menu/DropdownMenu.kt +39 -0
  21. package/android/src/main/java/expo/modules/ui/menu/DropdownMenuItem.kt +70 -0
  22. package/android/src/main/java/expo/modules/ui/menu/DropdownMenuRecords.kt +18 -0
  23. package/build/jetpack-compose/AnimatedVisibility/index.d.ts +134 -0
  24. package/build/jetpack-compose/AnimatedVisibility/index.d.ts.map +1 -0
  25. package/build/jetpack-compose/AnimatedVisibility/symbols.d.ts +3 -0
  26. package/build/jetpack-compose/AnimatedVisibility/symbols.d.ts.map +1 -0
  27. package/build/jetpack-compose/Button/index.d.ts +65 -51
  28. package/build/jetpack-compose/Button/index.d.ts.map +1 -1
  29. package/build/jetpack-compose/Card/index.d.ts +72 -14
  30. package/build/jetpack-compose/Card/index.d.ts.map +1 -1
  31. package/build/jetpack-compose/Checkbox/index.d.ts +73 -0
  32. package/build/jetpack-compose/Checkbox/index.d.ts.map +1 -0
  33. package/build/jetpack-compose/Chip/index.d.ts +247 -27
  34. package/build/jetpack-compose/Chip/index.d.ts.map +1 -1
  35. package/build/jetpack-compose/DatePicker/index.d.ts +38 -3
  36. package/build/jetpack-compose/DatePicker/index.d.ts.map +1 -1
  37. package/build/jetpack-compose/DropdownMenu/DropdownMenuItem.d.ts +70 -0
  38. package/build/jetpack-compose/DropdownMenu/DropdownMenuItem.d.ts.map +1 -0
  39. package/build/jetpack-compose/DropdownMenu/index.d.ts +68 -0
  40. package/build/jetpack-compose/DropdownMenu/index.d.ts.map +1 -0
  41. package/build/jetpack-compose/FloatingActionButton/index.d.ts +150 -0
  42. package/build/jetpack-compose/FloatingActionButton/index.d.ts.map +1 -0
  43. package/build/jetpack-compose/HorizontalFloatingToolbar/index.d.ts +2 -2
  44. package/build/jetpack-compose/HorizontalFloatingToolbar/index.d.ts.map +1 -1
  45. package/build/jetpack-compose/IconButton/index.d.ts +45 -29
  46. package/build/jetpack-compose/IconButton/index.d.ts.map +1 -1
  47. package/build/jetpack-compose/MultiChoiceSegmentedButtonRow/index.d.ts +17 -0
  48. package/build/jetpack-compose/MultiChoiceSegmentedButtonRow/index.d.ts.map +1 -0
  49. package/build/jetpack-compose/Progress/index.d.ts +78 -35
  50. package/build/jetpack-compose/Progress/index.d.ts.map +1 -1
  51. package/build/jetpack-compose/RadioButton/index.d.ts +2 -2
  52. package/build/jetpack-compose/RadioButton/index.d.ts.map +1 -1
  53. package/build/jetpack-compose/SegmentedButton/index.d.ts +74 -0
  54. package/build/jetpack-compose/SegmentedButton/index.d.ts.map +1 -0
  55. package/build/jetpack-compose/SingleChoiceSegmentedButtonRow/index.d.ts +17 -0
  56. package/build/jetpack-compose/SingleChoiceSegmentedButtonRow/index.d.ts.map +1 -0
  57. package/build/jetpack-compose/Slider/index.d.ts +34 -10
  58. package/build/jetpack-compose/Slider/index.d.ts.map +1 -1
  59. package/build/jetpack-compose/Switch/index.d.ts +10 -50
  60. package/build/jetpack-compose/Switch/index.d.ts.map +1 -1
  61. package/build/jetpack-compose/ToggleButton/index.d.ts +60 -32
  62. package/build/jetpack-compose/ToggleButton/index.d.ts.map +1 -1
  63. package/build/jetpack-compose/index.d.ts +5 -4
  64. package/build/jetpack-compose/index.d.ts.map +1 -1
  65. package/build/jetpack-compose/modifiers/index.d.ts +18 -1
  66. package/build/jetpack-compose/modifiers/index.d.ts.map +1 -1
  67. package/build/swift-ui/ProgressView/index.d.ts +1 -5
  68. package/build/swift-ui/ProgressView/index.d.ts.map +1 -1
  69. package/build/swift-ui/Stepper/index.d.ts +3 -3
  70. package/build/swift-ui/Stepper/index.d.ts.map +1 -1
  71. package/build/swift-ui/Text/index.d.ts +33 -1
  72. package/build/swift-ui/Text/index.d.ts.map +1 -1
  73. package/build/swift-ui/modifiers/index.d.ts +22 -1
  74. package/build/swift-ui/modifiers/index.d.ts.map +1 -1
  75. package/build/swift-ui/modifiers/shapes/index.d.ts +2 -2
  76. package/build/swift-ui/types.d.ts +7 -0
  77. package/build/swift-ui/types.d.ts.map +1 -1
  78. package/expo-module.config.json +1 -1
  79. package/ios/BottomSheetView.swift +1 -6
  80. package/ios/ClosedRangeDateRecord.swift +10 -0
  81. package/ios/ColorPickerView.swift +9 -8
  82. package/ios/ConfirmationDialog/ConfirmationDialog.swift +4 -6
  83. package/ios/DatePickerView.swift +7 -5
  84. package/ios/DisclosureGroupView.swift +5 -7
  85. package/ios/ListView.swift +6 -14
  86. package/ios/Modifiers/DefaultScrollAnchorForRoleModifier.swift +32 -0
  87. package/ios/Modifiers/DefaultScrollAnchorModifier.swift +16 -0
  88. package/ios/Modifiers/ViewModifierRegistry.swift +8 -0
  89. package/ios/Picker/PickerView.swift +6 -10
  90. package/ios/Popover/PopoverView.swift +3 -5
  91. package/ios/ProgressView.swift +0 -5
  92. package/ios/SectionView.swift +3 -5
  93. package/ios/SliderView.swift +8 -6
  94. package/ios/StepperView.swift +12 -16
  95. package/ios/TextView.swift +37 -1
  96. package/ios/Toggle/ToggleView.swift +5 -7
  97. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.3/expo.modules.ui-55.0.3-sources.jar +0 -0
  98. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.3/expo.modules.ui-55.0.3-sources.jar.md5 +1 -0
  99. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.3/expo.modules.ui-55.0.3-sources.jar.sha1 +1 -0
  100. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.3/expo.modules.ui-55.0.3-sources.jar.sha256 +1 -0
  101. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.3/expo.modules.ui-55.0.3-sources.jar.sha512 +1 -0
  102. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.3/expo.modules.ui-55.0.3.aar +0 -0
  103. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.3/expo.modules.ui-55.0.3.aar.md5 +1 -0
  104. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.3/expo.modules.ui-55.0.3.aar.sha1 +1 -0
  105. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.3/expo.modules.ui-55.0.3.aar.sha256 +1 -0
  106. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.3/expo.modules.ui-55.0.3.aar.sha512 +1 -0
  107. package/local-maven-repo/expo/modules/ui/expo.modules.ui/{55.0.2/expo.modules.ui-55.0.2.module → 55.0.3/expo.modules.ui-55.0.3.module} +22 -22
  108. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.3/expo.modules.ui-55.0.3.module.md5 +1 -0
  109. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.3/expo.modules.ui-55.0.3.module.sha1 +1 -0
  110. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.3/expo.modules.ui-55.0.3.module.sha256 +1 -0
  111. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.3/expo.modules.ui-55.0.3.module.sha512 +1 -0
  112. package/local-maven-repo/expo/modules/ui/expo.modules.ui/{55.0.2/expo.modules.ui-55.0.2.pom → 55.0.3/expo.modules.ui-55.0.3.pom} +1 -1
  113. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.3/expo.modules.ui-55.0.3.pom.md5 +1 -0
  114. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.3/expo.modules.ui-55.0.3.pom.sha1 +1 -0
  115. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.3/expo.modules.ui-55.0.3.pom.sha256 +1 -0
  116. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.3/expo.modules.ui-55.0.3.pom.sha512 +1 -0
  117. package/local-maven-repo/expo/modules/ui/expo.modules.ui/maven-metadata.xml +4 -4
  118. package/local-maven-repo/expo/modules/ui/expo.modules.ui/maven-metadata.xml.md5 +1 -1
  119. package/local-maven-repo/expo/modules/ui/expo.modules.ui/maven-metadata.xml.sha1 +1 -1
  120. package/local-maven-repo/expo/modules/ui/expo.modules.ui/maven-metadata.xml.sha256 +1 -1
  121. package/local-maven-repo/expo/modules/ui/expo.modules.ui/maven-metadata.xml.sha512 +1 -1
  122. package/package.json +5 -2
  123. package/src/jetpack-compose/AnimatedVisibility/index.tsx +206 -0
  124. package/src/jetpack-compose/AnimatedVisibility/symbols.ts +8 -0
  125. package/src/jetpack-compose/Button/index.tsx +69 -92
  126. package/src/jetpack-compose/Card/index.tsx +105 -29
  127. package/src/jetpack-compose/Checkbox/index.tsx +126 -0
  128. package/src/jetpack-compose/Chip/index.tsx +391 -51
  129. package/src/jetpack-compose/DatePicker/index.tsx +112 -7
  130. package/src/jetpack-compose/DropdownMenu/DropdownMenuItem.tsx +126 -0
  131. package/src/jetpack-compose/DropdownMenu/index.tsx +107 -0
  132. package/src/jetpack-compose/FloatingActionButton/index.tsx +207 -0
  133. package/src/jetpack-compose/HorizontalFloatingToolbar/index.tsx +4 -2
  134. package/src/jetpack-compose/IconButton/index.tsx +49 -56
  135. package/src/jetpack-compose/MultiChoiceSegmentedButtonRow/index.tsx +34 -0
  136. package/src/jetpack-compose/Progress/index.tsx +120 -62
  137. package/src/jetpack-compose/RadioButton/index.tsx +8 -9
  138. package/src/jetpack-compose/SegmentedButton/index.tsx +109 -0
  139. package/src/jetpack-compose/SingleChoiceSegmentedButtonRow/index.tsx +34 -0
  140. package/src/jetpack-compose/Slider/index.tsx +76 -29
  141. package/src/jetpack-compose/Switch/index.tsx +17 -87
  142. package/src/jetpack-compose/ToggleButton/index.tsx +67 -43
  143. package/src/jetpack-compose/index.ts +5 -4
  144. package/src/jetpack-compose/modifiers/index.ts +26 -2
  145. package/src/swift-ui/ProgressView/index.tsx +1 -3
  146. package/src/swift-ui/Stepper/index.tsx +7 -7
  147. package/src/swift-ui/Text/index.tsx +66 -2
  148. package/src/swift-ui/modifiers/index.ts +40 -0
  149. package/src/swift-ui/types.ts +5 -0
  150. package/android/src/main/java/expo/modules/ui/FilterChipView.kt +0 -59
  151. package/android/src/main/java/expo/modules/ui/PickerView.kt +0 -161
  152. package/android/src/main/java/expo/modules/ui/TextButtonView.kt +0 -33
  153. package/android/src/main/java/expo/modules/ui/menu/ContextMenu.kt +0 -183
  154. package/android/src/main/java/expo/modules/ui/menu/ContextMenuRecords.kt +0 -64
  155. package/build/jetpack-compose/Button/types.d.ts +0 -5
  156. package/build/jetpack-compose/Button/types.d.ts.map +0 -1
  157. package/build/jetpack-compose/ContextMenu/Submenu.d.ts +0 -17
  158. package/build/jetpack-compose/ContextMenu/Submenu.d.ts.map +0 -1
  159. package/build/jetpack-compose/ContextMenu/index.d.ts +0 -65
  160. package/build/jetpack-compose/ContextMenu/index.d.ts.map +0 -1
  161. package/build/jetpack-compose/ContextMenu/utils.d.ts +0 -24
  162. package/build/jetpack-compose/ContextMenu/utils.d.ts.map +0 -1
  163. package/build/jetpack-compose/FilterChip/index.d.ts +0 -49
  164. package/build/jetpack-compose/FilterChip/index.d.ts.map +0 -1
  165. package/build/jetpack-compose/Picker/index.d.ts +0 -62
  166. package/build/jetpack-compose/Picker/index.d.ts.map +0 -1
  167. package/build/jetpack-compose/TextButton/index.d.ts +0 -29
  168. package/build/jetpack-compose/TextButton/index.d.ts.map +0 -1
  169. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.2/expo.modules.ui-55.0.2-sources.jar +0 -0
  170. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.2/expo.modules.ui-55.0.2-sources.jar.md5 +0 -1
  171. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.2/expo.modules.ui-55.0.2-sources.jar.sha1 +0 -1
  172. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.2/expo.modules.ui-55.0.2-sources.jar.sha256 +0 -1
  173. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.2/expo.modules.ui-55.0.2-sources.jar.sha512 +0 -1
  174. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.2/expo.modules.ui-55.0.2.aar +0 -0
  175. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.2/expo.modules.ui-55.0.2.aar.md5 +0 -1
  176. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.2/expo.modules.ui-55.0.2.aar.sha1 +0 -1
  177. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.2/expo.modules.ui-55.0.2.aar.sha256 +0 -1
  178. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.2/expo.modules.ui-55.0.2.aar.sha512 +0 -1
  179. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.2/expo.modules.ui-55.0.2.module.md5 +0 -1
  180. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.2/expo.modules.ui-55.0.2.module.sha1 +0 -1
  181. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.2/expo.modules.ui-55.0.2.module.sha256 +0 -1
  182. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.2/expo.modules.ui-55.0.2.module.sha512 +0 -1
  183. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.2/expo.modules.ui-55.0.2.pom.md5 +0 -1
  184. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.2/expo.modules.ui-55.0.2.pom.sha1 +0 -1
  185. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.2/expo.modules.ui-55.0.2.pom.sha256 +0 -1
  186. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.2/expo.modules.ui-55.0.2.pom.sha512 +0 -1
  187. package/src/jetpack-compose/Button/types.ts +0 -57
  188. package/src/jetpack-compose/ContextMenu/Submenu.tsx +0 -21
  189. package/src/jetpack-compose/ContextMenu/index.tsx +0 -149
  190. package/src/jetpack-compose/ContextMenu/utils.ts +0 -144
  191. package/src/jetpack-compose/FilterChip/index.tsx +0 -89
  192. package/src/jetpack-compose/Picker/index.tsx +0 -90
  193. package/src/jetpack-compose/TextButton/index.tsx +0 -55
@@ -1,24 +1,16 @@
1
1
  package expo.modules.ui.button
2
2
 
3
3
  import android.graphics.Color
4
- import androidx.compose.foundation.layout.Row
5
- import androidx.compose.foundation.layout.RowScope
6
- import androidx.compose.foundation.layout.padding
4
+ import androidx.compose.foundation.layout.PaddingValues
7
5
  import androidx.compose.material3.ButtonDefaults
8
6
  import androidx.compose.material3.ElevatedButton
9
7
  import androidx.compose.material3.FilledTonalButton
10
- import androidx.compose.material3.Icon
11
8
  import androidx.compose.material3.OutlinedButton
12
- import androidx.compose.material3.Text
13
9
  import androidx.compose.material3.TextButton
14
10
  import androidx.compose.runtime.Composable
15
- import androidx.compose.ui.Alignment
16
- import androidx.compose.ui.Modifier
17
- import androidx.compose.ui.graphics.Shape
18
11
  import androidx.compose.ui.unit.dp
19
12
  import expo.modules.kotlin.records.Field
20
13
  import expo.modules.kotlin.records.Record
21
- import expo.modules.kotlin.types.Enumerable
22
14
  import expo.modules.kotlin.views.ComposableScope
23
15
  import expo.modules.kotlin.views.ComposeProps
24
16
  import expo.modules.kotlin.views.FunctionalComposableScope
@@ -26,180 +18,147 @@ import expo.modules.ui.ModifierList
26
18
  import expo.modules.ui.ModifierRegistry
27
19
  import expo.modules.ui.ShapeRecord
28
20
  import expo.modules.ui.compose
29
- import expo.modules.ui.getImageVector
30
- import expo.modules.ui.menu.LocalContextMenuExpanded
31
21
  import expo.modules.ui.shapeFromShapeRecord
32
22
  import java.io.Serializable
33
23
 
34
24
  open class ButtonPressedEvent() : Record, Serializable
35
25
 
36
- enum class ButtonVariant(val value: String) : Enumerable {
37
- DEFAULT("default"),
38
- BORDERED("bordered"),
39
- BORDERLESS("borderless"),
40
- OUTLINED("outlined"),
41
- ELEVATED("elevated")
42
- }
43
-
44
26
  class ButtonColors : Record {
45
- @Field
46
- val containerColor: Color? = null
47
-
48
- @Field
49
- val contentColor: Color? = null
50
-
51
- @Field
52
- val disabledContainerColor: Color? = null
27
+ @Field val containerColor: Color? = null
28
+ @Field val contentColor: Color? = null
29
+ @Field val disabledContainerColor: Color? = null
30
+ @Field val disabledContentColor: Color? = null
31
+ }
53
32
 
54
- @Field
55
- val disabledContentColor: Color? = null
33
+ class ContentPaddingRecord : Record {
34
+ @Field val start: Double? = null
35
+ @Field val top: Double? = null
36
+ @Field val end: Double? = null
37
+ @Field val bottom: Double? = null
56
38
  }
57
39
 
40
+ fun ContentPaddingRecord.toPaddingValues(): PaddingValues =
41
+ PaddingValues(
42
+ start = start?.dp ?: ButtonDefaults.ContentPadding.calculateLeftPadding(androidx.compose.ui.unit.LayoutDirection.Ltr),
43
+ top = top?.dp ?: ButtonDefaults.ContentPadding.calculateTopPadding(),
44
+ end = end?.dp ?: ButtonDefaults.ContentPadding.calculateRightPadding(androidx.compose.ui.unit.LayoutDirection.Ltr),
45
+ bottom = bottom?.dp ?: ButtonDefaults.ContentPadding.calculateBottomPadding()
46
+ )
47
+
58
48
  data class ButtonProps(
59
- val text: String = "",
60
- val variant: ButtonVariant? = ButtonVariant.DEFAULT,
61
- val elementColors: ButtonColors = ButtonColors(),
62
- val leadingIcon: String? = null,
63
- val trailingIcon: String? = null,
64
- val disabled: Boolean? = false,
49
+ val colors: ButtonColors = ButtonColors(),
50
+ val enabled: Boolean = true,
51
+ val contentPadding: ContentPaddingRecord? = null,
65
52
  val shape: ShapeRecord? = null,
66
53
  val modifiers: ModifierList = emptyList()
67
54
  ) : ComposeProps
68
55
 
69
56
  @Composable
70
- fun StyledButton(
71
- variant: ButtonVariant,
72
- colors: ButtonColors,
73
- disabled: Boolean,
74
- onPress: () -> Unit,
75
- modifier: Modifier = Modifier,
76
- shape: Shape?,
77
- content: @Composable (RowScope.() -> Unit)
57
+ fun FunctionalComposableScope.ButtonContent(
58
+ props: ButtonProps,
59
+ onClick: (ButtonPressedEvent) -> Unit
78
60
  ) {
79
- when (variant) {
80
- ButtonVariant.BORDERED -> FilledTonalButton(
81
- onPress,
82
- enabled = !disabled,
83
- content = content,
84
- colors = ButtonDefaults.filledTonalButtonColors(
85
- containerColor = colors.containerColor.compose,
86
- contentColor = colors.contentColor.compose,
87
- disabledContainerColor = colors.disabledContainerColor.compose,
88
- disabledContentColor = colors.disabledContentColor.compose
89
- ),
90
- shape = shape ?: ButtonDefaults.filledTonalShape,
91
- modifier = modifier
92
- )
93
-
94
- ButtonVariant.BORDERLESS -> TextButton(
95
- onPress,
96
- enabled = !disabled,
97
- content = content,
98
- colors = ButtonDefaults.textButtonColors(
99
- containerColor = colors.containerColor.compose,
100
- contentColor = colors.contentColor.compose,
101
- disabledContainerColor = colors.disabledContainerColor.compose,
102
- disabledContentColor = colors.disabledContentColor.compose
103
- ),
104
- shape = shape ?: ButtonDefaults.textShape,
105
- modifier = modifier
106
- )
107
-
108
- ButtonVariant.OUTLINED -> OutlinedButton(
109
- onPress,
110
- enabled = !disabled,
111
- content = content,
112
- colors = ButtonDefaults.outlinedButtonColors(
113
- containerColor = colors.containerColor.compose,
114
- contentColor = colors.contentColor.compose,
115
- disabledContainerColor = colors.disabledContainerColor.compose,
116
- disabledContentColor = colors.disabledContentColor.compose
117
- ),
118
- shape = shape ?: ButtonDefaults.outlinedShape,
119
- modifier = modifier
120
- )
121
-
122
- ButtonVariant.ELEVATED -> ElevatedButton(
123
- onPress,
124
- enabled = !disabled,
125
- content = content,
126
- colors = ButtonDefaults.elevatedButtonColors(
127
- containerColor = colors.containerColor.compose,
128
- contentColor = colors.contentColor.compose,
129
- disabledContainerColor = colors.disabledContainerColor.compose,
130
- disabledContentColor = colors.disabledContentColor.compose
131
- ),
132
- shape = shape ?: ButtonDefaults.elevatedShape,
133
- modifier = modifier
134
- )
135
-
136
- else -> androidx.compose.material3.Button(
137
- onPress,
138
- enabled = !disabled,
139
- content = content,
140
- colors = ButtonDefaults.buttonColors(
141
- containerColor = colors.containerColor.compose,
142
- contentColor = colors.contentColor.compose,
143
- disabledContainerColor = colors.disabledContainerColor.compose,
144
- disabledContentColor = colors.disabledContentColor.compose
145
- ),
146
- shape = shape ?: ButtonDefaults.shape,
147
- modifier = modifier
148
- )
61
+ androidx.compose.material3.Button(
62
+ onClick = { onClick(ButtonPressedEvent()) },
63
+ enabled = props.enabled,
64
+ contentPadding = props.contentPadding?.toPaddingValues() ?: ButtonDefaults.ContentPadding,
65
+ colors = ButtonDefaults.buttonColors(
66
+ containerColor = props.colors.containerColor.compose,
67
+ contentColor = props.colors.contentColor.compose,
68
+ disabledContainerColor = props.colors.disabledContainerColor.compose,
69
+ disabledContentColor = props.colors.disabledContentColor.compose
70
+ ),
71
+ shape = shapeFromShapeRecord(props.shape) ?: ButtonDefaults.shape,
72
+ modifier = ModifierRegistry.applyModifiers(props.modifiers, appContext, composableScope, globalEventDispatcher)
73
+ ) {
74
+ Children(ComposableScope(rowScope = this))
149
75
  }
150
76
  }
151
77
 
152
78
  @Composable
153
- fun FunctionalComposableScope.ButtonContent(
79
+ fun FunctionalComposableScope.FilledTonalButtonContent(
154
80
  props: ButtonProps,
155
- onButtonPressed: (ButtonPressedEvent) -> Unit
81
+ onClick: (ButtonPressedEvent) -> Unit
156
82
  ) {
157
- val variant = props.variant
158
- val text = props.text
159
- val colors = props.elementColors
160
- val leadingIcon = props.leadingIcon
161
- val trailingIcon = props.trailingIcon
162
- val disabled = props.disabled
163
-
164
- // Check if this Button is inside a ContextMenu
165
- val contextMenuExpanded = LocalContextMenuExpanded.current
83
+ FilledTonalButton(
84
+ onClick = { onClick(ButtonPressedEvent()) },
85
+ enabled = props.enabled,
86
+ contentPadding = props.contentPadding?.toPaddingValues() ?: ButtonDefaults.ContentPadding,
87
+ colors = ButtonDefaults.filledTonalButtonColors(
88
+ containerColor = props.colors.containerColor.compose,
89
+ contentColor = props.colors.contentColor.compose,
90
+ disabledContainerColor = props.colors.disabledContainerColor.compose,
91
+ disabledContentColor = props.colors.disabledContentColor.compose
92
+ ),
93
+ shape = shapeFromShapeRecord(props.shape) ?: ButtonDefaults.filledTonalShape,
94
+ modifier = ModifierRegistry.applyModifiers(props.modifiers, appContext, composableScope, globalEventDispatcher)
95
+ ) {
96
+ Children(ComposableScope(rowScope = this))
97
+ }
98
+ }
166
99
 
167
- StyledButton(
168
- variant ?: ButtonVariant.DEFAULT,
169
- colors,
170
- disabled ?: false,
171
- onPress = {
172
- // If inside ContextMenu, expand the menu
173
- contextMenuExpanded?.let { it.value = true }
174
- // Also fire the button pressed event
175
- onButtonPressed(ButtonPressedEvent())
176
- },
177
- modifier = ModifierRegistry.applyModifiers(props.modifiers, appContext, composableScope, globalEventDispatcher),
178
- shape = shapeFromShapeRecord(props.shape)
100
+ @Composable
101
+ fun FunctionalComposableScope.OutlinedButtonContent(
102
+ props: ButtonProps,
103
+ onClick: (ButtonPressedEvent) -> Unit
104
+ ) {
105
+ OutlinedButton(
106
+ onClick = { onClick(ButtonPressedEvent()) },
107
+ enabled = props.enabled,
108
+ contentPadding = props.contentPadding?.toPaddingValues() ?: ButtonDefaults.ContentPadding,
109
+ colors = ButtonDefaults.outlinedButtonColors(
110
+ containerColor = props.colors.containerColor.compose,
111
+ contentColor = props.colors.contentColor.compose,
112
+ disabledContainerColor = props.colors.disabledContainerColor.compose,
113
+ disabledContentColor = props.colors.disabledContentColor.compose
114
+ ),
115
+ shape = shapeFromShapeRecord(props.shape) ?: ButtonDefaults.outlinedShape,
116
+ modifier = ModifierRegistry.applyModifiers(props.modifiers, appContext, composableScope, globalEventDispatcher)
179
117
  ) {
180
- Row(verticalAlignment = Alignment.CenterVertically) {
181
- Children(ComposableScope(rowScope = this))
182
- leadingIcon?.let { iconName ->
183
- getImageVector(iconName)?.let {
184
- Icon(
185
- it,
186
- contentDescription = iconName,
187
- modifier = Modifier.padding(end = 8.dp)
188
- )
189
- }
190
- }
118
+ Children(ComposableScope(rowScope = this))
119
+ }
120
+ }
191
121
 
192
- Text(text)
122
+ @Composable
123
+ fun FunctionalComposableScope.ElevatedButtonContent(
124
+ props: ButtonProps,
125
+ onClick: (ButtonPressedEvent) -> Unit
126
+ ) {
127
+ ElevatedButton(
128
+ onClick = { onClick(ButtonPressedEvent()) },
129
+ enabled = props.enabled,
130
+ contentPadding = props.contentPadding?.toPaddingValues() ?: ButtonDefaults.ContentPadding,
131
+ colors = ButtonDefaults.elevatedButtonColors(
132
+ containerColor = props.colors.containerColor.compose,
133
+ contentColor = props.colors.contentColor.compose,
134
+ disabledContainerColor = props.colors.disabledContainerColor.compose,
135
+ disabledContentColor = props.colors.disabledContentColor.compose
136
+ ),
137
+ shape = shapeFromShapeRecord(props.shape) ?: ButtonDefaults.elevatedShape,
138
+ modifier = ModifierRegistry.applyModifiers(props.modifiers, appContext, composableScope, globalEventDispatcher)
139
+ ) {
140
+ Children(ComposableScope(rowScope = this))
141
+ }
142
+ }
193
143
 
194
- trailingIcon?.let { iconName ->
195
- getImageVector(iconName)?.let {
196
- Icon(
197
- it,
198
- contentDescription = iconName,
199
- modifier = Modifier.padding(start = 8.dp)
200
- )
201
- }
202
- }
203
- }
144
+ @Composable
145
+ fun FunctionalComposableScope.TextButtonContent(
146
+ props: ButtonProps,
147
+ onClick: (ButtonPressedEvent) -> Unit
148
+ ) {
149
+ TextButton(
150
+ onClick = { onClick(ButtonPressedEvent()) },
151
+ enabled = props.enabled,
152
+ contentPadding = props.contentPadding?.toPaddingValues() ?: ButtonDefaults.TextButtonContentPadding,
153
+ colors = ButtonDefaults.textButtonColors(
154
+ containerColor = props.colors.containerColor.compose,
155
+ contentColor = props.colors.contentColor.compose,
156
+ disabledContainerColor = props.colors.disabledContainerColor.compose,
157
+ disabledContentColor = props.colors.disabledContentColor.compose
158
+ ),
159
+ shape = shapeFromShapeRecord(props.shape) ?: ButtonDefaults.textShape,
160
+ modifier = ModifierRegistry.applyModifiers(props.modifiers, appContext, composableScope, globalEventDispatcher)
161
+ ) {
162
+ Children(ComposableScope(rowScope = this))
204
163
  }
205
164
  }
@@ -0,0 +1,92 @@
1
+ package expo.modules.ui.button
2
+
3
+ import android.graphics.Color
4
+ import androidx.compose.material3.ExtendedFloatingActionButton
5
+ import androidx.compose.material3.FloatingActionButton
6
+ import androidx.compose.material3.FloatingActionButtonDefaults
7
+ import androidx.compose.material3.LargeFloatingActionButton
8
+ import androidx.compose.material3.SmallFloatingActionButton
9
+ import androidx.compose.runtime.Composable
10
+ import expo.modules.kotlin.types.Enumerable
11
+ import expo.modules.kotlin.views.ComposableScope
12
+ import expo.modules.kotlin.views.ComposeProps
13
+ import expo.modules.kotlin.views.FunctionalComposableScope
14
+ import expo.modules.ui.ModifierList
15
+ import expo.modules.ui.ModifierRegistry
16
+ import expo.modules.ui.compose
17
+ import expo.modules.ui.findChildSlotView
18
+
19
+ enum class FloatingActionButtonVariant(val value: String) : Enumerable {
20
+ SMALL("small"),
21
+ MEDIUM("medium"),
22
+ LARGE("large"),
23
+ EXTENDED("extended")
24
+ }
25
+
26
+ data class FloatingActionButtonProps(
27
+ val variant: FloatingActionButtonVariant = FloatingActionButtonVariant.MEDIUM,
28
+ val expanded: Boolean = true,
29
+ val containerColor: Color? = null,
30
+ val modifiers: ModifierList = emptyList()
31
+ ) : ComposeProps
32
+
33
+ @Composable
34
+ fun FunctionalComposableScope.FloatingActionButtonContent(
35
+ props: FloatingActionButtonProps,
36
+ onClick: () -> Unit
37
+ ) {
38
+ val containerColor = props.containerColor?.compose ?: FloatingActionButtonDefaults.containerColor
39
+ val modifier = ModifierRegistry.applyModifiers(props.modifiers, appContext, composableScope, globalEventDispatcher)
40
+
41
+ val iconSlotView = findChildSlotView(view, "icon")
42
+ val iconContent: (@Composable () -> Unit) = iconSlotView?.let {
43
+ {
44
+ with(ComposableScope()) {
45
+ with(it) {
46
+ Content()
47
+ }
48
+ }
49
+ }
50
+ } ?: {}
51
+
52
+ when (props.variant) {
53
+ FloatingActionButtonVariant.SMALL -> SmallFloatingActionButton(
54
+ onClick = onClick,
55
+ containerColor = containerColor,
56
+ modifier = modifier,
57
+ content = iconContent
58
+ )
59
+ FloatingActionButtonVariant.LARGE -> LargeFloatingActionButton(
60
+ onClick = onClick,
61
+ containerColor = containerColor,
62
+ modifier = modifier,
63
+ content = iconContent
64
+ )
65
+ FloatingActionButtonVariant.EXTENDED -> {
66
+ val textSlotView = findChildSlotView(view, "text")
67
+ val textContent: (@Composable () -> Unit) = textSlotView?.let {
68
+ {
69
+ with(ComposableScope()) {
70
+ with(it) {
71
+ Content()
72
+ }
73
+ }
74
+ }
75
+ } ?: {}
76
+ ExtendedFloatingActionButton(
77
+ onClick = onClick,
78
+ expanded = props.expanded,
79
+ icon = iconContent,
80
+ text = textContent,
81
+ containerColor = containerColor,
82
+ modifier = modifier
83
+ )
84
+ }
85
+ FloatingActionButtonVariant.MEDIUM -> FloatingActionButton(
86
+ onClick = onClick,
87
+ containerColor = containerColor,
88
+ modifier = modifier,
89
+ content = iconContent
90
+ )
91
+ }
92
+ }
@@ -1,113 +1,100 @@
1
1
  package expo.modules.ui.button
2
2
 
3
- import androidx.compose.material3.ButtonDefaults
3
+ import androidx.compose.material3.FilledIconButton
4
4
  import androidx.compose.material3.FilledTonalIconButton
5
5
  import androidx.compose.material3.IconButton
6
6
  import androidx.compose.material3.IconButtonDefaults
7
7
  import androidx.compose.material3.OutlinedIconButton
8
8
  import androidx.compose.runtime.Composable
9
- import androidx.compose.ui.Modifier
10
- import androidx.compose.ui.graphics.Shape
11
- import expo.modules.kotlin.types.Enumerable
12
9
  import expo.modules.kotlin.views.ComposableScope
13
- import expo.modules.kotlin.views.ComposeProps
14
10
  import expo.modules.kotlin.views.FunctionalComposableScope
15
- import expo.modules.ui.ModifierList
16
11
  import expo.modules.ui.ModifierRegistry
17
- import expo.modules.ui.ShapeRecord
18
12
  import expo.modules.ui.compose
19
- import expo.modules.ui.menu.LocalContextMenuExpanded
20
13
  import expo.modules.ui.shapeFromShapeRecord
21
14
 
22
- enum class IconButtonVariant(val value: String) : Enumerable {
23
- DEFAULT("default"),
24
- BORDERED("bordered"),
25
- OUTLINED("outlined")
15
+ @Composable
16
+ fun FunctionalComposableScope.IconButtonContent(
17
+ props: ButtonProps,
18
+ onButtonPressed: (ButtonPressedEvent) -> Unit
19
+ ) {
20
+ val shape = shapeFromShapeRecord(props.shape)
21
+ IconButton(
22
+ onClick = { onButtonPressed(ButtonPressedEvent()) },
23
+ enabled = props.enabled,
24
+ colors = IconButtonDefaults.iconButtonColors(
25
+ containerColor = props.colors.containerColor.compose,
26
+ contentColor = props.colors.contentColor.compose,
27
+ disabledContainerColor = props.colors.disabledContainerColor.compose,
28
+ disabledContentColor = props.colors.disabledContentColor.compose
29
+ ),
30
+ shape = shape ?: IconButtonDefaults.standardShape,
31
+ modifier = ModifierRegistry.applyModifiers(props.modifiers, appContext, composableScope, globalEventDispatcher)
32
+ ) {
33
+ Children(ComposableScope())
34
+ }
26
35
  }
27
36
 
28
- data class IconButtonProps(
29
- val variant: IconButtonVariant? = IconButtonVariant.DEFAULT,
30
- val elementColors: ButtonColors = ButtonColors(),
31
- val disabled: Boolean? = false,
32
- val shape: ShapeRecord? = null,
33
- val modifiers: ModifierList = emptyList()
34
- ) : ComposeProps
35
-
36
37
  @Composable
37
- fun StyledIconButton(
38
- variant: IconButtonVariant,
39
- colors: ButtonColors,
40
- disabled: Boolean,
41
- onPress: () -> Unit,
42
- modifier: Modifier = Modifier,
43
- shape: Shape?,
44
- content: @Composable (() -> Unit)
38
+ fun FunctionalComposableScope.FilledIconButtonContent(
39
+ props: ButtonProps,
40
+ onButtonPressed: (ButtonPressedEvent) -> Unit
45
41
  ) {
46
- when (variant) {
47
- IconButtonVariant.BORDERED -> FilledTonalIconButton(
48
- onPress,
49
- enabled = !disabled,
50
- content = content,
51
- colors = IconButtonDefaults.filledTonalIconButtonColors(
52
- containerColor = colors.containerColor.compose,
53
- contentColor = colors.contentColor.compose,
54
- disabledContainerColor = colors.disabledContainerColor.compose,
55
- disabledContentColor = colors.disabledContentColor.compose
56
- ),
57
- shape = shape ?: ButtonDefaults.filledTonalShape,
58
- modifier = modifier
59
- )
60
-
61
- IconButtonVariant.OUTLINED -> OutlinedIconButton(
62
- onPress,
63
- enabled = !disabled,
64
- content = content,
65
- colors = IconButtonDefaults.outlinedIconButtonColors(
66
- containerColor = colors.containerColor.compose,
67
- contentColor = colors.contentColor.compose,
68
- disabledContainerColor = colors.disabledContainerColor.compose,
69
- disabledContentColor = colors.disabledContentColor.compose
70
- ),
71
- shape = shape ?: ButtonDefaults.outlinedShape,
72
- modifier = modifier
73
- )
74
-
75
- else -> IconButton(
76
- onPress,
77
- enabled = !disabled,
78
- content = content,
79
- colors = IconButtonDefaults.iconButtonColors(
80
- containerColor = colors.containerColor.compose,
81
- contentColor = colors.contentColor.compose,
82
- disabledContainerColor = colors.disabledContainerColor.compose,
83
- disabledContentColor = colors.disabledContentColor.compose
84
- ),
85
- modifier = modifier
86
- )
42
+ val shape = shapeFromShapeRecord(props.shape)
43
+ FilledIconButton(
44
+ onClick = { onButtonPressed(ButtonPressedEvent()) },
45
+ enabled = props.enabled,
46
+ colors = IconButtonDefaults.filledIconButtonColors(
47
+ containerColor = props.colors.containerColor.compose,
48
+ contentColor = props.colors.contentColor.compose,
49
+ disabledContainerColor = props.colors.disabledContainerColor.compose,
50
+ disabledContentColor = props.colors.disabledContentColor.compose
51
+ ),
52
+ shape = shape ?: IconButtonDefaults.filledShape,
53
+ modifier = ModifierRegistry.applyModifiers(props.modifiers, appContext, composableScope, globalEventDispatcher)
54
+ ) {
55
+ Children(ComposableScope())
87
56
  }
88
57
  }
89
58
 
90
59
  @Composable
91
- fun FunctionalComposableScope.IconButtonContent(
92
- props: IconButtonProps,
60
+ fun FunctionalComposableScope.FilledTonalIconButtonContent(
61
+ props: ButtonProps,
93
62
  onButtonPressed: (ButtonPressedEvent) -> Unit
94
63
  ) {
95
- val variant = props.variant
96
- val colors = props.elementColors
97
- val disabled = props.disabled
98
-
99
- val contextMenuExpanded = LocalContextMenuExpanded.current
64
+ val shape = shapeFromShapeRecord(props.shape)
65
+ FilledTonalIconButton(
66
+ onClick = { onButtonPressed(ButtonPressedEvent()) },
67
+ enabled = props.enabled,
68
+ colors = IconButtonDefaults.filledTonalIconButtonColors(
69
+ containerColor = props.colors.containerColor.compose,
70
+ contentColor = props.colors.contentColor.compose,
71
+ disabledContainerColor = props.colors.disabledContainerColor.compose,
72
+ disabledContentColor = props.colors.disabledContentColor.compose
73
+ ),
74
+ shape = shape ?: IconButtonDefaults.filledShape,
75
+ modifier = ModifierRegistry.applyModifiers(props.modifiers, appContext, composableScope, globalEventDispatcher)
76
+ ) {
77
+ Children(ComposableScope())
78
+ }
79
+ }
100
80
 
101
- StyledIconButton(
102
- variant ?: IconButtonVariant.DEFAULT,
103
- colors,
104
- disabled ?: false,
105
- onPress = {
106
- contextMenuExpanded?.let { it.value = true }
107
- onButtonPressed(ButtonPressedEvent())
108
- },
109
- modifier = ModifierRegistry.applyModifiers(props.modifiers, appContext, composableScope, globalEventDispatcher),
110
- shape = shapeFromShapeRecord(props.shape)
81
+ @Composable
82
+ fun FunctionalComposableScope.OutlinedIconButtonContent(
83
+ props: ButtonProps,
84
+ onButtonPressed: (ButtonPressedEvent) -> Unit
85
+ ) {
86
+ val shape = shapeFromShapeRecord(props.shape)
87
+ OutlinedIconButton(
88
+ onClick = { onButtonPressed(ButtonPressedEvent()) },
89
+ enabled = props.enabled,
90
+ colors = IconButtonDefaults.outlinedIconButtonColors(
91
+ containerColor = props.colors.containerColor.compose,
92
+ contentColor = props.colors.contentColor.compose,
93
+ disabledContainerColor = props.colors.disabledContainerColor.compose,
94
+ disabledContentColor = props.colors.disabledContentColor.compose
95
+ ),
96
+ shape = shape ?: IconButtonDefaults.outlinedShape,
97
+ modifier = ModifierRegistry.applyModifiers(props.modifiers, appContext, composableScope, globalEventDispatcher)
111
98
  ) {
112
99
  Children(ComposableScope())
113
100
  }
@@ -0,0 +1,39 @@
1
+ package expo.modules.ui.menu
2
+
3
+ import androidx.compose.foundation.layout.Box
4
+ import androidx.compose.material3.DropdownMenu
5
+ import androidx.compose.material3.MenuDefaults
6
+ import androidx.compose.runtime.Composable
7
+ import expo.modules.kotlin.views.ComposableScope
8
+ import expo.modules.kotlin.views.FunctionalComposableScope
9
+ import expo.modules.ui.ModifierRegistry
10
+ import expo.modules.ui.composeOrNull
11
+ import expo.modules.ui.findChildSlotView
12
+ import expo.modules.ui.isSlotView
13
+
14
+ @Composable
15
+ fun FunctionalComposableScope.DropdownMenuContent(
16
+ props: DropdownMenuProps,
17
+ onDismissRequest: () -> Unit
18
+ ) {
19
+ val itemsSlotView = findChildSlotView(view, "items")
20
+
21
+ Box(modifier = ModifierRegistry.applyModifiers(props.modifiers, appContext, composableScope, globalEventDispatcher)) {
22
+ // Trigger - non-items children
23
+ Children(ComposableScope(), filter = { !isSlotView(it) })
24
+
25
+ DropdownMenu(
26
+ containerColor = props.color?.composeOrNull ?: MenuDefaults.containerColor,
27
+ expanded = props.expanded,
28
+ onDismissRequest = onDismissRequest
29
+ ) {
30
+ itemsSlotView?.let {
31
+ with(ComposableScope()) {
32
+ with(it) {
33
+ Content()
34
+ }
35
+ }
36
+ }
37
+ }
38
+ }
39
+ }