@expo/ui 55.0.1 → 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 (269) hide show
  1. package/CHANGELOG.md +58 -0
  2. package/CONTRIBUTING.md +30 -0
  3. package/android/build.gradle +2 -2
  4. package/android/src/main/java/expo/modules/ui/AnimatedVisibilityView.kt +130 -0
  5. package/android/src/main/java/expo/modules/ui/CardView.kt +138 -34
  6. package/android/src/main/java/expo/modules/ui/CheckboxView.kt +98 -0
  7. package/android/src/main/java/expo/modules/ui/ChipView.kt +267 -142
  8. package/android/src/main/java/expo/modules/ui/DatePickerView.kt +302 -31
  9. package/android/src/main/java/expo/modules/ui/ExpoUIModule.kt +204 -57
  10. package/android/src/main/java/expo/modules/ui/HorizontalFloatingToolbarView.kt +21 -8
  11. package/android/src/main/java/expo/modules/ui/ModifierRegistry.kt +149 -40
  12. package/android/src/main/java/expo/modules/ui/ProgressView.kt +189 -89
  13. package/android/src/main/java/expo/modules/ui/RNHostView.kt +204 -50
  14. package/android/src/main/java/expo/modules/ui/RadioButtonView.kt +3 -7
  15. package/android/src/main/java/expo/modules/ui/SegmentedButtonView.kt +115 -0
  16. package/android/src/main/java/expo/modules/ui/SegmentedControlView.kt +35 -0
  17. package/android/src/main/java/expo/modules/ui/SliderView.kt +70 -12
  18. package/android/src/main/java/expo/modules/ui/SwitchView.kt +62 -104
  19. package/android/src/main/java/expo/modules/ui/ToggleButtonView.kt +95 -57
  20. package/android/src/main/java/expo/modules/ui/button/Button.kt +117 -158
  21. package/android/src/main/java/expo/modules/ui/button/FloatingActionButton.kt +92 -0
  22. package/android/src/main/java/expo/modules/ui/button/IconButton.kt +73 -80
  23. package/android/src/main/java/expo/modules/ui/convertibles/AnimatableFloat.kt +26 -0
  24. package/android/src/main/java/expo/modules/ui/convertibles/AnimationSpecParams.kt +93 -0
  25. package/android/src/main/java/expo/modules/ui/convertibles/GraphicsLayerParams.kt +24 -0
  26. package/android/src/main/java/expo/modules/ui/menu/DropdownMenu.kt +39 -0
  27. package/android/src/main/java/expo/modules/ui/menu/DropdownMenuItem.kt +70 -0
  28. package/android/src/main/java/expo/modules/ui/menu/DropdownMenuRecords.kt +18 -0
  29. package/build/jetpack-compose/AnimatedVisibility/index.d.ts +134 -0
  30. package/build/jetpack-compose/AnimatedVisibility/index.d.ts.map +1 -0
  31. package/build/jetpack-compose/AnimatedVisibility/symbols.d.ts +3 -0
  32. package/build/jetpack-compose/AnimatedVisibility/symbols.d.ts.map +1 -0
  33. package/build/jetpack-compose/Button/index.d.ts +65 -51
  34. package/build/jetpack-compose/Button/index.d.ts.map +1 -1
  35. package/build/jetpack-compose/Card/index.d.ts +72 -14
  36. package/build/jetpack-compose/Card/index.d.ts.map +1 -1
  37. package/build/jetpack-compose/Checkbox/index.d.ts +73 -0
  38. package/build/jetpack-compose/Checkbox/index.d.ts.map +1 -0
  39. package/build/jetpack-compose/Chip/index.d.ts +247 -27
  40. package/build/jetpack-compose/Chip/index.d.ts.map +1 -1
  41. package/build/jetpack-compose/DatePicker/index.d.ts +137 -3
  42. package/build/jetpack-compose/DatePicker/index.d.ts.map +1 -1
  43. package/build/jetpack-compose/DropdownMenu/DropdownMenuItem.d.ts +70 -0
  44. package/build/jetpack-compose/DropdownMenu/DropdownMenuItem.d.ts.map +1 -0
  45. package/build/jetpack-compose/DropdownMenu/index.d.ts +68 -0
  46. package/build/jetpack-compose/DropdownMenu/index.d.ts.map +1 -0
  47. package/build/jetpack-compose/FloatingActionButton/index.d.ts +150 -0
  48. package/build/jetpack-compose/FloatingActionButton/index.d.ts.map +1 -0
  49. package/build/jetpack-compose/HorizontalFloatingToolbar/index.d.ts +2 -2
  50. package/build/jetpack-compose/HorizontalFloatingToolbar/index.d.ts.map +1 -1
  51. package/build/jetpack-compose/IconButton/index.d.ts +45 -29
  52. package/build/jetpack-compose/IconButton/index.d.ts.map +1 -1
  53. package/build/jetpack-compose/MultiChoiceSegmentedButtonRow/index.d.ts +17 -0
  54. package/build/jetpack-compose/MultiChoiceSegmentedButtonRow/index.d.ts.map +1 -0
  55. package/build/jetpack-compose/Progress/index.d.ts +78 -35
  56. package/build/jetpack-compose/Progress/index.d.ts.map +1 -1
  57. package/build/jetpack-compose/RadioButton/index.d.ts +2 -2
  58. package/build/jetpack-compose/RadioButton/index.d.ts.map +1 -1
  59. package/build/jetpack-compose/SegmentedButton/index.d.ts +74 -0
  60. package/build/jetpack-compose/SegmentedButton/index.d.ts.map +1 -0
  61. package/build/jetpack-compose/SingleChoiceSegmentedButtonRow/index.d.ts +17 -0
  62. package/build/jetpack-compose/SingleChoiceSegmentedButtonRow/index.d.ts.map +1 -0
  63. package/build/jetpack-compose/Slider/index.d.ts +34 -10
  64. package/build/jetpack-compose/Slider/index.d.ts.map +1 -1
  65. package/build/jetpack-compose/Spacer/index.d.ts +2 -2
  66. package/build/jetpack-compose/Switch/index.d.ts +25 -47
  67. package/build/jetpack-compose/Switch/index.d.ts.map +1 -1
  68. package/build/jetpack-compose/ToggleButton/index.d.ts +60 -32
  69. package/build/jetpack-compose/ToggleButton/index.d.ts.map +1 -1
  70. package/build/jetpack-compose/index.d.ts +5 -4
  71. package/build/jetpack-compose/index.d.ts.map +1 -1
  72. package/build/jetpack-compose/modifiers/animation.d.ts +44 -0
  73. package/build/jetpack-compose/modifiers/animation.d.ts.map +1 -0
  74. package/build/jetpack-compose/modifiers/index.d.ts +68 -4
  75. package/build/jetpack-compose/modifiers/index.d.ts.map +1 -1
  76. package/build/swift-ui/AccessoryWidgetBackground/index.d.ts +4 -0
  77. package/build/swift-ui/AccessoryWidgetBackground/index.d.ts.map +1 -0
  78. package/build/swift-ui/ConfirmationDialog/index.d.ts.map +1 -1
  79. package/build/swift-ui/ContextMenu/index.d.ts.map +1 -1
  80. package/build/swift-ui/ControlGroup/index.d.ts +29 -0
  81. package/build/swift-ui/ControlGroup/index.d.ts.map +1 -0
  82. package/build/swift-ui/Gauge/index.d.ts.map +1 -1
  83. package/build/swift-ui/Image/index.d.ts +7 -1
  84. package/build/swift-ui/Image/index.d.ts.map +1 -1
  85. package/build/swift-ui/Label/index.d.ts.map +1 -1
  86. package/build/swift-ui/LabeledContent/index.d.ts.map +1 -1
  87. package/build/swift-ui/Menu/index.d.ts.map +1 -1
  88. package/build/swift-ui/Picker/index.d.ts.map +1 -1
  89. package/build/swift-ui/Popover/index.d.ts.map +1 -1
  90. package/build/swift-ui/ProgressView/index.d.ts +1 -5
  91. package/build/swift-ui/ProgressView/index.d.ts.map +1 -1
  92. package/build/swift-ui/Section/index.d.ts.map +1 -1
  93. package/build/swift-ui/Slider/index.d.ts.map +1 -1
  94. package/build/swift-ui/SlotView.d.ts +5 -0
  95. package/build/swift-ui/SlotView.d.ts.map +1 -0
  96. package/build/swift-ui/Stepper/index.d.ts +3 -3
  97. package/build/swift-ui/Stepper/index.d.ts.map +1 -1
  98. package/build/swift-ui/Text/index.d.ts +33 -1
  99. package/build/swift-ui/Text/index.d.ts.map +1 -1
  100. package/build/swift-ui/index.d.ts +2 -0
  101. package/build/swift-ui/index.d.ts.map +1 -1
  102. package/build/swift-ui/modifiers/index.d.ts +54 -1
  103. package/build/swift-ui/modifiers/index.d.ts.map +1 -1
  104. package/build/swift-ui/modifiers/shapes/index.d.ts +2 -2
  105. package/build/swift-ui/types.d.ts +7 -0
  106. package/build/swift-ui/types.d.ts.map +1 -1
  107. package/expo-module.config.json +1 -1
  108. package/ios/AccessoryWidgetBackgroundView.swift +27 -0
  109. package/ios/BottomSheetView.swift +1 -6
  110. package/ios/ClosedRangeDateRecord.swift +10 -0
  111. package/ios/ColorPickerView.swift +9 -8
  112. package/ios/ConfirmationDialog/ConfirmationDialog.swift +7 -15
  113. package/ios/ConfirmationDialog/ConfirmationDialogProps.swift +0 -5
  114. package/ios/ContextMenu/ContextMenu.swift +27 -22
  115. package/ios/ContextMenu/ContextMenuRecords.swift +0 -6
  116. package/ios/ControlGroupView.swift +33 -0
  117. package/ios/DatePickerView.swift +7 -5
  118. package/ios/DisclosureGroupView.swift +5 -7
  119. package/ios/ExpoUIModule.swift +10 -32
  120. package/ios/GaugeView.swift +4 -26
  121. package/ios/HostView.swift +1 -2
  122. package/ios/ImageView.swift +22 -11
  123. package/ios/Label.swift +2 -17
  124. package/ios/LabeledContentView.swift +3 -27
  125. package/ios/ListView.swift +6 -14
  126. package/ios/Menu/MenuRecords.swift +0 -2
  127. package/ios/Menu/MenuView.swift +2 -5
  128. package/ios/Modifiers/DefaultScrollAnchorForRoleModifier.swift +32 -0
  129. package/ios/Modifiers/DefaultScrollAnchorModifier.swift +16 -0
  130. package/ios/Modifiers/ResizableModifier.swift +24 -0
  131. package/ios/Modifiers/Rotation3DEffectModifier.swift +20 -0
  132. package/ios/Modifiers/View+ModifierArray.swift +29 -0
  133. package/ios/Modifiers/ViewModifierRegistry.swift +37 -3
  134. package/ios/Modifiers/WidgetModifiers.swift +46 -0
  135. package/ios/Picker/PickerView.swift +8 -16
  136. package/ios/Popover/PopoverProps.swift +0 -4
  137. package/ios/Popover/PopoverView.swift +5 -11
  138. package/ios/ProgressView.swift +0 -5
  139. package/ios/RNHostView.swift +91 -10
  140. package/ios/SectionView.swift +9 -17
  141. package/ios/SecureFieldView.swift +0 -1
  142. package/ios/ShareLink/ShareLinkView.swift +1 -1
  143. package/ios/SliderView.swift +16 -31
  144. package/ios/SlotView.swift +38 -0
  145. package/ios/StepperView.swift +12 -16
  146. package/ios/TextFieldView.swift +0 -1
  147. package/ios/TextView.swift +37 -1
  148. package/ios/Toggle/ToggleView.swift +5 -7
  149. package/ios/UIBaseView.swift +34 -3
  150. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.3/expo.modules.ui-55.0.3-sources.jar +0 -0
  151. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.3/expo.modules.ui-55.0.3-sources.jar.md5 +1 -0
  152. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.3/expo.modules.ui-55.0.3-sources.jar.sha1 +1 -0
  153. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.3/expo.modules.ui-55.0.3-sources.jar.sha256 +1 -0
  154. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.3/expo.modules.ui-55.0.3-sources.jar.sha512 +1 -0
  155. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.3/expo.modules.ui-55.0.3.aar +0 -0
  156. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.3/expo.modules.ui-55.0.3.aar.md5 +1 -0
  157. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.3/expo.modules.ui-55.0.3.aar.sha1 +1 -0
  158. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.3/expo.modules.ui-55.0.3.aar.sha256 +1 -0
  159. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.3/expo.modules.ui-55.0.3.aar.sha512 +1 -0
  160. package/local-maven-repo/expo/modules/ui/expo.modules.ui/{55.0.1/expo.modules.ui-55.0.1.module → 55.0.3/expo.modules.ui-55.0.3.module} +22 -22
  161. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.3/expo.modules.ui-55.0.3.module.md5 +1 -0
  162. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.3/expo.modules.ui-55.0.3.module.sha1 +1 -0
  163. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.3/expo.modules.ui-55.0.3.module.sha256 +1 -0
  164. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.3/expo.modules.ui-55.0.3.module.sha512 +1 -0
  165. package/local-maven-repo/expo/modules/ui/expo.modules.ui/{55.0.1/expo.modules.ui-55.0.1.pom → 55.0.3/expo.modules.ui-55.0.3.pom} +1 -1
  166. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.3/expo.modules.ui-55.0.3.pom.md5 +1 -0
  167. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.3/expo.modules.ui-55.0.3.pom.sha1 +1 -0
  168. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.3/expo.modules.ui-55.0.3.pom.sha256 +1 -0
  169. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.3/expo.modules.ui-55.0.3.pom.sha512 +1 -0
  170. package/local-maven-repo/expo/modules/ui/expo.modules.ui/maven-metadata.xml +4 -4
  171. package/local-maven-repo/expo/modules/ui/expo.modules.ui/maven-metadata.xml.md5 +1 -1
  172. package/local-maven-repo/expo/modules/ui/expo.modules.ui/maven-metadata.xml.sha1 +1 -1
  173. package/local-maven-repo/expo/modules/ui/expo.modules.ui/maven-metadata.xml.sha256 +1 -1
  174. package/local-maven-repo/expo/modules/ui/expo.modules.ui/maven-metadata.xml.sha512 +1 -1
  175. package/package.json +5 -2
  176. package/src/jetpack-compose/AnimatedVisibility/index.tsx +206 -0
  177. package/src/jetpack-compose/AnimatedVisibility/symbols.ts +8 -0
  178. package/src/jetpack-compose/Button/index.tsx +69 -92
  179. package/src/jetpack-compose/Card/index.tsx +105 -29
  180. package/src/jetpack-compose/Checkbox/index.tsx +126 -0
  181. package/src/jetpack-compose/Chip/index.tsx +391 -51
  182. package/src/jetpack-compose/DatePicker/index.tsx +215 -6
  183. package/src/jetpack-compose/DropdownMenu/DropdownMenuItem.tsx +126 -0
  184. package/src/jetpack-compose/DropdownMenu/index.tsx +107 -0
  185. package/src/jetpack-compose/FloatingActionButton/index.tsx +207 -0
  186. package/src/jetpack-compose/HorizontalFloatingToolbar/index.tsx +4 -2
  187. package/src/jetpack-compose/IconButton/index.tsx +49 -56
  188. package/src/jetpack-compose/MultiChoiceSegmentedButtonRow/index.tsx +34 -0
  189. package/src/jetpack-compose/Progress/index.tsx +120 -62
  190. package/src/jetpack-compose/RadioButton/index.tsx +8 -9
  191. package/src/jetpack-compose/SegmentedButton/index.tsx +109 -0
  192. package/src/jetpack-compose/SingleChoiceSegmentedButtonRow/index.tsx +34 -0
  193. package/src/jetpack-compose/Slider/index.tsx +76 -29
  194. package/src/jetpack-compose/Spacer/index.tsx +2 -2
  195. package/src/jetpack-compose/Switch/index.tsx +32 -84
  196. package/src/jetpack-compose/ToggleButton/index.tsx +67 -43
  197. package/src/jetpack-compose/index.ts +5 -4
  198. package/src/jetpack-compose/modifiers/animation.ts +37 -0
  199. package/src/jetpack-compose/modifiers/index.ts +86 -6
  200. package/src/swift-ui/AccessoryWidgetBackground/index.tsx +12 -0
  201. package/src/swift-ui/ConfirmationDialog/index.tsx +4 -12
  202. package/src/swift-ui/ContextMenu/index.tsx +6 -20
  203. package/src/swift-ui/ControlGroup/index.tsx +59 -0
  204. package/src/swift-ui/Gauge/index.tsx +5 -20
  205. package/src/swift-ui/Image/index.tsx +7 -1
  206. package/src/swift-ui/Label/index.tsx +2 -5
  207. package/src/swift-ui/LabeledContent/index.tsx +3 -12
  208. package/src/swift-ui/Menu/index.tsx +2 -6
  209. package/src/swift-ui/Picker/index.tsx +4 -11
  210. package/src/swift-ui/Popover/index.tsx +3 -12
  211. package/src/swift-ui/ProgressView/index.tsx +1 -3
  212. package/src/swift-ui/Section/index.tsx +4 -9
  213. package/src/swift-ui/Slider/index.tsx +4 -12
  214. package/src/swift-ui/SlotView.tsx +8 -0
  215. package/src/swift-ui/Stepper/index.tsx +7 -7
  216. package/src/swift-ui/Text/index.tsx +66 -2
  217. package/src/swift-ui/index.tsx +2 -0
  218. package/src/swift-ui/modifiers/index.ts +87 -1
  219. package/src/swift-ui/types.ts +5 -0
  220. package/android/src/main/java/expo/modules/ui/FilterChipView.kt +0 -59
  221. package/android/src/main/java/expo/modules/ui/PickerView.kt +0 -161
  222. package/android/src/main/java/expo/modules/ui/TextButtonView.kt +0 -33
  223. package/android/src/main/java/expo/modules/ui/menu/ContextMenu.kt +0 -183
  224. package/android/src/main/java/expo/modules/ui/menu/ContextMenuRecords.kt +0 -64
  225. package/build/jetpack-compose/Button/types.d.ts +0 -5
  226. package/build/jetpack-compose/Button/types.d.ts.map +0 -1
  227. package/build/jetpack-compose/ContextMenu/Submenu.d.ts +0 -17
  228. package/build/jetpack-compose/ContextMenu/Submenu.d.ts.map +0 -1
  229. package/build/jetpack-compose/ContextMenu/index.d.ts +0 -65
  230. package/build/jetpack-compose/ContextMenu/index.d.ts.map +0 -1
  231. package/build/jetpack-compose/ContextMenu/utils.d.ts +0 -24
  232. package/build/jetpack-compose/ContextMenu/utils.d.ts.map +0 -1
  233. package/build/jetpack-compose/FilterChip/index.d.ts +0 -49
  234. package/build/jetpack-compose/FilterChip/index.d.ts.map +0 -1
  235. package/build/jetpack-compose/Picker/index.d.ts +0 -62
  236. package/build/jetpack-compose/Picker/index.d.ts.map +0 -1
  237. package/build/jetpack-compose/TextButton/index.d.ts +0 -29
  238. package/build/jetpack-compose/TextButton/index.d.ts.map +0 -1
  239. package/ios/ConfirmationDialog/ConfirmationDialogComponents.swift +0 -26
  240. package/ios/ContextMenu/ContextMenuComponents.swift +0 -37
  241. package/ios/Menu/MenuComponents.swift +0 -12
  242. package/ios/Picker/PickerComponents.swift +0 -24
  243. package/ios/Popover/PopoverComponents.swift +0 -18
  244. package/ios/SectionComponents.swift +0 -34
  245. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.1/expo.modules.ui-55.0.1-sources.jar +0 -0
  246. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.1/expo.modules.ui-55.0.1-sources.jar.md5 +0 -1
  247. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.1/expo.modules.ui-55.0.1-sources.jar.sha1 +0 -1
  248. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.1/expo.modules.ui-55.0.1-sources.jar.sha256 +0 -1
  249. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.1/expo.modules.ui-55.0.1-sources.jar.sha512 +0 -1
  250. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.1/expo.modules.ui-55.0.1.aar +0 -0
  251. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.1/expo.modules.ui-55.0.1.aar.md5 +0 -1
  252. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.1/expo.modules.ui-55.0.1.aar.sha1 +0 -1
  253. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.1/expo.modules.ui-55.0.1.aar.sha256 +0 -1
  254. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.1/expo.modules.ui-55.0.1.aar.sha512 +0 -1
  255. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.1/expo.modules.ui-55.0.1.module.md5 +0 -1
  256. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.1/expo.modules.ui-55.0.1.module.sha1 +0 -1
  257. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.1/expo.modules.ui-55.0.1.module.sha256 +0 -1
  258. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.1/expo.modules.ui-55.0.1.module.sha512 +0 -1
  259. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.1/expo.modules.ui-55.0.1.pom.md5 +0 -1
  260. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.1/expo.modules.ui-55.0.1.pom.sha1 +0 -1
  261. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.1/expo.modules.ui-55.0.1.pom.sha256 +0 -1
  262. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.1/expo.modules.ui-55.0.1.pom.sha512 +0 -1
  263. package/src/jetpack-compose/Button/types.ts +0 -57
  264. package/src/jetpack-compose/ContextMenu/Submenu.tsx +0 -21
  265. package/src/jetpack-compose/ContextMenu/index.tsx +0 -149
  266. package/src/jetpack-compose/ContextMenu/utils.ts +0 -144
  267. package/src/jetpack-compose/FilterChip/index.tsx +0 -89
  268. package/src/jetpack-compose/Picker/index.tsx +0 -90
  269. package/src/jetpack-compose/TextButton/index.tsx +0 -55
