react-native-platform-components 1.2.0 → 1.4.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.
Files changed (242) hide show
  1. package/README.md +33 -31
  2. package/android/src/main/java/com/platformcomponents/PCButtonGroupView.kt +498 -0
  3. package/android/src/main/java/com/platformcomponents/PCButtonGroupViewManager.kt +191 -0
  4. package/android/src/main/java/com/platformcomponents/PCButtonSupport.kt +127 -0
  5. package/android/src/main/java/com/platformcomponents/PCButtonView.kt +345 -0
  6. package/android/src/main/java/com/platformcomponents/PCButtonViewManager.kt +126 -0
  7. package/android/src/main/java/com/platformcomponents/PCExpressive.kt +107 -0
  8. package/android/src/main/java/com/platformcomponents/PCFloatingToolbarView.kt +115 -0
  9. package/android/src/main/java/com/platformcomponents/PCFloatingToolbarViewManager.kt +65 -0
  10. package/android/src/main/java/com/platformcomponents/PCNativeThemeModule.kt +3 -0
  11. package/android/src/main/java/com/platformcomponents/PCSegmentedControlView.kt +13 -5
  12. package/android/src/main/java/com/platformcomponents/PCSegmentedControlViewManager.kt +6 -1
  13. package/android/src/main/java/com/platformcomponents/PCTextFieldView.kt +1018 -0
  14. package/android/src/main/java/com/platformcomponents/PCTextFieldViewManager.kt +248 -0
  15. package/android/src/main/java/com/platformcomponents/PlatformComponentsPackage.kt +13 -6
  16. package/android/src/main/jni/CMakeLists.txt +13 -1
  17. package/android/src/main/res/values/attrs.xml +13 -0
  18. package/android/src/main/res/values/styles.xml +183 -0
  19. package/ios/PCButton.h +10 -0
  20. package/ios/PCButton.mm +196 -0
  21. package/ios/PCButtonGroup.h +10 -0
  22. package/ios/PCButtonGroup.mm +256 -0
  23. package/ios/PCButtonGroupView.swift +254 -0
  24. package/ios/PCButtonSupport.swift +141 -0
  25. package/ios/PCButtonView.swift +155 -0
  26. package/ios/PCFloatingToolbar.h +10 -0
  27. package/ios/PCFloatingToolbar.mm +76 -0
  28. package/ios/PCFloatingToolbarView.swift +95 -0
  29. package/ios/PCNativeThemeModule.mm +13 -0
  30. package/ios/PCSelectionMenu.swift +9 -1
  31. package/ios/PCTextField.h +10 -0
  32. package/ios/PCTextField.mm +391 -0
  33. package/ios/PCTextFieldView.swift +1012 -0
  34. package/lib/commonjs/Button.js +77 -0
  35. package/lib/commonjs/Button.js.map +1 -0
  36. package/lib/commonjs/ButtonGroup.js +99 -0
  37. package/lib/commonjs/ButtonGroup.js.map +1 -0
  38. package/lib/commonjs/ButtonGroupNativeComponent.ts +121 -0
  39. package/lib/commonjs/ButtonNativeComponent.ts +76 -0
  40. package/lib/commonjs/ContextMenuNativeComponent.ts +5 -4
  41. package/lib/commonjs/DatePickerNativeComponent.ts +17 -11
  42. package/lib/commonjs/FloatingToolbar.js +69 -0
  43. package/lib/commonjs/FloatingToolbar.js.map +1 -0
  44. package/lib/commonjs/FloatingToolbarNativeComponent.ts +31 -0
  45. package/lib/commonjs/LiquidGlass.js +24 -4
  46. package/lib/commonjs/LiquidGlass.js.map +1 -1
  47. package/lib/commonjs/LiquidGlassNativeComponent.ts +6 -5
  48. package/lib/commonjs/NativePlatformComponentsTheme.js.map +1 -1
  49. package/lib/commonjs/SegmentedControl.js +11 -85
  50. package/lib/commonjs/SegmentedControl.js.map +1 -1
  51. package/lib/commonjs/SegmentedControlNativeComponent.ts +15 -11
  52. package/lib/commonjs/SelectionMenuNativeComponent.ts +6 -5
  53. package/lib/commonjs/TextField.js +195 -0
  54. package/lib/commonjs/TextField.js.map +1 -0
  55. package/lib/commonjs/TextFieldNativeComponent.ts +218 -0
  56. package/lib/commonjs/codegenTypes.js +6 -0
  57. package/lib/commonjs/codegenTypes.js.map +1 -0
  58. package/lib/commonjs/focusRegistry.js +78 -0
  59. package/lib/commonjs/focusRegistry.js.map +1 -0
  60. package/lib/commonjs/icons.js +92 -0
  61. package/lib/commonjs/icons.js.map +1 -0
  62. package/lib/commonjs/index.js +66 -0
  63. package/lib/commonjs/index.js.map +1 -1
  64. package/lib/commonjs/index.web.js +32 -2
  65. package/lib/commonjs/index.web.js.map +1 -1
  66. package/lib/commonjs/labelStyle.js +27 -0
  67. package/lib/commonjs/labelStyle.js.map +1 -0
  68. package/lib/commonjs/reactNativeInternals.d.js +2 -0
  69. package/lib/commonjs/reactNativeInternals.d.js.map +1 -0
  70. package/lib/module/Button.js +70 -0
  71. package/lib/module/Button.js.map +1 -0
  72. package/lib/module/ButtonGroup.js +92 -0
  73. package/lib/module/ButtonGroup.js.map +1 -0
  74. package/lib/module/ButtonGroupNativeComponent.ts +121 -0
  75. package/lib/module/ButtonNativeComponent.ts +76 -0
  76. package/lib/module/ContextMenuNativeComponent.ts +5 -4
  77. package/lib/module/DatePickerNativeComponent.ts +17 -11
  78. package/lib/module/FloatingToolbar.js +62 -0
  79. package/lib/module/FloatingToolbar.js.map +1 -0
  80. package/lib/module/FloatingToolbarNativeComponent.ts +31 -0
  81. package/lib/module/LiquidGlass.js +24 -4
  82. package/lib/module/LiquidGlass.js.map +1 -1
  83. package/lib/module/LiquidGlassNativeComponent.ts +6 -5
  84. package/lib/module/NativePlatformComponentsTheme.js.map +1 -1
  85. package/lib/module/SegmentedControl.js +12 -87
  86. package/lib/module/SegmentedControl.js.map +1 -1
  87. package/lib/module/SegmentedControlNativeComponent.ts +15 -11
  88. package/lib/module/SelectionMenuNativeComponent.ts +6 -5
  89. package/lib/module/TextField.js +189 -0
  90. package/lib/module/TextField.js.map +1 -0
  91. package/lib/module/TextFieldNativeComponent.ts +218 -0
  92. package/lib/module/codegenTypes.js +4 -0
  93. package/lib/module/codegenTypes.js.map +1 -0
  94. package/lib/module/focusRegistry.js +74 -0
  95. package/lib/module/focusRegistry.js.map +1 -0
  96. package/lib/module/icons.js +87 -0
  97. package/lib/module/icons.js.map +1 -0
  98. package/lib/module/index.js +6 -0
  99. package/lib/module/index.js.map +1 -1
  100. package/lib/module/index.web.js +28 -0
  101. package/lib/module/index.web.js.map +1 -1
  102. package/lib/module/labelStyle.js +23 -0
  103. package/lib/module/labelStyle.js.map +1 -0
  104. package/lib/module/reactNativeInternals.d.js +2 -0
  105. package/lib/module/reactNativeInternals.d.js.map +1 -0
  106. package/lib/typescript/commonjs/docs/sidebars.d.ts.map +1 -1
  107. package/lib/typescript/commonjs/src/Button.d.ts +76 -0
  108. package/lib/typescript/commonjs/src/Button.d.ts.map +1 -0
  109. package/lib/typescript/commonjs/src/ButtonGroup.d.ts +102 -0
  110. package/lib/typescript/commonjs/src/ButtonGroup.d.ts.map +1 -0
  111. package/lib/typescript/commonjs/src/ButtonGroupNativeComponent.d.ts +93 -0
  112. package/lib/typescript/commonjs/src/ButtonGroupNativeComponent.d.ts.map +1 -0
  113. package/lib/typescript/commonjs/src/ButtonNativeComponent.d.ts +57 -0
  114. package/lib/typescript/commonjs/src/ButtonNativeComponent.d.ts.map +1 -0
  115. package/lib/typescript/commonjs/src/ContextMenuNativeComponent.d.ts +5 -4
  116. package/lib/typescript/commonjs/src/ContextMenuNativeComponent.d.ts.map +1 -1
  117. package/lib/typescript/commonjs/src/DatePickerNativeComponent.d.ts +12 -11
  118. package/lib/typescript/commonjs/src/DatePickerNativeComponent.d.ts.map +1 -1
  119. package/lib/typescript/commonjs/src/FloatingToolbar.d.ts +45 -0
  120. package/lib/typescript/commonjs/src/FloatingToolbar.d.ts.map +1 -0
  121. package/lib/typescript/commonjs/src/FloatingToolbarNativeComponent.d.ts +24 -0
  122. package/lib/typescript/commonjs/src/FloatingToolbarNativeComponent.d.ts.map +1 -0
  123. package/lib/typescript/commonjs/src/LiquidGlass.d.ts +4 -3
  124. package/lib/typescript/commonjs/src/LiquidGlass.d.ts.map +1 -1
  125. package/lib/typescript/commonjs/src/LiquidGlassNativeComponent.d.ts +6 -5
  126. package/lib/typescript/commonjs/src/LiquidGlassNativeComponent.d.ts.map +1 -1
  127. package/lib/typescript/commonjs/src/NativePlatformComponentsTheme.d.ts +10 -2
  128. package/lib/typescript/commonjs/src/NativePlatformComponentsTheme.d.ts.map +1 -1
  129. package/lib/typescript/commonjs/src/SegmentedControl.d.ts +17 -46
  130. package/lib/typescript/commonjs/src/SegmentedControl.d.ts.map +1 -1
  131. package/lib/typescript/commonjs/src/SegmentedControlNativeComponent.d.ts +9 -6
  132. package/lib/typescript/commonjs/src/SegmentedControlNativeComponent.d.ts.map +1 -1
  133. package/lib/typescript/commonjs/src/SelectionMenuNativeComponent.d.ts +6 -5
  134. package/lib/typescript/commonjs/src/SelectionMenuNativeComponent.d.ts.map +1 -1
  135. package/lib/typescript/commonjs/src/TextField.d.ts +174 -0
  136. package/lib/typescript/commonjs/src/TextField.d.ts.map +1 -0
  137. package/lib/typescript/commonjs/src/TextFieldNativeComponent.d.ts +162 -0
  138. package/lib/typescript/commonjs/src/TextFieldNativeComponent.d.ts.map +1 -0
  139. package/lib/typescript/commonjs/src/codegenTypes.d.ts +12 -0
  140. package/lib/typescript/commonjs/src/codegenTypes.d.ts.map +1 -0
  141. package/lib/typescript/commonjs/src/focusRegistry.d.ts +13 -0
  142. package/lib/typescript/commonjs/src/focusRegistry.d.ts.map +1 -0
  143. package/lib/typescript/commonjs/src/icons.d.ts +52 -0
  144. package/lib/typescript/commonjs/src/icons.d.ts.map +1 -0
  145. package/lib/typescript/commonjs/src/index.d.ts +6 -0
  146. package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
  147. package/lib/typescript/commonjs/src/index.web.d.ts +121 -0
  148. package/lib/typescript/commonjs/src/index.web.d.ts.map +1 -1
  149. package/lib/typescript/commonjs/src/labelStyle.d.ts +20 -0
  150. package/lib/typescript/commonjs/src/labelStyle.d.ts.map +1 -0
  151. package/lib/typescript/commonjs/src/sharedTypes.d.ts +8 -3
  152. package/lib/typescript/commonjs/src/sharedTypes.d.ts.map +1 -1
  153. package/lib/typescript/module/docs/sidebars.d.ts.map +1 -1
  154. package/lib/typescript/module/src/Button.d.ts +76 -0
  155. package/lib/typescript/module/src/Button.d.ts.map +1 -0
  156. package/lib/typescript/module/src/ButtonGroup.d.ts +102 -0
  157. package/lib/typescript/module/src/ButtonGroup.d.ts.map +1 -0
  158. package/lib/typescript/module/src/ButtonGroupNativeComponent.d.ts +93 -0
  159. package/lib/typescript/module/src/ButtonGroupNativeComponent.d.ts.map +1 -0
  160. package/lib/typescript/module/src/ButtonNativeComponent.d.ts +57 -0
  161. package/lib/typescript/module/src/ButtonNativeComponent.d.ts.map +1 -0
  162. package/lib/typescript/module/src/ContextMenuNativeComponent.d.ts +5 -4
  163. package/lib/typescript/module/src/ContextMenuNativeComponent.d.ts.map +1 -1
  164. package/lib/typescript/module/src/DatePickerNativeComponent.d.ts +12 -11
  165. package/lib/typescript/module/src/DatePickerNativeComponent.d.ts.map +1 -1
  166. package/lib/typescript/module/src/FloatingToolbar.d.ts +45 -0
  167. package/lib/typescript/module/src/FloatingToolbar.d.ts.map +1 -0
  168. package/lib/typescript/module/src/FloatingToolbarNativeComponent.d.ts +24 -0
  169. package/lib/typescript/module/src/FloatingToolbarNativeComponent.d.ts.map +1 -0
  170. package/lib/typescript/module/src/LiquidGlass.d.ts +4 -3
  171. package/lib/typescript/module/src/LiquidGlass.d.ts.map +1 -1
  172. package/lib/typescript/module/src/LiquidGlassNativeComponent.d.ts +6 -5
  173. package/lib/typescript/module/src/LiquidGlassNativeComponent.d.ts.map +1 -1
  174. package/lib/typescript/module/src/NativePlatformComponentsTheme.d.ts +10 -2
  175. package/lib/typescript/module/src/NativePlatformComponentsTheme.d.ts.map +1 -1
  176. package/lib/typescript/module/src/SegmentedControl.d.ts +17 -46
  177. package/lib/typescript/module/src/SegmentedControl.d.ts.map +1 -1
  178. package/lib/typescript/module/src/SegmentedControlNativeComponent.d.ts +9 -6
  179. package/lib/typescript/module/src/SegmentedControlNativeComponent.d.ts.map +1 -1
  180. package/lib/typescript/module/src/SelectionMenuNativeComponent.d.ts +6 -5
  181. package/lib/typescript/module/src/SelectionMenuNativeComponent.d.ts.map +1 -1
  182. package/lib/typescript/module/src/TextField.d.ts +174 -0
  183. package/lib/typescript/module/src/TextField.d.ts.map +1 -0
  184. package/lib/typescript/module/src/TextFieldNativeComponent.d.ts +162 -0
  185. package/lib/typescript/module/src/TextFieldNativeComponent.d.ts.map +1 -0
  186. package/lib/typescript/module/src/codegenTypes.d.ts +12 -0
  187. package/lib/typescript/module/src/codegenTypes.d.ts.map +1 -0
  188. package/lib/typescript/module/src/focusRegistry.d.ts +13 -0
  189. package/lib/typescript/module/src/focusRegistry.d.ts.map +1 -0
  190. package/lib/typescript/module/src/icons.d.ts +52 -0
  191. package/lib/typescript/module/src/icons.d.ts.map +1 -0
  192. package/lib/typescript/module/src/index.d.ts +6 -0
  193. package/lib/typescript/module/src/index.d.ts.map +1 -1
  194. package/lib/typescript/module/src/index.web.d.ts +121 -0
  195. package/lib/typescript/module/src/index.web.d.ts.map +1 -1
  196. package/lib/typescript/module/src/labelStyle.d.ts +20 -0
  197. package/lib/typescript/module/src/labelStyle.d.ts.map +1 -0
  198. package/lib/typescript/module/src/sharedTypes.d.ts +8 -3
  199. package/lib/typescript/module/src/sharedTypes.d.ts.map +1 -1
  200. package/package.json +28 -6
  201. package/react-native.config.js +3 -0
  202. package/shared/PCButtonComponentDescriptors-custom.h +22 -0
  203. package/shared/PCButtonGroupComponentDescriptors-custom.h +22 -0
  204. package/shared/PCButtonGroupShadowNode-custom.cpp +48 -0
  205. package/shared/PCButtonGroupShadowNode-custom.h +55 -0
  206. package/shared/PCButtonGroupState-custom.h +61 -0
  207. package/shared/PCButtonShadowNode-custom.cpp +48 -0
  208. package/shared/PCButtonShadowNode-custom.h +55 -0
  209. package/shared/PCButtonState-custom.h +61 -0
  210. package/shared/PCDatePickerState-custom.h +2 -2
  211. package/shared/PCSegmentedControlState-custom.h +2 -2
  212. package/shared/PCSelectionMenuState-custom.h +2 -2
  213. package/shared/PCTextFieldComponentDescriptors-custom.h +22 -0
  214. package/shared/PCTextFieldShadowNode-custom.cpp +47 -0
  215. package/shared/PCTextFieldShadowNode-custom.h +55 -0
  216. package/shared/PCTextFieldState-custom.h +61 -0
  217. package/shared/react/renderer/components/PlatformComponentsViewSpec/ComponentDescriptors.h +3 -0
  218. package/src/Button.tsx +144 -0
  219. package/src/ButtonGroup.tsx +233 -0
  220. package/src/ButtonGroupNativeComponent.ts +121 -0
  221. package/src/ButtonNativeComponent.ts +76 -0
  222. package/src/ContextMenuNativeComponent.ts +5 -4
  223. package/src/DatePickerNativeComponent.ts +17 -11
  224. package/src/FloatingToolbar.tsx +113 -0
  225. package/src/FloatingToolbarNativeComponent.ts +31 -0
  226. package/src/LiquidGlass.tsx +24 -5
  227. package/src/LiquidGlassNativeComponent.ts +6 -5
  228. package/src/NativePlatformComponentsTheme.ts +11 -2
  229. package/src/SegmentedControl.tsx +26 -118
  230. package/src/SegmentedControlNativeComponent.ts +15 -11
  231. package/src/SelectionMenuNativeComponent.ts +6 -5
  232. package/src/TextField.tsx +494 -0
  233. package/src/TextFieldNativeComponent.ts +218 -0
  234. package/src/codegenTypes.ts +40 -0
  235. package/src/focusRegistry.ts +89 -0
  236. package/src/icons.ts +116 -0
  237. package/src/index.tsx +6 -0
  238. package/src/index.web.tsx +194 -0
  239. package/src/labelStyle.ts +36 -0
  240. package/src/reactNativeInternals.d.ts +22 -0
  241. package/src/sharedTypes.ts +9 -3
  242. /package/{app.plugin.cjs → app.plugin.js} +0 -0
