react-native-platform-components 0.7.0 → 0.8.1

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 (34) hide show
  1. package/README.md +238 -102
  2. package/android/src/main/java/com/platformcomponents/PCLiquidGlassView.kt +84 -0
  3. package/android/src/main/java/com/platformcomponents/PCLiquidGlassViewManager.kt +52 -0
  4. package/android/src/main/java/com/platformcomponents/PlatformComponentsPackage.kt +1 -0
  5. package/ios/PCLiquidGlass.h +10 -0
  6. package/ios/PCLiquidGlass.mm +140 -0
  7. package/ios/PCLiquidGlass.swift +354 -0
  8. package/ios/PCSelectionMenu.swift +1 -1
  9. package/lib/commonjs/LiquidGlass.js +72 -0
  10. package/lib/commonjs/LiquidGlass.js.map +1 -0
  11. package/lib/commonjs/LiquidGlassNativeComponent.ts +110 -0
  12. package/lib/commonjs/index.js +11 -0
  13. package/lib/commonjs/index.js.map +1 -1
  14. package/lib/module/LiquidGlass.js +64 -0
  15. package/lib/module/LiquidGlass.js.map +1 -0
  16. package/lib/module/LiquidGlassNativeComponent.ts +110 -0
  17. package/lib/module/index.js +1 -0
  18. package/lib/module/index.js.map +1 -1
  19. package/lib/typescript/commonjs/src/LiquidGlass.d.ts +96 -0
  20. package/lib/typescript/commonjs/src/LiquidGlass.d.ts.map +1 -0
  21. package/lib/typescript/commonjs/src/LiquidGlassNativeComponent.d.ts +93 -0
  22. package/lib/typescript/commonjs/src/LiquidGlassNativeComponent.d.ts.map +1 -0
  23. package/lib/typescript/commonjs/src/index.d.ts +1 -0
  24. package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
  25. package/lib/typescript/module/src/LiquidGlass.d.ts +96 -0
  26. package/lib/typescript/module/src/LiquidGlass.d.ts.map +1 -0
  27. package/lib/typescript/module/src/LiquidGlassNativeComponent.d.ts +93 -0
  28. package/lib/typescript/module/src/LiquidGlassNativeComponent.d.ts.map +1 -0
  29. package/lib/typescript/module/src/index.d.ts +1 -0
  30. package/lib/typescript/module/src/index.d.ts.map +1 -1
  31. package/package.json +12 -4
  32. package/src/LiquidGlass.tsx +169 -0
  33. package/src/LiquidGlassNativeComponent.ts +110 -0
  34. package/src/index.tsx +1 -0
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "react-native-platform-components",
3
- "version": "0.7.0",
4
- "description": "Native UI components for React Native: DatePicker, ContextMenu, SelectionMenu, SegmentedControl.",
3
+ "version": "0.8.1",
4
+ "description": "Native UI components for React Native: DatePicker, ContextMenu, SelectionMenu, SegmentedControl, LiquidGlass.",
5
5
  "main": "./lib/commonjs/index.js",
6
6
  "module": "./lib/module/index.js",
7
7
  "types": "./lib/typescript/commonjs/src/index.d.ts",
@@ -73,7 +73,14 @@
73
73
  "dropdown",
74
74
  "native",
75
75
  "material-design",
76
- "expo"
76
+ "expo",
77
+ "segmented-control",
78
+ "segmentedcontrol",
79
+ "tabs",
80
+ "segmented-buttons",
81
+ "segmentedbuttons",
82
+ "liquid-glass",
83
+ "liquidglass"
77
84
  ],
78
85
  "repository": {
79
86
  "type": "git",
@@ -158,7 +165,8 @@
158
165
  "PCSelectionMenu": "PCSelectionMenu",
159
166
  "PCDatePicker": "PCDatePicker",
160
167
  "PCContextMenu": "PCContextMenu",
161
- "PCSegmentedControl": "PCSegmentedControl"
168
+ "PCSegmentedControl": "PCSegmentedControl",
169
+ "PCLiquidGlass": "PCLiquidGlass"
162
170
  }
163
171
  }
164
172
  },