@@ -0,0 +1,115 @@
1
+ package expo.modules.ui
2
+
3
+ import android.graphics.Color
4
+ import android.util.Log
5
+ import android.view.ViewGroup
6
+ import androidx.compose.material3.MultiChoiceSegmentedButtonRowScope
7
+ import androidx.compose.material3.SegmentedButton
8
+ import androidx.compose.material3.SegmentedButtonDefaults
9
+ import androidx.compose.material3.SingleChoiceSegmentedButtonRowScope
10
+ import androidx.compose.runtime.Composable
11
+ import expo.modules.kotlin.records.Field
12
+ import expo.modules.kotlin.records.Record
13
+ import expo.modules.kotlin.views.ComposableScope
14
+
15
+ import expo.modules.kotlin.views.ComposeProps
16
+ import expo.modules.kotlin.views.FunctionalComposableScope
17
+
18
+ data class SegmentedButtonColors(
19
+ @Field val activeBorderColor: Color? = null,
20
+ @Field val activeContentColor: Color? = null,
21
+ @Field val inactiveBorderColor: Color? = null,
22
+ @Field val inactiveContentColor: Color? = null,
23
+ @Field val disabledActiveBorderColor: Color? = null,
24
+ @Field val disabledActiveContentColor: Color? = null,
25
+ @Field val disabledInactiveBorderColor: Color? = null,
26
+ @Field val disabledInactiveContentColor: Color? = null,
27
+ @Field val activeContainerColor: Color? = null,
28
+ @Field val inactiveContainerColor: Color? = null,
29
+ @Field val disabledActiveContainerColor: Color? = null,
30
+ @Field val disabledInactiveContainerColor: Color? = null
31
+ ) : Record
32
+
33
+ data class SegmentedButtonProps(
34
+ val selected: Boolean = false,
35
+ val checked: Boolean = false,
36
+ val enabled: Boolean = true,
37
+ val colors: SegmentedButtonColors = SegmentedButtonColors(),
38
+ val modifiers: ModifierList = emptyList()
39
+ ) : ComposeProps
40
+
41
+ @Composable
42
+ fun FunctionalComposableScope.SegmentedButtonContent(
43
+ props: SegmentedButtonProps,
44
+ onClick: () -> Unit,
45
+ onCheckedChange: (GenericEventPayload1<Boolean>) -> Unit
46
+ ) {
47
+ val colors = props.colors
48
+ val labelSlotView = findChildSlotView(view, "label")
49
+ val parent = view.parent as? ViewGroup
50
+ val index = parent?.indexOfChild(view) ?: 0
51
+ val count = parent?.childCount ?: 1
52
+
53
+ val segmentedColors = SegmentedButtonDefaults.colors(
54
+ activeBorderColor = colors.activeBorderColor.compose,
55
+ activeContentColor = colors.activeContentColor.compose,
56
+ inactiveBorderColor = colors.inactiveBorderColor.compose,
57
+ inactiveContentColor = colors.inactiveContentColor.compose,
58
+ disabledActiveBorderColor = colors.disabledActiveBorderColor.compose,
59
+ disabledActiveContentColor = colors.disabledActiveContentColor.compose,
60
+ disabledInactiveBorderColor = colors.disabledInactiveBorderColor.compose,
61
+ disabledInactiveContentColor = colors.disabledInactiveContentColor.compose,
62
+ activeContainerColor = colors.activeContainerColor.compose,
63
+ inactiveContainerColor = colors.inactiveContainerColor.compose,
64
+ disabledActiveContainerColor = colors.disabledActiveContainerColor.compose,
65
+ disabledInactiveContainerColor = colors.disabledInactiveContainerColor.compose
66
+ )
67
+
68
+ val shape = SegmentedButtonDefaults.itemShape(index = index, count = count)
69
+ val modifier = ModifierRegistry.applyModifiers(props.modifiers, appContext, composableScope, globalEventDispatcher)
70
+ val label: @Composable () -> Unit = labelSlotView?.let {
71
+ {
72
+ with(ComposableScope()) {
73
+ with(it) {
74
+ Content()
75
+ }
76
+ }
77
+ }
78
+ } ?: {}
79
+
80
+ val singleScope = composableScope.rowScope as? SingleChoiceSegmentedButtonRowScope
81
+ val multiScope = composableScope.rowScope as? MultiChoiceSegmentedButtonRowScope
82
+
83
+ if (singleScope == null && multiScope == null) {
84
+ if (BuildConfig.DEBUG) {
85
+ Log.w("ExpoUI", "SegmentedButton must be used within a SingleChoiceSegmentedButtonRow or MultiChoiceSegmentedButtonRow. It will not render on its own.")
86
+ }
87
+ return
88
+ }
89
+
90
+ if (singleScope != null) {
91
+ with(singleScope) {
92
+ SegmentedButton(
93
+ selected = props.selected,
94
+ onClick = onClick,
95
+ shape = shape,
96
+ enabled = props.enabled,
97
+ colors = segmentedColors,
98
+ modifier = modifier,
99
+ label = label
100
+ )
101
+ }
102
+ } else if (multiScope != null) {
103
+ with(multiScope) {
104
+ SegmentedButton(
105
+ checked = props.checked,
106
+ onCheckedChange = { onCheckedChange(GenericEventPayload1(it)) },
107
+ shape = shape,
108
+ enabled = props.enabled,
109
+ colors = segmentedColors,
110
+ modifier = modifier,
111
+ label = label
112
+ )
113
+ }
114
+ }
115
+ }
@@ -0,0 +1,35 @@
1
+ package expo.modules.ui
2
+
3
+ import androidx.compose.material3.MultiChoiceSegmentedButtonRow
4
+ import androidx.compose.material3.SingleChoiceSegmentedButtonRow
5
+ import androidx.compose.runtime.Composable
6
+ import expo.modules.kotlin.views.ComposableScope
7
+ import expo.modules.kotlin.views.ComposeProps
8
+ import expo.modules.kotlin.views.FunctionalComposableScope
9
+ import expo.modules.kotlin.views.with
10
+
11
+ data class SingleChoiceSegmentedButtonRowProps(
12
+ val modifiers: ModifierList = emptyList()
13
+ ) : ComposeProps
14
+
15
+ @Composable
16
+ fun FunctionalComposableScope.SingleChoiceSegmentedButtonRowContent(props: SingleChoiceSegmentedButtonRowProps) {
17
+ SingleChoiceSegmentedButtonRow(
18
+ modifier = ModifierRegistry.applyModifiers(props.modifiers, appContext, composableScope, globalEventDispatcher)
19
+ ) {
20
+ Children(ComposableScope().with(rowScope = this@SingleChoiceSegmentedButtonRow))
21
+ }
22
+ }
23
+
24
+ data class MultiChoiceSegmentedButtonRowProps(
25
+ val modifiers: ModifierList = emptyList()
26
+ ) : ComposeProps
27
+
28
+ @Composable
29
+ fun FunctionalComposableScope.MultiChoiceSegmentedButtonRowContent(props: MultiChoiceSegmentedButtonRowProps) {
30
+ MultiChoiceSegmentedButtonRow(
31
+ modifier = ModifierRegistry.applyModifiers(props.modifiers, appContext, composableScope, globalEventDispatcher)
32
+ ) {
33
+ Children(ComposableScope().with(rowScope = this@MultiChoiceSegmentedButtonRow))
34
+ }
35
+ }
@@ -1,13 +1,20 @@
1
1
  package expo.modules.ui
