Skip to content

Commit 1250446

Browse files
Merge pull request #210 from testshallpass/constants-setbarstyle-unmounted-fixes
Fix to constants and setBarStyle
2 parents 291d1c2 + 93ba585 commit 1250446

File tree

2 files changed

+17
-33
lines changed

2 files changed

+17
-33
lines changed

DropdownAlert.js

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { StyleSheet, SafeAreaView, View, TouchableOpacity, Animated, StatusBar,
33
import PropTypes from 'prop-types';
44
import {
55
DEFAULT_IMAGE_DIMENSIONS,
6-
IS_IOS,
76
IS_ANDROID,
87
IS_IOS_BELOW_11,
98
TYPE,
@@ -180,7 +179,6 @@ export default class DropdownAlert extends Component {
180179
this.panResponder = this.getPanResponder();
181180
}
182181
componentWillUnmount() {
183-
this.clearCloseTimeoutID();
184182
if (this.state.isOpen) {
185183
this.closeAction(ACTION.programmatic);
186184
}
@@ -329,13 +327,12 @@ export default class DropdownAlert extends Component {
329327
} else {
330328
StatusBar.setBackgroundColor(inactiveStatusBarBackgroundColor, true);
331329
}
332-
} else if (IS_IOS) {
333-
const { inactiveStatusBarStyle, activeStatusBarStyle } = this.props;
334-
if (active) {
335-
StatusBar.setBarStyle(activeStatusBarStyle, true);
336-
} else {
337-
StatusBar.setBarStyle(inactiveStatusBarStyle, true);
338-
}
330+
}
331+
const { inactiveStatusBarStyle, activeStatusBarStyle } = this.props;
332+
if (active) {
333+
StatusBar.setBarStyle(activeStatusBarStyle, true);
334+
} else {
335+
StatusBar.setBarStyle(inactiveStatusBarStyle, true);
339336
}
340337
}
341338
};

constants.js

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,36 @@
11
import { StatusBar, Platform, Dimensions } from 'react-native';
22

3-
const DEFAULT_IMAGE_DIMENSIONS = 36;
4-
const WINDOW = Dimensions.get('window');
5-
const HEIGHT = WINDOW.height;
6-
const WIDTH = WINDOW.width;
3+
export const DEFAULT_IMAGE_DIMENSIONS = 36;
4+
export const WINDOW = Dimensions.get('window');
5+
export const HEIGHT = WINDOW.height;
6+
export const WIDTH = WINDOW.width;
7+
export const IS_ANDROID = Platform.OS == 'android';
78
const IS_IOS = Platform.OS == 'ios';
8-
const IS_ANDROID = Platform.OS == 'android';
9-
const IS_IOS_BELOW_11 = IS_IOS && parseInt(Platform.Version, 10) < 11;
10-
const TYPE = {
9+
const PLATFORM_VERSION = parseInt(Platform.Version, 10);
10+
export const IS_IOS_BELOW_11 = IS_IOS && PLATFORM_VERSION < 11;
11+
export const TYPE = {
1112
info: 'info',
1213
warn: 'warn',
1314
error: 'error',
1415
success: 'success',
1516
custom: 'custom',
1617
};
17-
const ACTION = {
18+
export const ACTION = {
1819
automatic: 'automatic',
1920
cancel: 'cancel',
2021
pan: 'pan',
2122
programmatic: 'programmatic',
2223
tap: 'tap',
2324
};
24-
const getDefaultStatusBarStyle = () => {
25+
export function getDefaultStatusBarStyle() {
2526
if (StatusBar._defaultProps) {
2627
return StatusBar._defaultProps.barStyle.value;
2728
}
2829
return 'default';
2930
};
30-
const getDefaultStatusBarBackgroundColor = () => {
31+
export function getDefaultStatusBarBackgroundColor() {
3132
if (StatusBar._defaultProps) {
3233
return StatusBar._defaultProps.backgroundColor.value;
3334
}
3435
return 'black';
3536
};
36-
37-
module.exports = {
38-
DEFAULT_IMAGE_DIMENSIONS,
39-
WINDOW,
40-
HEIGHT,
41-
WIDTH,
42-
IS_IOS,
43-
IS_ANDROID,
44-
IS_IOS_BELOW_11,
45-
TYPE,
46-
ACTION,
47-
getDefaultStatusBarStyle,
48-
getDefaultStatusBarBackgroundColor,
49-
};

0 commit comments

Comments
 (0)