@sbaiahmed1/react-native-blur 3.2.0 → 4.0.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.
- package/README.md +319 -309
- package/ReactNativeBlur.podspec +1 -1
- package/android/build.gradle +2 -3
- package/android/src/main/java/com/sbaiahmed1/reactnativeblur/ReactNativeBlurView.kt +62 -269
- package/android/src/main/java/com/sbaiahmed1/reactnativeblur/ReactNativeBlurViewManager.kt +9 -9
- package/ios/Helpers/BlurStyleHelpers.swift +1 -1
- package/ios/Helpers/ReactNativeBlurViewHelper.swift +6 -35
- package/ios/Helpers/ReactNativeLiquidGlassViewHelper.swift +44 -0
- package/ios/ReactNativeBlurView.mm +8 -61
- package/ios/{ReactNativeBlurViewManager.m → ReactNativeBlurViewManager.mm} +5 -35
- package/ios/ReactNativeLiquidGlassView.h +14 -0
- package/ios/ReactNativeLiquidGlassView.mm +291 -0
- package/ios/ReactNativeLiquidGlassViewManager.h +6 -0
- package/ios/ReactNativeLiquidGlassViewManager.mm +20 -0
- package/ios/Views/AdvancedBlurView.swift +5 -40
- package/ios/Views/BasicColoredView.swift +6 -50
- package/ios/Views/LiquidGlassContainerView.swift +151 -0
- package/lib/module/BlurView.js +16 -33
- package/lib/module/BlurView.js.map +1 -1
- package/lib/module/LiquidGlassView.js +75 -0
- package/lib/module/LiquidGlassView.js.map +1 -0
- package/lib/module/ReactNativeBlurViewNativeComponent.ts +0 -7
- package/lib/module/ReactNativeLiquidGlassViewNativeComponent.ts +57 -0
- package/lib/module/index.js +2 -0
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/BlurView.d.ts +19 -45
- package/lib/typescript/src/BlurView.d.ts.map +1 -1
- package/lib/typescript/src/LiquidGlassView.d.ts +85 -0
- package/lib/typescript/src/LiquidGlassView.d.ts.map +1 -0
- package/lib/typescript/src/ReactNativeBlurViewNativeComponent.d.ts +0 -6
- package/lib/typescript/src/ReactNativeBlurViewNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/ReactNativeLiquidGlassViewNativeComponent.d.ts +44 -0
- package/lib/typescript/src/ReactNativeLiquidGlassViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +4 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/package.json +8 -6
- package/src/BlurView.tsx +36 -77
- package/src/LiquidGlassView.tsx +138 -0
- package/src/ReactNativeBlurViewNativeComponent.ts +0 -7
- package/src/ReactNativeLiquidGlassViewNativeComponent.ts +57 -0
- package/src/index.tsx +6 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { ViewProps } from 'react-native';
|
|
2
|
+
import type { WithDefault, Double } from 'react-native/Libraries/Types/CodegenTypes';
|
|
3
|
+
export type GlassType = 'clear' | 'regular';
|
|
4
|
+
interface NativeProps extends ViewProps {
|
|
5
|
+
/**
|
|
6
|
+
* The type of glass effect to apply
|
|
7
|
+
* Platform: iOS only
|
|
8
|
+
* @default 'clear'
|
|
9
|
+
*/
|
|
10
|
+
glassType?: WithDefault<GlassType, 'clear'>;
|
|
11
|
+
/**
|
|
12
|
+
* The tint color of the glass effect
|
|
13
|
+
* Platform: iOS only
|
|
14
|
+
* @default 'clear'
|
|
15
|
+
*/
|
|
16
|
+
glassTintColor?: WithDefault<string, 'clear'>;
|
|
17
|
+
/**
|
|
18
|
+
* The opacity of the glass effect (0-1)
|
|
19
|
+
* Platform: iOS only
|
|
20
|
+
* @default 1.0
|
|
21
|
+
*/
|
|
22
|
+
glassOpacity?: WithDefault<Double, 1.0>;
|
|
23
|
+
/**
|
|
24
|
+
* Fallback color when reduced transparency is enabled
|
|
25
|
+
* Platform: iOS only
|
|
26
|
+
* @default '#FFFFFF'
|
|
27
|
+
*/
|
|
28
|
+
reducedTransparencyFallbackColor?: WithDefault<string, '#FFFFFF'>;
|
|
29
|
+
/**
|
|
30
|
+
* Whether the glass view should be interactive
|
|
31
|
+
* Platform: iOS only
|
|
32
|
+
* @default true
|
|
33
|
+
*/
|
|
34
|
+
isInteractive?: WithDefault<boolean, true>;
|
|
35
|
+
/**
|
|
36
|
+
* Whether the glass view should ignore safe area insets
|
|
37
|
+
* Platform: iOS only
|
|
38
|
+
* @default false
|
|
39
|
+
*/
|
|
40
|
+
ignoreSafeArea?: WithDefault<boolean, false>;
|
|
41
|
+
}
|
|
42
|
+
declare const _default: import("react-native/Libraries/Utilities/codegenNativeComponent").NativeComponentType<NativeProps>;
|
|
43
|
+
export default _default;
|
|
44
|
+
//# sourceMappingURL=ReactNativeLiquidGlassViewNativeComponent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ReactNativeLiquidGlassViewNativeComponent.d.ts","sourceRoot":"","sources":["../../../src/ReactNativeLiquidGlassViewNativeComponent.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EACV,WAAW,EACX,MAAM,EACP,MAAM,2CAA2C,CAAC;AAEnD,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,SAAS,CAAC;AAE5C,UAAU,WAAY,SAAQ,SAAS;IACrC;;;;OAIG;IACH,SAAS,CAAC,EAAE,WAAW,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IAE5C;;;;OAIG;IACH,cAAc,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAE9C;;;;OAIG;IACH,YAAY,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAExC;;;;OAIG;IACH,gCAAgC,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IAElE;;;;OAIG;IACH,aAAa,CAAC,EAAE,WAAW,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAE3C;;;;OAIG;IACH,cAAc,CAAC,EAAE,WAAW,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;CAC9C;;AAED,wBAGE"}
|
|
@@ -2,4 +2,8 @@ export { default as ReactNativeBlurView } from './ReactNativeBlurViewNativeCompo
|
|
|
2
2
|
export * from './ReactNativeBlurViewNativeComponent';
|
|
3
3
|
export { BlurView as default, BlurView } from './BlurView';
|
|
4
4
|
export type { BlurViewProps } from './BlurView';
|
|
5
|
+
export { default as ReactNativeLiquidGlassView } from './ReactNativeLiquidGlassViewNativeComponent';
|
|
6
|
+
export type { GlassType } from './ReactNativeLiquidGlassViewNativeComponent';
|
|
7
|
+
export { LiquidGlassView } from './LiquidGlassView';
|
|
8
|
+
export type { LiquidGlassViewProps } from './LiquidGlassView';
|
|
5
9
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AACtF,cAAc,sCAAsC,CAAC;AAErD,OAAO,EAAE,QAAQ,IAAI,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3D,YAAY,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AACtF,cAAc,sCAAsC,CAAC;AAErD,OAAO,EAAE,QAAQ,IAAI,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3D,YAAY,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,OAAO,EAAE,OAAO,IAAI,0BAA0B,EAAE,MAAM,6CAA6C,CAAC;AACpG,YAAY,EAAE,SAAS,EAAE,MAAM,6CAA6C,CAAC;AAE7E,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,YAAY,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sbaiahmed1/react-native-blur",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.1",
|
|
4
4
|
"description": "React native modern blur view",
|
|
5
5
|
"main": "./lib/module/index.js",
|
|
6
6
|
"types": "./lib/typescript/src/index.d.ts",
|
|
@@ -32,13 +32,14 @@
|
|
|
32
32
|
"!**/.*"
|
|
33
33
|
],
|
|
34
34
|
"scripts": {
|
|
35
|
-
"example": "yarn workspace @sbaiahmed1/react-native-blur-example",
|
|
36
35
|
"test": "jest",
|
|
37
36
|
"typecheck": "tsc",
|
|
38
37
|
"lint": "eslint \"**/*.{js,ts,tsx}\"",
|
|
39
38
|
"clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib",
|
|
40
39
|
"prepare": "bob build",
|
|
41
|
-
"release": "release-it"
|
|
40
|
+
"release": "release-it",
|
|
41
|
+
"setup": "yarn && yarn prepare",
|
|
42
|
+
"setup:example": "yarn setup && cd example && yarn && cd ios && pod install && cd .. && yarn start --client-logs"
|
|
42
43
|
},
|
|
43
44
|
"keywords": [
|
|
44
45
|
"react-native",
|
|
@@ -72,7 +73,7 @@
|
|
|
72
73
|
"@react-native-community/cli": "15.0.0-alpha.2",
|
|
73
74
|
"@react-native/babel-preset": "0.79.2",
|
|
74
75
|
"@react-native/eslint-config": "^0.78.0",
|
|
75
|
-
"@release-it/conventional-changelog": "^
|
|
76
|
+
"@release-it/conventional-changelog": "^10.0.1",
|
|
76
77
|
"@types/jest": "^29.5.5",
|
|
77
78
|
"@types/react": "^19.0.0",
|
|
78
79
|
"commitlint": "^19.6.1",
|
|
@@ -85,7 +86,7 @@
|
|
|
85
86
|
"react": "19.0.0",
|
|
86
87
|
"react-native": "0.79.2",
|
|
87
88
|
"react-native-builder-bob": "^0.40.11",
|
|
88
|
-
"release-it": "^
|
|
89
|
+
"release-it": "^19.0.4",
|
|
89
90
|
"turbo": "^1.10.7",
|
|
90
91
|
"typescript": "^5.8.3"
|
|
91
92
|
},
|
|
@@ -162,7 +163,8 @@
|
|
|
162
163
|
},
|
|
163
164
|
"ios": {
|
|
164
165
|
"componentProvider": {
|
|
165
|
-
"ReactNativeBlurView": "ReactNativeBlurView"
|
|
166
|
+
"ReactNativeBlurView": "ReactNativeBlurView",
|
|
167
|
+
"ReactNativeLiquidGlassView": "ReactNativeLiquidGlassView"
|
|
166
168
|
}
|
|
167
169
|
}
|
|
168
170
|
},
|
package/src/BlurView.tsx
CHANGED
|
@@ -1,85 +1,54 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { View } from 'react-native';
|
|
2
|
+
import { StyleSheet, View } from 'react-native';
|
|
3
3
|
import type { ViewStyle, StyleProp } from 'react-native';
|
|
4
4
|
import ReactNativeBlurView, {
|
|
5
5
|
type BlurType,
|
|
6
6
|
} from './ReactNativeBlurViewNativeComponent';
|
|
7
|
-
import type { GlassType } from '../src/ReactNativeBlurViewNativeComponent';
|
|
8
7
|
|
|
9
8
|
export interface BlurViewProps {
|
|
10
9
|
/**
|
|
11
|
-
* The type of blur effect to apply
|
|
10
|
+
* @description The type of blur effect to apply
|
|
11
|
+
*
|
|
12
12
|
* @default 'xlight'
|
|
13
13
|
*/
|
|
14
14
|
blurType?: BlurType;
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
|
-
* The intensity of the blur effect (0-100)
|
|
17
|
+
* @description The intensity of the blur effect (0-100)
|
|
18
|
+
*
|
|
18
19
|
* @default 10
|
|
19
20
|
*/
|
|
20
21
|
blurAmount?: number;
|
|
21
22
|
|
|
22
23
|
/**
|
|
23
|
-
* Fallback color when reduced transparency is enabled
|
|
24
|
-
*
|
|
24
|
+
* @description Fallback color when reduced transparency is enabled
|
|
25
|
+
*
|
|
26
|
+
* Accepts hex color strings like `#FFFFFF`
|
|
27
|
+
*
|
|
25
28
|
* @default '#FFFFFF'
|
|
26
29
|
*/
|
|
27
30
|
reducedTransparencyFallbackColor?: string;
|
|
28
31
|
|
|
29
32
|
/**
|
|
30
|
-
*
|
|
33
|
+
* @description style object for the blur view
|
|
34
|
+
*
|
|
35
|
+
* @default undefined
|
|
31
36
|
*/
|
|
32
37
|
style?: StyleProp<ViewStyle>;
|
|
33
38
|
|
|
34
39
|
/**
|
|
35
|
-
*
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Platform: iOS only
|
|
41
|
-
* The type of glass effect to apply
|
|
42
|
-
* @default 'clear'
|
|
43
|
-
*/
|
|
44
|
-
glassType?: GlassType;
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Platform: iOS only
|
|
48
|
-
* The tint color of the glass effect
|
|
49
|
-
* accepts hex color strings like '#FFFFFF'
|
|
50
|
-
* accepts color names like 'white', 'clear', 'black', 'red', 'green', 'blue', 'yellow', 'cyan', 'magenta'
|
|
51
|
-
* @default 'clear'
|
|
52
|
-
*/
|
|
53
|
-
glassTintColor?: string;
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Platform: iOS only
|
|
57
|
-
* The opacity of the glass effect (0-1)
|
|
58
|
-
* @default 1.0
|
|
59
|
-
*/
|
|
60
|
-
glassOpacity?: number;
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* The type of blur effect to apply
|
|
64
|
-
* liquidGlass = iOS Only
|
|
65
|
-
* blur = Android | iOS
|
|
66
|
-
* @default 'blur'
|
|
67
|
-
*/
|
|
68
|
-
type?: 'blur' | 'liquidGlass';
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Platform: iOS only
|
|
72
|
-
* Whether the blur view should be interactive
|
|
73
|
-
* @default true
|
|
40
|
+
* @description style object for the blur view
|
|
41
|
+
*
|
|
42
|
+
* @default false
|
|
74
43
|
*/
|
|
75
|
-
|
|
44
|
+
ignoreSafeArea?: boolean;
|
|
76
45
|
|
|
77
46
|
/**
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
* @default
|
|
47
|
+
* @description Child components to render inside the blur view
|
|
48
|
+
*
|
|
49
|
+
* @default undefined
|
|
81
50
|
*/
|
|
82
|
-
|
|
51
|
+
children?: React.ReactNode;
|
|
83
52
|
}
|
|
84
53
|
|
|
85
54
|
/**
|
|
@@ -110,11 +79,6 @@ export const BlurView: React.FC<BlurViewProps> = ({
|
|
|
110
79
|
reducedTransparencyFallbackColor = '#FFFFFF',
|
|
111
80
|
style,
|
|
112
81
|
children,
|
|
113
|
-
type = 'blur',
|
|
114
|
-
glassType = 'clear',
|
|
115
|
-
glassTintColor = 'clear',
|
|
116
|
-
glassOpacity = 1.0,
|
|
117
|
-
isInteractive = true,
|
|
118
82
|
ignoreSafeArea = false,
|
|
119
83
|
...props
|
|
120
84
|
}) => {
|
|
@@ -122,16 +86,11 @@ export const BlurView: React.FC<BlurViewProps> = ({
|
|
|
122
86
|
if (React.Children.count(children) === 0) {
|
|
123
87
|
return (
|
|
124
88
|
<ReactNativeBlurView
|
|
89
|
+
ignoreSafeArea={ignoreSafeArea}
|
|
125
90
|
blurType={blurType}
|
|
126
91
|
blurAmount={blurAmount}
|
|
127
|
-
glassType={glassType}
|
|
128
|
-
glassTintColor={glassTintColor}
|
|
129
|
-
glassOpacity={glassOpacity}
|
|
130
|
-
type={type}
|
|
131
92
|
reducedTransparencyFallbackColor={reducedTransparencyFallbackColor}
|
|
132
93
|
style={style}
|
|
133
|
-
isInteractive={isInteractive}
|
|
134
|
-
ignoreSafeArea={ignoreSafeArea}
|
|
135
94
|
{...props}
|
|
136
95
|
/>
|
|
137
96
|
);
|
|
@@ -139,31 +98,31 @@ export const BlurView: React.FC<BlurViewProps> = ({
|
|
|
139
98
|
|
|
140
99
|
// If children exist, use the absolute positioning pattern
|
|
141
100
|
return (
|
|
142
|
-
<View style={[
|
|
101
|
+
<View style={[styles.container, style]}>
|
|
143
102
|
{/* Blur effect positioned absolutely behind content */}
|
|
144
103
|
<ReactNativeBlurView
|
|
104
|
+
ignoreSafeArea={ignoreSafeArea}
|
|
145
105
|
blurType={blurType}
|
|
146
106
|
blurAmount={blurAmount}
|
|
147
|
-
glassType={glassType}
|
|
148
|
-
glassTintColor={glassTintColor}
|
|
149
|
-
glassOpacity={glassOpacity}
|
|
150
|
-
type={type}
|
|
151
|
-
isInteractive={isInteractive}
|
|
152
|
-
ignoreSafeArea={ignoreSafeArea}
|
|
153
107
|
reducedTransparencyFallbackColor={reducedTransparencyFallbackColor}
|
|
154
|
-
style={
|
|
155
|
-
position: 'absolute',
|
|
156
|
-
top: 0,
|
|
157
|
-
left: 0,
|
|
158
|
-
right: 0,
|
|
159
|
-
bottom: 0,
|
|
160
|
-
}}
|
|
108
|
+
style={StyleSheet.absoluteFill}
|
|
161
109
|
{...props}
|
|
162
110
|
/>
|
|
163
111
|
{/* Content positioned relatively on top */}
|
|
164
|
-
<View style={
|
|
112
|
+
<View style={styles.children}>{children}</View>
|
|
165
113
|
</View>
|
|
166
114
|
);
|
|
167
115
|
};
|
|
168
116
|
|
|
169
117
|
export default BlurView;
|
|
118
|
+
|
|
119
|
+
const styles = StyleSheet.create({
|
|
120
|
+
container: {
|
|
121
|
+
position: 'relative',
|
|
122
|
+
overflow: 'hidden',
|
|
123
|
+
},
|
|
124
|
+
children: {
|
|
125
|
+
position: 'relative',
|
|
126
|
+
zIndex: 1,
|
|
127
|
+
},
|
|
128
|
+
});
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Platform } from 'react-native';
|
|
3
|
+
import type { ViewStyle, StyleProp } from 'react-native';
|
|
4
|
+
import ReactNativeLiquidGlassView, {
|
|
5
|
+
type GlassType,
|
|
6
|
+
} from './ReactNativeLiquidGlassViewNativeComponent';
|
|
7
|
+
import BlurView from './BlurView';
|
|
8
|
+
|
|
9
|
+
export interface LiquidGlassViewProps {
|
|
10
|
+
/**
|
|
11
|
+
* The type of glass effect to apply
|
|
12
|
+
* Platform: iOS 26+ only
|
|
13
|
+
* @default 'clear'
|
|
14
|
+
*/
|
|
15
|
+
glassType?: GlassType /**
|
|
16
|
+
* The tint color of the glass effect
|
|
17
|
+
* Accepts hex color strings like '#FFFFFF' or color names
|
|
18
|
+
* Platform: iOS 26+ only
|
|
19
|
+
* @default 'clear'
|
|
20
|
+
*/;
|
|
21
|
+
glassTintColor?: string;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* The opacity of the glass effect (0-1)
|
|
25
|
+
* Platform: iOS 26+ only
|
|
26
|
+
* @default 1.0
|
|
27
|
+
*/
|
|
28
|
+
glassOpacity?: number;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Fallback color when reduced transparency is enabled or on older iOS versions
|
|
32
|
+
* Accepts hex color strings like '#FFFFFF'
|
|
33
|
+
* Platform: iOS only
|
|
34
|
+
* @default '#FFFFFF'
|
|
35
|
+
*/
|
|
36
|
+
reducedTransparencyFallbackColor?: string;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Whether the glass view should be interactive
|
|
40
|
+
* Platform: iOS 26+ only
|
|
41
|
+
* @default true
|
|
42
|
+
*/
|
|
43
|
+
isInteractive?: boolean;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Whether the glass view should ignore safe area insets
|
|
47
|
+
* Platform: iOS 26+ only
|
|
48
|
+
* @default false
|
|
49
|
+
*/
|
|
50
|
+
ignoreSafeArea?: boolean;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Style object for the liquid glass view
|
|
54
|
+
*/
|
|
55
|
+
style?: StyleProp<ViewStyle>;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Child components to render inside the liquid glass view
|
|
59
|
+
*/
|
|
60
|
+
children?: React.ReactNode;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* A Liquid Glass view component that provides iOS 26+ glass effects.
|
|
65
|
+
*
|
|
66
|
+
* This component uses the new UIKit glass effect API available on iOS 26+.
|
|
67
|
+
* On older iOS versions or when reduced transparency is enabled, it falls back
|
|
68
|
+
* to a solid color background.
|
|
69
|
+
*
|
|
70
|
+
* **Platform Support:**
|
|
71
|
+
* - iOS 26+: Native glass effect with full functionality
|
|
72
|
+
* - iOS < 26 or Android: Fallback to reducedTransparencyFallbackColor
|
|
73
|
+
*
|
|
74
|
+
* This component automatically handles the proper positioning pattern where the glass
|
|
75
|
+
* effect is positioned absolutely behind the content, ensuring interactive elements
|
|
76
|
+
* work correctly.
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* ```tsx
|
|
80
|
+
* import { LiquidGlassView } from '@sbaiahmed1/react-native-blur';
|
|
81
|
+
*
|
|
82
|
+
* <LiquidGlassView
|
|
83
|
+
* glassType="clear"
|
|
84
|
+
* glassTintColor="#007AFF"
|
|
85
|
+
* glassOpacity={0.8}
|
|
86
|
+
* style={{ flex: 1 }}
|
|
87
|
+
* >
|
|
88
|
+
* <Text>Content on top of liquid glass</Text>
|
|
89
|
+
* <Button title="Interactive Button" onPress={() => {}} />
|
|
90
|
+
* </LiquidGlassView>
|
|
91
|
+
* ```
|
|
92
|
+
*
|
|
93
|
+
* @platform ios
|
|
94
|
+
*/
|
|
95
|
+
export const LiquidGlassView: React.FC<LiquidGlassViewProps> = ({
|
|
96
|
+
glassType = 'clear',
|
|
97
|
+
glassTintColor = 'clear',
|
|
98
|
+
glassOpacity = 1.0,
|
|
99
|
+
reducedTransparencyFallbackColor = '#FFFFFF',
|
|
100
|
+
isInteractive = true,
|
|
101
|
+
ignoreSafeArea = false,
|
|
102
|
+
style,
|
|
103
|
+
children,
|
|
104
|
+
...props
|
|
105
|
+
}) => {
|
|
106
|
+
// Only render on iOS 26+ (fallback otherwise)
|
|
107
|
+
if (
|
|
108
|
+
Platform.OS !== 'ios' ||
|
|
109
|
+
(Platform.OS === 'ios' && parseInt(Platform.Version, 10) < 26)
|
|
110
|
+
) {
|
|
111
|
+
console.warn(
|
|
112
|
+
'LiquidGlassView is only supported on iOS. Rendering children without glass effect.'
|
|
113
|
+
);
|
|
114
|
+
return (
|
|
115
|
+
<BlurView blurAmount={70} style={style}>
|
|
116
|
+
{children}
|
|
117
|
+
</BlurView>
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// If children exist, use the absolute positioning pattern
|
|
122
|
+
return (
|
|
123
|
+
<ReactNativeLiquidGlassView
|
|
124
|
+
glassType={glassType}
|
|
125
|
+
glassTintColor={glassTintColor}
|
|
126
|
+
glassOpacity={glassOpacity}
|
|
127
|
+
reducedTransparencyFallbackColor={reducedTransparencyFallbackColor}
|
|
128
|
+
isInteractive={isInteractive}
|
|
129
|
+
ignoreSafeArea={ignoreSafeArea}
|
|
130
|
+
style={style}
|
|
131
|
+
{...props}
|
|
132
|
+
>
|
|
133
|
+
{children}
|
|
134
|
+
</ReactNativeLiquidGlassView>
|
|
135
|
+
);
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
export default LiquidGlassView;
|
|
@@ -18,17 +18,10 @@ export type BlurType =
|
|
|
18
18
|
| 'systemThickMaterial'
|
|
19
19
|
| 'systemChromeMaterial';
|
|
20
20
|
|
|
21
|
-
export type GlassType = 'clear' | 'regular';
|
|
22
|
-
|
|
23
21
|
interface NativeProps extends ViewProps {
|
|
24
|
-
glassTintColor?: WithDefault<string, 'clear'>;
|
|
25
|
-
glassOpacity?: WithDefault<Double, 1.0>;
|
|
26
22
|
blurAmount?: WithDefault<Double, 10.0>;
|
|
27
|
-
type?: WithDefault<'blur' | 'liquidGlass', 'blur'>;
|
|
28
23
|
blurType?: WithDefault<BlurType, 'xlight'>;
|
|
29
|
-
glassType?: WithDefault<GlassType, 'clear'>;
|
|
30
24
|
reducedTransparencyFallbackColor?: WithDefault<string, '#FFFFFF'>;
|
|
31
|
-
isInteractive?: WithDefault<boolean, true>;
|
|
32
25
|
ignoreSafeArea?: WithDefault<boolean, false>;
|
|
33
26
|
}
|
|
34
27
|
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
|
|
2
|
+
import type { ViewProps } from 'react-native';
|
|
3
|
+
import type {
|
|
4
|
+
WithDefault,
|
|
5
|
+
Double,
|
|
6
|
+
} from 'react-native/Libraries/Types/CodegenTypes';
|
|
7
|
+
|
|
8
|
+
export type GlassType = 'clear' | 'regular';
|
|
9
|
+
|
|
10
|
+
interface NativeProps extends ViewProps {
|
|
11
|
+
/**
|
|
12
|
+
* The type of glass effect to apply
|
|
13
|
+
* Platform: iOS only
|
|
14
|
+
* @default 'clear'
|
|
15
|
+
*/
|
|
16
|
+
glassType?: WithDefault<GlassType, 'clear'>;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* The tint color of the glass effect
|
|
20
|
+
* Platform: iOS only
|
|
21
|
+
* @default 'clear'
|
|
22
|
+
*/
|
|
23
|
+
glassTintColor?: WithDefault<string, 'clear'>;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The opacity of the glass effect (0-1)
|
|
27
|
+
* Platform: iOS only
|
|
28
|
+
* @default 1.0
|
|
29
|
+
*/
|
|
30
|
+
glassOpacity?: WithDefault<Double, 1.0>;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Fallback color when reduced transparency is enabled
|
|
34
|
+
* Platform: iOS only
|
|
35
|
+
* @default '#FFFFFF'
|
|
36
|
+
*/
|
|
37
|
+
reducedTransparencyFallbackColor?: WithDefault<string, '#FFFFFF'>;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Whether the glass view should be interactive
|
|
41
|
+
* Platform: iOS only
|
|
42
|
+
* @default true
|
|
43
|
+
*/
|
|
44
|
+
isInteractive?: WithDefault<boolean, true>;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Whether the glass view should ignore safe area insets
|
|
48
|
+
* Platform: iOS only
|
|
49
|
+
* @default false
|
|
50
|
+
*/
|
|
51
|
+
ignoreSafeArea?: WithDefault<boolean, false>;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export default codegenNativeComponent<NativeProps>(
|
|
55
|
+
'ReactNativeLiquidGlassView',
|
|
56
|
+
{ excludedPlatforms: ['android'] }
|
|
57
|
+
);
|
package/src/index.tsx
CHANGED
|
@@ -3,3 +3,9 @@ export * from './ReactNativeBlurViewNativeComponent';
|
|
|
3
3
|
|
|
4
4
|
export { BlurView as default, BlurView } from './BlurView';
|
|
5
5
|
export type { BlurViewProps } from './BlurView';
|
|
6
|
+
|
|
7
|
+
export { default as ReactNativeLiquidGlassView } from './ReactNativeLiquidGlassViewNativeComponent';
|
|
8
|
+
export type { GlassType } from './ReactNativeLiquidGlassViewNativeComponent';
|
|
9
|
+
|
|
10
|
+
export { LiquidGlassView } from './LiquidGlassView';
|
|
11
|
+
export type { LiquidGlassViewProps } from './LiquidGlassView';
|