2
2
 
3
3
  import android.graphics.Color
4
+ import androidx.compose.foundation.interaction.MutableInteractionSource
5
+ import androidx.compose.material3.ExperimentalMaterial3Api
4
6
  import androidx.compose.material3.Slider
5
7
  import androidx.compose.material3.SliderDefaults
6
8
  import androidx.compose.runtime.Composable
9
+ import androidx.compose.runtime.getValue
10
+ import androidx.compose.runtime.mutableFloatStateOf
11
+ import androidx.compose.runtime.mutableStateOf
7
12
  import androidx.compose.runtime.remember
13
+ import androidx.compose.runtime.setValue
8
14
  import expo.modules.kotlin.records.Field
9
15
  import expo.modules.kotlin.records.Record
10
16
  import expo.modules.kotlin.viewevent.getValue
17
+ import expo.modules.kotlin.views.ComposableScope
11
18
  import expo.modules.kotlin.views.ComposeProps
12
19
  import expo.modules.kotlin.views.FunctionalComposableScope
13
20
 
@@ -33,7 +40,8 @@ data class SliderProps(
33
40
  val min: Float = 0.0f,
34
41
  val max: Float = 1.0f,
35
42
  val steps: Int = 0,
36
- val elementColors: SliderColors = SliderColors(),
43
+ val enabled: Boolean = true,
44
+ val colors: SliderColors = SliderColors(),
37
45
  val modifiers: ModifierList = emptyList()
38
46
  ) : ComposeProps
