Skip to content

Commit c3dea89

Browse files
Le Xufacebook-github-bot
Le Xu
authored andcommittedNov 23, 2018
Back out "[react-native][PR] [flow-strict] Flow strict StatusBar"
Summary: Original commit changeset: 27f69c6df3a8 This reverts D13103971 Differential Revision: D13185679 fbshipit-source-id: 0de9da31bd75786c7978e2c3860486ac37420342
1 parent 4514041 commit c3dea89

File tree

1 file changed

+38
-70
lines changed

1 file changed

+38
-70
lines changed
 

‎Libraries/Components/StatusBar/StatusBar.js

+38-70
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* LICENSE file in the root directory of this source tree.
66
*
77
* @format
8-
* @flow strict-local
8+
* @flow
99
*/
1010

1111
'use strict';
@@ -103,88 +103,53 @@ type Props = $ReadOnly<{|
103103
barStyle?: ?('default' | 'light-content' | 'dark-content'),
104104
|}>;
105105

106-
type StackEntryProps = {|
107-
/**
108-
* The background color of the status bar.
109-
*
110-
* @platform android
111-
*/
112-
backgroundColor: {|
113-
value: ?string,
114-
animated: ?boolean,
115-
|},
116-
/**
117-
* Sets the color of the status bar text.
118-
*/
119-
barStyle: {|
120-
value: ?string,
121-
animated: ?boolean,
122-
|},
123-
/**
124-
* If the status bar is translucent.
125-
* When translucent is set to true, the app will draw under the status bar.
126-
* This is useful when using a semi transparent status bar color.
127-
*/
128-
translucent: ?boolean,
129-
/**
130-
*
131-
*/
132-
hidden: {|
133-
value: ?boolean,
134-
animated: boolean,
135-
transition: ?('slide' | 'fade'),
136-
|},
137-
/**
138-
* If the network activity indicator should be visible.
139-
*
140-
* @platform ios
141-
*/
142-
networkActivityIndicatorVisible: ?boolean,
143-
|};
144-
145106
/**
146107
* Merges the prop stack with the default values.
147108
*/
148109
function mergePropsStack(
149-
propsStack: $ReadOnlyArray<StackEntryProps>,
150-
defaultValues: StackEntryProps,
151-
): StackEntryProps {
152-
const init: StackEntryProps = {
153-
...defaultValues,
154-
};
155-
110+
propsStack: Array<Object>,
111+
defaultValues: Object,
112+
): Object {
156113
return propsStack.reduce((prev, cur) => {
157114
for (const prop in cur) {
158115
if (cur[prop] != null) {
159116
prev[prop] = cur[prop];
160117
}
161118
}
162119
return prev;
163-
}, init);
120+
}, Object.assign({}, defaultValues));
164121
}
165122

166123
/**
167124
* Returns an object to insert in the props stack from the props
168125
* and the transition/animation info.
169126
*/
170-
function createStackEntry(props: Props): StackEntryProps {
127+
function createStackEntry(props: any): any {
171128
return {
172-
backgroundColor: {
173-
value: props.backgroundColor,
174-
animated: props.animated,
175-
},
176-
barStyle: {
177-
value: props.barStyle,
178-
animated: props.animated,
179-
},
180-
translucent: props.translucent || false,
181-
hidden: {
182-
value: props.hidden,
183-
animated: props.animated || false,
184-
transition: props.showHideTransition,
185-
},
186-
networkActivityIndicatorVisible:
187-
props.networkActivityIndicatorVisible || false,
129+
backgroundColor:
130+
props.backgroundColor != null
131+
? {
132+
value: props.backgroundColor,
133+
animated: props.animated,
134+
}
135+
: null,
136+
barStyle:
137+
props.barStyle != null
138+
? {
139+
value: props.barStyle,
140+
animated: props.animated,
141+
}
142+
: null,
143+
translucent: props.translucent,
144+
hidden:
145+
props.hidden != null
146+
? {
147+
value: props.hidden,
148+
animated: props.animated,
149+
transition: props.showHideTransition,
150+
}
151+
: null,
152+
networkActivityIndicatorVisible: props.networkActivityIndicatorVisible,
188153
};
189154
}
190155

@@ -228,9 +193,9 @@ function createStackEntry(props: Props): StackEntryProps {
228193
* `currentHeight` (Android only) The height of the status bar.
229194
*/
230195
class StatusBar extends React.Component<Props> {
231-
static _propsStack: Array<StackEntryProps> = [];
196+
static _propsStack = [];
232197

233-
static _defaultProps: StackEntryProps = createStackEntry({
198+
static _defaultProps = createStackEntry({
234199
animated: false,
235200
showHideTransition: 'fade',
236201
backgroundColor: 'black',
@@ -265,9 +230,10 @@ class StatusBar extends React.Component<Props> {
265230
* changing the status bar hidden property.
266231
*/
267232
static setHidden(hidden: boolean, animation?: StatusBarAnimation) {
233+
animation = animation || 'none';
268234
StatusBar._defaultProps.hidden.value = hidden;
269235
if (Platform.OS === 'ios') {
270-
StatusBarManager.setHidden(hidden, animation || 'none');
236+
StatusBarManager.setHidden(hidden, animation);
271237
} else if (Platform.OS === 'android') {
272238
StatusBarManager.setHidden(hidden);
273239
}
@@ -279,9 +245,10 @@ class StatusBar extends React.Component<Props> {
279245
* @param animated Animate the style change.
280246
*/
281247
static setBarStyle(style: StatusBarStyle, animated?: boolean) {
248+
animated = animated || false;
282249
StatusBar._defaultProps.barStyle.value = style;
283250
if (Platform.OS === 'ios') {
284-
StatusBarManager.setStyle(style, animated || false);
251+
StatusBarManager.setStyle(style, animated);
285252
} else if (Platform.OS === 'android') {
286253
StatusBarManager.setStyle(style);
287254
}
@@ -312,8 +279,9 @@ class StatusBar extends React.Component<Props> {
312279
console.warn('`setBackgroundColor` is only available on Android');
313280
return;
314281
}
282+
animated = animated || false;
315283
StatusBar._defaultProps.backgroundColor.value = color;
316-
StatusBarManager.setColor(processColor(color), animated || false);
284+
StatusBarManager.setColor(processColor(color), animated);
317285
}
318286

319287
/**

0 commit comments

Comments
 (0)
Please sign in to comment.