@@ -1,6 +1,7 @@
1
1
  // ContextMenuNativeComponent.ts
2
- import type { CodegenTypes, HostComponent, ViewProps } from 'react-native';
2
+ import type { HostComponent, ViewProps } from 'react-native';
3
3
  import { codegenNativeComponent } from 'react-native';
4
+ import type { BubblingEventHandler } from './codegenTypes';
4
5
 
5
6
  /**
6
7
  * Attributes for a context menu action.
@@ -120,17 +121,17 @@ export interface ContextMenuProps extends ViewProps {
120
121
  /**
121
122
  * Fired when user presses an action.
122
123
  */
123
- onPressAction?: CodegenTypes.BubblingEventHandler<ContextMenuPressActionEvent>;
124
+ onPressAction?: BubblingEventHandler<ContextMenuPressActionEvent>;
124
125
 
125
126
  /**
126
127
  * Fired when menu opens.
127
128
  */
128
- onMenuOpen?: CodegenTypes.BubblingEventHandler<Readonly<{}>>;
129
+ onMenuOpen?: BubblingEventHandler<Readonly<{}>>;
129
130
 
130
131
  /**
131
132
  * Fired when menu closes.
132
133
  */
133
- onMenuClose?: CodegenTypes.BubblingEventHandler<Readonly<{}>>;
134
+ onMenuClose?: BubblingEventHandler<Readonly<{}>>;
134
135
 
