react-native-edge-to-edge 1.5.1 → 1.6.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 +40 -7
- package/dist/commonjs/SystemBars.js +131 -51
- package/dist/commonjs/SystemBars.js.map +1 -1
- package/dist/module/SystemBars.js +131 -51
- package/dist/module/SystemBars.js.map +1 -1
- package/dist/typescript/SystemBars.d.ts +3 -1
- package/dist/typescript/SystemBars.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/SystemBars.ts +150 -90
package/README.md
CHANGED
|
@@ -70,7 +70,7 @@ Add the library plugin in your `app.json` config file and [create a new build](h
|
|
|
70
70
|
"react-native-edge-to-edge",
|
|
71
71
|
{
|
|
72
72
|
"android": {
|
|
73
|
-
"parentTheme": "
|
|
73
|
+
"parentTheme": "Default",
|
|
74
74
|
"enforceNavigationBarContrast": false
|
|
75
75
|
}
|
|
76
76
|
}
|
|
@@ -104,7 +104,7 @@ type Options = {
|
|
|
104
104
|
```
|
|
105
105
|
|
|
106
106
|
> [!NOTE]
|
|
107
|
-
>
|
|
107
|
+
> These configuration properties are not supported in the [Expo Go](https://expo.dev/go) sandbox app, use a [development build](https://docs.expo.dev/develop/development-builds/create-a-build/).
|
|
108
108
|
|
|
109
109
|
### Bare React Native
|
|
110
110
|
|
|
@@ -170,6 +170,8 @@ const App = () => (
|
|
|
170
170
|
|
|
171
171
|
#### SystemBars.pushStackEntry
|
|
172
172
|
|
|
173
|
+
Push a `SystemBars` entry onto the stack. The return value should be passed to `popStackEntry` when complete.
|
|
174
|
+
|
|
173
175
|
```ts
|
|
174
176
|
const entry: SystemBarsEntry = SystemBars.pushStackEntry(
|
|
175
177
|
props /*: SystemBarsProps */,
|
|
@@ -178,12 +180,16 @@ const entry: SystemBarsEntry = SystemBars.pushStackEntry(
|
|
|
178
180
|
|
|
179
181
|
#### SystemBars.popStackEntry
|
|
180
182
|
|
|
183
|
+
Remove an existing `SystemBars` stack entry from the stack.
|
|
184
|
+
|
|
181
185
|
```ts
|
|
182
186
|
SystemBars.popStackEntry(entry /*: SystemBarsEntry */);
|
|
183
187
|
```
|
|
184
188
|
|
|
185
189
|
#### SystemBars.replaceStackEntry
|
|
186
190
|
|
|
191
|
+
Replace an existing `SystemBars` stack entry with new props.
|
|
192
|
+
|
|
187
193
|
```ts
|
|
188
194
|
const entry: SystemBarsEntry = SystemBars.replaceStackEntry(
|
|
189
195
|
entry /*: SystemBarsEntry */,
|
|
@@ -191,18 +197,45 @@ const entry: SystemBarsEntry = SystemBars.replaceStackEntry(
|
|
|
191
197
|
);
|
|
192
198
|
```
|
|
193
199
|
|
|
200
|
+
#### SystemBars.setStyle
|
|
201
|
+
|
|
202
|
+
Set the system bars style.
|
|
203
|
+
|
|
204
|
+
```ts
|
|
205
|
+
SystemBars.setStyle(style /*: SystemBarsProps["style"] */);
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
#### SystemBars.setHidden
|
|
209
|
+
|
|
210
|
+
Show or hide the system bars.
|
|
211
|
+
|
|
212
|
+
```ts
|
|
213
|
+
SystemBars.setHidden(style /*: SystemBarsProps["hidden"] */);
|
|
214
|
+
```
|
|
215
|
+
|
|
194
216
|
## Third-party libraries 🧩
|
|
195
217
|
|
|
196
218
|
If you're an author and your package interferes with edge-to-edge, refer to the [`react-native-is-edge-to-edge` `README.md`](./react-native-is-edge-to-edge) for compatibility instructions.
|
|
197
219
|
|
|
198
220
|
## Troubleshooting 🤔
|
|
199
221
|
|
|
200
|
-
#### The
|
|
222
|
+
#### The navigation bar style is erratic
|
|
201
223
|
|
|
202
|
-
|
|
224
|
+
There's currently [an open issue](https://issuetracker.google.com/issues/346386744) with the Android 15 emulator image regarding the navigation bar style when it is is fully transparent. This issue does not occur on physical devices.
|
|
203
225
|
|
|
204
|
-
|
|
226
|
+
#### The system bars stays opaque
|
|
205
227
|
|
|
206
|
-
|
|
228
|
+
In recent months, support has been added across the React Native ecosystem. If you use any of the following libraries, make sure you're on the latest version:
|
|
207
229
|
|
|
208
|
-
|
|
230
|
+
- `expo-router`
|
|
231
|
+
- `galeria`
|
|
232
|
+
- `react-native-avoid-softinput`
|
|
233
|
+
- `react-native-bootsplash`
|
|
234
|
+
- `react-native-bottom-tabs`
|
|
235
|
+
- `react-native-keyboard-controller`
|
|
236
|
+
- `react-native-reanimated`
|
|
237
|
+
- `react-native-screens`
|
|
238
|
+
- `react-native-true-sheet`
|
|
239
|
+
- `react-native-unistyles (v3)`
|
|
240
|
+
|
|
241
|
+
Make also sure to replace all occurrences of the built-in `StatusBar`, [`expo-status-bar`](https://docs.expo.dev/versions/latest/sdk/status-bar) and [`expo-navigation-bar`](https://docs.expo.dev/versions/latest/sdk/navigation-bar/) with `SystemBars`.
|
|
@@ -8,8 +8,19 @@ var _react = require("react");
|
|
|
8
8
|
var _reactNative = require("react-native");
|
|
9
9
|
var _NativeEdgeToEdgeModule = _interopRequireDefault(require("./specs/NativeEdgeToEdgeModule"));
|
|
10
10
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
-
function
|
|
12
|
-
|
|
11
|
+
function isLightColorScheme() {
|
|
12
|
+
const colorScheme = _reactNative.Appearance?.getColorScheme() ?? "light";
|
|
13
|
+
return colorScheme === "light";
|
|
14
|
+
}
|
|
15
|
+
function resolveSystemBarStyle(style) {
|
|
16
|
+
switch (style) {
|
|
17
|
+
case "auto":
|
|
18
|
+
return isLightColorScheme() ? "dark" : "light";
|
|
19
|
+
case "inverted":
|
|
20
|
+
return isLightColorScheme() ? "light" : "dark";
|
|
21
|
+
default:
|
|
22
|
+
return style;
|
|
23
|
+
}
|
|
13
24
|
}
|
|
14
25
|
function toNativeBarStyle(style) {
|
|
15
26
|
return style === "light" || style === "dark" ? `${style}-content` : "default";
|
|
@@ -30,21 +41,29 @@ function mergeEntriesStack(entriesStack) {
|
|
|
30
41
|
}, {
|
|
31
42
|
statusBarStyle: undefined,
|
|
32
43
|
navigationBarStyle: undefined,
|
|
33
|
-
statusBarHidden:
|
|
34
|
-
navigationBarHidden:
|
|
44
|
+
statusBarHidden: undefined,
|
|
45
|
+
navigationBarHidden: undefined
|
|
35
46
|
});
|
|
36
47
|
}
|
|
48
|
+
function resolveProps({
|
|
49
|
+
hidden,
|
|
50
|
+
style
|
|
51
|
+
}) {
|
|
52
|
+
const compactStyle = typeof style === "string";
|
|
53
|
+
const compactHidden = typeof hidden === "boolean";
|
|
54
|
+
return {
|
|
55
|
+
statusBarStyle: compactStyle ? style : style?.statusBar,
|
|
56
|
+
navigationBarStyle: compactStyle ? style : style?.navigationBar,
|
|
57
|
+
statusBarHidden: compactHidden ? hidden : hidden?.statusBar,
|
|
58
|
+
navigationBarHidden: compactHidden ? hidden : hidden?.navigationBar
|
|
59
|
+
};
|
|
60
|
+
}
|
|
37
61
|
|
|
38
62
|
/**
|
|
39
63
|
* Returns an object to insert in the props stack from the props.
|
|
40
64
|
*/
|
|
41
65
|
function createStackEntry(props) {
|
|
42
|
-
return
|
|
43
|
-
statusBarStyle: typeof props.style === "string" ? props.style : props.style?.statusBar,
|
|
44
|
-
navigationBarStyle: typeof props.style === "string" ? props.style : props.style?.navigationBar,
|
|
45
|
-
statusBarHidden: typeof props.hidden === "boolean" ? props.hidden : props.hidden?.statusBar,
|
|
46
|
-
navigationBarHidden: typeof props.hidden === "boolean" ? props.hidden : props.hidden?.navigationBar
|
|
47
|
-
};
|
|
66
|
+
return resolveProps(props);
|
|
48
67
|
}
|
|
49
68
|
const entriesStack = [];
|
|
50
69
|
|
|
@@ -52,12 +71,50 @@ const entriesStack = [];
|
|
|
52
71
|
let updateImmediate = null;
|
|
53
72
|
|
|
54
73
|
// The current merged values from the entries stack.
|
|
55
|
-
|
|
74
|
+
const currentValues = {
|
|
56
75
|
statusBarStyle: undefined,
|
|
57
76
|
navigationBarStyle: undefined,
|
|
58
|
-
statusBarHidden:
|
|
59
|
-
navigationBarHidden:
|
|
77
|
+
statusBarHidden: undefined,
|
|
78
|
+
navigationBarHidden: undefined
|
|
60
79
|
};
|
|
80
|
+
function setStatusBarStyle(style) {
|
|
81
|
+
if (style !== currentValues.statusBarStyle) {
|
|
82
|
+
currentValues.statusBarStyle = style;
|
|
83
|
+
const nativeStyle = toNativeBarStyle(style);
|
|
84
|
+
if (_reactNative.Platform.OS === "android") {
|
|
85
|
+
_NativeEdgeToEdgeModule.default?.setStatusBarStyle(nativeStyle);
|
|
86
|
+
} else if (_reactNative.Platform.OS === "ios") {
|
|
87
|
+
_reactNative.StatusBar.setBarStyle(nativeStyle, true);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
function setNavigationBarStyle(style) {
|
|
92
|
+
if (style !== currentValues.navigationBarStyle) {
|
|
93
|
+
currentValues.navigationBarStyle = style;
|
|
94
|
+
if (_reactNative.Platform.OS === "android") {
|
|
95
|
+
const nativeStyle = toNativeBarStyle(style);
|
|
96
|
+
_NativeEdgeToEdgeModule.default?.setNavigationBarStyle(nativeStyle);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
function setStatusBarHidden(hidden) {
|
|
101
|
+
if (hidden !== currentValues.statusBarHidden) {
|
|
102
|
+
currentValues.statusBarHidden = hidden;
|
|
103
|
+
if (_reactNative.Platform.OS === "android") {
|
|
104
|
+
_NativeEdgeToEdgeModule.default?.setStatusBarHidden(hidden);
|
|
105
|
+
} else if (_reactNative.Platform.OS === "ios") {
|
|
106
|
+
_reactNative.StatusBar.setHidden(hidden, "fade"); // 'slide' doesn't work in this context
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
function setNavigationBarHidden(hidden) {
|
|
111
|
+
if (hidden !== currentValues.navigationBarHidden) {
|
|
112
|
+
currentValues.navigationBarHidden = hidden;
|
|
113
|
+
if (_reactNative.Platform.OS === "android") {
|
|
114
|
+
_NativeEdgeToEdgeModule.default?.setNavigationBarHidden(hidden);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
61
118
|
|
|
62
119
|
/**
|
|
63
120
|
* Updates the native system bars with the entries from the stack.
|
|
@@ -68,47 +125,30 @@ function updateEntriesStack() {
|
|
|
68
125
|
clearImmediate(updateImmediate);
|
|
69
126
|
}
|
|
70
127
|
updateImmediate = setImmediate(() => {
|
|
71
|
-
const isLightColorScheme = getColorScheme() === "light";
|
|
72
|
-
const autoBarStyle = isLightColorScheme ? "dark" : "light";
|
|
73
|
-
const invertedBarStyle = isLightColorScheme ? "light" : "dark";
|
|
74
128
|
const mergedEntries = mergeEntriesStack(entriesStack);
|
|
75
|
-
const statusBarStyle = mergedEntries.statusBarStyle === "auto" ? autoBarStyle : mergedEntries.statusBarStyle === "inverted" ? invertedBarStyle : mergedEntries.statusBarStyle;
|
|
76
|
-
const navigationBarStyle = mergedEntries.navigationBarStyle === "auto" ? autoBarStyle : mergedEntries.navigationBarStyle === "inverted" ? invertedBarStyle : mergedEntries.navigationBarStyle;
|
|
77
129
|
const {
|
|
78
130
|
statusBarHidden,
|
|
79
131
|
navigationBarHidden
|
|
80
132
|
} = mergedEntries;
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
133
|
+
const statusBarStyle = resolveSystemBarStyle(mergedEntries.statusBarStyle);
|
|
134
|
+
const navigationBarStyle = resolveSystemBarStyle(mergedEntries.navigationBarStyle);
|
|
135
|
+
setStatusBarStyle(statusBarStyle);
|
|
136
|
+
setNavigationBarStyle(navigationBarStyle);
|
|
137
|
+
if (statusBarHidden != null) {
|
|
138
|
+
setStatusBarHidden(statusBarHidden);
|
|
84
139
|
}
|
|
85
|
-
if (
|
|
86
|
-
|
|
140
|
+
if (navigationBarHidden != null) {
|
|
141
|
+
setNavigationBarHidden(navigationBarHidden);
|
|
87
142
|
}
|
|
88
|
-
if (_reactNative.Platform.OS === "android") {
|
|
89
|
-
if (navigationBarStyle !== currentMergedEntries.navigationBarStyle) {
|
|
90
|
-
const style = toNativeBarStyle(navigationBarStyle);
|
|
91
|
-
_NativeEdgeToEdgeModule.default?.setNavigationBarStyle(style);
|
|
92
|
-
}
|
|
93
|
-
if (navigationBarHidden !== currentMergedEntries.navigationBarHidden) {
|
|
94
|
-
_NativeEdgeToEdgeModule.default?.setNavigationBarHidden(navigationBarHidden);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
currentMergedEntries = {
|
|
98
|
-
statusBarStyle,
|
|
99
|
-
navigationBarStyle,
|
|
100
|
-
statusBarHidden,
|
|
101
|
-
navigationBarHidden
|
|
102
|
-
};
|
|
103
143
|
});
|
|
104
144
|
}
|
|
105
145
|
}
|
|
106
146
|
|
|
107
147
|
/**
|
|
108
|
-
* Push a SystemBars entry onto the stack.
|
|
148
|
+
* Push a `SystemBars` entry onto the stack.
|
|
109
149
|
* The return value should be passed to `popStackEntry` when complete.
|
|
110
150
|
*
|
|
111
|
-
* @param props Object containing the SystemBars props to use in the stack entry.
|
|
151
|
+
* @param props Object containing the `SystemBars` props to use in the stack entry.
|
|
112
152
|
*/
|
|
113
153
|
function pushStackEntry(props) {
|
|
114
154
|
const entry = createStackEntry(props);
|
|
@@ -118,7 +158,7 @@ function pushStackEntry(props) {
|
|
|
118
158
|
}
|
|
119
159
|
|
|
120
160
|
/**
|
|
121
|
-
*
|
|
161
|
+
* Remove an existing `SystemBars` stack entry from the stack.
|
|
122
162
|
*
|
|
123
163
|
* @param entry Entry returned from `pushStackEntry`.
|
|
124
164
|
*/
|
|
@@ -131,10 +171,10 @@ function popStackEntry(entry) {
|
|
|
131
171
|
}
|
|
132
172
|
|
|
133
173
|
/**
|
|
134
|
-
* Replace an existing SystemBars stack entry with new props.
|
|
174
|
+
* Replace an existing `SystemBars` stack entry with new props.
|
|
135
175
|
*
|
|
136
176
|
* @param entry Entry returned from `pushStackEntry` to replace.
|
|
137
|
-
* @param props Object containing the SystemBars props to use in the replacement stack entry.
|
|
177
|
+
* @param props Object containing the `SystemBars` props to use in the replacement stack entry.
|
|
138
178
|
*/
|
|
139
179
|
function replaceStackEntry(entry, props) {
|
|
140
180
|
const newEntry = createStackEntry(props);
|
|
@@ -145,14 +185,52 @@ function replaceStackEntry(entry, props) {
|
|
|
145
185
|
updateEntriesStack();
|
|
146
186
|
return newEntry;
|
|
147
187
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
const
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Set the system bars style.
|
|
191
|
+
*
|
|
192
|
+
* @param style System bars style to set.
|
|
193
|
+
*/
|
|
194
|
+
function setStyle(style) {
|
|
195
|
+
const props = resolveProps({
|
|
196
|
+
style
|
|
197
|
+
});
|
|
198
|
+
const statusBarStyle = resolveSystemBarStyle(props.statusBarStyle);
|
|
199
|
+
const navigationBarStyle = resolveSystemBarStyle(props.navigationBarStyle);
|
|
200
|
+
if (typeof statusBarStyle === "string") {
|
|
201
|
+
setStatusBarStyle(statusBarStyle);
|
|
202
|
+
}
|
|
203
|
+
if (typeof navigationBarStyle === "string") {
|
|
204
|
+
setNavigationBarStyle(navigationBarStyle);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Show or hide the system bars.
|
|
210
|
+
*
|
|
211
|
+
* @param hidden Hide the system bars.
|
|
212
|
+
*/
|
|
213
|
+
function setHidden(hidden) {
|
|
214
|
+
const {
|
|
215
|
+
statusBarHidden,
|
|
216
|
+
navigationBarHidden
|
|
217
|
+
} = resolveProps({
|
|
218
|
+
hidden
|
|
219
|
+
});
|
|
220
|
+
if (typeof statusBarHidden === "boolean") {
|
|
221
|
+
setStatusBarHidden(statusBarHidden);
|
|
222
|
+
}
|
|
223
|
+
if (typeof navigationBarHidden === "boolean") {
|
|
224
|
+
setNavigationBarHidden(navigationBarHidden);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
function SystemBars(props) {
|
|
228
|
+
const {
|
|
229
|
+
statusBarStyle,
|
|
230
|
+
navigationBarStyle,
|
|
231
|
+
statusBarHidden,
|
|
232
|
+
navigationBarHidden
|
|
233
|
+
} = resolveProps(props);
|
|
156
234
|
const stableProps = (0, _react.useMemo)(() => ({
|
|
157
235
|
style: statusBarStyle === navigationBarStyle ? statusBarStyle : {
|
|
158
236
|
statusBar: statusBarStyle,
|
|
@@ -189,4 +267,6 @@ function SystemBars({
|
|
|
189
267
|
SystemBars.pushStackEntry = pushStackEntry;
|
|
190
268
|
SystemBars.popStackEntry = popStackEntry;
|
|
191
269
|
SystemBars.replaceStackEntry = replaceStackEntry;
|
|
270
|
+
SystemBars.setStyle = setStyle;
|
|
271
|
+
SystemBars.setHidden = setHidden;
|
|
192
272
|
//# sourceMappingURL=SystemBars.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","require","_reactNative","_NativeEdgeToEdgeModule","_interopRequireDefault","e","__esModule","default","
|
|
1
|
+
{"version":3,"names":["_react","require","_reactNative","_NativeEdgeToEdgeModule","_interopRequireDefault","e","__esModule","default","isLightColorScheme","colorScheme","Appearance","getColorScheme","resolveSystemBarStyle","style","toNativeBarStyle","mergeEntriesStack","entriesStack","reduce","prev","cur","prop","statusBarStyle","undefined","navigationBarStyle","statusBarHidden","navigationBarHidden","resolveProps","hidden","compactStyle","compactHidden","statusBar","navigationBar","createStackEntry","props","updateImmediate","currentValues","setStatusBarStyle","nativeStyle","Platform","OS","NativeModule","StatusBar","setBarStyle","setNavigationBarStyle","setStatusBarHidden","setHidden","setNavigationBarHidden","updateEntriesStack","clearImmediate","setImmediate","mergedEntries","pushStackEntry","entry","push","popStackEntry","index","indexOf","splice","replaceStackEntry","newEntry","setStyle","SystemBars","stableProps","useMemo","useColorScheme","stackEntryRef","useRef","useEffect","current"],"sourceRoot":"../../src","sources":["SystemBars.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,uBAAA,GAAAC,sBAAA,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AAEN;IAAoB;EACzE,CAAC,CAAC,EACF,CAACJ,cAAc,EAAEE,kBAAkB,EAAEC,eAAe,EAAEC,mBAAmB,CAC3E,CAAC;EAED,MAAMhB,WAAW,GAAG,IAAAuD,2BAAc,EAAC,CAAC;EACpC,MAAMC,aAAa,GAAG,IAAAC,aAAM,EAAyB,IAAI,CAAC;EAE1D,IAAAC,gBAAS,EAAC,MAAM;IACd;IACA;IACA;IACA;IACAF,aAAa,CAACG,OAAO,GAAGjB,cAAc,CAACW,WAAW,CAAC;IAEnD,OAAO,MAAM;MACX;MACA;MACA,IAAIG,aAAa,CAACG,OAAO,EAAE;QACzBd,aAAa,CAACW,aAAa,CAACG,OAAO,CAAC;MACtC;IACF,CAAC;EACH,CAAC,EAAE,EAAE,CAAC;EAEN,IAAAD,gBAAS,EAAC,MAAM;IACd,IAAIF,aAAa,CAACG,OAAO,EAAE;MACzBH,aAAa,CAACG,OAAO,GAAGV,iBAAiB,CACvCO,aAAa,CAACG,OAAO,EACrBN,WACF,CAAC;IACH;EACF,CAAC,EAAE,CAACrD,WAAW,EAAEqD,WAAW,CAAC,CAAC;EAE9B,OAAO,IAAI;AACb;AAEAD,UAAU,CAACV,cAAc,GAAGA,cAAc;AAC1CU,UAAU,CAACP,aAAa,GAAGA,aAAa;AACxCO,UAAU,CAACH,iBAAiB,GAAGA,iBAAiB;AAChDG,UAAU,CAACD,QAAQ,GAAGA,QAAQ;AAC9BC,UAAU,CAAChB,SAAS,GAAGA,SAAS","ignoreList":[]}
|
|
@@ -3,8 +3,19 @@
|
|
|
3
3
|
import { useEffect, useMemo, useRef } from "react";
|
|
4
4
|
import { Appearance, Platform, StatusBar, useColorScheme } from "react-native";
|
|
5
5
|
import NativeModule from "./specs/NativeEdgeToEdgeModule";
|
|
6
|
-
function
|
|
7
|
-
|
|
6
|
+
function isLightColorScheme() {
|
|
7
|
+
const colorScheme = Appearance?.getColorScheme() ?? "light";
|
|
8
|
+
return colorScheme === "light";
|
|
9
|
+
}
|
|
10
|
+
function resolveSystemBarStyle(style) {
|
|
11
|
+
switch (style) {
|
|
12
|
+
case "auto":
|
|
13
|
+
return isLightColorScheme() ? "dark" : "light";
|
|
14
|
+
case "inverted":
|
|
15
|
+
return isLightColorScheme() ? "light" : "dark";
|
|
16
|
+
default:
|
|
17
|
+
return style;
|
|
18
|
+
}
|
|
8
19
|
}
|
|
9
20
|
function toNativeBarStyle(style) {
|
|
10
21
|
return style === "light" || style === "dark" ? `${style}-content` : "default";
|
|
@@ -25,21 +36,29 @@ function mergeEntriesStack(entriesStack) {
|
|
|
25
36
|
}, {
|
|
26
37
|
statusBarStyle: undefined,
|
|
27
38
|
navigationBarStyle: undefined,
|
|
28
|
-
statusBarHidden:
|
|
29
|
-
navigationBarHidden:
|
|
39
|
+
statusBarHidden: undefined,
|
|
40
|
+
navigationBarHidden: undefined
|
|
30
41
|
});
|
|
31
42
|
}
|
|
43
|
+
function resolveProps({
|
|
44
|
+
hidden,
|
|
45
|
+
style
|
|
46
|
+
}) {
|
|
47
|
+
const compactStyle = typeof style === "string";
|
|
48
|
+
const compactHidden = typeof hidden === "boolean";
|
|
49
|
+
return {
|
|
50
|
+
statusBarStyle: compactStyle ? style : style?.statusBar,
|
|
51
|
+
navigationBarStyle: compactStyle ? style : style?.navigationBar,
|
|
52
|
+
statusBarHidden: compactHidden ? hidden : hidden?.statusBar,
|
|
53
|
+
navigationBarHidden: compactHidden ? hidden : hidden?.navigationBar
|
|
54
|
+
};
|
|
55
|
+
}
|
|
32
56
|
|
|
33
57
|
/**
|
|
34
58
|
* Returns an object to insert in the props stack from the props.
|
|
35
59
|
*/
|
|
36
60
|
function createStackEntry(props) {
|
|
37
|
-
return
|
|
38
|
-
statusBarStyle: typeof props.style === "string" ? props.style : props.style?.statusBar,
|
|
39
|
-
navigationBarStyle: typeof props.style === "string" ? props.style : props.style?.navigationBar,
|
|
40
|
-
statusBarHidden: typeof props.hidden === "boolean" ? props.hidden : props.hidden?.statusBar,
|
|
41
|
-
navigationBarHidden: typeof props.hidden === "boolean" ? props.hidden : props.hidden?.navigationBar
|
|
42
|
-
};
|
|
61
|
+
return resolveProps(props);
|
|
43
62
|
}
|
|
44
63
|
const entriesStack = [];
|
|
45
64
|
|
|
@@ -47,12 +66,50 @@ const entriesStack = [];
|
|
|
47
66
|
let updateImmediate = null;
|
|
48
67
|
|
|
49
68
|
// The current merged values from the entries stack.
|
|
50
|
-
|
|
69
|
+
const currentValues = {
|
|
51
70
|
statusBarStyle: undefined,
|
|
52
71
|
navigationBarStyle: undefined,
|
|
53
|
-
statusBarHidden:
|
|
54
|
-
navigationBarHidden:
|
|
72
|
+
statusBarHidden: undefined,
|
|
73
|
+
navigationBarHidden: undefined
|
|
55
74
|
};
|
|
75
|
+
function setStatusBarStyle(style) {
|
|
76
|
+
if (style !== currentValues.statusBarStyle) {
|
|
77
|
+
currentValues.statusBarStyle = style;
|
|
78
|
+
const nativeStyle = toNativeBarStyle(style);
|
|
79
|
+
if (Platform.OS === "android") {
|
|
80
|
+
NativeModule?.setStatusBarStyle(nativeStyle);
|
|
81
|
+
} else if (Platform.OS === "ios") {
|
|
82
|
+
StatusBar.setBarStyle(nativeStyle, true);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
function setNavigationBarStyle(style) {
|
|
87
|
+
if (style !== currentValues.navigationBarStyle) {
|
|
88
|
+
currentValues.navigationBarStyle = style;
|
|
89
|
+
if (Platform.OS === "android") {
|
|
90
|
+
const nativeStyle = toNativeBarStyle(style);
|
|
91
|
+
NativeModule?.setNavigationBarStyle(nativeStyle);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
function setStatusBarHidden(hidden) {
|
|
96
|
+
if (hidden !== currentValues.statusBarHidden) {
|
|
97
|
+
currentValues.statusBarHidden = hidden;
|
|
98
|
+
if (Platform.OS === "android") {
|
|
99
|
+
NativeModule?.setStatusBarHidden(hidden);
|
|
100
|
+
} else if (Platform.OS === "ios") {
|
|
101
|
+
StatusBar.setHidden(hidden, "fade"); // 'slide' doesn't work in this context
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
function setNavigationBarHidden(hidden) {
|
|
106
|
+
if (hidden !== currentValues.navigationBarHidden) {
|
|
107
|
+
currentValues.navigationBarHidden = hidden;
|
|
108
|
+
if (Platform.OS === "android") {
|
|
109
|
+
NativeModule?.setNavigationBarHidden(hidden);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
56
113
|
|
|
57
114
|
/**
|
|
58
115
|
* Updates the native system bars with the entries from the stack.
|
|
@@ -63,47 +120,30 @@ function updateEntriesStack() {
|
|
|
63
120
|
clearImmediate(updateImmediate);
|
|
64
121
|
}
|
|
65
122
|
updateImmediate = setImmediate(() => {
|
|
66
|
-
const isLightColorScheme = getColorScheme() === "light";
|
|
67
|
-
const autoBarStyle = isLightColorScheme ? "dark" : "light";
|
|
68
|
-
const invertedBarStyle = isLightColorScheme ? "light" : "dark";
|
|
69
123
|
const mergedEntries = mergeEntriesStack(entriesStack);
|
|
70
|
-
const statusBarStyle = mergedEntries.statusBarStyle === "auto" ? autoBarStyle : mergedEntries.statusBarStyle === "inverted" ? invertedBarStyle : mergedEntries.statusBarStyle;
|
|
71
|
-
const navigationBarStyle = mergedEntries.navigationBarStyle === "auto" ? autoBarStyle : mergedEntries.navigationBarStyle === "inverted" ? invertedBarStyle : mergedEntries.navigationBarStyle;
|
|
72
124
|
const {
|
|
73
125
|
statusBarHidden,
|
|
74
126
|
navigationBarHidden
|
|
75
127
|
} = mergedEntries;
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
128
|
+
const statusBarStyle = resolveSystemBarStyle(mergedEntries.statusBarStyle);
|
|
129
|
+
const navigationBarStyle = resolveSystemBarStyle(mergedEntries.navigationBarStyle);
|
|
130
|
+
setStatusBarStyle(statusBarStyle);
|
|
131
|
+
setNavigationBarStyle(navigationBarStyle);
|
|
132
|
+
if (statusBarHidden != null) {
|
|
133
|
+
setStatusBarHidden(statusBarHidden);
|
|
79
134
|
}
|
|
80
|
-
if (
|
|
81
|
-
|
|
135
|
+
if (navigationBarHidden != null) {
|
|
136
|
+
setNavigationBarHidden(navigationBarHidden);
|
|
82
137
|
}
|
|
83
|
-
if (Platform.OS === "android") {
|
|
84
|
-
if (navigationBarStyle !== currentMergedEntries.navigationBarStyle) {
|
|
85
|
-
const style = toNativeBarStyle(navigationBarStyle);
|
|
86
|
-
NativeModule?.setNavigationBarStyle(style);
|
|
87
|
-
}
|
|
88
|
-
if (navigationBarHidden !== currentMergedEntries.navigationBarHidden) {
|
|
89
|
-
NativeModule?.setNavigationBarHidden(navigationBarHidden);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
currentMergedEntries = {
|
|
93
|
-
statusBarStyle,
|
|
94
|
-
navigationBarStyle,
|
|
95
|
-
statusBarHidden,
|
|
96
|
-
navigationBarHidden
|
|
97
|
-
};
|
|
98
138
|
});
|
|
99
139
|
}
|
|
100
140
|
}
|
|
101
141
|
|
|
102
142
|
/**
|
|
103
|
-
* Push a SystemBars entry onto the stack.
|
|
143
|
+
* Push a `SystemBars` entry onto the stack.
|
|
104
144
|
* The return value should be passed to `popStackEntry` when complete.
|
|
105
145
|
*
|
|
106
|
-
* @param props Object containing the SystemBars props to use in the stack entry.
|
|
146
|
+
* @param props Object containing the `SystemBars` props to use in the stack entry.
|
|
107
147
|
*/
|
|
108
148
|
function pushStackEntry(props) {
|
|
109
149
|
const entry = createStackEntry(props);
|
|
@@ -113,7 +153,7 @@ function pushStackEntry(props) {
|
|
|
113
153
|
}
|
|
114
154
|
|
|
115
155
|
/**
|
|
116
|
-
*
|
|
156
|
+
* Remove an existing `SystemBars` stack entry from the stack.
|
|
117
157
|
*
|
|
118
158
|
* @param entry Entry returned from `pushStackEntry`.
|
|
119
159
|
*/
|
|
@@ -126,10 +166,10 @@ function popStackEntry(entry) {
|
|
|
126
166
|
}
|
|
127
167
|
|
|
128
168
|
/**
|
|
129
|
-
* Replace an existing SystemBars stack entry with new props.
|
|
169
|
+
* Replace an existing `SystemBars` stack entry with new props.
|
|
130
170
|
*
|
|
131
171
|
* @param entry Entry returned from `pushStackEntry` to replace.
|
|
132
|
-
* @param props Object containing the SystemBars props to use in the replacement stack entry.
|
|
172
|
+
* @param props Object containing the `SystemBars` props to use in the replacement stack entry.
|
|
133
173
|
*/
|
|
134
174
|
function replaceStackEntry(entry, props) {
|
|
135
175
|
const newEntry = createStackEntry(props);
|
|
@@ -140,14 +180,52 @@ function replaceStackEntry(entry, props) {
|
|
|
140
180
|
updateEntriesStack();
|
|
141
181
|
return newEntry;
|
|
142
182
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
const
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Set the system bars style.
|
|
186
|
+
*
|
|
187
|
+
* @param style System bars style to set.
|
|
188
|
+
*/
|
|
189
|
+
function setStyle(style) {
|
|
190
|
+
const props = resolveProps({
|
|
191
|
+
style
|
|
192
|
+
});
|
|
193
|
+
const statusBarStyle = resolveSystemBarStyle(props.statusBarStyle);
|
|
194
|
+
const navigationBarStyle = resolveSystemBarStyle(props.navigationBarStyle);
|
|
195
|
+
if (typeof statusBarStyle === "string") {
|
|
196
|
+
setStatusBarStyle(statusBarStyle);
|
|
197
|
+
}
|
|
198
|
+
if (typeof navigationBarStyle === "string") {
|
|
199
|
+
setNavigationBarStyle(navigationBarStyle);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Show or hide the system bars.
|
|
205
|
+
*
|
|
206
|
+
* @param hidden Hide the system bars.
|
|
207
|
+
*/
|
|
208
|
+
function setHidden(hidden) {
|
|
209
|
+
const {
|
|
210
|
+
statusBarHidden,
|
|
211
|
+
navigationBarHidden
|
|
212
|
+
} = resolveProps({
|
|
213
|
+
hidden
|
|
214
|
+
});
|
|
215
|
+
if (typeof statusBarHidden === "boolean") {
|
|
216
|
+
setStatusBarHidden(statusBarHidden);
|
|
217
|
+
}
|
|
218
|
+
if (typeof navigationBarHidden === "boolean") {
|
|
219
|
+
setNavigationBarHidden(navigationBarHidden);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
export function SystemBars(props) {
|
|
223
|
+
const {
|
|
224
|
+
statusBarStyle,
|
|
225
|
+
navigationBarStyle,
|
|
226
|
+
statusBarHidden,
|
|
227
|
+
navigationBarHidden
|
|
228
|
+
} = resolveProps(props);
|
|
151
229
|
const stableProps = useMemo(() => ({
|
|
152
230
|
style: statusBarStyle === navigationBarStyle ? statusBarStyle : {
|
|
153
231
|
statusBar: statusBarStyle,
|
|
@@ -184,4 +262,6 @@ export function SystemBars({
|
|
|
184
262
|
SystemBars.pushStackEntry = pushStackEntry;
|
|
185
263
|
SystemBars.popStackEntry = popStackEntry;
|
|
186
264
|
SystemBars.replaceStackEntry = replaceStackEntry;
|
|
265
|
+
SystemBars.setStyle = setStyle;
|
|
266
|
+
SystemBars.setHidden = setHidden;
|
|
187
267
|
//# sourceMappingURL=SystemBars.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useEffect","useMemo","useRef","Appearance","Platform","StatusBar","useColorScheme","NativeModule","getColorScheme","
|
|
1
|
+
{"version":3,"names":["useEffect","useMemo","useRef","Appearance","Platform","StatusBar","useColorScheme","NativeModule","isLightColorScheme","colorScheme","getColorScheme","resolveSystemBarStyle","style","toNativeBarStyle","mergeEntriesStack","entriesStack","reduce","prev","cur","prop","statusBarStyle","undefined","navigationBarStyle","statusBarHidden","navigationBarHidden","resolveProps","hidden","compactStyle","compactHidden","statusBar","navigationBar","createStackEntry","props","updateImmediate","currentValues","setStatusBarStyle","nativeStyle","OS","setBarStyle","setNavigationBarStyle","setStatusBarHidden","setHidden","setNavigationBarHidden","updateEntriesStack","clearImmediate","setImmediate","mergedEntries","pushStackEntry","entry","push","popStackEntry","index","indexOf","splice","replaceStackEntry","newEntry","setStyle","SystemBars","stableProps","stackEntryRef","current"],"sourceRoot":"../../src","sources":["SystemBars.ts"],"mappings":";;AAAA,SAASA,SAAS,EAAEC,OAAO,EAAEC,MAAM,QAAQ,OAAO;AAClD,SAASC,UAAU,EAAEC,QAAQ,EAAEC,SAAS,EAAEC,cAAc,QAAQ,cAAc;AAC9E,OAAOC,YAAY,MAAM,gCAAgC;AAKzD,SAASC,kBAAkBA,CAAA,EAAG;EAC5B,MAAMC,WAAW,GAAGN,UAAU,EAAEO,cAAc,CAAC,CAAC,IAAI,OAAO;EAC3D,OAAOD,WAAW,KAAK,OAAO;AAChC;AAEA,SAASE,qBAAqBA,CAC5BC,KAAiC,EACf;EAClB,QAAQA,KAAK;IACX,KAAK,MAAM;MACT,OAAOJ,kBAAkB,CAAC,CAAC,GAAG,MAAM,GAAG,OAAO;IAChD,KAAK,UAAU;MACb,OAAOA,kBAAkB,CAAC,CAAC,GAAG,OAAO,GAAG,MAAM;IAChD;MACE,OAAOI,KAAK;EAChB;AACF;AAEA,SAASC,gBAAgBA,CACvBD,KAAuB,EACuB;EAC9C,OAAOA,KAAK,KAAK,OAAO,IAAIA,KAAK,KAAK,MAAM,GAAG,GAAGA,KAAK,UAAU,GAAG,SAAS;AAC/E;;AAEA;AACA;AACA;AACA,SAASE,iBAAiBA,CAACC,YAA+B,EAAE;EAC1D,OAAOA,YAAY,CAACC,MAAM,CAMxB,CAACC,IAAI,EAAEC,GAAG,KAAK;IACb,KAAK,MAAMC,IAAI,IAAID,GAAG,EAAE;MACtB,IAAIA,GAAG,CAACC,IAAI,CAA0B,IAAI,IAAI,EAAE;QAC9C;QACAF,IAAI,CAACE,IAAI,CAAC,GAAGD,GAAG,CAACC,IAAI,CAAC;MACxB;IACF;IACA,OAAOF,IAAI;EACb,CAAC,EACD;IACEG,cAAc,EAAEC,SAAS;IACzBC,kBAAkB,EAAED,SAAS;IAC7BE,eAAe,EAA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ACd;MAAES,SAAS,EAAET,cAAc;MAAEU,aAAa,EAAER;IAAmB,CAAC;IACtEI,MAAM,EACJH,eAAe,KAAKC,mBAAmB,GACnCD,eAAe,GACf;MAAEM,SAAS,EAAEN,eAAe;MAAEO,aAAa,EAAEN;IAAoB;EACzE,CAAC,CAAC,EACF,CAACJ,cAAc,EAAEE,kBAAkB,EAAEC,eAAe,EAAEC,mBAAmB,CAC3E,CAAC;EAED,MAAMf,WAAW,GAAGH,cAAc,CAAC,CAAC;EACpC,MAAMqD,aAAa,GAAGzD,MAAM,CAAyB,IAAI,CAAC;EAE1DF,SAAS,CAAC,MAAM;IACd;IACA;IACA;IACA;IACA2D,aAAa,CAACC,OAAO,GAAGb,cAAc,CAACW,WAAW,CAAC;IAEnD,OAAO,MAAM;MACX;MACA;MACA,IAAIC,aAAa,CAACC,OAAO,EAAE;QACzBV,aAAa,CAACS,aAAa,CAACC,OAAO,CAAC;MACtC;IACF,CAAC;EACH,CAAC,EAAE,EAAE,CAAC;EAEN5D,SAAS,CAAC,MAAM;IACd,IAAI2D,aAAa,CAACC,OAAO,EAAE;MACzBD,aAAa,CAACC,OAAO,GAAGN,iBAAiB,CACvCK,aAAa,CAACC,OAAO,EACrBF,WACF,CAAC;IACH;EACF,CAAC,EAAE,CAACjD,WAAW,EAAEiD,WAAW,CAAC,CAAC;EAE9B,OAAO,IAAI;AACb;AAEAD,UAAU,CAACV,cAAc,GAAGA,cAAc;AAC1CU,UAAU,CAACP,aAAa,GAAGA,aAAa;AACxCO,UAAU,CAACH,iBAAiB,GAAGA,iBAAiB;AAChDG,UAAU,CAACD,QAAQ,GAAGA,QAAQ;AAC9BC,UAAU,CAAChB,SAAS,GAAGA,SAAS","ignoreList":[]}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { SystemBarsEntry, SystemBarsProps } from "./types";
|
|
2
|
-
export declare function SystemBars(
|
|
2
|
+
export declare function SystemBars(props: SystemBarsProps): null;
|
|
3
3
|
export declare namespace SystemBars {
|
|
4
4
|
var pushStackEntry: (props: SystemBarsProps) => SystemBarsEntry;
|
|
5
5
|
var popStackEntry: (entry: SystemBarsEntry) => void;
|
|
6
6
|
var replaceStackEntry: (entry: SystemBarsEntry, props: SystemBarsProps) => SystemBarsEntry;
|
|
7
|
+
var setStyle: (style: SystemBarsProps["style"]) => void;
|
|
8
|
+
var setHidden: (hidden: SystemBarsProps["hidden"]) => void;
|
|
7
9
|
}
|
|
8
10
|
//# sourceMappingURL=SystemBars.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SystemBars.d.ts","sourceRoot":"","sources":["../../src/SystemBars.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,eAAe,EAAkB,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"SystemBars.d.ts","sourceRoot":"","sources":["../../src/SystemBars.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,eAAe,EAAkB,MAAM,SAAS,CAAC;AA6P3E,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,QAmDhD;yBAnDe,UAAU;gCA1EK,eAAe,KAAG,eAAe;+BAYlC,eAAe,KAAG,IAAI;mCAe3C,eAAe,SACf,eAAe,KACrB,eAAe;0BAeO,eAAe,CAAC,OAAO,CAAC;4BAmBtB,eAAe,CAAC,QAAQ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-edge-to-edge",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Effortlessly enable edge-to-edge display in React Native",
|
|
6
6
|
"author": "Mathieu Acthernoene <zoontek@gmail.com>",
|
|
@@ -63,9 +63,9 @@
|
|
|
63
63
|
"prettier": "^3.5.3",
|
|
64
64
|
"prettier-plugin-organize-imports": "^4.1.0",
|
|
65
65
|
"react": "19.0.0",
|
|
66
|
-
"react-native": "0.
|
|
67
|
-
"react-native-builder-bob": "^0.
|
|
68
|
-
"typescript": "^5.8.
|
|
66
|
+
"react-native": "0.79.0",
|
|
67
|
+
"react-native-builder-bob": "^0.40.6",
|
|
68
|
+
"typescript": "^5.8.3"
|
|
69
69
|
},
|
|
70
70
|
"codegenConfig": {
|
|
71
71
|
"name": "RNEdgeToEdge",
|
package/src/SystemBars.ts
CHANGED
|
@@ -3,14 +3,28 @@ import { Appearance, Platform, StatusBar, useColorScheme } from "react-native";
|
|
|
3
3
|
import NativeModule from "./specs/NativeEdgeToEdgeModule";
|
|
4
4
|
import { SystemBarsEntry, SystemBarsProps, SystemBarStyle } from "./types";
|
|
5
5
|
|
|
6
|
-
type
|
|
6
|
+
type ResolvedBarStyle = "light" | "dark" | undefined;
|
|
7
7
|
|
|
8
|
-
function
|
|
9
|
-
|
|
8
|
+
function isLightColorScheme() {
|
|
9
|
+
const colorScheme = Appearance?.getColorScheme() ?? "light";
|
|
10
|
+
return colorScheme === "light";
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function resolveSystemBarStyle(
|
|
14
|
+
style: SystemBarStyle | undefined,
|
|
15
|
+
): ResolvedBarStyle {
|
|
16
|
+
switch (style) {
|
|
17
|
+
case "auto":
|
|
18
|
+
return isLightColorScheme() ? "dark" : "light";
|
|
19
|
+
case "inverted":
|
|
20
|
+
return isLightColorScheme() ? "light" : "dark";
|
|
21
|
+
default:
|
|
22
|
+
return style;
|
|
23
|
+
}
|
|
10
24
|
}
|
|
11
25
|
|
|
12
26
|
function toNativeBarStyle(
|
|
13
|
-
style:
|
|
27
|
+
style: ResolvedBarStyle,
|
|
14
28
|
): "default" | "light-content" | "dark-content" {
|
|
15
29
|
return style === "light" || style === "dark" ? `${style}-content` : "default";
|
|
16
30
|
}
|
|
@@ -22,8 +36,8 @@ function mergeEntriesStack(entriesStack: SystemBarsEntry[]) {
|
|
|
22
36
|
return entriesStack.reduce<{
|
|
23
37
|
statusBarStyle: SystemBarStyle | undefined;
|
|
24
38
|
navigationBarStyle: SystemBarStyle | undefined;
|
|
25
|
-
statusBarHidden: boolean;
|
|
26
|
-
navigationBarHidden: boolean;
|
|
39
|
+
statusBarHidden: boolean | undefined;
|
|
40
|
+
navigationBarHidden: boolean | undefined;
|
|
27
41
|
}>(
|
|
28
42
|
(prev, cur) => {
|
|
29
43
|
for (const prop in cur) {
|
|
@@ -37,32 +51,29 @@ function mergeEntriesStack(entriesStack: SystemBarsEntry[]) {
|
|
|
37
51
|
{
|
|
38
52
|
statusBarStyle: undefined,
|
|
39
53
|
navigationBarStyle: undefined,
|
|
40
|
-
statusBarHidden:
|
|
41
|
-
navigationBarHidden:
|
|
54
|
+
statusBarHidden: undefined,
|
|
55
|
+
navigationBarHidden: undefined,
|
|
42
56
|
},
|
|
43
57
|
);
|
|
44
58
|
}
|
|
45
59
|
|
|
60
|
+
function resolveProps({ hidden, style }: SystemBarsProps) {
|
|
61
|
+
const compactStyle = typeof style === "string";
|
|
62
|
+
const compactHidden = typeof hidden === "boolean";
|
|
63
|
+
|
|
64
|
+
return {
|
|
65
|
+
statusBarStyle: compactStyle ? style : style?.statusBar,
|
|
66
|
+
navigationBarStyle: compactStyle ? style : style?.navigationBar,
|
|
67
|
+
statusBarHidden: compactHidden ? hidden : hidden?.statusBar,
|
|
68
|
+
navigationBarHidden: compactHidden ? hidden : hidden?.navigationBar,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
|
|
46
72
|
/**
|
|
47
73
|
* Returns an object to insert in the props stack from the props.
|
|
48
74
|
*/
|
|
49
75
|
function createStackEntry(props: SystemBarsProps): SystemBarsEntry {
|
|
50
|
-
return
|
|
51
|
-
statusBarStyle:
|
|
52
|
-
typeof props.style === "string" ? props.style : props.style?.statusBar,
|
|
53
|
-
navigationBarStyle:
|
|
54
|
-
typeof props.style === "string"
|
|
55
|
-
? props.style
|
|
56
|
-
: props.style?.navigationBar,
|
|
57
|
-
statusBarHidden:
|
|
58
|
-
typeof props.hidden === "boolean"
|
|
59
|
-
? props.hidden
|
|
60
|
-
: props.hidden?.statusBar,
|
|
61
|
-
navigationBarHidden:
|
|
62
|
-
typeof props.hidden === "boolean"
|
|
63
|
-
? props.hidden
|
|
64
|
-
: props.hidden?.navigationBar,
|
|
65
|
-
};
|
|
76
|
+
return resolveProps(props);
|
|
66
77
|
}
|
|
67
78
|
|
|
68
79
|
const entriesStack: SystemBarsEntry[] = [];
|
|
@@ -71,18 +82,65 @@ const entriesStack: SystemBarsEntry[] = [];
|
|
|
71
82
|
let updateImmediate: NodeJS.Immediate | null = null;
|
|
72
83
|
|
|
73
84
|
// The current merged values from the entries stack.
|
|
74
|
-
|
|
75
|
-
statusBarStyle:
|
|
76
|
-
navigationBarStyle:
|
|
77
|
-
statusBarHidden: boolean;
|
|
78
|
-
navigationBarHidden: boolean;
|
|
85
|
+
const currentValues: {
|
|
86
|
+
statusBarStyle: ResolvedBarStyle;
|
|
87
|
+
navigationBarStyle: ResolvedBarStyle;
|
|
88
|
+
statusBarHidden: boolean | undefined;
|
|
89
|
+
navigationBarHidden: boolean | undefined;
|
|
79
90
|
} = {
|
|
80
91
|
statusBarStyle: undefined,
|
|
81
92
|
navigationBarStyle: undefined,
|
|
82
|
-
statusBarHidden:
|
|
83
|
-
navigationBarHidden:
|
|
93
|
+
statusBarHidden: undefined,
|
|
94
|
+
navigationBarHidden: undefined,
|
|
84
95
|
};
|
|
85
96
|
|
|
97
|
+
function setStatusBarStyle(style: ResolvedBarStyle) {
|
|
98
|
+
if (style !== currentValues.statusBarStyle) {
|
|
99
|
+
currentValues.statusBarStyle = style;
|
|
100
|
+
|
|
101
|
+
const nativeStyle = toNativeBarStyle(style);
|
|
102
|
+
|
|
103
|
+
if (Platform.OS === "android") {
|
|
104
|
+
NativeModule?.setStatusBarStyle(nativeStyle);
|
|
105
|
+
} else if (Platform.OS === "ios") {
|
|
106
|
+
StatusBar.setBarStyle(nativeStyle, true);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function setNavigationBarStyle(style: ResolvedBarStyle) {
|
|
112
|
+
if (style !== currentValues.navigationBarStyle) {
|
|
113
|
+
currentValues.navigationBarStyle = style;
|
|
114
|
+
|
|
115
|
+
if (Platform.OS === "android") {
|
|
116
|
+
const nativeStyle = toNativeBarStyle(style);
|
|
117
|
+
NativeModule?.setNavigationBarStyle(nativeStyle);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function setStatusBarHidden(hidden: boolean) {
|
|
123
|
+
if (hidden !== currentValues.statusBarHidden) {
|
|
124
|
+
currentValues.statusBarHidden = hidden;
|
|
125
|
+
|
|
126
|
+
if (Platform.OS === "android") {
|
|
127
|
+
NativeModule?.setStatusBarHidden(hidden);
|
|
128
|
+
} else if (Platform.OS === "ios") {
|
|
129
|
+
StatusBar.setHidden(hidden, "fade"); // 'slide' doesn't work in this context
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function setNavigationBarHidden(hidden: boolean) {
|
|
135
|
+
if (hidden !== currentValues.navigationBarHidden) {
|
|
136
|
+
currentValues.navigationBarHidden = hidden;
|
|
137
|
+
|
|
138
|
+
if (Platform.OS === "android") {
|
|
139
|
+
NativeModule?.setNavigationBarHidden(hidden);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
86
144
|
/**
|
|
87
145
|
* Updates the native system bars with the entries from the stack.
|
|
88
146
|
*/
|
|
@@ -93,68 +151,34 @@ function updateEntriesStack() {
|
|
|
93
151
|
}
|
|
94
152
|
|
|
95
153
|
updateImmediate = setImmediate(() => {
|
|
96
|
-
const isLightColorScheme = getColorScheme() === "light";
|
|
97
|
-
const autoBarStyle = isLightColorScheme ? "dark" : "light";
|
|
98
|
-
const invertedBarStyle = isLightColorScheme ? "light" : "dark";
|
|
99
|
-
|
|
100
154
|
const mergedEntries = mergeEntriesStack(entriesStack);
|
|
101
|
-
|
|
102
|
-
const statusBarStyle: MergeableBarStyle =
|
|
103
|
-
mergedEntries.statusBarStyle === "auto"
|
|
104
|
-
? autoBarStyle
|
|
105
|
-
: mergedEntries.statusBarStyle === "inverted"
|
|
106
|
-
? invertedBarStyle
|
|
107
|
-
: mergedEntries.statusBarStyle;
|
|
108
|
-
|
|
109
|
-
const navigationBarStyle: MergeableBarStyle =
|
|
110
|
-
mergedEntries.navigationBarStyle === "auto"
|
|
111
|
-
? autoBarStyle
|
|
112
|
-
: mergedEntries.navigationBarStyle === "inverted"
|
|
113
|
-
? invertedBarStyle
|
|
114
|
-
: mergedEntries.navigationBarStyle;
|
|
115
|
-
|
|
116
155
|
const { statusBarHidden, navigationBarHidden } = mergedEntries;
|
|
117
156
|
|
|
118
|
-
|
|
119
|
-
|
|
157
|
+
const statusBarStyle = resolveSystemBarStyle(
|
|
158
|
+
mergedEntries.statusBarStyle,
|
|
159
|
+
);
|
|
160
|
+
const navigationBarStyle = resolveSystemBarStyle(
|
|
161
|
+
mergedEntries.navigationBarStyle,
|
|
162
|
+
);
|
|
120
163
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
: StatusBar.setBarStyle(style, true);
|
|
124
|
-
}
|
|
164
|
+
setStatusBarStyle(statusBarStyle);
|
|
165
|
+
setNavigationBarStyle(navigationBarStyle);
|
|
125
166
|
|
|
126
|
-
if (statusBarHidden
|
|
127
|
-
|
|
128
|
-
? NativeModule?.setStatusBarHidden(statusBarHidden)
|
|
129
|
-
: StatusBar.setHidden(statusBarHidden, "fade"); // 'slide' doesn't work in this context
|
|
167
|
+
if (statusBarHidden != null) {
|
|
168
|
+
setStatusBarHidden(statusBarHidden);
|
|
130
169
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
if (navigationBarStyle !== currentMergedEntries.navigationBarStyle) {
|
|
134
|
-
const style = toNativeBarStyle(navigationBarStyle);
|
|
135
|
-
NativeModule?.setNavigationBarStyle(style);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
if (navigationBarHidden !== currentMergedEntries.navigationBarHidden) {
|
|
139
|
-
NativeModule?.setNavigationBarHidden(navigationBarHidden);
|
|
140
|
-
}
|
|
170
|
+
if (navigationBarHidden != null) {
|
|
171
|
+
setNavigationBarHidden(navigationBarHidden);
|
|
141
172
|
}
|
|
142
|
-
|
|
143
|
-
currentMergedEntries = {
|
|
144
|
-
statusBarStyle,
|
|
145
|
-
navigationBarStyle,
|
|
146
|
-
statusBarHidden,
|
|
147
|
-
navigationBarHidden,
|
|
148
|
-
};
|
|
149
173
|
});
|
|
150
174
|
}
|
|
151
175
|
}
|
|
152
176
|
|
|
153
177
|
/**
|
|
154
|
-
* Push a SystemBars entry onto the stack.
|
|
178
|
+
* Push a `SystemBars` entry onto the stack.
|
|
155
179
|
* The return value should be passed to `popStackEntry` when complete.
|
|
156
180
|
*
|
|
157
|
-
* @param props Object containing the SystemBars props to use in the stack entry.
|
|
181
|
+
* @param props Object containing the `SystemBars` props to use in the stack entry.
|
|
158
182
|
*/
|
|
159
183
|
function pushStackEntry(props: SystemBarsProps): SystemBarsEntry {
|
|
160
184
|
const entry = createStackEntry(props);
|
|
@@ -164,7 +188,7 @@ function pushStackEntry(props: SystemBarsProps): SystemBarsEntry {
|
|
|
164
188
|
}
|
|
165
189
|
|
|
166
190
|
/**
|
|
167
|
-
*
|
|
191
|
+
* Remove an existing `SystemBars` stack entry from the stack.
|
|
168
192
|
*
|
|
169
193
|
* @param entry Entry returned from `pushStackEntry`.
|
|
170
194
|
*/
|
|
@@ -177,10 +201,10 @@ function popStackEntry(entry: SystemBarsEntry): void {
|
|
|
177
201
|
}
|
|
178
202
|
|
|
179
203
|
/**
|
|
180
|
-
* Replace an existing SystemBars stack entry with new props.
|
|
204
|
+
* Replace an existing `SystemBars` stack entry with new props.
|
|
181
205
|
*
|
|
182
206
|
* @param entry Entry returned from `pushStackEntry` to replace.
|
|
183
|
-
* @param props Object containing the SystemBars props to use in the replacement stack entry.
|
|
207
|
+
* @param props Object containing the `SystemBars` props to use in the replacement stack entry.
|
|
184
208
|
*/
|
|
185
209
|
function replaceStackEntry(
|
|
186
210
|
entry: SystemBarsEntry,
|
|
@@ -195,14 +219,48 @@ function replaceStackEntry(
|
|
|
195
219
|
return newEntry;
|
|
196
220
|
}
|
|
197
221
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
const
|
|
205
|
-
|
|
222
|
+
/**
|
|
223
|
+
* Set the system bars style.
|
|
224
|
+
*
|
|
225
|
+
* @param style System bars style to set.
|
|
226
|
+
*/
|
|
227
|
+
function setStyle(style: SystemBarsProps["style"]) {
|
|
228
|
+
const props = resolveProps({ style });
|
|
229
|
+
|
|
230
|
+
const statusBarStyle = resolveSystemBarStyle(props.statusBarStyle);
|
|
231
|
+
const navigationBarStyle = resolveSystemBarStyle(props.navigationBarStyle);
|
|
232
|
+
|
|
233
|
+
if (typeof statusBarStyle === "string") {
|
|
234
|
+
setStatusBarStyle(statusBarStyle);
|
|
235
|
+
}
|
|
236
|
+
if (typeof navigationBarStyle === "string") {
|
|
237
|
+
setNavigationBarStyle(navigationBarStyle);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Show or hide the system bars.
|
|
243
|
+
*
|
|
244
|
+
* @param hidden Hide the system bars.
|
|
245
|
+
*/
|
|
246
|
+
function setHidden(hidden: SystemBarsProps["hidden"]) {
|
|
247
|
+
const { statusBarHidden, navigationBarHidden } = resolveProps({ hidden });
|
|
248
|
+
|
|
249
|
+
if (typeof statusBarHidden === "boolean") {
|
|
250
|
+
setStatusBarHidden(statusBarHidden);
|
|
251
|
+
}
|
|
252
|
+
if (typeof navigationBarHidden === "boolean") {
|
|
253
|
+
setNavigationBarHidden(navigationBarHidden);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
export function SystemBars(props: SystemBarsProps) {
|
|
258
|
+
const {
|
|
259
|
+
statusBarStyle,
|
|
260
|
+
navigationBarStyle,
|
|
261
|
+
statusBarHidden,
|
|
262
|
+
navigationBarHidden,
|
|
263
|
+
} = resolveProps(props);
|
|
206
264
|
|
|
207
265
|
const stableProps = useMemo<SystemBarsProps>(
|
|
208
266
|
() => ({
|
|
@@ -252,3 +310,5 @@ export function SystemBars({ hidden, style }: SystemBarsProps) {
|
|
|
252
310
|
SystemBars.pushStackEntry = pushStackEntry;
|
|
253
311
|
SystemBars.popStackEntry = popStackEntry;
|
|
254
312
|
SystemBars.replaceStackEntry = replaceStackEntry;
|
|
313
|
+
SystemBars.setStyle = setStyle;
|
|
314
|
+
SystemBars.setHidden = setHidden;
|