@granite-js/react-native 0.1.2 → 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 +27 -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 +2 -0
- package/dist/keyboard/index.d.ts +1 -0
- package/dist/status-bar/StatusBar.android.d.ts +3 -0
- package/dist/status-bar/StatusBar.ios.d.ts +3 -0
- package/dist/status-bar/index.d.ts +2 -0
- package/dist/status-bar/types.d.ts +20 -0
- package/dist/status-bar/utils.d.ts +3 -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 +2 -0
- package/src/keyboard/index.ts +1 -0
- package/src/status-bar/StatusBar.android.tsx +36 -0
- package/src/status-bar/StatusBar.d.ts +4 -0
- package/src/status-bar/StatusBar.ios.tsx +34 -0
- package/src/status-bar/index.ts +2 -0
- package/src/status-bar/types.ts +21 -0
- package/src/status-bar/utils.ts +20 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,32 @@
|
|
|
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
|
+
|
|
16
|
+
## 0.1.3
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- 1adad4c: add StatusBar API
|
|
21
|
+
- a4783c8: expose keyboard utils
|
|
22
|
+
- @granite-js/cli@0.1.3
|
|
23
|
+
- @granite-js/image@0.1.3
|
|
24
|
+
- @granite-js/jest@0.1.3
|
|
25
|
+
- @granite-js/lottie@0.1.3
|
|
26
|
+
- @granite-js/mpack@0.1.3
|
|
27
|
+
- @granite-js/native@0.1.3
|
|
28
|
+
- @granite-js/style-utils@0.1.3
|
|
29
|
+
|
|
3
30
|
## 0.1.2
|
|
4
31
|
|
|
5
32
|
### 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
|
@@ -15,5 +15,7 @@ export * from './react';
|
|
|
15
15
|
export * from './router/createRoute';
|
|
16
16
|
export * from './event';
|
|
17
17
|
export * from './video';
|
|
18
|
+
export * from './status-bar';
|
|
19
|
+
export * from './blur';
|
|
18
20
|
export type { InitialProps, ColorPreference } from './initial-props';
|
|
19
21
|
export type { GraniteProps } from './app';
|
package/dist/keyboard/index.d.ts
CHANGED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { StatusBarProps } from './types';
|
|
2
|
+
export declare function StatusBar({ style, animated, hidden, backgroundColor, translucent }: StatusBarProps): import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
export declare function useStatusBar({ style, animated, hidden, backgroundColor, translucent }: StatusBarProps): void;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export type StatusBarStyle = 'light' | 'dark' | 'auto' | 'inverted';
|
|
2
|
+
export type StatusBarProps = {
|
|
3
|
+
/**
|
|
4
|
+
* @default 'auto'
|
|
5
|
+
*/
|
|
6
|
+
style?: StatusBarStyle;
|
|
7
|
+
hidden?: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* @platform android
|
|
10
|
+
*/
|
|
11
|
+
animated?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* @platform android
|
|
14
|
+
*/
|
|
15
|
+
backgroundColor?: string;
|
|
16
|
+
/**
|
|
17
|
+
* @platform android
|
|
18
|
+
*/
|
|
19
|
+
translucent?: boolean;
|
|
20
|
+
};
|
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
|
@@ -17,6 +17,8 @@ export * from './react';
|
|
|
17
17
|
export * from './router/createRoute';
|
|
18
18
|
export * from './event';
|
|
19
19
|
export * from './video';
|
|
20
|
+
export * from './status-bar';
|
|
21
|
+
export * from './blur';
|
|
20
22
|
|
|
21
23
|
export type { InitialProps, ColorPreference } from './initial-props';
|
|
22
24
|
export type { GraniteProps } from './app';
|
package/src/keyboard/index.ts
CHANGED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { useLayoutEffect } from 'react';
|
|
2
|
+
import { StatusBar as BaseStatusBar, useColorScheme } from 'react-native';
|
|
3
|
+
import type { StatusBarProps } from './types';
|
|
4
|
+
import { toStatusBarContentStyle } from './utils';
|
|
5
|
+
|
|
6
|
+
export function StatusBar({ style, animated, hidden, backgroundColor, translucent = true }: StatusBarProps) {
|
|
7
|
+
const colorScheme = useColorScheme() ?? 'light';
|
|
8
|
+
const translucentWithNoBackgroundColor = translucent && backgroundColor == null;
|
|
9
|
+
|
|
10
|
+
return (
|
|
11
|
+
<BaseStatusBar
|
|
12
|
+
translucent={translucent}
|
|
13
|
+
barStyle={toStatusBarContentStyle(style, colorScheme)}
|
|
14
|
+
backgroundColor={translucentWithNoBackgroundColor ? 'transparent' : backgroundColor}
|
|
15
|
+
animated={animated}
|
|
16
|
+
hidden={hidden}
|
|
17
|
+
/>
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function useStatusBar({ style, animated, hidden, backgroundColor, translucent = true }: StatusBarProps) {
|
|
22
|
+
const colorScheme = useColorScheme() ?? 'light';
|
|
23
|
+
const translucentWithNoBackgroundColor = translucent && backgroundColor == null;
|
|
24
|
+
|
|
25
|
+
useLayoutEffect(() => {
|
|
26
|
+
BaseStatusBar.setTranslucent(translucent);
|
|
27
|
+
BaseStatusBar.setBarStyle(toStatusBarContentStyle(style, colorScheme));
|
|
28
|
+
BaseStatusBar.setBackgroundColor(
|
|
29
|
+
translucentWithNoBackgroundColor ? 'transparent' : (backgroundColor ?? 'transparent')
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
if (hidden !== undefined) {
|
|
33
|
+
BaseStatusBar.setHidden(hidden);
|
|
34
|
+
}
|
|
35
|
+
}, [colorScheme, translucentWithNoBackgroundColor, style, animated, hidden, backgroundColor, translucent]);
|
|
36
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { useLayoutEffect } from 'react';
|
|
2
|
+
import { useColorScheme } from 'react-native';
|
|
3
|
+
import type { StatusBarProps } from './types';
|
|
4
|
+
import { toStatusBarContentStyle } from './utils';
|
|
5
|
+
import { useNavigation } from '../router/createRoute';
|
|
6
|
+
|
|
7
|
+
export function StatusBar(props: StatusBarProps) {
|
|
8
|
+
useStatusBar(props);
|
|
9
|
+
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function useStatusBar({ style, hidden }: StatusBarProps) {
|
|
14
|
+
const navigation = useNavigation();
|
|
15
|
+
const colorScheme = useColorScheme() ?? 'light';
|
|
16
|
+
|
|
17
|
+
useLayoutEffect(() => {
|
|
18
|
+
let statusBarStyle: 'light' | 'dark';
|
|
19
|
+
|
|
20
|
+
switch (toStatusBarContentStyle(style, colorScheme)) {
|
|
21
|
+
case 'light-content':
|
|
22
|
+
statusBarStyle = 'light';
|
|
23
|
+
break;
|
|
24
|
+
case 'dark-content':
|
|
25
|
+
statusBarStyle = 'dark';
|
|
26
|
+
break;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
navigation.setOptions({
|
|
30
|
+
statusBarStyle,
|
|
31
|
+
statusBarHidden: hidden,
|
|
32
|
+
});
|
|
33
|
+
}, [navigation, colorScheme, style, hidden]);
|
|
34
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export type StatusBarStyle = 'light' | 'dark' | 'auto' | 'inverted';
|
|
2
|
+
|
|
3
|
+
export type StatusBarProps = {
|
|
4
|
+
/**
|
|
5
|
+
* @default 'auto'
|
|
6
|
+
*/
|
|
7
|
+
style?: StatusBarStyle;
|
|
8
|
+
hidden?: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* @platform android
|
|
11
|
+
*/
|
|
12
|
+
animated?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* @platform android
|
|
15
|
+
*/
|
|
16
|
+
backgroundColor?: string;
|
|
17
|
+
/**
|
|
18
|
+
* @platform android
|
|
19
|
+
*/
|
|
20
|
+
translucent?: boolean;
|
|
21
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { StatusBarStyle } from './types';
|
|
2
|
+
import type { ColorPreference } from '../initial-props';
|
|
3
|
+
|
|
4
|
+
export function toStatusBarContentStyle(
|
|
5
|
+
statusBarStyle: StatusBarStyle = 'auto',
|
|
6
|
+
colorPreference: ColorPreference = 'light'
|
|
7
|
+
): 'light-content' | 'dark-content' {
|
|
8
|
+
const resolvedStyle = (() => {
|
|
9
|
+
switch (statusBarStyle) {
|
|
10
|
+
case 'auto':
|
|
11
|
+
return colorPreference === 'light' ? 'dark' : 'light';
|
|
12
|
+
case 'inverted':
|
|
13
|
+
return colorPreference === 'light' ? 'light' : 'dark';
|
|
14
|
+
default:
|
|
15
|
+
return statusBarStyle;
|
|
16
|
+
}
|
|
17
|
+
})();
|
|
18
|
+
|
|
19
|
+
return resolvedStyle === 'light' ? 'light-content' : 'dark-content';
|
|
20
|
+
}
|