135
136
  ios?: IOSProps;
136
137
  android?: AndroidProps;
@@ -1,11 +1,17 @@
1
1
  // DatePickerNativeComponent.ts
2
- import type { CodegenTypes, HostComponent, ViewProps } from 'react-native';
2
+ import type { HostComponent, ViewProps } from 'react-native';
3
3
  import { codegenNativeComponent } from 'react-native';
4
+ import type {
5
+ BubblingEventHandler,
6
+ Double,
7
+ Int32,
8
+ WithDefault,
9
+ } from './codegenTypes';
4
10
 
5
- export type TimestampMs = CodegenTypes.Double;
11
+ export type TimestampMs = Double;
6
12
 
7
13
  export type DateChangeEvent = {
8
- timestampMs: CodegenTypes.Double;
14
+ timestampMs: Double;
9
15
  confirmed: boolean;
10
16
  };
11
17
 
@@ -18,14 +24,14 @@ export type IOSConfirmToolbar = 'show' | 'hide';
18
24
 
19
25
  export type IOSProps = {
20
26
  preferredStyle?: string; // IOSDatePickerStyle
21
- countDownDurationSeconds?: CodegenTypes.Double;
22
- minuteInterval?: CodegenTypes.Int32;
27
+ countDownDurationSeconds?: Double;
28
+ minuteInterval?: Int32;
23
29
  roundsToMinuteInterval?: string; // IOSRoundsToMinuteInterval
24
30
  confirmToolbar?: string; // IOSConfirmToolbar
25
31
  };
