Skip to content
This repository was archived by the owner on Nov 12, 2019. It is now read-only.

Commit 7f1f722

Browse files
committed
removed anonymous functions
1 parent 4e6cdbc commit 7f1f722

File tree

3 files changed

+50
-65
lines changed

3 files changed

+50
-65
lines changed

components/NavButton.js

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,16 @@ const { Platform, TouchableOpacity, View, PropTypes } = React
44
import styles from '../styles'
55

66
function NavButton({ style, onPress, children }: Object): React.Element {
7-
const getNavBarButtonStyles = (): Array<Object> => {
8-
if (Platform.OS === 'ios') {
9-
return [
10-
styles.navBarButtonIOS,
11-
style,
12-
]
13-
} else if (Platform.OS === 'android') {
14-
return [
15-
styles.navBarButtonAndroid,
16-
style,
17-
]
18-
}
19-
return []
7+
let navBarStyles = []
8+
if (Platform.OS === 'ios') {
9+
navBarStyles = [styles.navBarButtonIOS, style]
10+
} else if (Platform.OS === 'android') {
11+
navBarStyles = [styles.navBarButtonAndroid, style]
2012
}
2113

2214
const getTouchable = () => (
2315
<TouchableOpacity onPress={onPress}>
24-
<View style={getNavBarButtonStyles()}>
16+
<View style={navBarStyles}>
2517
{children}
2618
</View>
2719
</TouchableOpacity>

components/StatusBarEnhanced.js

Lines changed: 30 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4,47 +4,42 @@ const { Platform, View, PropTypes, StatusBar } = React
44
import styles from '../styles'
55

66
function StatusBarEnhanced({ statusBar, style }: Object): React.Element {
7-
const getConfig = (): Object => {
8-
if (Platform.OS === 'ios') {
9-
const statusBarConfig = {
10-
animated: true,
11-
hidden: false,
12-
barStyle: 'default',
13-
networkActivityIndicatorVisible: true,
14-
showHideTransition: 'fade',
15-
}
16-
return Object.assign({}, statusBarConfig, statusBar)
17-
} else if (Platform.OS === 'android') {
18-
const statusBarConfig = {
19-
animated: true,
20-
hidden: false,
21-
showHideTransition: 'fade',
22-
backgroundColor: 'rgba(0, 0, 0, 0.2)',
23-
translucent: true,
24-
}
25-
return Object.assign({}, statusBarConfig, statusBar)
7+
let statusBarConfig = {}
8+
if (Platform.OS === 'ios') {
9+
statusBarConfig = {
10+
animated: true,
11+
hidden: false,
12+
barStyle: 'default',
13+
networkActivityIndicatorVisible: true,
14+
showHideTransition: 'fade',
15+
}
16+
} else if (Platform.OS === 'android') {
17+
statusBarConfig = {
18+
animated: true,
19+
hidden: false,
20+
showHideTransition: 'fade',
21+
backgroundColor: 'rgba(0, 0, 0, 0.2)',
22+
translucent: true,
2623
}
27-
return {}
2824
}
25+
const config = Object.assign({}, statusBarConfig, statusBar)
2926

30-
const getStyles = (): Array<Object> => {
31-
if (Platform.OS === 'ios') {
32-
return [
33-
styles.statusBarIOS,
34-
style,
35-
]
36-
} else if (Platform.OS === 'android') {
37-
return [
38-
styles.statusBarAndroid,
39-
style,
40-
]
41-
}
42-
return [{}]
27+
let statusBarStyles = []
28+
if (Platform.OS === 'ios') {
29+
statusBarStyles = [
30+
styles.statusBarIOS,
31+
style,
32+
]
33+
} else if (Platform.OS === 'android') {
34+
statusBarStyles = [
35+
styles.statusBarAndroid,
36+
style,
37+
]
4338
}
4439

4540
return (
46-
<View style={getStyles()}>
47-
<StatusBar {...getConfig()} />
41+
<View style={statusBarStyles}>
42+
<StatusBar {...config} />
4843
</View>
4944
)
5045
}

index.js

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,29 +13,27 @@ export { NavTitle } from './components/NavTitle'
1313
import styles from './styles'
1414

1515
function NavigationBar({ style, children, statusBar }: Object): React.Element {
16-
const getNavBar = (): React.Element => {
17-
if (Platform.OS === 'ios') {
18-
return (
19-
<View style={[styles.navBar, styles.navBarIOS, style.navBar]}>
20-
{children}
21-
</View>
22-
)
23-
} else if (Platform.OS === 'android') {
24-
return (
25-
<View style={[styles.navBar, styles.navBarAndroid, style.navBar]}>
26-
{children}
27-
</View>
28-
)
29-
}
30-
return null
16+
let navBar = null
17+
if (Platform.OS === 'ios') {
18+
navBar = (
19+
<View style={[styles.navBar, styles.navBarIOS, style.navBar]}>
20+
{children}
21+
</View>
22+
)
23+
} else if (Platform.OS === 'android') {
24+
navBar = (
25+
<View style={[styles.navBar, styles.navBarAndroid, style.navBar]}>
26+
{children}
27+
</View>
28+
)
3129
}
3230

3331
return (
3432
<View style={[styles.navBarContainer, style.navBarContainer]}>
3533
<StatusBarEnhanced style={style.statusBar}
3634
statusBar={statusBar}
3735
/>
38-
{getNavBar()}
36+
{navBar}
3937
</View>
4038
)
4139
}

0 commit comments

Comments
 (0)