@@ -0,0 +1,169 @@
1
+ // LiquidGlass.tsx
2
+ import React, { useCallback, useMemo } from 'react';
3
+ import { Platform, type ViewProps } from 'react-native';
4
+
5
+ import NativeLiquidGlass, {
6
+ type LiquidGlassColorScheme,
7
+ type LiquidGlassEffect,
8
+ type LiquidGlassPressEvent,
9
+ } from './LiquidGlassNativeComponent';
10
+
11
+ export type {
12
+ LiquidGlassEffect,
13
+ LiquidGlassColorScheme,
14
+ LiquidGlassPressEvent,
15
+ };
16
+
17
+ /**
18
+ * Whether the LiquidGlass effect is supported on the current device.
19
+ * Returns true on iOS 26+ (with Liquid Glass support), false otherwise.
20
+ *
21
+ * Use this to conditionally render fallback UI on unsupported devices.
22
+ */
23
+ export const isLiquidGlassSupported: boolean =
24
+ Platform.OS === 'ios' && Number(Platform.Version) >= 26;
25
+
26
+ export interface LiquidGlassProps extends ViewProps {
27
+ /**
28
+ * Corner radius for the glass effect.
29
+ * Applied uniformly to all corners.
30
+ * @default 0
31
+ */
32
+ cornerRadius?: number;
33
+
34
+ /**
35
+ * iOS-specific props for the glass effect.
36
+ */
37
+ ios?: {
38
+ /**
39
+ * Glass effect style.
40
+ * - 'clear': More transparent, subtle glass effect
41
+ * - 'regular': Standard blur intensity (default)
42
+ * - 'none': No glass effect (useful for animating materialization)
43
+ * @default 'regular'
44
+ */
45
+ effect?: LiquidGlassEffect;
46
+
47
+ /**
48
+ * Enables native touch interaction effects when pressing the view.
49
+ * When enabled, the glass effect responds to touch location with
50
+ * position-aware visual feedback (iOS 26+ UIGlassEffect.isInteractive).
51
+ *
52
+ * Note: Only applies on component mount; cannot be changed dynamically.
53
+ * @default false
54
+ */
55
+ interactive?: boolean;
56
+
57
+ /**
58
+ * Overlay tint color applied to the glass effect.
59
+ * Accepts any valid color value (hex, rgba, named colors).
60
+ *
61
+ * Example: '#FF0000', 'rgba(255, 0, 0, 0.5)', 'red'
62
+ */
63
+ tintColor?: string;
64
+
65
+ /**
66
+ * Appearance adaptation mode.
67
+ * - 'light': Force light appearance
68
+ * - 'dark': Force dark appearance
69
+ * - 'system': Follow system appearance (default)
70
+ * @default 'system'
71
+ */
72
+ colorScheme?: LiquidGlassColorScheme;
73
+
74
+ /**
75
+ * Shadow radius for the glass effect glow.
76
+ * Higher values create a more diffuse shadow.
77
+ * @default 20
78
+ */
79
+ shadowRadius?: number;
80
+
81
+ /**
82
+ * @deprecated Use `interactive` instead for native touch-based highlighting.
83
+ * This prop is a no-op on iOS 26+ where UIGlassEffect handles touch feedback.
84
+ * @default false
85
+ */
86
+ isHighlighted?: boolean;
87
+ };
88
+
89
+ /**
90
+ * Android-specific props.
91
+ * Note: LiquidGlass is an iOS-only effect. On Android, the component
92
+ * renders as a regular View with optional fallback styling.
93
+ */
94
+ android?: {
95
+ /**
96
+ * Fallback background color for Android since glass effect is not supported.
97
+ * If not provided, the view renders transparently.
98
+ */
99
+ fallbackBackgroundColor?: string;
100
+ };
101
+
102
+ /**
103
+ * Content to render inside the glass effect container.
104
+ */
105
+ children?: React.ReactNode;
106
+
107
+ /**
108
+ * Called when the glass view is pressed.
109
+ * Includes touch coordinates relative to the view bounds.
110
+ */
111
+ onPress?: (event: { x: number; y: number }) => void;
112
+
113
+ /** Test identifier */
114
+ testID?: string;
115
+ }
116
+
117
+ export function LiquidGlass(props: LiquidGlassProps): React.ReactElement {
118
+ const {
119
+ style,
120
+ cornerRadius = 0,
121
+ ios,
122
+ android,
123
+ children,
124
+ onPress,
125
+ ...viewProps
126
+ } = props;
127
+
128
+ // Normalize iOS props for native layer (strings for codegen)
129
+ const nativeIos = useMemo(() => {
130
+ if (Platform.OS !== 'ios' || !ios) return undefined;
131
+ return {
132
+ effect: ios.effect,
133
+ interactive: ios.interactive ? 'true' : 'false',
134
+ tintColor: ios.tintColor,
135
+ colorScheme: ios.colorScheme,
136
+ shadowRadius: ios.shadowRadius,
137
+ isHighlighted: ios.isHighlighted ? 'true' : 'false',
138
+ };
139
+ }, [ios]);
140
+
141
+ // Normalize Android props
142
+ const nativeAndroid = useMemo(() => {
143
+ if (Platform.OS !== 'android' || !android) return undefined;
144
+ return {
145
+ fallbackBackgroundColor: android.fallbackBackgroundColor,
146
+ };
147
+ }, [android]);
148
+
149
+ // Handle native press event
150
+ const handlePress = useCallback(
151
+ (event: { nativeEvent: { x: number; y: number } }) => {
152
+ onPress?.({ x: event.nativeEvent.x, y: event.nativeEvent.y });
153
+ },
154
+ [onPress]
155
+ );
156
+
157
+ return (
158
+ <NativeLiquidGlass
159
+ style={style}
160
+ cornerRadius={cornerRadius}
161
+ ios={nativeIos}
162
+ android={nativeAndroid}
163
+ onGlassPress={onPress ? handlePress : undefined}
164
+ {...viewProps}
165
+ >
166
+ {children}
167
+ </NativeLiquidGlass>
168
+ );
169
+ }
@@ -0,0 +1,110 @@
1
+ // LiquidGlassNativeComponent.ts
2
+ import type { CodegenTypes, HostComponent, ViewProps } from 'react-native';
3
+ import { codegenNativeComponent } from 'react-native';
4
+
5
+ /**
6
+ * Glass effect intensity/style.
7
+ * - 'clear': More transparent, subtle glass effect
8
+ * - 'regular': Standard blur intensity (default)
9
+ * - 'none': No glass effect (useful for animating materialization)
10
+ */
11
+ export type LiquidGlassEffect = 'clear' | 'regular' | 'none';
12
+
13
+ /**
14
+ * Color scheme for the glass effect.
15
+ * - 'light': Force light appearance
16
+ * - 'dark': Force dark appearance
17
+ * - 'system': Follow system appearance (default)
18
+ */
19
+ export type LiquidGlassColorScheme = 'light' | 'dark' | 'system';
20
+
21
+ /**
22
+ * iOS-specific configuration.
23
+ */
24
+ export type LiquidGlassIOSProps = Readonly<{
25
+ /**
26
+ * Glass effect style.
27
+ * @default 'regular'
28
+ */
29
+ effect?: string; // LiquidGlassEffect
30
+
31
+ /**
32
+ * Enables touch interaction effects when pressing the view.
33
+ * Note: Only applies on component mount; cannot be changed dynamically.
34
+ * @default false
35
+ */
36
+ interactive?: string; // 'true' | 'false'
37
+
38
+ /**
39
+ * Overlay tint color applied to the glass effect.
40
+ * Accepts hex color strings (e.g., '#FF0000', '#FF000080').
41
+ */
42
+ tintColor?: string;
43
+
44
+ /**
45
+ * Appearance adaptation mode.
46
+ * @default 'system'
47
+ */
48
+ colorScheme?: string; // LiquidGlassColorScheme
49
+
50
+ /**
51
+ * Shadow radius for the glass effect.
52
+ * @default 20
53
+ */
54
+ shadowRadius?: CodegenTypes.Float;
55
+
56
+ /**
57
+ * Whether the view is highlighted (pressed state).
58
+ */
59
+ isHighlighted?: string; // 'true' | 'false'
60
+ }>;
61
+
62
+ /**
63
+ * Android-specific configuration (stub - LiquidGlass is iOS only).
64
+ */
65
+ export type LiquidGlassAndroidProps = Readonly<{
66
+ /**
67
+ * Fallback background color for Android (since glass effect is not supported).
68
+ * If not provided, renders as transparent.
69
+ */
70
+ fallbackBackgroundColor?: string;
71
+ }>;
72
+
73
+ /**
74
+ * Event emitted when the glass view is pressed.
75
+ */
76
+ export type LiquidGlassPressEvent = Readonly<{
77
+ /** X coordinate of touch relative to view bounds */
78
+ x: CodegenTypes.Float;
79
+ /** Y coordinate of touch relative to view bounds */
80
+ y: CodegenTypes.Float;
81
+ }>;
82
+
83
+ export interface LiquidGlassNativeProps extends ViewProps {
84
+ /**
85
+ * Corner radius for the glass effect.
86
+ * Applied uniformly to all corners.
87
+ * @default 0
88
+ */
89
+ cornerRadius?: CodegenTypes.WithDefault<CodegenTypes.Float, 0>;
90
+
91
+ /**
92
+ * iOS-specific props.
93
+ */
94
+ ios?: LiquidGlassIOSProps;
95
+
96
+ /**
97
+ * Android-specific props.
98
+ */
99
+ android?: LiquidGlassAndroidProps;
100
+
101
+ /**
102
+ * Fired when the glass view is pressed.
103
+ * Includes touch coordinates relative to view bounds.
104
+ */
105
+ onGlassPress?: CodegenTypes.DirectEventHandler<LiquidGlassPressEvent>;
106
+ }
107
+
108
+ export default codegenNativeComponent<LiquidGlassNativeProps>(
109
+ 'PCLiquidGlass'
110
+ ) as HostComponent<LiquidGlassNativeProps>;
package/src/index.tsx CHANGED
@@ -2,4 +2,5 @@ export * from './DatePicker';
2
2
  export * from './SelectionMenu';
3
3
  export * from './ContextMenu';
4
4
  export * from './SegmentedControl';
5
+ export * from './LiquidGlass';
5
6
  export * from './sharedTypes';