26
32
 
27
33
  export type AndroidProps = {
28
- firstDayOfWeek?: CodegenTypes.Int32;
34
+ firstDayOfWeek?: Int32;
29
35
  material?: string; // AndroidMaterialMode
30
36
  dialogTitle?: string;
31
37
  positiveButtonTitle?: string;
@@ -44,9 +50,9 @@ export type MacOSProps = Readonly<{}>;
44
50
  export type CommonProps = {
45
51
  mode?: string; // DatePickerMode
46
52
 
47
- dateMs?: CodegenTypes.WithDefault<TimestampMs, -9007199254740991>;
48
- minDateMs?: CodegenTypes.WithDefault<TimestampMs, -9007199254740991>;
49
- maxDateMs?: CodegenTypes.WithDefault<TimestampMs, -9007199254740991>;
53
+ dateMs?: WithDefault<TimestampMs, -9007199254740991>;
54
+ minDateMs?: WithDefault<TimestampMs, -9007199254740991>;
55
+ maxDateMs?: WithDefault<TimestampMs, -9007199254740991>;
50
56
 
51
57
  locale?: string;
52
58
  timeZoneName?: string;
@@ -65,8 +71,8 @@ export interface NativeProps extends ViewProps, CommonProps {
65
71
  ios?: IOSProps;
66
72
  android?: AndroidProps;
67
73
 
68
- onConfirm?: CodegenTypes.BubblingEventHandler<DateChangeEvent>;
69
- onClosed?: CodegenTypes.BubblingEventHandler<Readonly<{}>>;
74
+ onConfirm?: BubblingEventHandler<DateChangeEvent>;
75
+ onClosed?: BubblingEventHandler<Readonly<{}>>;
70
76
  }
71
77
 
72
78
  export default codegenNativeComponent<NativeProps>(
@@ -0,0 +1,113 @@
1
+ // FloatingToolbar.tsx
2
+ import React, { useMemo } from 'react';
3
+ import {
4
+ Platform,
5
+ StyleSheet,
6
+ type ColorValue,
7
+ type StyleProp,
8
+ type ViewProps,
9
+ type ViewStyle,
10
+ } from 'react-native';
11
+
12
+ import NativeFloatingToolbar from './FloatingToolbarNativeComponent';
13
+
14
+ /** Glass effect style of the toolbar on iOS 26. */
15
+ export type FloatingToolbarIOSEffect = 'regular' | 'clear';
16
+
17
+ /** Material 3 color variant of the toolbar on Android. */
18
+ export type FloatingToolbarAndroidVariant = 'standard' | 'vibrant';
19
+
20
+ export interface FloatingToolbarProps extends ViewProps {
21
+ /**
22
+ * Layout direction of the children. Default: `'horizontal'`.
23
+ */
24
+ orientation?: 'horizontal' | 'vertical';
25
+
26
+ /**
27
+ * Container color. Default: the platform's toolbar material (Material 3
28
+ * `surfaceContainer` or `primaryContainer` on Android, Liquid Glass or a
29
+ * blur on iOS). Use this rather than `style.backgroundColor`, which would
30
+ * replace the native shape.
31
+ */
32
+ color?: ColorValue;
33
+
34
+ /**
35
+ * iOS-specific configuration
36
+ */
37
+ ios?: {
38
+ /**
39
+ * Glass effect style on iOS 26. Older versions use a blur.
40
+ * Default: `'regular'`.
41
+ */
42
+ effect?: FloatingToolbarIOSEffect;
43
+ };
44
+
45
+ /**
46
+ * Android-specific configuration
47
+ */
48
+ android?: {
49
+ /**
50
+ * Material 3 color variant: `'standard'` (surface) or `'vibrant'`
51
+ * (primary container). Default: `'standard'`.
52
+ */
53
+ variant?: FloatingToolbarAndroidVariant;
54
+ };
55
+
56
+ /** The toolbar's actions, usually `Button`s. */
57
+ children?: React.ReactNode;
58
+
59
+ /** Test identifier */
60
+ testID?: string;
61
+ }
62
+
63
+ export function FloatingToolbar(
64
+ props: FloatingToolbarProps
65
+ ): React.ReactElement {
66
+ const { style, orientation, color, ios, android, children, ...viewProps } =
67
+ props;
68
+
69
+ const nativeIos = useMemo(() => {
70
+ if (Platform.OS !== 'ios' || !ios) return undefined;
71
+ return { effect: ios.effect ?? 'regular' };
72
+ }, [ios]);
73
+
74
+ const nativeAndroid = useMemo(() => {
75
+ if (Platform.OS !== 'android' || !android) return undefined;
76
+ return { variant: android.variant ?? 'standard' };
77
+ }, [android]);
78
+
79
+ const mergedStyle = useMemo(
80
+ (): StyleProp<ViewStyle> => [
81
+ styles.toolbar,
82
+ orientation === 'vertical' ? styles.vertical : styles.horizontal,
83
+ style,
84
+ ],
85
+ [orientation, style]
86
+ );
87
+
88
+ return (
89
+ <NativeFloatingToolbar
90
+ style={mergedStyle}
91
+ color={color}
92
+ ios={nativeIos}
93
+ android={nativeAndroid}
94
+ {...viewProps}
95
+ >
96
+ {children}
97
+ </NativeFloatingToolbar>
98
+ );
99
+ }
100
+
101
+ // Material 3 floating toolbar: 8dp container padding, 4dp between actions.
102
+ // The capsule shape comes from native.
103
+ const styles = StyleSheet.create({
104
+ toolbar: {
105
+ alignSelf: 'center',
106
+ alignItems: 'center',
107
+ justifyContent: 'center',
108
+ padding: 8,
109
+ gap: 4,
110
+ },
111
+ horizontal: { flexDirection: 'row' },
112
+ vertical: { flexDirection: 'column' },
113
+ });
@@ -0,0 +1,31 @@
1
+ // FloatingToolbarNativeComponent.ts
2
+ import type { ColorValue, HostComponent, ViewProps } from 'react-native';
3
+ import { codegenNativeComponent } from 'react-native';
4
+
5
+ /**
6
+ * iOS-specific configuration.
7
+ */
8
+ export type FloatingToolbarIOSProps = Readonly<{
9
+ /** Glass effect style on iOS 26: 'regular' | 'clear' */
10
+ effect?: string;
11
+ }>;
12
+
13
+ /**
14
+ * Android-specific configuration.
15
+ */
16
+ export type FloatingToolbarAndroidProps = Readonly<{
17
+ /** Material color variant: 'standard' | 'vibrant' */
18
+ variant?: string;
19
+ }>;
20
+
21
+ export interface FloatingToolbarNativeProps extends ViewProps {
22
+ /** Container color. Default: the platform's toolbar material. */
23
+ color?: ColorValue;
24
+
25
+ ios?: FloatingToolbarIOSProps;
26
+ android?: FloatingToolbarAndroidProps;
27
+ }
28
+
29
+ export default codegenNativeComponent<FloatingToolbarNativeProps>(
30
+ 'PCFloatingToolbar'
31
+ ) as HostComponent<FloatingToolbarNativeProps>;
@@ -7,6 +7,7 @@ import NativeLiquidGlass, {
7
7
  type LiquidGlassEffect,
8
8
  type LiquidGlassPressEvent,
9
9
  } from './LiquidGlassNativeComponent';
10
+ import NativePlatformComponentsTheme from './NativePlatformComponentsTheme';
10
11
 
11
12
  export type {
12
13
  LiquidGlassEffect,
@@ -14,14 +15,32 @@ export type {
14
15
  LiquidGlassPressEvent,
15
16
  };
16
17
 
18
+ function resolveLiquidGlassSupport(): boolean {
19
+ if (Platform.OS !== 'ios') {
20
+ return false;
21
+ }
22
+ try {
23
+ // The native module answers for this build: Liquid Glass is compiled out
24
+ // when the library is built with an Xcode that predates the iOS 26 SDK,
25
+ // and then no device version makes it available.
26
+ const supported = NativePlatformComponentsTheme?.isLiquidGlassSupported();
27
+ if (typeof supported === 'boolean') {
28
+ return supported;
29
+ }
30
+ } catch {
31
+ // Native module not available (web, tests): fall back to the OS version.
32
+ }
33
+ return parseInt(String(Platform.Version), 10) >= 26;
34
+ }
35
+
17
36
  /**
18
- * Whether the LiquidGlass effect is supported on the current device.
19
- * Returns true on iOS 26+ (with Liquid Glass support), false otherwise.
37
+ * Whether the LiquidGlass effect is supported here: iOS 26 or newer, in a
38
+ * build compiled against the iOS 26 SDK. False on Android, on older iOS, and
39
+ * in builds made with an older Xcode, where the views fall back to a blur.
20
40
  *
21
- * Use this to conditionally render fallback UI on unsupported devices.
41
+ * Use this to conditionally render fallback UI.
22
42
  */
23
- export const isLiquidGlassSupported: boolean =
24
- Platform.OS === 'ios' && parseInt(String(Platform.Version), 10) >= 26;
43
+ export const isLiquidGlassSupported: boolean = resolveLiquidGlassSupport();
25
44
 
26
45
  export interface LiquidGlassProps extends ViewProps {
27
46
  /**
@@ -1,6 +1,7 @@
1
1
  // LiquidGlassNativeComponent.ts
2
- import type { CodegenTypes, HostComponent, ViewProps } from 'react-native';
2
+ import type { HostComponent, ViewProps } from 'react-native';
3
3
  import { codegenNativeComponent } from 'react-native';
4
+ import type { DirectEventHandler, Float, WithDefault } from './codegenTypes';
4
5
 
5
6
  /**
6
7
  * Glass effect intensity/style.
@@ -64,9 +65,9 @@ export type LiquidGlassAndroidProps = Readonly<{
64
65
  */
65
66
  export type LiquidGlassPressEvent = Readonly<{
66
67
  /** X coordinate of touch relative to view bounds */
67
- x: CodegenTypes.Float;
68
+ x: Float;
68
69
  /** Y coordinate of touch relative to view bounds */
69
- y: CodegenTypes.Float;
70
+ y: Float;
70
71
  }>;
71
72
 
72
73
  export interface LiquidGlassNativeProps extends ViewProps {
@@ -75,7 +76,7 @@ export interface LiquidGlassNativeProps extends ViewProps {
75
76
  * Applied uniformly to all corners.
76
77
  * @default 0
77
78
  */
78
- cornerRadius?: CodegenTypes.WithDefault<CodegenTypes.Float, 0>;
79
+ cornerRadius?: WithDefault<Float, 0>;
79
80
 
80
81
  /**
81
82
  * iOS-specific props.
@@ -91,7 +92,7 @@ export interface LiquidGlassNativeProps extends ViewProps {
91
92
  * Fired when the glass view is pressed.
92
93
  * Includes touch coordinates relative to view bounds.
93
94
  */
94
- onGlassPress?: CodegenTypes.DirectEventHandler<LiquidGlassPressEvent>;
95
+ onGlassPress?: DirectEventHandler<LiquidGlassPressEvent>;
95
96
  }
96
97
 
97
98
  export default codegenNativeComponent<LiquidGlassNativeProps>(
@@ -1,13 +1,22 @@
1
1
  // NativePlatformComponentsTheme.ts
2
- import type { CodegenTypes, TurboModule } from 'react-native';
2
+ import type { TurboModule } from 'react-native';
3
3
  import { TurboModuleRegistry } from 'react-native';
4
+ import type { UnsafeObject } from './codegenTypes';
4
5
 
5
6
  export interface Spec extends TurboModule {
6
7
  /**
7
8
  * `{ primary }`, where `primary` is a color from `processColor`. An empty
8
9
  * object restores the app's own theme colors.
9
10
  */
10
- setTheme(theme: CodegenTypes.UnsafeObject): void;
11
+ setTheme(theme: UnsafeObject): void;
12
+
13
+ /**
14
+ * Whether this build can render Liquid Glass: true only when the library was
15
+ * compiled against the iOS 26 SDK *and* the device runs iOS 26 or newer.
16
+ * Built with an older Xcode, the glass code is compiled out and the views
17
+ * fall back to a blur, so the device version alone cannot answer this.
18
+ */
19
+ isLiquidGlassSupported(): boolean;
11
20
  }
12
21
 
13
22
  export default TurboModuleRegistry.get<Spec>('PlatformComponentsTheme');
@@ -1,14 +1,10 @@
1
1
  // SegmentedControl.tsx
2
2
  import React, { useCallback, useMemo } from 'react';
3
3
  import {
4
- Image,
5
4
  Platform,
6
5
  StyleSheet,
7
6
  type ColorValue,
8
- type ImageRequireSource,
9
- type ImageURISource,
10
7
  type StyleProp,
11
- type TextStyle,
12
8
  type ViewProps,
13
9
  type ViewStyle,
14
10
  } from 'react-native';
@@ -17,44 +13,27 @@ import NativeSegmentedControl, {
17
13
  type SegmentedControlSegment as NativeSegment,
18
14
  type SegmentedControlSelectEvent,
19
15
  } from './SegmentedControlNativeComponent';
16
+ import {
17
+ resolveIcon,
18
+ type PlatformIcon,
19
+ type PlatformIconSource,
20
+ } from './icons';
21
+ import { normalizeLabelStyle, type LabelStyle } from './labelStyle';
22
+ import type { AndroidMaterialStyle } from './sharedTypes';
20
23
 
21
24
  // Android: Minimum height to ensure visibility.
22
25
  // Fabric's shadow node measurement isn't being called on initial render,
23
26
  // so we apply a minHeight that matches Material design touch target guidelines.
24
27
  const ANDROID_MIN_HEIGHT = 48;
25
28
 
26
- /**
27
- * A single icon source.
28
- *
29
- * - `string`: shorthand for an SF Symbol name on iOS and a drawable resource
30
- * name on Android (the original API).
31
- * - `{ type: 'sfSymbol' }`: an SF Symbol. iOS only; ignored on Android.
32
- * - `{ type: 'drawable' }`: a drawable from the app's `res/drawable`.
33
- * Android only; ignored on iOS.
34
- * - `{ type: 'image' }`: an image asset (`require('./icon.png')`) or a
35
- * `{ uri }` source. Works on both platforms. Images are drawn as tinted
36
- * templates unless `tinted` is `false`.
37
- */
38
- export type SegmentedControlIconSource =
39
- | string
40
- | { type: 'sfSymbol'; name: string }
41
- | { type: 'drawable'; name: string }
42
- | {
43
- type: 'image';
44
- source: ImageRequireSource | ImageURISource;
45
- tinted?: boolean;
46
- };
29
+ /** A single icon source. Alias of {@link PlatformIconSource}. */
30
+ export type SegmentedControlIconSource = PlatformIconSource;
47
31
 
48
32
  /**
49
33
  * An icon for a segment: a single source used on both platforms, or a
50
- * per-platform pair so callers don't need to branch on `Platform.OS`.
34
+ * per-platform pair. Alias of {@link PlatformIcon}.
51
35
  */
52
- export type SegmentedControlIcon =
53
- | SegmentedControlIconSource
54
- | {
55
- ios?: SegmentedControlIconSource;
56
- android?: SegmentedControlIconSource;
57
- };
36
+ export type SegmentedControlIcon = PlatformIcon;
58
37
 
59
38
  /**
60
39
  * How labels and icons combine for segments that have an icon.
@@ -67,15 +46,8 @@ export type SegmentedControlIcon =
67
46
  */
68
47
  export type SegmentedControlLabelVisibility = 'auto' | 'labeled' | 'unlabeled';
69
48
 
70
- /**
71
- * Font for segment labels. Each field falls back to the platform default.
72
- */
73
- export interface SegmentedControlLabelStyle {
74
- fontFamily?: string;
75
- fontSize?: number;
76
- fontWeight?: TextStyle['fontWeight'];
77
- fontStyle?: 'normal' | 'italic';
78
- }
49
+ /** Font for segment labels. Alias of {@link LabelStyle}. */
50
+ export type SegmentedControlLabelStyle = LabelStyle;
79
51
 
80
52
  /**
81
53
  * Badge colors. Both default to the platform look (red with white text).
@@ -201,77 +173,20 @@ export interface SegmentedControlProps extends ViewProps {
201
173
 
202
174
  /** Outline color of the segments. */
203
175
  strokeColor?: ColorValue;
176
+
177
+ /**
178
+ * Material style: the Material 3 Expressive connected buttons (default),
179
+ * or the classic Material 3 segmented buttons.
180
+ */
181
+ material?: AndroidMaterialStyle;
204
182
  };
205
183
 
206
184
  /** Test identifier */
207
185
  testID?: string;
208
186
  }
209
187
 
210
- type NativeIconFields = Pick<
211
- NativeSegment,
212
- 'iconType' | 'iconName' | 'iconUri' | 'iconScale' | 'iconTinted'
213
- >;
214
-
215
- const NO_ICON: NativeIconFields = {
216
- iconType: '',
217
- iconName: '',
218
- iconUri: '',
219
- iconScale: 1,
220
- iconTinted: 'true',
221
- };
222
-
223
- function pickIconSource(
224
- icon: SegmentedControlIcon | undefined
225
- ): SegmentedControlIconSource | undefined {
226
- if (icon === undefined || typeof icon === 'string' || 'type' in icon) {
227
- return icon;
228
- }
229
- return Platform.OS === 'ios' ? icon.ios : icon.android;
230
- }
231
-
232
- /**
233
- * Flattens the public icon shape into the strings native expects, dropping
234
- * sources that don't apply to the current platform.
235
- */
236
- export function resolveSegmentIcon(
237
- icon: SegmentedControlIcon | undefined
238
- ): NativeIconFields {
239
- const source = pickIconSource(icon);
240
- if (source === undefined) return NO_ICON;
241
-
242
- if (typeof source === 'string') {
243
- if (source.length === 0) return NO_ICON;
244
- return {
245
- ...NO_ICON,
246
- iconType: Platform.OS === 'ios' ? 'sfSymbol' : 'drawable',
247
- iconName: source,
248
- };
249
- }
250
-
251
- switch (source.type) {
252
- case 'sfSymbol':
253
- return Platform.OS === 'ios'
254
- ? { ...NO_ICON, iconType: 'sfSymbol', iconName: source.name }
255
- : NO_ICON;
256
- case 'drawable':
257
- return Platform.OS === 'android'
258
- ? { ...NO_ICON, iconType: 'drawable', iconName: source.name }
259
- : NO_ICON;
260
- case 'image': {
261
- const resolved = Image.resolveAssetSource(source.source);
262
- if (!resolved?.uri) return NO_ICON;
263
- return {
264
- iconType: 'image',
265
- iconName: '',
266
- iconUri: resolved.uri,
267
- iconScale: resolved.scale > 0 ? resolved.scale : 1,
268
- iconTinted: source.tinted === false ? 'false' : 'true',
269
- };
270
- }
271
- default:
272
- return NO_ICON;
273
- }
274
- }
188
+ /** Flattens a segment icon for native. Alias of {@link resolveIcon}. */
189
+ export const resolveSegmentIcon = resolveIcon;
275
190
 
276
191
  function normalizeSelectedValue(selected: string | null): string {
277
192
  return selected ?? '';
@@ -346,24 +261,17 @@ export function SegmentedControl(
346
261
  (Platform.OS === 'ios' ? ios?.selectedSegmentTintColor : undefined);
347
262
 
348
263
  // Normalize the label font; empty / 0 means platform default
349
- const nativeLabelStyle = useMemo(() => {
350
- if (!labelStyle) return undefined;
351
- return {
352
- fontFamily: labelStyle.fontFamily ?? '',
353
- fontSize: labelStyle.fontSize ?? 0,
354
- fontWeight:
355
- labelStyle.fontWeight === undefined
356
- ? ''
357
- : String(labelStyle.fontWeight),
358
- fontStyle: labelStyle.fontStyle ?? '',
359
- };
360
- }, [labelStyle]);
264
+ const nativeLabelStyle = useMemo(
265
+ () => normalizeLabelStyle(labelStyle),
266
+ [labelStyle]
267
+ );
361
268
 
362
269
  // Normalize Android props
363
270
  const nativeAndroid = useMemo(() => {
364
271
  if (!android) return undefined;
365
272
  return {
366
273
  selectionRequired: android.selectionRequired === false ? 'false' : 'true',
274
+ material: android.material ?? 'expressive',
367
275
  };
368
276
  }, [android]);
369
277
 
@@ -1,11 +1,12 @@
1
1
  // SegmentedControlNativeComponent.ts
2
- import type {
3
- CodegenTypes,
4
- ColorValue,
5
- HostComponent,
6
- ViewProps,
7
- } from 'react-native';
2
+ import type { ColorValue, HostComponent, ViewProps } from 'react-native';
8
3
  import { codegenNativeComponent } from 'react-native';
4
+ import type {
5
+ BubblingEventHandler,
6
+ Double,
7
+ Int32,
8
+ WithDefault,
9
+ } from './codegenTypes';
9
10
 
10
11
  /**
11
12
  * A single segment in the control.
@@ -21,7 +22,7 @@ export type SegmentedControlSegment = Readonly<{
21
22
  iconType: string; // '' | 'sfSymbol' | 'drawable' | 'image'
22
23
  iconName: string; // SF Symbol (iOS) or drawable resource name (Android)
23
24
  iconUri: string; // Resolved image URI when iconType === 'image'
24
- iconScale: CodegenTypes.Double; // Resolved image scale when iconType === 'image'
25
+ iconScale: Double; // Resolved image scale when iconType === 'image'
25
26
  iconTinted: string; // 'true' | 'false' — draw the image as a tinted template
26
27
  badge: string; // Badge text, empty = no badge
27
28
  accessibilityLabel: string; // Screen-reader label, empty = use label
@@ -32,7 +33,7 @@ export type SegmentedControlSegment = Readonly<{
32
33
  */
33
34
  export type SegmentedControlSelectEvent = Readonly<{
34
35
  /** Selected segment index. -1 means the selection was cleared. */
35
- index: CodegenTypes.Int32;
36
+ index: Int32;
36
37
 
37
38
  /** Selected segment value. Empty when the selection was cleared. */
38
39
  value: string;
@@ -49,7 +50,7 @@ export type SegmentedControlLabelVisibility = 'auto' | 'labeled' | 'unlabeled';
49
50
  */
50
51
  export type LabelStyleProps = Readonly<{
51
52
  fontFamily?: string;
52
- fontSize?: CodegenTypes.Double;
53
+ fontSize?: Double;
53
54
  fontWeight?: string; // 'normal' | 'bold' | '100'..'900'
54
55
  fontStyle?: string; // 'normal' | 'italic'
55
56
  }>;
@@ -71,6 +72,9 @@ export type IOSProps = Readonly<{
71
72
  export type AndroidProps = Readonly<{
72
73
  /** Whether one segment must always be selected */
73
74
  selectionRequired?: string; // 'true' | 'false'
75
+
76
+ /** Material style: 'm3' | 'expressive' */
77
+ material?: string;
74
78
  }>;
75
79
 
76
80
  export interface SegmentedControlProps extends ViewProps {
@@ -83,7 +87,7 @@ export interface SegmentedControlProps extends ViewProps {
83
87
  * Controlled selection by `value`.
84
88
  * Empty string means "no selection".
85
89
  */
86
- selectedValue?: CodegenTypes.WithDefault<string, ''>;
90
+ selectedValue?: WithDefault<string, ''>;
87
91
 
88
92
  /**
89
93
  * Enabled / disabled state.
@@ -122,7 +126,7 @@ export interface SegmentedControlProps extends ViewProps {
122
126
  /**
123
127
  * Fired when the user selects a segment.
124
128
  */
125
- onSelect?: CodegenTypes.BubblingEventHandler<SegmentedControlSelectEvent>;
129
+ onSelect?: BubblingEventHandler<SegmentedControlSelectEvent>;
126
130
 
127
131
  ios?: IOSProps;
128
132
  android?: AndroidProps;
@@ -1,6 +1,7 @@
1
1
  // SelectionMenuNativeComponent.ts
2
- import type { CodegenTypes, HostComponent, ViewProps } from 'react-native';
2
+ import type { HostComponent, ViewProps } from 'react-native';
3
3
  import { codegenNativeComponent } from 'react-native';
4
+ import type { BubblingEventHandler, Int32, WithDefault } from './codegenTypes';
4
5
 
5
6
  /**
6
7
  * A single option in the menu.
@@ -15,7 +16,7 @@ export type SelectionMenuOption = Readonly<{
15
16
  */
16
17
  export type SelectionMenuSelectEvent = Readonly<{
17
18
  /** Selected option index (implementation detail; stable for this render) */
18
- index: CodegenTypes.Int32;
19
+ index: Int32;
19
20
 
20
21
  /** Selected option label */
21
22
  label: string;
@@ -57,7 +58,7 @@ export interface SelectionMenuProps extends ViewProps {
57
58
  * - Empty string means "no selection".
58
59
  * - Native should treat this as the single source of truth.
59
60
  */
60
- selectedData?: CodegenTypes.WithDefault<string, ''>;
61
+ selectedData?: WithDefault<string, ''>;
61
62
 
62
63
  /**
63
64
  * Enabled / disabled state.
@@ -83,12 +84,12 @@ export interface SelectionMenuProps extends ViewProps {
83
84
  /**
84
85
  * Fired when the user selects an option.
85
86
  */
86
- onSelect?: CodegenTypes.BubblingEventHandler<SelectionMenuSelectEvent>;
87
+ onSelect?: BubblingEventHandler<SelectionMenuSelectEvent>;
87
88
 
88
89
  /**
89
90
  * Fired when dismissed without selection.
90
91
  */
91
- onRequestClose?: CodegenTypes.BubblingEventHandler<Readonly<{}>>;
92
+ onRequestClose?: BubblingEventHandler<Readonly<{}>>;
92
93
 
93
94
  ios?: IOSProps;
94
95
  android?: AndroidProps;