Skip to content

Commit 551fa9e

Browse files
committed
Update react and move to react-navigation
1 parent a4260e6 commit 551fa9e

8 files changed

Lines changed: 110 additions & 319 deletions

File tree

example/Pages/Avignon.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import React from 'react';
22
import { StyleSheet, Text, Image, TouchableOpacity, View, Dimensions } from 'react-native';
3-
import { NavigationBar } from '@exponent/ex-navigation';
43

4+
import { Header } from 'react-navigation';
55
import HeaderImageScrollView, { TriggeringView } from 'react-native-image-header-scroll-view';
66

7-
const MIN_HEIGHT = NavigationBar.DEFAULT_HEIGHT;
7+
const MIN_HEIGHT = Header.HEIGHT;
88
const MAX_HEIGHT = 200;
99

1010
class BasicUsage extends React.Component {
@@ -41,7 +41,6 @@ class BasicUsage extends React.Component {
4141

4242
const styles = StyleSheet.create({
4343
container: {
44-
marginTop: -MIN_HEIGHT,
4544
flex: 1,
4645
},
4746
image: {

example/Pages/BasicUsage.js

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
import React from 'react';
22
import { StyleSheet, Text, Image, TouchableOpacity, View, Dimensions } from 'react-native';
3-
import { NavigationBar } from '@exponent/ex-navigation';
43

4+
import { Header } from 'react-navigation';
55
import HeaderImageScrollView, { TriggeringView } from 'react-native-image-header-scroll-view';
66

7-
const MIN_HEIGHT = NavigationBar.DEFAULT_HEIGHT;
7+
const MIN_HEIGHT = Header.HEIGHT;
88

99
const styles = StyleSheet.create({
1010
container: {
11-
marginTop: -MIN_HEIGHT,
1211
flex: 1,
1312
},
1413
image: {
@@ -47,14 +46,4 @@ class BasicUsage extends React.Component {
4746
}
4847
}
4948

50-
BasicUsage.route = {
51-
navigationBar: {
52-
tintColor: 'white',
53-
backgroundColor: 'transparent',
54-
borderBottomWidth: 0,
55-
statusBarHeight: 0,
56-
elevation: 0,
57-
},
58-
};
59-
6049
export default BasicUsage;

example/Pages/Colors.js

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import React from 'react';
22
import { StyleSheet, Image, View, Dimensions } from 'react-native';
3-
import { NavigationBar } from '@exponent/ex-navigation';
43

4+
import { Header } from 'react-navigation';
55
import HeaderImageScrollView from 'react-native-image-header-scroll-view';
66

7-
const MIN_HEIGHT = NavigationBar.DEFAULT_HEIGHT;
7+
const MIN_HEIGHT = Header.HEIGHT;
88

99
const styles = StyleSheet.create({
1010
image: {
@@ -16,7 +16,7 @@ const styles = StyleSheet.create({
1616
class ColorsPage extends React.Component {
1717
render() {
1818
return (
19-
<View style={{ flex: 1, marginTop: -MIN_HEIGHT }}>
19+
<View style={{ flex: 1 }}>
2020
<HeaderImageScrollView
2121
maxHeight={150}
2222
minHeight={80}
@@ -39,14 +39,4 @@ class ColorsPage extends React.Component {
3939
}
4040
}
4141

42-
ColorsPage.route = {
43-
navigationBar: {
44-
tintColor: 'white',
45-
backgroundColor: 'transparent',
46-
borderBottomWidth: 0,
47-
statusBarHeight: 0,
48-
elevation: 0,
49-
},
50-
};
51-
5242
export default ColorsPage;

example/Pages/Menu.js

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@ import {
99
ScrollView,
1010
Dimensions,
1111
} from 'react-native';
12-
import { withNavigation } from '@exponent/ex-navigation';
13-
import { Router } from '../main';
14-
1512
import tvShowContent from '../assets/tvShowContent';
1613

1714
const styles = StyleSheet.create({
@@ -43,14 +40,14 @@ const styles = StyleSheet.create({
4340
},
4441
});
4542

46-
@withNavigation class Button extends React.Component {
43+
class Button extends React.Component {
4744
render() {
4845
const props = this.props;
4946
return (
5047
<TouchableOpacity
5148
activeOpacity={0.7}
5249
onPress={() => {
53-
this.props.navigator.push(Router.getRoute(props.target));
50+
this.props.navigation.navigate(props.target);
5451
}}
5552
>
5653
<Image style={styles.button} source={props.image}>
@@ -63,13 +60,13 @@ const styles = StyleSheet.create({
6360
}
6461
}
6562

66-
const Menu = () => (
63+
const Menu = (props) => (
6764
<ScrollView style={styles.page} contentContainerStyle={styles.pageContent}>
6865
<StatusBar />
69-
<Button image={require('../assets/NZ.jpg')} text="BasicUsage" target="basicUsage" />
70-
<Button image={tvShowContent.image} text="TV Show" target="tvShow" />
71-
<Button image={require('../assets/cutecat.jpg')} text="Cute cat" target="colors" />
72-
<Button image={require('../assets/avignon.jpg')} text="Forms and buttons" target="avignon" />
66+
<Button {...props} image={require('../assets/NZ.jpg')} text="BasicUsage" target="basicUsage" />
67+
<Button {...props} image={tvShowContent.image} text="TV Show" target="tvShow" />
68+
<Button {...props} image={require('../assets/cutecat.jpg')} text="Cute cat" target="colors" />
69+
<Button {...props} image={require('../assets/avignon.jpg')} text="Forms and buttons" target="avignon" />
7370
</ScrollView>
7471
);
7572

example/Pages/TvShow.js

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,12 @@ import {
88
StatusBar,
99
} from 'react-native';
1010
import * as Animatable from 'react-native-animatable';
11-
import { NavigationBar } from '@exponent/ex-navigation';
12-
11+
import { Header } from 'react-navigation';
1312

1413
import HeaderImageScrollView, { TriggeringView } from 'react-native-image-header-scroll-view';
1514
import tvShowContent from '../assets/tvShowContent';
1615

17-
const MIN_HEIGHT = NavigationBar.DEFAULT_HEIGHT;
16+
const MIN_HEIGHT = Header.HEIGHT;
1817
const MAX_HEIGHT = 250;
1918

2019
const styles = StyleSheet.create({
@@ -96,7 +95,7 @@ class TvShow extends Component {
9695

9796
render() {
9897
return (
99-
<View style={{ flex: 1, marginTop: -MIN_HEIGHT }}>
98+
<View style={{ flex: 1 }}>
10099
<StatusBar barStyle="light-content" />
101100
<HeaderImageScrollView
102101
maxHeight={MAX_HEIGHT}
@@ -150,14 +149,4 @@ class TvShow extends Component {
150149
}
151150
}
152151

153-
TvShow.route = {
154-
navigationBar: {
155-
tintColor: 'white',
156-
backgroundColor: 'transparent',
157-
borderBottomWidth: 0,
158-
statusBarHeight: 0,
159-
elevation: 0,
160-
},
161-
};
162-
163152
export default TvShow;

example/main.js

Lines changed: 32 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,37 @@
1-
import React from 'react';
2-
import { AppRegistry, Text, View } from 'react-native';
3-
4-
import { createRouter, NavigationProvider, StackNavigation } from '@exponent/ex-navigation';
1+
import { StackNavigator } from 'react-navigation';
52

63
import { Menu, TvShow, BasicUsage, ColorsPage, Avignon } from './Pages';
74

8-
export const Router = createRouter(() => ({
9-
menu: () => Menu,
10-
tvShow: () => TvShow,
11-
basicUsage: () => BasicUsage,
12-
colors: () => ColorsPage,
13-
avignon: () => Avignon,
14-
}));
15-
16-
class App extends React.Component {
17-
render() {
18-
return (
19-
<NavigationProvider router={Router}>
20-
<StackNavigation initialRoute={Router.getRoute('menu')} />
21-
</NavigationProvider>
22-
);
23-
}
24-
}
5+
export const App = StackNavigator({
6+
menu: {
7+
screen: Menu,
8+
},
9+
tvShow: {
10+
screen: TvShow,
11+
},
12+
basicUsage: {
13+
screen: BasicUsage,
14+
},
15+
colors: {
16+
screen: ColorsPage,
17+
},
18+
avignon: {
19+
screen: Avignon,
20+
},
21+
}, {
22+
navigationOptions: {
23+
headerTintColor: 'white',
24+
headerStyle: {
25+
position: 'absolute',
26+
top: 0,
27+
elevation: 0,
28+
shadowColor: 'transparent',
29+
shadowRadius: 0,
30+
shadowOffset: {
31+
height: 0,
32+
},
33+
},
34+
},
35+
});
2536

2637
export default App;

example/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
"start": "node node_modules/react-native/local-cli/cli.js start"
77
},
88
"dependencies": {
9-
"@exponent/ex-navigation": "^2.9.1",
109
"babel-preset-react-native-stage-0": "^1.0.1",
11-
"react": "~15.4.1",
10+
"react": "16.0.0-alpha.12",
1211
"react-native": "^0.47.1",
1312
"react-native-animatable": "^1.1.0",
14-
"react-native-image-header-scroll-view": "^0.6.1"
13+
"react-native-image-header-scroll-view": "^0.6.1",
14+
"react-navigation": "^1.0.0-beta.11"
1515
},
1616
"devDependencies": {
1717
"babel-jest": "19.0.0",

0 commit comments

Comments
 (0)