39
47
 
@@ -41,24 +49,74 @@ data class SliderValueChangedEvent(
41
49
  @Field val value: Float
42
50
  ) : Record
43
51
 
52
+ @OptIn(ExperimentalMaterial3Api::class)
44
53
  @Composable
45
54
  fun FunctionalComposableScope.SliderContent(props: SliderProps) {
46
- val onValueChanged by remember { this@SliderContent.EventDispatcher<SliderValueChangedEvent>() }
47
- val colors = props.elementColors
55
+ val onValueChange by remember { this@SliderContent.EventDispatcher<SliderValueChangedEvent>() }
56
+ val onValueChangeFinished by remember { this@SliderContent.EventDispatcher<Unit>() }
57
+ val interactionSource = remember { MutableInteractionSource() }
58
+
59
+ var localValue by remember { mutableFloatStateOf(props.value.coerceIn(props.min, props.max)) }
60
+ var isDragging by remember { mutableStateOf(false) }
61
+ val clampedPropsValue = props.value.coerceIn(props.min, props.max)
62
+ var prevPropsValue by remember { mutableFloatStateOf(clampedPropsValue) }
63
+
64
+ if (clampedPropsValue != prevPropsValue) {
65
+ prevPropsValue = clampedPropsValue
66
+ if (!isDragging) {
67
+ localValue = clampedPropsValue
68
+ }
69
+ }
70
+
71
+ val thumbSlotView = findChildSlotView(view, "thumb")
72
+ val trackSlotView = findChildSlotView(view, "track")
73
+
74
+ val sliderColors = SliderDefaults.colors(
75
+ thumbColor = props.colors.thumbColor.compose,
76
+ activeTrackColor = props.colors.activeTrackColor.compose,
77
+ inactiveTrackColor = props.colors.inactiveTrackColor.compose,
78
+ activeTickColor = props.colors.activeTickColor.compose,
79
+ inactiveTickColor = props.colors.inactiveTickColor.compose
80
+ )
81
+
48
82
  Slider(
49
- value = props.value.coerceAtLeast(props.min).coerceAtMost(props.max),
83
+ value = localValue,
50
84
  valueRange = props.min..props.max,
51
85
  steps = props.steps,
86
+ enabled = props.enabled,
87
+ interactionSource = interactionSource,
52
88
  onValueChange = {
53
- onValueChanged(SliderValueChangedEvent(it))
89
+ isDragging = true
90
+ localValue = it
91
+ onValueChange(SliderValueChangedEvent(it))
92
+ },
93
+ onValueChangeFinished = {
94
+ isDragging = false
95
+ onValueChangeFinished(Unit)
96
+ },
97
+ colors = sliderColors,
98
+ thumb = { sliderState ->
99
+ if (thumbSlotView != null) {
100
+ with(ComposableScope()) { with(thumbSlotView) { Content() } }
101
+ } else {
102
+ SliderDefaults.Thumb(
103
+ interactionSource = interactionSource,
104
+ colors = sliderColors,
105
+ enabled = props.enabled
106
+ )
107
+ }
108
+ },
109
+ track = { sliderState ->
110
+ if (trackSlotView != null) {
111
+ with(ComposableScope()) { with(trackSlotView) { Content() } }
112
+ } else {
113
+ SliderDefaults.Track(
114
+ sliderState = sliderState,
115
+ colors = sliderColors,
116
+ enabled = props.enabled
117
+ )
118
+ }
54
119
  },
55
- colors = SliderDefaults.colors(
56
- thumbColor = colors.thumbColor.compose,
57
- activeTrackColor = colors.activeTrackColor.compose,
58
- inactiveTrackColor = colors.inactiveTrackColor.compose,
59
- activeTickColor = colors.activeTickColor.compose,
60
- inactiveTickColor = colors.inactiveTickColor.compose
61
- ),
62
120
  modifier = ModifierRegistry.applyModifiers(props.modifiers, appContext, composableScope, globalEventDispatcher)
63
121
  )
64
122
  }
