@react-native-oh/react-native-harmony 0.72.86 → 0.77.18
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/LICENSE +21 -0
- package/LICENSE-Meta +21 -0
- package/Libraries/Alert/delegates/AlertDelegate.harmony.ts +84 -0
- package/Libraries/Alert/{AlertManager.ts → delegates/AlertManager.harmony.ts} +10 -4
- package/Libraries/Animated/shouldUseTurboAnimatedModule.harmony.ts +10 -0
- package/Libraries/Components/AccessibilityInfo/delegates/AccessibilityInfoDelegate.harmony.ts +44 -0
- package/Libraries/Components/AccessibilityInfo/{NativeAccessibilityInfoHarmony.ts → delegates/NativeAccessibilityInfoHarmony.harmony.ts} +9 -2
- package/Libraries/Components/Keyboard/delegates/KeyboardAvoidingViewDelegate.harmony.ts +42 -0
- package/Libraries/Components/RefreshControl/delegates/RefreshControlDelegate.harmony.tsx +29 -0
- package/Libraries/Components/SafeAreaView/SafeAreaView.harmony.tsx +93 -31
- package/Libraries/Components/ScrollView/delegates/ScrollViewDelegate.harmony.tsx +41 -0
- package/Libraries/Components/ScrollView/delegates/ScrollViewNativeComponentDelegate.harmony.ts +89 -0
- package/Libraries/Components/ScrollView/processDecelerationRate.harmony.ts +19 -0
- package/Libraries/Components/StatusBar/delegates/NativeStatusBarManagerHarmony.harmony.ts +53 -0
- package/Libraries/Components/StatusBar/delegates/StatusBarDelegate.harmony.ts +83 -0
- package/Libraries/Components/TextInput/delegates/TextInputDelegate.harmony.tsx +98 -0
- package/Libraries/Components/TextInput/delegates/TextInputStateDelegate.harmony.tsx +20 -0
- package/Libraries/Components/Touchable/delegates/TouchableHighlightDelegate.harmony.ts +14 -0
- package/Libraries/Components/Touchable/delegates/TouchableNativeFeedbackDelegate.harmony.ts +14 -0
- package/Libraries/Components/Touchable/delegates/TouchableWithoutFeedbackDelegate.harmony.ts +14 -0
- package/Libraries/Components/delegates/ButtonDelegate.harmony.ts +41 -0
- package/Libraries/Core/setUpPlatform.harmony.js +30 -0
- package/Libraries/Image/AssetSourceResolver.harmony.ts +1 -5
- package/Libraries/Image/Image.harmony.ts +17 -0
- package/Libraries/NativeComponent/BaseViewConfig.harmony.js +12 -326
- package/Libraries/NativeComponent/delegates/ViewConfigIgnoreDelegate.harmony.ts +13 -0
- package/Libraries/ReactNative/delegates/BridgelessUIManagerDelegate.harmony.ts +14 -0
- package/Libraries/ReactNative/delegates/I18nManagerDelegate.harmony.ts +22 -0
- package/Libraries/Settings/Settings.harmony.ts +20 -0
- package/Libraries/Share/delegates/ShareDelegate.harmony.ts +42 -0
- package/Libraries/StyleSheet/NativePlatformColor.harmony.ts +15 -0
- package/Libraries/StyleSheet/PlatformColorValueTypes.harmony.ts +8 -1
- package/Libraries/Utilities/BackHandler.harmony.ts +10 -0
- package/Libraries/Utilities/NativePlatformConstantsHarmony.harmony.ts +17 -0
- package/Libraries/Utilities/Platform.harmony.ts +38 -13
- package/Libraries/Vibration/delegates/VibrationDelegate.harmony.ts +14 -0
- package/NOTICE.md +846 -0
- package/README.md +2 -2
- package/index.js +53 -63
- package/jest.config.js +0 -7
- package/metro.config.d.ts +17 -0
- package/metro.config.js +398 -115
- package/package.json +58 -37
- package/react-native.config.js +57 -9
- package/react_native_openharmony.har +0 -0
- package/tsconfig.json +10 -4
- package/types/index.harmony.d.ts +99 -0
- package/Libraries/Alert/Alert.harmony.js +0 -77
- package/Libraries/Animated/NativeAnimatedHelper.harmony.js +0 -601
- package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.harmony.js +0 -441
- package/Libraries/Components/Button/Button.harmony.js +0 -451
- package/Libraries/Components/Image/Image.flow.harmony.js +0 -53
- package/Libraries/Components/Image/Image.harmony.js +0 -317
- package/Libraries/Components/Image/NativeImageLoaderHarmony.js +0 -38
- package/Libraries/Components/Keyboard/KeyboardAvoidingView.harmony.js +0 -256
- package/Libraries/Components/RefreshControl/RefreshControl.harmony.js +0 -210
- package/Libraries/Components/ScrollView/ScrollView.harmony.js +0 -1951
- package/Libraries/Components/ScrollView/processDecelerationRate.harmony.js +0 -24
- package/Libraries/Components/StatusBar/NativeStatusBarManagerHarmony.js +0 -71
- package/Libraries/Components/StatusBar/StatusBar.harmony.js +0 -447
- package/Libraries/Components/TextInput/TextInput.harmony.js +0 -1716
- package/Libraries/Components/TextInput/TextInputState.harmony.js +0 -220
- package/Libraries/Components/Touchable/TouchableHighlight.harmony.js +0 -396
- package/Libraries/Components/Touchable/TouchableNativeFeedback.harmony.js +0 -364
- package/Libraries/Components/Touchable/TouchableWithoutFeedback.harmony.js +0 -227
- package/Libraries/Components/View/View.harmony.js +0 -149
- package/Libraries/Core/setUpReactDevTools.harmony.js +0 -93
- package/Libraries/ReactNative/I18nManager.harmony.js +0 -78
- package/Libraries/ReactNative/UIManager.harmony.js +0 -210
- package/Libraries/Settings/Settings.harmony.js +0 -15
- package/Libraries/Share/Share.harmony.js +0 -174
- package/Libraries/StyleSheet/NativePlatformColor.ts +0 -8
- package/Libraries/Utilities/BackHandler.harmony.js +0 -109
- package/Libraries/Utilities/NativePlatformConstants.harmony.ts +0 -8
- package/Libraries/Utilities/Platform.d.ts +0 -117
- package/Libraries/Utilities/createPerformanceLogger.harmony.js +0 -328
- package/Libraries/Vibration/Vibration.harmony.js +0 -88
- package/harmony/.keep +0 -0
- package/harmony/rnoh-hvigor-plugin-0.2.0.tgz +0 -0
- package/react_native_openharmony_release.har +0 -0
- package/types/index.d.ts +0 -108
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
* @format
|
|
8
|
-
* @flow strict-local
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
//RNOH patch - fix return values for Platform.OS = ios
|
|
12
|
-
|
|
13
|
-
function processDecelerationRate(
|
|
14
|
-
decelerationRate: number | "normal" | "fast"
|
|
15
|
-
): number {
|
|
16
|
-
if (decelerationRate === "normal") {
|
|
17
|
-
return 0.998;
|
|
18
|
-
} else if (decelerationRate === "fast") {
|
|
19
|
-
return 0.99;
|
|
20
|
-
}
|
|
21
|
-
return decelerationRate;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
module.exports = processDecelerationRate;
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
* @flow strict
|
|
8
|
-
* @format
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import type { TurboModule } from "react-native/Libraries/TurboModule/RCTExport";
|
|
12
|
-
|
|
13
|
-
import * as TurboModuleRegistry from "react-native/Libraries/TurboModule/TurboModuleRegistry";
|
|
14
|
-
|
|
15
|
-
export interface Spec extends TurboModule {
|
|
16
|
-
+getConstants: () => {|
|
|
17
|
-
+HEIGHT: number,
|
|
18
|
-
+DEFAULT_BACKGROUND_COLOR: number,
|
|
19
|
-
|};
|
|
20
|
-
+setColor: (color: string, animated: boolean) => void;
|
|
21
|
-
+setTranslucent: (translucent: boolean) => void;
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* - statusBarStyles can be:
|
|
25
|
-
* - 'default'
|
|
26
|
-
* - 'dark-content'
|
|
27
|
-
*/
|
|
28
|
-
+setStyle: (statusBarStyle?: ?string, animated: boolean) => void;
|
|
29
|
-
/**
|
|
30
|
-
* - withAnimation can be: 'none' | 'slide'
|
|
31
|
-
*/
|
|
32
|
-
+setHidden: (hidden: boolean, withAnimation: string) => void;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const NativeModule = TurboModuleRegistry.getEnforcing<Spec>("StatusBarManager");
|
|
36
|
-
let constants = null;
|
|
37
|
-
|
|
38
|
-
const NativeStatusBarManager = {
|
|
39
|
-
getConstants(): {|
|
|
40
|
-
+HEIGHT: number,
|
|
41
|
-
+DEFAULT_BACKGROUND_COLOR?: number,
|
|
42
|
-
|} {
|
|
43
|
-
if (constants == null) {
|
|
44
|
-
constants = NativeModule.getConstants();
|
|
45
|
-
}
|
|
46
|
-
return constants;
|
|
47
|
-
},
|
|
48
|
-
|
|
49
|
-
setColor(color: number, animated: boolean): void {
|
|
50
|
-
NativeModule.setColor(color, animated);
|
|
51
|
-
},
|
|
52
|
-
|
|
53
|
-
setTranslucent(translucent: boolean): void {
|
|
54
|
-
NativeModule.setTranslucent(translucent);
|
|
55
|
-
},
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* - statusBarStyles can be:
|
|
59
|
-
* - 'default'
|
|
60
|
-
* - 'dark-content'
|
|
61
|
-
*/
|
|
62
|
-
setStyle(statusBarStyle?: ?string, animated: boolean): void {
|
|
63
|
-
NativeModule.setStyle(statusBarStyle, animated);
|
|
64
|
-
},
|
|
65
|
-
|
|
66
|
-
setHidden(hidden: boolean, withAnimation: string): void {
|
|
67
|
-
NativeModule.setHidden(hidden, withAnimation);
|
|
68
|
-
},
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
export default NativeStatusBarManager;
|
|
@@ -1,447 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
* @format
|
|
8
|
-
* @flow
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import type { ColorValue } from "react-native/Libraries/StyleSheet/StyleSheet";
|
|
12
|
-
|
|
13
|
-
import processColor from "react-native/Libraries/StyleSheet/processColor";
|
|
14
|
-
import Platform from "react-native/Libraries/Utilities/Platform";
|
|
15
|
-
//RNOH: patch - fix imports
|
|
16
|
-
import NativeStatusBarManagerHarmony from "./NativeStatusBarManagerHarmony";
|
|
17
|
-
import invariant from "invariant";
|
|
18
|
-
import * as React from "react";
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Status bar style
|
|
22
|
-
*/
|
|
23
|
-
export type StatusBarStyle = $Keys<{
|
|
24
|
-
/**
|
|
25
|
-
* Default status bar style (dark for iOS, light for Android)
|
|
26
|
-
*/
|
|
27
|
-
default: string,
|
|
28
|
-
/**
|
|
29
|
-
* Dark background, white texts and icons
|
|
30
|
-
*/
|
|
31
|
-
"light-content": string,
|
|
32
|
-
/**
|
|
33
|
-
* Light background, dark texts and icons
|
|
34
|
-
*/
|
|
35
|
-
"dark-content": string,
|
|
36
|
-
...
|
|
37
|
-
}>;
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Status bar animation
|
|
41
|
-
*/
|
|
42
|
-
export type StatusBarAnimation = $Keys<{
|
|
43
|
-
/**
|
|
44
|
-
* No animation
|
|
45
|
-
*/
|
|
46
|
-
none: string,
|
|
47
|
-
/**
|
|
48
|
-
* Fade animation
|
|
49
|
-
*/
|
|
50
|
-
fade: string,
|
|
51
|
-
/**
|
|
52
|
-
* Slide animation
|
|
53
|
-
*/
|
|
54
|
-
slide: string,
|
|
55
|
-
...
|
|
56
|
-
}>;
|
|
57
|
-
|
|
58
|
-
type AndroidProps = $ReadOnly<{|
|
|
59
|
-
/**
|
|
60
|
-
* The background color of the status bar.
|
|
61
|
-
* @platform android
|
|
62
|
-
*/
|
|
63
|
-
backgroundColor?: ?ColorValue,
|
|
64
|
-
/**
|
|
65
|
-
* If the status bar is translucent.
|
|
66
|
-
* When translucent is set to true, the app will draw under the status bar.
|
|
67
|
-
* This is useful when using a semi transparent status bar color.
|
|
68
|
-
*
|
|
69
|
-
* @platform android
|
|
70
|
-
*/
|
|
71
|
-
translucent?: ?boolean,
|
|
72
|
-
|}>;
|
|
73
|
-
|
|
74
|
-
type IOSProps = $ReadOnly<{|
|
|
75
|
-
/**
|
|
76
|
-
* If the network activity indicator should be visible.
|
|
77
|
-
*
|
|
78
|
-
* @platform ios
|
|
79
|
-
*/
|
|
80
|
-
networkActivityIndicatorVisible?: ?boolean,
|
|
81
|
-
/**
|
|
82
|
-
* The transition effect when showing and hiding the status bar using the `hidden`
|
|
83
|
-
* prop. Defaults to 'fade'.
|
|
84
|
-
*
|
|
85
|
-
* @platform ios
|
|
86
|
-
*/
|
|
87
|
-
showHideTransition?: ?("fade" | "slide" | "none"),
|
|
88
|
-
|}>;
|
|
89
|
-
|
|
90
|
-
type Props = $ReadOnly<{|
|
|
91
|
-
...AndroidProps,
|
|
92
|
-
...IOSProps,
|
|
93
|
-
/**
|
|
94
|
-
* If the status bar is hidden.
|
|
95
|
-
*/
|
|
96
|
-
hidden?: ?boolean,
|
|
97
|
-
/**
|
|
98
|
-
* If the transition between status bar property changes should be animated.
|
|
99
|
-
* Supported for backgroundColor, barStyle and hidden.
|
|
100
|
-
*/
|
|
101
|
-
animated?: ?boolean,
|
|
102
|
-
/**
|
|
103
|
-
* Sets the color of the status bar text.
|
|
104
|
-
*/
|
|
105
|
-
barStyle?: ?("default" | "light-content" | "dark-content"),
|
|
106
|
-
|}>;
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Merges the prop stack with the default values.
|
|
110
|
-
*/
|
|
111
|
-
function mergePropsStack(
|
|
112
|
-
propsStack: Array<Object>,
|
|
113
|
-
defaultValues: Object
|
|
114
|
-
): Object {
|
|
115
|
-
return propsStack.reduce(
|
|
116
|
-
(prev, cur) => {
|
|
117
|
-
for (const prop in cur) {
|
|
118
|
-
if (cur[prop] != null) {
|
|
119
|
-
prev[prop] = cur[prop];
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
return prev;
|
|
123
|
-
},
|
|
124
|
-
{ ...defaultValues }
|
|
125
|
-
);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* Returns an object to insert in the props stack from the props
|
|
130
|
-
* and the transition/animation info.
|
|
131
|
-
*/
|
|
132
|
-
function createStackEntry(props: any): any {
|
|
133
|
-
const animated = props.animated ?? false;
|
|
134
|
-
const showHideTransition = props.showHideTransition ?? "fade";
|
|
135
|
-
return {
|
|
136
|
-
backgroundColor:
|
|
137
|
-
props.backgroundColor != null
|
|
138
|
-
? {
|
|
139
|
-
value: props.backgroundColor,
|
|
140
|
-
animated,
|
|
141
|
-
}
|
|
142
|
-
: null,
|
|
143
|
-
barStyle:
|
|
144
|
-
props.barStyle != null
|
|
145
|
-
? {
|
|
146
|
-
value: props.barStyle,
|
|
147
|
-
animated,
|
|
148
|
-
}
|
|
149
|
-
: null,
|
|
150
|
-
translucent: props.translucent,
|
|
151
|
-
hidden:
|
|
152
|
-
props.hidden != null
|
|
153
|
-
? {
|
|
154
|
-
value: props.hidden,
|
|
155
|
-
animated,
|
|
156
|
-
transition: showHideTransition,
|
|
157
|
-
}
|
|
158
|
-
: null,
|
|
159
|
-
networkActivityIndicatorVisible: props.networkActivityIndicatorVisible,
|
|
160
|
-
};
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
/**
|
|
164
|
-
* Component to control the app status bar.
|
|
165
|
-
*
|
|
166
|
-
* ### Usage with Navigator
|
|
167
|
-
*
|
|
168
|
-
* It is possible to have multiple `StatusBar` components mounted at the same
|
|
169
|
-
* time. The props will be merged in the order the `StatusBar` components were
|
|
170
|
-
* mounted. One use case is to specify status bar styles per route using `Navigator`.
|
|
171
|
-
*
|
|
172
|
-
* ```
|
|
173
|
-
* <View>
|
|
174
|
-
* <StatusBar
|
|
175
|
-
* backgroundColor="blue"
|
|
176
|
-
* barStyle="light-content"
|
|
177
|
-
* />
|
|
178
|
-
* <Navigator
|
|
179
|
-
* initialRoute={{statusBarHidden: true}}
|
|
180
|
-
* renderScene={(route, navigator) =>
|
|
181
|
-
* <View>
|
|
182
|
-
* <StatusBar hidden={route.statusBarHidden} />
|
|
183
|
-
* ...
|
|
184
|
-
* </View>
|
|
185
|
-
* }
|
|
186
|
-
* />
|
|
187
|
-
* </View>
|
|
188
|
-
* ```
|
|
189
|
-
*
|
|
190
|
-
* ### Imperative API
|
|
191
|
-
*
|
|
192
|
-
* For cases where using a component is not ideal, there are static methods
|
|
193
|
-
* to manipulate the `StatusBar` display stack. These methods have the same
|
|
194
|
-
* behavior as mounting and unmounting a `StatusBar` component.
|
|
195
|
-
*
|
|
196
|
-
* For example, you can call `StatusBar.pushStackEntry` to update the status bar
|
|
197
|
-
* before launching a third-party native UI component, and then call
|
|
198
|
-
* `StatusBar.popStackEntry` when completed.
|
|
199
|
-
*
|
|
200
|
-
* ```
|
|
201
|
-
* const openThirdPartyBugReporter = async () => {
|
|
202
|
-
* // The bug reporter has a dark background, so we push a new status bar style.
|
|
203
|
-
* const stackEntry = StatusBar.pushStackEntry({barStyle: 'light-content'});
|
|
204
|
-
*
|
|
205
|
-
* // `open` returns a promise that resolves when the UI is dismissed.
|
|
206
|
-
* await BugReporter.open();
|
|
207
|
-
*
|
|
208
|
-
* // Don't forget to call `popStackEntry` when you're done.
|
|
209
|
-
* StatusBar.popStackEntry(stackEntry);
|
|
210
|
-
* };
|
|
211
|
-
* ```
|
|
212
|
-
*
|
|
213
|
-
* There is a legacy imperative API that enables you to manually update the
|
|
214
|
-
* status bar styles. However, the legacy API does not update the internal
|
|
215
|
-
* `StatusBar` display stack, which means that any changes will be overridden
|
|
216
|
-
* whenever a `StatusBar` component is mounted or unmounted.
|
|
217
|
-
*
|
|
218
|
-
* It is strongly advised that you use `pushStackEntry`, `popStackEntry`, or
|
|
219
|
-
* `replaceStackEntry` instead of the static methods beginning with `set`.
|
|
220
|
-
*
|
|
221
|
-
* ### Constants
|
|
222
|
-
*
|
|
223
|
-
* `currentHeight` (Android only) The height of the status bar.
|
|
224
|
-
*/
|
|
225
|
-
class StatusBar extends React.Component<Props> {
|
|
226
|
-
static _propsStack: Array<any> = [];
|
|
227
|
-
|
|
228
|
-
static _defaultProps: any = createStackEntry({
|
|
229
|
-
// RNOH: patch - use NativeStatusBarManager harmony
|
|
230
|
-
backgroundColor:
|
|
231
|
-
NativeStatusBarManagerHarmony.getConstants().DEFAULT_BACKGROUND_COLOR ??
|
|
232
|
-
"#00000000",
|
|
233
|
-
barStyle: "default",
|
|
234
|
-
translucent: false,
|
|
235
|
-
hidden: false,
|
|
236
|
-
networkActivityIndicatorVisible: false,
|
|
237
|
-
});
|
|
238
|
-
|
|
239
|
-
// Timer for updating the native module values at the end of the frame.
|
|
240
|
-
static _updateImmediate = null;
|
|
241
|
-
|
|
242
|
-
// The current merged values from the props stack.
|
|
243
|
-
static _currentValues = null;
|
|
244
|
-
|
|
245
|
-
// TODO(janic): Provide a real API to deal with status bar height. See the
|
|
246
|
-
// discussion in #6195.
|
|
247
|
-
/**
|
|
248
|
-
* The current height of the status bar on the device.
|
|
249
|
-
*
|
|
250
|
-
* @platform android
|
|
251
|
-
*/
|
|
252
|
-
// RNOH: patch - use NativeStatusBarManagerHarmony
|
|
253
|
-
static currentHeight: ?number =
|
|
254
|
-
NativeStatusBarManagerHarmony.getConstants().HEIGHT;
|
|
255
|
-
|
|
256
|
-
// Provide an imperative API as static functions of the component.
|
|
257
|
-
// See the corresponding prop for more detail.
|
|
258
|
-
|
|
259
|
-
/**
|
|
260
|
-
* Show or hide the status bar
|
|
261
|
-
* @param hidden Hide the status bar.
|
|
262
|
-
* @param animation Optional animation when
|
|
263
|
-
* changing the status bar hidden property.
|
|
264
|
-
*/
|
|
265
|
-
static setHidden(hidden: boolean, animation?: StatusBarAnimation) {
|
|
266
|
-
animation = animation || "none";
|
|
267
|
-
//RNOH: patch - delete code specific to other platforms
|
|
268
|
-
StatusBar._defaultProps.hidden.value = hidden;
|
|
269
|
-
NativeStatusBarManagerHarmony.setHidden(hidden, animation);
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
/**
|
|
273
|
-
* Set the status bar style
|
|
274
|
-
* @param style Status bar style to set
|
|
275
|
-
* @param animated Animate the style change.
|
|
276
|
-
*/
|
|
277
|
-
static setBarStyle(style: StatusBarStyle, animated?: boolean) {
|
|
278
|
-
//RNOH: patch - delete code specific to other platforms
|
|
279
|
-
StatusBar._defaultProps.barStyle.value = style;
|
|
280
|
-
NativeStatusBarManagerHarmony.setStyle(style, animated);
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
/**
|
|
284
|
-
* Control the visibility of the network activity indicator
|
|
285
|
-
* @param visible Show the indicator.
|
|
286
|
-
*/
|
|
287
|
-
static setNetworkActivityIndicatorVisible(visible: boolean) {
|
|
288
|
-
//RNOH: patch - delete code specific to other platforms
|
|
289
|
-
if (Platform.OS !== "ios") {
|
|
290
|
-
console.warn(
|
|
291
|
-
"`setNetworkActivityIndicatorVisible` is only available on iOS"
|
|
292
|
-
);
|
|
293
|
-
return;
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
/**
|
|
298
|
-
* Set the background color for the status bar
|
|
299
|
-
* @param color Background color.
|
|
300
|
-
* @param animated Animate the style change.
|
|
301
|
-
*/
|
|
302
|
-
static setBackgroundColor(color: string, animated?: boolean): void {
|
|
303
|
-
animated = animated || false;
|
|
304
|
-
StatusBar._defaultProps.backgroundColor.value = color;
|
|
305
|
-
//RNOH: patch - delete platform check
|
|
306
|
-
const processedColor = processColor(color);
|
|
307
|
-
if (processedColor == null) {
|
|
308
|
-
console.warn(
|
|
309
|
-
`\`StatusBar.setBackgroundColor\`: Color ${color} parsed to null or undefined`
|
|
310
|
-
);
|
|
311
|
-
return;
|
|
312
|
-
}
|
|
313
|
-
invariant(
|
|
314
|
-
typeof processedColor === "number",
|
|
315
|
-
"Unexpected color given for StatusBar.setBackgroundColor"
|
|
316
|
-
);
|
|
317
|
-
//RNOH: patch - use harmony NativeStatusBarManager
|
|
318
|
-
NativeStatusBarManagerHarmony.setColor(processedColor, animated);
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
/**
|
|
322
|
-
* Control the translucency of the status bar
|
|
323
|
-
* @param translucent Set as translucent.
|
|
324
|
-
*/
|
|
325
|
-
static setTranslucent(translucent: boolean) {
|
|
326
|
-
//RNOH: patch - delete platform check and use NativeStatusBarManagerHarmony
|
|
327
|
-
StatusBar._defaultProps.translucent = translucent;
|
|
328
|
-
NativeStatusBarManagerHarmony.setTranslucent(translucent);
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
/**
|
|
332
|
-
* Push a StatusBar entry onto the stack.
|
|
333
|
-
* The return value should be passed to `popStackEntry` when complete.
|
|
334
|
-
*
|
|
335
|
-
* @param props Object containing the StatusBar props to use in the stack entry.
|
|
336
|
-
*/
|
|
337
|
-
static pushStackEntry(props: any): any {
|
|
338
|
-
const entry = createStackEntry(props);
|
|
339
|
-
StatusBar._propsStack.push(entry);
|
|
340
|
-
StatusBar._updatePropsStack();
|
|
341
|
-
return entry;
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
/**
|
|
345
|
-
* Pop a StatusBar entry from the stack.
|
|
346
|
-
*
|
|
347
|
-
* @param entry Entry returned from `pushStackEntry`.
|
|
348
|
-
*/
|
|
349
|
-
static popStackEntry(entry: any) {
|
|
350
|
-
const index = StatusBar._propsStack.indexOf(entry);
|
|
351
|
-
if (index !== -1) {
|
|
352
|
-
StatusBar._propsStack.splice(index, 1);
|
|
353
|
-
}
|
|
354
|
-
StatusBar._updatePropsStack();
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
/**
|
|
358
|
-
* Replace an existing StatusBar stack entry with new props.
|
|
359
|
-
*
|
|
360
|
-
* @param entry Entry returned from `pushStackEntry` to replace.
|
|
361
|
-
* @param props Object containing the StatusBar props to use in the replacement stack entry.
|
|
362
|
-
*/
|
|
363
|
-
static replaceStackEntry(entry: any, props: any): any {
|
|
364
|
-
const newEntry = createStackEntry(props);
|
|
365
|
-
const index = StatusBar._propsStack.indexOf(entry);
|
|
366
|
-
if (index !== -1) {
|
|
367
|
-
StatusBar._propsStack[index] = newEntry;
|
|
368
|
-
}
|
|
369
|
-
StatusBar._updatePropsStack();
|
|
370
|
-
return newEntry;
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
_stackEntry = null;
|
|
374
|
-
|
|
375
|
-
componentDidMount() {
|
|
376
|
-
// Every time a StatusBar component is mounted, we push it's prop to a stack
|
|
377
|
-
// and always update the native status bar with the props from the top of then
|
|
378
|
-
// stack. This allows having multiple StatusBar components and the one that is
|
|
379
|
-
// added last or is deeper in the view hierarchy will have priority.
|
|
380
|
-
this._stackEntry = StatusBar.pushStackEntry(this.props);
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
componentWillUnmount() {
|
|
384
|
-
// When a StatusBar is unmounted, remove itself from the stack and update
|
|
385
|
-
// the native bar with the next props.
|
|
386
|
-
StatusBar.popStackEntry(this._stackEntry);
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
componentDidUpdate() {
|
|
390
|
-
this._stackEntry = StatusBar.replaceStackEntry(
|
|
391
|
-
this._stackEntry,
|
|
392
|
-
this.props
|
|
393
|
-
);
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
/**
|
|
397
|
-
* Updates the native status bar with the props from the stack.
|
|
398
|
-
*/
|
|
399
|
-
static _updatePropsStack = () => {
|
|
400
|
-
// Send the update to the native module only once at the end of the frame.
|
|
401
|
-
clearImmediate(StatusBar._updateImmediate);
|
|
402
|
-
StatusBar._updateImmediate = setImmediate(() => {
|
|
403
|
-
const oldProps = StatusBar._currentValues;
|
|
404
|
-
const mergedProps = mergePropsStack(
|
|
405
|
-
StatusBar._propsStack,
|
|
406
|
-
StatusBar._defaultProps
|
|
407
|
-
);
|
|
408
|
-
//RNOH: patch - delete code specific to IOS and Android
|
|
409
|
-
if (!oldProps || oldProps.hidden.value !== mergedProps.hidden.value) {
|
|
410
|
-
NativeStatusBarManagerHarmony.setHidden(mergedProps.hidden.value);
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
// Update the props that have changed using the merged values from the props stack.
|
|
414
|
-
if (!oldProps || oldProps.barStyle.value !== mergedProps.barStyle.value) {
|
|
415
|
-
NativeStatusBarManagerHarmony.setStyle(mergedProps.barStyle.value);
|
|
416
|
-
}
|
|
417
|
-
if (!oldProps || oldProps.translucent !== mergedProps.translucent) {
|
|
418
|
-
NativeStatusBarManagerHarmony.setTranslucent(mergedProps.translucent);
|
|
419
|
-
}
|
|
420
|
-
if (
|
|
421
|
-
!oldProps ||
|
|
422
|
-
oldProps.backgroundColor.value !== mergedProps.backgroundColor.value
|
|
423
|
-
) {
|
|
424
|
-
const processedColor = processColor(mergedProps.backgroundColor.value);
|
|
425
|
-
if (processedColor == null) {
|
|
426
|
-
console.warn(
|
|
427
|
-
`\`StatusBar._updatePropsStack\`: Color ${mergedProps.backgroundColor.value} parsed to null or undefined`
|
|
428
|
-
);
|
|
429
|
-
} else {
|
|
430
|
-
invariant(
|
|
431
|
-
typeof processedColor === "number",
|
|
432
|
-
"Unexpected color given in StatusBar._updatePropsStack"
|
|
433
|
-
);
|
|
434
|
-
NativeStatusBarManagerHarmony.setColor(processedColor, mergedProps.backgroundColor.animated);
|
|
435
|
-
}
|
|
436
|
-
}
|
|
437
|
-
// Update the current prop values.
|
|
438
|
-
StatusBar._currentValues = mergedProps;
|
|
439
|
-
});
|
|
440
|
-
};
|
|
441
|
-
|
|
442
|
-
render(): React.Node {
|
|
443
|
-
return null;
|
|
444
|
-
}
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
module.exports = StatusBar;
|