@granite-js/react-native 0.1.3 → 0.1.4
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/CHANGELOG.md +13 -0
- package/dist/blur/BlurView.d.ts +78 -0
- package/dist/blur/ReactNativeBlurModule.d.ts +6 -0
- package/dist/blur/constants.d.ts +1 -0
- package/dist/blur/index.d.ts +1 -0
- package/dist/index.d.ts +1 -0
- package/package.json +8 -8
- package/src/blur/BlurView.tsx +103 -0
- package/src/blur/ReactNativeBlurModule.ts +20 -0
- package/src/blur/constants.ts +3 -0
- package/src/blur/index.ts +1 -0
- package/src/index.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @granite-js/react-native
|
|
2
2
|
|
|
3
|
+
## 0.1.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- ecaae2b: add BlurView
|
|
8
|
+
- @granite-js/cli@0.1.4
|
|
9
|
+
- @granite-js/image@0.1.4
|
|
10
|
+
- @granite-js/jest@0.1.4
|
|
11
|
+
- @granite-js/lottie@0.1.4
|
|
12
|
+
- @granite-js/mpack@0.1.4
|
|
13
|
+
- @granite-js/native@0.1.4
|
|
14
|
+
- @granite-js/style-utils@0.1.4
|
|
15
|
+
|
|
3
16
|
## 0.1.3
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { BlurViewProps as InternalBlurViewProps } from '@granite-js/native/@react-native-community/blur';
|
|
2
|
+
import { ViewProps } from 'react-native';
|
|
3
|
+
export type BlurType = InternalBlurViewProps['blurType'];
|
|
4
|
+
export interface BlurViewProps extends ViewProps {
|
|
5
|
+
blurType?: BlurType;
|
|
6
|
+
blurAmount?: number;
|
|
7
|
+
vibrancyEffect?: boolean;
|
|
8
|
+
reducedTransparencyFallbackColor?: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* @public
|
|
12
|
+
* @category UI
|
|
13
|
+
* @name BlurView
|
|
14
|
+
* @description
|
|
15
|
+
* `BlurView` adds a blurred background effect, primarily on iOS. It creates a visual blur on the background view.
|
|
16
|
+
*
|
|
17
|
+
* This component is supported only on iOS. On Android, it simply renders a regular [`View`](https://reactnative.dev/docs/0.72/view) without any blur effect.
|
|
18
|
+
*
|
|
19
|
+
* You can control the blur intensity and optionally enable the [vibrancy effect](https://developer.apple.com/documentation/uikit/uivibrancyeffect?language=objc), which enhances the visual impact of content displayed over a blurred background.
|
|
20
|
+
*
|
|
21
|
+
* If blur is not supported or doesn't render properly, you can use the `reducedTransparencyFallbackColor` prop to set a fallback background color.
|
|
22
|
+
*
|
|
23
|
+
* Use the `isSupported` property to check whether the current device supports blur. Blur is available on iOS from version 5.126.0 and not supported on Android.
|
|
24
|
+
*
|
|
25
|
+
* @param {BlurViewProps} [props] The props you can pass to `BlurView`. It extends `react-native`'s `ViewProps`, so you can use layout and style properties. The props align with those of [`@react-native-community/blur`](https://github.com/Kureev/react-native-blur/tree/v4.3.2?tab=readme-ov-file#blurview).
|
|
26
|
+
* @param {BlurType} [props.blurType] Type of blur to apply, such as `light`, `dark`, or `extraDark`.
|
|
27
|
+
* @param {number} [props.blurAmount=10] Intensity of the blur effect. Higher values make the blur stronger. Accepts values from `0` to `100`. Default is `10`.
|
|
28
|
+
* @param {boolean} [props.vibrancyEffect=false] Enables the vibrancy effect. This effect enhances content displayed on top of the blur. Only supported on iOS. Default is `false`.
|
|
29
|
+
* @param {string} [props.reducedTransparencyFallbackColor] Fallback background color used when blur cannot be applied due to system settings or device limitations.
|
|
30
|
+
*
|
|
31
|
+
* @returns {JSX.Element} On iOS, returns a blurred `BlurView` or `VibrancyView` component. On Android, returns a regular `View` without blur.
|
|
32
|
+
*
|
|
33
|
+
* ::: warning Note
|
|
34
|
+
* `BlurView` is only supported on iOS. On Android, it renders a regular `View` without any blur effect.
|
|
35
|
+
* :::
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
*
|
|
39
|
+
* ### Blurring background behind a text
|
|
40
|
+
*
|
|
41
|
+
* ```tsx
|
|
42
|
+
* import { BlurView } from '@granite-js/react-native';
|
|
43
|
+
* import { View, Text, StyleSheet } from 'react-native';
|
|
44
|
+
*
|
|
45
|
+
* export function BlurViewExample() {
|
|
46
|
+
* return (
|
|
47
|
+
* <View style={styles.container}>
|
|
48
|
+
* <Text style={styles.absolute}>Blurred Text</Text>
|
|
49
|
+
* <BlurView style={styles.absolute} blurType="light" blurAmount={1} />
|
|
50
|
+
* <Text>Non Blurred Text</Text>
|
|
51
|
+
* </View>
|
|
52
|
+
* );
|
|
53
|
+
* }
|
|
54
|
+
*
|
|
55
|
+
* const styles = StyleSheet.create({
|
|
56
|
+
* container: {
|
|
57
|
+
* justifyContent: 'center',
|
|
58
|
+
* alignItems: 'center',
|
|
59
|
+
* width: '100%',
|
|
60
|
+
* height: 300,
|
|
61
|
+
* },
|
|
62
|
+
* absolute: {
|
|
63
|
+
* position: 'absolute',
|
|
64
|
+
* top: 0,
|
|
65
|
+
* left: 0,
|
|
66
|
+
* bottom: 0,
|
|
67
|
+
* right: 0,
|
|
68
|
+
* },
|
|
69
|
+
* });
|
|
70
|
+
* ```
|
|
71
|
+
*
|
|
72
|
+
* @see [iOS Vibrancy Effect Documentation](https://developer.apple.com/documentation/uikit/uivibrancyeffect)
|
|
73
|
+
* @see [Zeddios Blog Explanation](https://zeddios.tistory.com/1140)
|
|
74
|
+
*/
|
|
75
|
+
export declare function BlurView({ blurType, blurAmount, reducedTransparencyFallbackColor, vibrancyEffect, ...viewProps }: BlurViewProps): import("react/jsx-runtime").JSX.Element;
|
|
76
|
+
export declare namespace BlurView {
|
|
77
|
+
var isSupported: boolean;
|
|
78
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isBlurNativeModuleSupported: boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './BlurView';
|
package/dist/index.d.ts
CHANGED
|
@@ -16,5 +16,6 @@ export * from './router/createRoute';
|
|
|
16
16
|
export * from './event';
|
|
17
17
|
export * from './video';
|
|
18
18
|
export * from './status-bar';
|
|
19
|
+
export * from './blur';
|
|
19
20
|
export type { InitialProps, ColorPreference } from './initial-props';
|
|
20
21
|
export type { GraniteProps } from './app';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@granite-js/react-native",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "The Granite Framework",
|
|
5
5
|
"bin": {
|
|
6
6
|
"granite": "./bin/cli.js"
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"@babel/core": "^7.24.9",
|
|
57
57
|
"@babel/preset-env": "^7.24.8",
|
|
58
58
|
"@babel/preset-typescript": "^7.24.7",
|
|
59
|
-
"@granite-js/native": "0.1.
|
|
59
|
+
"@granite-js/native": "0.1.4",
|
|
60
60
|
"@testing-library/dom": "^10.4.0",
|
|
61
61
|
"@testing-library/react": "^16.1.0",
|
|
62
62
|
"@types/babel__core": "^7",
|
|
@@ -82,12 +82,12 @@
|
|
|
82
82
|
"react-native": "*"
|
|
83
83
|
},
|
|
84
84
|
"dependencies": {
|
|
85
|
-
"@granite-js/cli": "0.1.
|
|
86
|
-
"@granite-js/image": "0.1.
|
|
87
|
-
"@granite-js/jest": "0.1.
|
|
88
|
-
"@granite-js/lottie": "0.1.
|
|
89
|
-
"@granite-js/mpack": "0.1.
|
|
90
|
-
"@granite-js/style-utils": "0.1.
|
|
85
|
+
"@granite-js/cli": "0.1.4",
|
|
86
|
+
"@granite-js/image": "0.1.4",
|
|
87
|
+
"@granite-js/jest": "0.1.4",
|
|
88
|
+
"@granite-js/lottie": "0.1.4",
|
|
89
|
+
"@granite-js/mpack": "0.1.4",
|
|
90
|
+
"@granite-js/style-utils": "0.1.4",
|
|
91
91
|
"es-toolkit": "^1.34.1",
|
|
92
92
|
"react-native-url-polyfill": "1.3.0"
|
|
93
93
|
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import type { BlurViewProps as InternalBlurViewProps } from '@granite-js/native/@react-native-community/blur';
|
|
2
|
+
import { View, ViewProps } from 'react-native';
|
|
3
|
+
import { ReactNativeBlurModule } from './ReactNativeBlurModule';
|
|
4
|
+
import { isBlurNativeModuleSupported } from './constants';
|
|
5
|
+
|
|
6
|
+
export type BlurType = InternalBlurViewProps['blurType'];
|
|
7
|
+
|
|
8
|
+
export interface BlurViewProps extends ViewProps {
|
|
9
|
+
blurType?: BlurType;
|
|
10
|
+
blurAmount?: number;
|
|
11
|
+
vibrancyEffect?: boolean;
|
|
12
|
+
reducedTransparencyFallbackColor?: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @public
|
|
17
|
+
* @category UI
|
|
18
|
+
* @name BlurView
|
|
19
|
+
* @description
|
|
20
|
+
* `BlurView` adds a blurred background effect, primarily on iOS. It creates a visual blur on the background view.
|
|
21
|
+
*
|
|
22
|
+
* This component is supported only on iOS. On Android, it simply renders a regular [`View`](https://reactnative.dev/docs/0.72/view) without any blur effect.
|
|
23
|
+
*
|
|
24
|
+
* You can control the blur intensity and optionally enable the [vibrancy effect](https://developer.apple.com/documentation/uikit/uivibrancyeffect?language=objc), which enhances the visual impact of content displayed over a blurred background.
|
|
25
|
+
*
|
|
26
|
+
* If blur is not supported or doesn't render properly, you can use the `reducedTransparencyFallbackColor` prop to set a fallback background color.
|
|
27
|
+
*
|
|
28
|
+
* Use the `isSupported` property to check whether the current device supports blur. Blur is available on iOS from version 5.126.0 and not supported on Android.
|
|
29
|
+
*
|
|
30
|
+
* @param {BlurViewProps} [props] The props you can pass to `BlurView`. It extends `react-native`'s `ViewProps`, so you can use layout and style properties. The props align with those of [`@react-native-community/blur`](https://github.com/Kureev/react-native-blur/tree/v4.3.2?tab=readme-ov-file#blurview).
|
|
31
|
+
* @param {BlurType} [props.blurType] Type of blur to apply, such as `light`, `dark`, or `extraDark`.
|
|
32
|
+
* @param {number} [props.blurAmount=10] Intensity of the blur effect. Higher values make the blur stronger. Accepts values from `0` to `100`. Default is `10`.
|
|
33
|
+
* @param {boolean} [props.vibrancyEffect=false] Enables the vibrancy effect. This effect enhances content displayed on top of the blur. Only supported on iOS. Default is `false`.
|
|
34
|
+
* @param {string} [props.reducedTransparencyFallbackColor] Fallback background color used when blur cannot be applied due to system settings or device limitations.
|
|
35
|
+
*
|
|
36
|
+
* @returns {JSX.Element} On iOS, returns a blurred `BlurView` or `VibrancyView` component. On Android, returns a regular `View` without blur.
|
|
37
|
+
*
|
|
38
|
+
* ::: warning Note
|
|
39
|
+
* `BlurView` is only supported on iOS. On Android, it renders a regular `View` without any blur effect.
|
|
40
|
+
* :::
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
*
|
|
44
|
+
* ### Blurring background behind a text
|
|
45
|
+
*
|
|
46
|
+
* ```tsx
|
|
47
|
+
* import { BlurView } from '@granite-js/react-native';
|
|
48
|
+
* import { View, Text, StyleSheet } from 'react-native';
|
|
49
|
+
*
|
|
50
|
+
* export function BlurViewExample() {
|
|
51
|
+
* return (
|
|
52
|
+
* <View style={styles.container}>
|
|
53
|
+
* <Text style={styles.absolute}>Blurred Text</Text>
|
|
54
|
+
* <BlurView style={styles.absolute} blurType="light" blurAmount={1} />
|
|
55
|
+
* <Text>Non Blurred Text</Text>
|
|
56
|
+
* </View>
|
|
57
|
+
* );
|
|
58
|
+
* }
|
|
59
|
+
*
|
|
60
|
+
* const styles = StyleSheet.create({
|
|
61
|
+
* container: {
|
|
62
|
+
* justifyContent: 'center',
|
|
63
|
+
* alignItems: 'center',
|
|
64
|
+
* width: '100%',
|
|
65
|
+
* height: 300,
|
|
66
|
+
* },
|
|
67
|
+
* absolute: {
|
|
68
|
+
* position: 'absolute',
|
|
69
|
+
* top: 0,
|
|
70
|
+
* left: 0,
|
|
71
|
+
* bottom: 0,
|
|
72
|
+
* right: 0,
|
|
73
|
+
* },
|
|
74
|
+
* });
|
|
75
|
+
* ```
|
|
76
|
+
*
|
|
77
|
+
* @see [iOS Vibrancy Effect Documentation](https://developer.apple.com/documentation/uikit/uivibrancyeffect)
|
|
78
|
+
* @see [Zeddios Blog Explanation](https://zeddios.tistory.com/1140)
|
|
79
|
+
*/
|
|
80
|
+
export function BlurView({
|
|
81
|
+
blurType,
|
|
82
|
+
blurAmount = 10,
|
|
83
|
+
reducedTransparencyFallbackColor,
|
|
84
|
+
vibrancyEffect = false,
|
|
85
|
+
...viewProps
|
|
86
|
+
}: BlurViewProps) {
|
|
87
|
+
if (!isBlurNativeModuleSupported || ReactNativeBlurModule == null) {
|
|
88
|
+
return <View {...viewProps} />;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const Component = vibrancyEffect ? ReactNativeBlurModule.VibrancyView : ReactNativeBlurModule.BlurView;
|
|
92
|
+
|
|
93
|
+
return (
|
|
94
|
+
<Component
|
|
95
|
+
blurAmount={blurAmount}
|
|
96
|
+
blurType={blurType}
|
|
97
|
+
reducedTransparencyFallbackColor={reducedTransparencyFallbackColor}
|
|
98
|
+
{...viewProps}
|
|
99
|
+
/>
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
BlurView.isSupported = isBlurNativeModuleSupported;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { BlurView, VibrancyView } from '@granite-js/native/@react-native-community/blur';
|
|
2
|
+
import { isBlurNativeModuleSupported } from './constants';
|
|
3
|
+
|
|
4
|
+
const ReactNativeBlurModule = (() => {
|
|
5
|
+
if (!isBlurNativeModuleSupported) {
|
|
6
|
+
return undefined;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
try {
|
|
10
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
11
|
+
return require('@granite-js/native/@react-native-community/blur') as {
|
|
12
|
+
BlurView: typeof BlurView;
|
|
13
|
+
VibrancyView: typeof VibrancyView;
|
|
14
|
+
};
|
|
15
|
+
} catch {
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
})();
|
|
19
|
+
|
|
20
|
+
export { ReactNativeBlurModule };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './BlurView';
|
package/src/index.ts
CHANGED
|
@@ -18,6 +18,7 @@ export * from './router/createRoute';
|
|
|
18
18
|
export * from './event';
|
|
19
19
|
export * from './video';
|
|
20
20
|
export * from './status-bar';
|
|
21
|
+
export * from './blur';
|
|
21
22
|
|
|
22
23
|
export type { InitialProps, ColorPreference } from './initial-props';
|
|
23
24
|
export type { GraniteProps } from './app';
|