@@ -1,12 +1,9 @@
1
1
  package expo.modules.ui
2
2
 
3
3
  import android.graphics.Color
4
- import androidx.compose.material3.Checkbox
5
- import androidx.compose.material3.CheckboxDefaults
6
4
  import androidx.compose.material3.Switch
7
5
  import androidx.compose.material3.SwitchDefaults
8
6
  import androidx.compose.runtime.Composable
9
- import androidx.compose.ui.Modifier
10
7
  import expo.modules.kotlin.records.Field
11
8
  import expo.modules.kotlin.records.Record
12
9
  import expo.modules.kotlin.views.ComposableScope
@@ -14,121 +11,48 @@ import expo.modules.kotlin.views.ComposeProps
14
11
  import expo.modules.kotlin.views.FunctionalComposableScope
15
12
  import java.io.Serializable
16
13
 
17
- open class ValueChangeEvent(
14
+ open class CheckedChangeEvent(
18
15
  @Field open val value: Boolean = false
19
16
  ) : Record, Serializable
20
17
 
21
- class SwitchColors : Record {
22
- @Field
23
- val checkedThumbColor: Color? = null
24
-
25
- @Field
26
- val checkedTrackColor: Color? = null
27
-
28
- @Field
29
- val uncheckedThumbColor: Color? = null
30
-
31
- @Field
32
- val uncheckedTrackColor: Color? = null
33
-
34
- @Field
35
- val checkedColor: Color? = null
36
-
37
- @Field
38
- val disabledCheckedColor: Color? = null
39
-
40
- @Field
41
- val uncheckedColor: Color? = null
42
-
43
- @Field
44
- val disabledUncheckedColor: Color? = null
45
-
46
- @Field
47
- val checkmarkColor: Color? = null
48
-
49
- @Field
50
- val disabledIndeterminateColor: Color? = null
51
- }
18
+ data class SwitchColors(
19
+ @Field val checkedThumbColor: Color? = null,
20
+ @Field val checkedTrackColor: Color? = null,
21
+ @Field val checkedBorderColor: Color? = null,
22
+ @Field val checkedIconColor: Color? = null,
23
+ @Field val uncheckedThumbColor: Color? = null,
24
+ @Field val uncheckedTrackColor: Color? = null,
25
+ @Field val uncheckedBorderColor: Color? = null,
26
+ @Field val uncheckedIconColor: Color? = null,
27
+ @Field val disabledCheckedThumbColor: Color? = null,
28
+ @Field val disabledCheckedTrackColor: Color? = null,
29
+ @Field val disabledCheckedBorderColor: Color? = null,
30
+ @Field val disabledCheckedIconColor: Color? = null,
31
+ @Field val disabledUncheckedThumbColor: Color? = null,
32
+ @Field val disabledUncheckedTrackColor: Color? = null,
33
+ @Field val disabledUncheckedBorderColor: Color? = null,
34
+ @Field val disabledUncheckedIconColor: Color? = null
35
+ ) : Record
52
36
 
53
37
  data class SwitchProps(
54
38
  val value: Boolean = false,
55
- val variant: String = "switch",
56
- val elementColors: SwitchColors = SwitchColors(),
39
+ val enabled: Boolean = true,
40
+ val colors: SwitchColors = SwitchColors(),
57
41
  val modifiers: ModifierList = emptyList()
58
42
  ) : ComposeProps
59
43
 
60
- @Composable
61
- fun SwitchComposable(
62
- checked: Boolean,
63
- onCheckedChange: ((Boolean) -> Unit)?,
64
- colors: SwitchColors,
65
- modifier: Modifier = Modifier,
66
- thumbContent: (@Composable () -> Unit)? = null
67
- ) {
68
- Switch(
69
- checked = checked,
70
- onCheckedChange = onCheckedChange,
71
- modifier = modifier,
72
- thumbContent = thumbContent,
73
- colors = SwitchDefaults.colors(
74
- // For some reason the default way of passing colors using `compose` results in a transparent view
75
- checkedThumbColor = colors.checkedThumbColor.composeOrNull
76
- ?: SwitchDefaults.colors().checkedThumbColor,
77
- checkedTrackColor = colors.checkedTrackColor.composeOrNull
78
- ?: SwitchDefaults.colors().checkedTrackColor,
79
- uncheckedThumbColor = colors.uncheckedThumbColor.composeOrNull
80
- ?: SwitchDefaults.colors().uncheckedThumbColor,
81
- uncheckedTrackColor = colors.uncheckedTrackColor.composeOrNull
82
- ?: SwitchDefaults.colors().uncheckedTrackColor
83
- )
84
- )
85
- }
86
-
87
- @Composable
88
- fun CheckboxComposable(checked: Boolean, onCheckedChange: ((Boolean) -> Unit)?, colors: SwitchColors, modifier: Modifier) {
89
- Checkbox(
90
- checked = checked,
91
- onCheckedChange = onCheckedChange,
92
- modifier = modifier,
93
- colors = CheckboxDefaults.colors(
94
- checkedColor = colors.checkedColor.compose,
95
- disabledCheckedColor = colors.disabledCheckedColor.compose,
96
- uncheckedColor = colors.uncheckedColor.compose,
97
- disabledUncheckedColor = colors.disabledUncheckedColor.compose,
98
- checkmarkColor = colors.checkmarkColor.compose,
99
- disabledIndeterminateColor = colors.disabledIndeterminateColor.compose
100
- )
101
- )
102
- }
103
-
104
- @Composable
105
- fun ThemedHybridSwitch(
106
- variant: String,
107
- checked: Boolean,
108
- onCheckedChange: ((Boolean) -> Unit)?,
109
- colors: SwitchColors,
110
- modifier: Modifier = Modifier,
111
- thumbContent: (@Composable () -> Unit)? = null
112
- ) {
113
- when (variant) {
114
- "switch" -> SwitchComposable(checked, onCheckedChange, colors, modifier, thumbContent)
115
- else -> CheckboxComposable(checked, onCheckedChange, colors, modifier)
116
- }
117
- }
118
-
119
44
  @Composable
120
45
  fun FunctionalComposableScope.SwitchContent(
121
46
  props: SwitchProps,
122
- onValueChange: (ValueChangeEvent) -> Unit
47
+ onCheckedChange: (Boolean) -> Unit
123
48
  ) {
124
49
  val thumbContentSlotView = findChildSlotView(view, "thumbContent")
125
50
 
126
- ThemedHybridSwitch(
127
- props.variant,
128
- props.value,
129
- { newChecked -> onValueChange(ValueChangeEvent(newChecked)) },
130
- props.elementColors,
131
- ModifierRegistry.applyModifiers(props.modifiers, appContext, composableScope, globalEventDispatcher),
51
+ Switch(
52
+ checked = props.value,
53
+ onCheckedChange = onCheckedChange,
54
+ modifier = ModifierRegistry.applyModifiers(props.modifiers, appContext, composableScope, globalEventDispatcher),
55
+ enabled = props.enabled,
132
56
  thumbContent = thumbContentSlotView?.let {
133
57
  {
134
58
  with(ComposableScope()) {
@@ -137,6 +61,40 @@ fun FunctionalComposableScope.SwitchContent(
137
61
  }
138
62
  }
139
63
  }
140
- }
64
+ },
65
+ colors = SwitchDefaults.colors(
66
+ checkedThumbColor = props.colors.checkedThumbColor.composeOrNull
67
+ ?: SwitchDefaults.colors().checkedThumbColor,
68
+ checkedTrackColor = props.colors.checkedTrackColor.composeOrNull
69
+ ?: SwitchDefaults.colors().checkedTrackColor,
70
+ checkedBorderColor = props.colors.checkedBorderColor.composeOrNull
71
+ ?: SwitchDefaults.colors().checkedBorderColor,
72
+ checkedIconColor = props.colors.checkedIconColor.composeOrNull
73
+ ?: SwitchDefaults.colors().checkedIconColor,
74
+ uncheckedThumbColor = props.colors.uncheckedThumbColor.composeOrNull
75
+ ?: SwitchDefaults.colors().uncheckedThumbColor,
76
+ uncheckedTrackColor = props.colors.uncheckedTrackColor.composeOrNull
77
+ ?: SwitchDefaults.colors().uncheckedTrackColor,
78
+ uncheckedBorderColor = props.colors.uncheckedBorderColor.composeOrNull
79
+ ?: SwitchDefaults.colors().uncheckedBorderColor,
80
+ uncheckedIconColor = props.colors.uncheckedIconColor.composeOrNull
81
+ ?: SwitchDefaults.colors().uncheckedIconColor,
82
+ disabledCheckedBorderColor = props.colors.disabledCheckedBorderColor.composeOrNull
83
+ ?: SwitchDefaults.colors().disabledCheckedBorderColor,
84
+ disabledCheckedThumbColor = props.colors.disabledCheckedThumbColor.composeOrNull
85
+ ?: SwitchDefaults.colors().disabledCheckedThumbColor,
86
+ disabledCheckedTrackColor = props.colors.disabledCheckedTrackColor.composeOrNull
87
+ ?: SwitchDefaults.colors().disabledCheckedTrackColor,
88
+ disabledCheckedIconColor = props.colors.disabledCheckedIconColor.composeOrNull
89
+ ?: SwitchDefaults.colors().disabledCheckedIconColor,
90
+ disabledUncheckedBorderColor = props.colors.disabledUncheckedBorderColor.composeOrNull
91
+ ?: SwitchDefaults.colors().disabledUncheckedBorderColor,
92
+ disabledUncheckedThumbColor = props.colors.disabledUncheckedThumbColor.composeOrNull
93
+ ?: SwitchDefaults.colors().disabledUncheckedThumbColor,
94
+ disabledUncheckedTrackColor = props.colors.disabledUncheckedTrackColor.composeOrNull
95
+ ?: SwitchDefaults.colors().disabledUncheckedTrackColor,
96
+ disabledUncheckedIconColor = props.colors.disabledUncheckedIconColor.composeOrNull
97
+ ?: SwitchDefaults.colors().disabledUncheckedIconColor
98
+ )
141
99
  )
142
100
  }
@@ -3,26 +3,33 @@
3
3
  package expo.modules.ui
4
4
 
5
5
  import android.graphics.Color
6
- import androidx.compose.foundation.layout.RowScope
7
6
  import androidx.compose.material3.ExperimentalMaterial3ExpressiveApi
8
7
  import androidx.compose.material3.FilledIconToggleButton
8
+ import androidx.compose.material3.IconButtonDefaults
9
9
  import androidx.compose.material3.IconToggleButton
10
10
  import androidx.compose.material3.OutlinedIconToggleButton
11
- import androidx.compose.material3.Text
12
11
  import androidx.compose.material3.ToggleButton
13
12
  import androidx.compose.material3.ToggleButtonDefaults
14
13
  import androidx.compose.runtime.Composable
15
14
  import expo.modules.kotlin.records.Field
16
15
  import expo.modules.kotlin.records.Record
16
+ import expo.modules.kotlin.views.ComposableScope
17
17
  import expo.modules.kotlin.views.ComposeProps
18
18
  import expo.modules.kotlin.views.FunctionalComposableScope
19
19
 
20
+ data class ToggleButtonColors(
21
+ @Field val containerColor: Color? = null,
22
+ @Field val contentColor: Color? = null,
23
+ @Field val checkedContainerColor: Color? = null,
24
+ @Field val checkedContentColor: Color? = null,
25
+ @Field val disabledContainerColor: Color? = null,
26
+ @Field val disabledContentColor: Color? = null
27
+ ) : Record
28
+
20
29
  data class ToggleButtonProps(
21
30
  val checked: Boolean = false,
22
- val text: String? = null,
23
- val variant: String = "default",
24
- val color: Color? = null,
25
- val disabled: Boolean = false,
31
+ val enabled: Boolean = true,
32
+ val colors: ToggleButtonColors = ToggleButtonColors(),
26
33
  val modifiers: ModifierList = emptyList()
27
34
  ) : ComposeProps
28
35
 
@@ -36,61 +43,92 @@ fun FunctionalComposableScope.ToggleButtonContent(
36
43
  onCheckedChange: (ToggleButtonValueChangeEvent) -> Unit
37
44
  ) {
38
45
  val modifier = ModifierRegistry.applyModifiers(props.modifiers, appContext, composableScope, globalEventDispatcher)
46
+ ToggleButton(
47
+ checked = props.checked,
48
+ onCheckedChange = { onCheckedChange(ToggleButtonValueChangeEvent(it)) },
49
+ enabled = props.enabled,
50
+ modifier = modifier,
51
+ colors = ToggleButtonDefaults.toggleButtonColors(
52
+ checkedContainerColor = props.colors.checkedContainerColor.compose,
53
+ checkedContentColor = props.colors.checkedContentColor.compose,
54
+ containerColor = props.colors.containerColor.compose,
55
+ contentColor = props.colors.contentColor.compose,
56
+ disabledContainerColor = props.colors.disabledContainerColor.compose,
57
+ disabledContentColor = props.colors.disabledContentColor.compose
58
+ )
59
+ ) {
60
+ Children(ComposableScope(rowScope = this))
61
+ }
62
+ }
39
63
 
40
- val scope = this
41
-
42
- val content: @Composable () -> Unit = {
43
- when {
44
- props.text != null -> Text(text = props.text)
45
- else -> scope.Children(composableScope)
46
- }
64
+ @Composable
65
+ fun FunctionalComposableScope.IconToggleButtonContent(
66
+ props: ToggleButtonProps,
67
+ onCheckedChange: (ToggleButtonValueChangeEvent) -> Unit
68
+ ) {
69
+ val modifier = ModifierRegistry.applyModifiers(props.modifiers, appContext, composableScope, globalEventDispatcher)
70
+ IconToggleButton(
71
+ checked = props.checked,
72
+ onCheckedChange = { onCheckedChange(ToggleButtonValueChangeEvent(it)) },
73
+ enabled = props.enabled,
74
+ modifier = modifier,
75
+ colors = IconButtonDefaults.iconToggleButtonColors(
76
+ containerColor = props.colors.containerColor.compose,
77
+ contentColor = props.colors.contentColor.compose,
78
+ checkedContainerColor = props.colors.checkedContainerColor.compose,
79
+ checkedContentColor = props.colors.checkedContentColor.compose,
80
+ disabledContainerColor = props.colors.disabledContainerColor.compose,
81
+ disabledContentColor = props.colors.disabledContentColor.compose
82
+ )
83
+ ) {
84
+ Children(ComposableScope())
47
85
  }
86
+ }
48
87
 
49
- // RowScope content for ToggleButton
50
- val rowContent: @Composable RowScope.() -> Unit = {
51
- when {
52
- props.text != null -> Text(text = props.text)
53
- else -> scope.Children(composableScope)
54
- }
88
+ @Composable
89
+ fun FunctionalComposableScope.FilledIconToggleButtonContent(
90
+ props: ToggleButtonProps,
91
+ onCheckedChange: (ToggleButtonValueChangeEvent) -> Unit
92
+ ) {
93
+ val modifier = ModifierRegistry.applyModifiers(props.modifiers, appContext, composableScope, globalEventDispatcher)
94
+ FilledIconToggleButton(
95
+ checked = props.checked,
96
+ onCheckedChange = { onCheckedChange(ToggleButtonValueChangeEvent(it)) },
97
+ enabled = props.enabled,
98
+ modifier = modifier,
99
+ colors = IconButtonDefaults.filledIconToggleButtonColors(
100
+ containerColor = props.colors.containerColor.compose,
101
+ contentColor = props.colors.contentColor.compose,
102
+ checkedContainerColor = props.colors.checkedContainerColor.compose,
103
+ checkedContentColor = props.colors.checkedContentColor.compose,
104
+ disabledContainerColor = props.colors.disabledContainerColor.compose,
105
+ disabledContentColor = props.colors.disabledContentColor.compose
106
+ )
107
+ ) {
108
+ Children(ComposableScope())
55
109
  }
110
+ }
56
111
 
57
- when (props.variant) {
58
- "icon" -> {
59
- IconToggleButton(
60
- checked = props.checked,
61
- onCheckedChange = { onCheckedChange(ToggleButtonValueChangeEvent(it)) },
62
- enabled = !props.disabled,
63
- modifier = modifier,
64
- content = content
65
- )
66
- }
67
- "filledIcon" -> {
68
- FilledIconToggleButton(
69
- checked = props.checked,
70
- onCheckedChange = { onCheckedChange(ToggleButtonValueChangeEvent(it)) },
71
- enabled = !props.disabled,
72
- modifier = modifier,
73
- content = content
74
- )
75
- }
76
- "outlinedIcon" -> {
77
- OutlinedIconToggleButton(
78
- checked = props.checked,
79
- onCheckedChange = { onCheckedChange(ToggleButtonValueChangeEvent(it)) },
80
- enabled = !props.disabled,
81
- modifier = modifier,
82
- content = content
83
- )
84
- }
85
- else -> {
86
- ToggleButton(
87
- checked = props.checked,
88
- onCheckedChange = { onCheckedChange(ToggleButtonValueChangeEvent(it)) },
89
- enabled = !props.disabled,
90
- modifier = modifier,
91
- colors = ToggleButtonDefaults.toggleButtonColors(),
92
- content = rowContent
93
- )
94
- }
112
+ @Composable
113
+ fun FunctionalComposableScope.OutlinedIconToggleButtonContent(
114
+ props: ToggleButtonProps,
115
+ onCheckedChange: (ToggleButtonValueChangeEvent) -> Unit
116
+ ) {
117
+ val modifier = ModifierRegistry.applyModifiers(props.modifiers, appContext, composableScope, globalEventDispatcher)
118
+ OutlinedIconToggleButton(
119
+ checked = props.checked,
120
+ onCheckedChange = { onCheckedChange(ToggleButtonValueChangeEvent(it)) },
121
+ enabled = props.enabled,
122
+ modifier = modifier,
123
+ colors = IconButtonDefaults.outlinedIconToggleButtonColors(
124
+ containerColor = props.colors.containerColor.compose,
125
+ contentColor = props.colors.contentColor.compose,
126
+ checkedContainerColor = props.colors.checkedContainerColor.compose,
127
+ checkedContentColor = props.colors.checkedContentColor.compose,
128
+ disabledContainerColor = props.colors.disabledContainerColor.compose,
129
+ disabledContentColor = props.colors.disabledContentColor.compose
130
+ )
131
+ ) {
132
+ Children(ComposableScope())
95
133
  }
96
134
  }