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

Commit c991ddd

Browse files
committed
moved all components to stateless functional
1 parent 91706a1 commit c991ddd

File tree

8 files changed

+99
-109
lines changed

8 files changed

+99
-109
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,9 +343,11 @@ To find a preview of all examples go to the [examples](https://github.com/jinesh
343343
- [iOS Light](https://github.com/jineshshah36/react-native-nav/tree/master/examples/ios-light.js)
344344
- [iOS Dark](https://github.com/jineshshah36/react-native-nav/tree/master/examples/ios-dark.js)
345345
- [iOS Colored](https://github.com/jineshshah36/react-native-nav/tree/master/examples/ios-colored.js)
346+
- [iOS Icons Buttons](https://github.com/jineshshah36/react-native-nav/tree/master/examples/ios-image-icons.js)
346347
- [Android Light](https://github.com/jineshshah36/react-native-nav/tree/master/examples/android-light.js)
347348
- [Android Dark](https://github.com/jineshshah36/react-native-nav/tree/master/examples/android-dark.js)
348349
- [Android Colored](https://github.com/jineshshah36/react-native-nav/tree/master/examples/android-colored.js)
350+
- [Android Icons Buttons](https://github.com/jineshshah36/react-native-nav/tree/master/examples/android-image-icons.js)
349351

350352
### Questions?
351353

components/NavButton.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
/* @flow */
22
import React from 'react-native'
3-
const {
4-
Platform,
5-
TouchableOpacity,
6-
View,
7-
PropTypes,
8-
} = React
3+
const { Platform, TouchableOpacity, View, PropTypes } = React
94
import styles from '../styles'
105

116
function NavButton(props: Object): React.Element {
@@ -40,9 +35,9 @@ function NavButton(props: Object): React.Element {
4035
}
4136

4237
NavButton.propTypes = {
43-
style: View.propTypes.style,
4438
children: PropTypes.node,
4539
onPress: PropTypes.func,
40+
style: View.propTypes.style,
4641
}
4742

4843
NavButton.defaultProps = {

components/NavButtonText.js

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,24 @@
1+
/* @flow */
12
import React from 'react-native'
2-
const {
3-
Text,
4-
Component,
5-
PropTypes,
6-
} = React
3+
const { Text, PropTypes } = React
74
import styles from '../styles'
85

9-
export class NavButtonText extends Component {
10-
static propTypes = {
11-
style: Text.propTypes.style,
12-
children: PropTypes.node,
13-
}
6+
function NavButtonText(props: Object): React.Element {
7+
const { style, children } = props
8+
return (
9+
<Text style={[styles.navBarButtonText, style]}>
10+
{children}
11+
</Text>
12+
)
13+
}
1414

15-
static defaultProps = {
16-
style: {},
17-
}
15+
NavButtonText.propTypes = {
16+
style: Text.propTypes.style,
17+
children: PropTypes.node,
18+
}
1819

19-
render(): React.Element {
20-
const { style, children } = this.props
21-
return (
22-
<Text style={[styles.navBarButtonText, style]}>
23-
{children}
24-
</Text>
25-
)
26-
}
20+
NavButtonText.defaultProps = {
21+
style: {},
2722
}
23+
24+
export { NavButtonText }

components/NavGroup.js

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,24 @@
11
/* @flow */
22
import React from 'react-native'
3-
const {
4-
View,
5-
Component,
6-
PropTypes,
7-
} = React
3+
const { View, PropTypes } = React
84
import styles from '../styles'
95

10-
export class NavGroup extends Component {
11-
static propTypes = {
12-
style: View.propTypes.style,
13-
children: PropTypes.node,
14-
}
6+
function NavGroup(props: Object): React.Element {
7+
const { style, children } = props
8+
return (
9+
<View style={[styles.navGroup, style]}>
10+
{children}
11+
</View>
12+
)
13+
}
1514

16-
static defaultProps = {
17-
style: {},
18-
}
15+
NavGroup.propTypes = {
16+
style: View.propTypes.style,
17+
children: PropTypes.node,
18+
}
1919

20-
render(): React.Element {
21-
const { style, children } = this.props
22-
return (
23-
<View style={[styles.navGroup, style]}>
24-
{children}
25-
</View>
26-
)
27-
}
20+
NavGroup.defaultProps = {
21+
style: {},
2822
}
23+
24+
export { NavGroup }

components/NavTitle.js

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,24 @@
11
/* @flow */
22
import React from 'react-native'
3-
const {
4-
Text,
5-
Component,
6-
PropTypes,
7-
} = React
3+
const { Text, PropTypes } = React
84
import styles from '../styles'
95

10-
export class NavTitle extends Component {
11-
static propTypes = {
12-
style: Text.propTypes.style,
13-
children: PropTypes.node,
14-
}
6+
function NavTitle(props: Object): React.Element {
7+
const { style, children } = props
8+
return (
9+
<Text style={[styles.navBarTitleText, style]}>
10+
{children}
11+
</Text>
12+
)
13+
}
1514

16-
static defaultProps = {
17-
style: {},
18-
}
15+
NavTitle.propTypes = {
16+
style: Text.propTypes.style,
17+
children: PropTypes.node,
18+
}
1919

20-
render(): React.Element {
21-
const { style, children } = this.props
22-
return (
23-
<Text style={[styles.navBarTitleText, style]}>
24-
{children}
25-
</Text>
26-
)
27-
}
20+
NavTitle.defaultProps = {
21+
style: {},
2822
}
23+
24+
export { NavTitle }

components/StatusBarEnhanced.js

Lines changed: 23 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,10 @@
11
/* @flow */
22
import React from 'react-native'
3-
const {
4-
Platform,
5-
Component,
6-
View,
7-
PropTypes,
8-
StatusBar,
9-
} = React
3+
const { Platform, View, PropTypes, StatusBar } = React
104
import styles from '../styles'
115

12-
export default class StatusBarEnhanced extends Component {
13-
14-
static propTypes = {
15-
statusBarTintColor: PropTypes.string,
16-
statusBar: PropTypes.object,
17-
style: View.propTypes.style,
18-
}
19-
20-
static defaultProps = {
21-
statusBarTintColor: '#fff',
22-
style: {},
23-
statusBar: {},
24-
}
25-
26-
getConfig(): Object {
6+
function StatusBarEnhanced(props: Object): React.Element {
7+
const getConfig = (): Object => {
278
const { statusBar } = this.props
289
if (Platform.OS === 'ios') {
2910
const statusBarConfig = {
@@ -47,7 +28,7 @@ export default class StatusBarEnhanced extends Component {
4728
return null
4829
}
4930

50-
getStyles(): Array {
31+
const getStyles = (): Array => {
5132
const { style } = this.props
5233
if (Platform.OS === 'ios') {
5334
return [
@@ -63,12 +44,23 @@ export default class StatusBarEnhanced extends Component {
6344
return null
6445
}
6546

66-
render(): React.Element {
67-
const config: Object = this.getConfig()
68-
return (
69-
<View style={this.getStyles()}>
70-
<StatusBar {...config} />
71-
</View>
72-
)
73-
}
47+
return (
48+
<View style={getStyles}>
49+
<StatusBar {...getConfig} />
50+
</View>
51+
)
7452
}
53+
54+
StatusBarEnhanced.propTypes = {
55+
statusBarTintColor: PropTypes.string,
56+
statusBar: PropTypes.object,
57+
style: View.propTypes.style,
58+
}
59+
60+
StatusBarEnhanced.defaultProps = {
61+
statusBarTintColor: '#fff',
62+
style: {},
63+
statusBar: {},
64+
}
65+
66+
export { StatusBarEnhanced }

examples/android-image-icons.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ const styles = StyleSheet.create({
1717
navGroup: {
1818
justifyContent: 'flex-end',
1919
},
20+
navButton: {
21+
flex: 1,
22+
},
23+
image: {
24+
width: 30,
25+
},
2026
})
2127

2228
export default class NavBarAndroidColored extends Component {
@@ -27,14 +33,14 @@ export default class NavBarAndroidColored extends Component {
2733
{"App"}
2834
</NavTitle>
2935
<NavGroup style={styles.navGroup}>
30-
<NavButton style={{ flex: 1 }}>
31-
<Image style={{ width: 30 }}
36+
<NavButton style={styles.navButton}>
37+
<Image style={styles.width}
3238
resizeMode={"contain"}
3339
source={require('./shared/static/new-interface_cart.png')}
3440
/>
3541
</NavButton>
36-
<NavButton style={{ flex: 1 }}>
37-
<Image style={{ width: 30 }}
42+
<NavButton style={styles.navButton}>
43+
<Image style={styles.width}
3844
resizeMode={"contain"}
3945
source={require('./shared/static/new-interface_search.png')}
4046
/>

examples/ios-image-icons.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,29 @@ const styles = StyleSheet.create({
1414
buttonText: {
1515
color: 'rgba(231, 37, 156, 0.5)',
1616
},
17+
navButton: {
18+
flex: 1,
19+
},
20+
image: {
21+
width: 30,
22+
},
1723
})
1824

1925
export default class NavBarIOSColored extends Component {
2026
render() {
2127
return (
2228
<NavBar style={styles}>
23-
<NavButton style={{ flex: 1 }}>
24-
<Image style={{ width: 30 }}
29+
<NavButton style={styles.navButton}>
30+
<Image style={styles.image}
2531
resizeMode={"contain"}
2632
source={require('./shared/static/new-interface_cart.png')}
2733
/>
2834
</NavButton>
2935
<NavTitle style={styles.title}>
3036
{"App"}
3137
</NavTitle>
32-
<NavButton style={{ flex: 1 }}>
33-
<Image style={{ width: 30 }}
38+
<NavButton style={styles.navButton}>
39+
<Image style={styles.image}
3440
resizeMode={"contain"}
3541
source={require('./shared/static/new-interface_search.png')}
3642
/>

0 commit comments

Comments
 (0)