Browse Source

Minor changes in example project

consolidated some screens
minor ui changes and fixes
Guy Carmeli 8 years ago
parent
commit
efb2ffa213

+ 1
- 3
example/android/app/src/main/java/com/example/MyActivity.java View File

@@ -1,9 +1,7 @@
1 1
 package com.example;
2 2
 
3
-
4
-import android.view.View;
5
-
6 3
 import com.reactnativenavigation.controllers.SplashActivity;
7 4
 
8 5
 public class MyActivity extends SplashActivity {
6
+
9 7
 }

BIN
example/img/navicon_add@2x.android.png View File


example/img/navicon_add@2x.png → example/img/navicon_add@2x.ios.png View File


BIN
example/img/navicon_add@3x.android.png View File


BIN
example/img/one@1.5x.android.png View File


BIN
example/img/one@1x.android.png View File


example/img/one@2x.png → example/img/one@2x.ios.png View File


BIN
example/img/one@3x.android.png View File


BIN
example/img/one@4x.android.png View File


+ 0
- 20
example/src/app.android.js View File

@@ -1,20 +0,0 @@
1
-import {Navigation} from 'react-native-navigation';
2
-
3
-// screen related book keeping
4
-import {registerScreens} from './screens';
5
-registerScreens();
6
-
7
-// this will start our app
8
-Navigation.startSingleScreenApp({
9
-  screen: {
10
-    screen: 'example.FirstTabScreen',
11
-    title: 'Login',
12
-    navigatorStyle: {
13
-      navBarBackgroundColor: '#4dbce9',
14
-      navBarTextColor: '#ffff00',
15
-      navBarSubtitleTextColor: '#ff0000',
16
-      navBarButtonColor: '#ffffff',
17
-      statusBarTextColorScheme: 'light'
18
-    }
19
-  }
20
-});

+ 0
- 25
example/src/app.ios.js View File

@@ -1,25 +0,0 @@
1
-import {Navigation} from 'react-native-navigation';
2
-
3
-// screen related book keeping
4
-import {registerScreens} from './screens';
5
-registerScreens();
6
-
7
-// this will start our app
8
-Navigation.startSingleScreenApp({
9
-  screen: {
10
-    screen: 'example.FirstTabScreen',
11
-    title: 'Login',
12
-    navigatorStyle: {
13
-      navBarBackgroundColor: '#4dbce9',
14
-      navBarTextColor: '#ffff00',
15
-      navBarSubtitleTextColor: '#ff0000',
16
-      navBarButtonColor: '#ffffff',
17
-      statusBarTextColorScheme: 'light'
18
-    }
19
-  },
20
-  drawer: {
21
-    left: {
22
-      screen: 'example.SideMenu'
23
-    }
24
-  }
25
-});

+ 56
- 0
example/src/app.js View File

@@ -0,0 +1,56 @@
1
+import {Navigation} from 'react-native-navigation';
2
+
3
+// screen related book keeping
4
+import {registerScreens} from './screens';
5
+registerScreens();
6
+
7
+// this will start our app
8
+Navigation.startTabBasedApp({
9
+  tabs: [
10
+    {
11
+      label: 'One',
12
+      screen: 'example.FirstTabScreen',
13
+      icon: require('../img/one.png'),
14
+      selectedIcon: require('../img/one_selected.png'),
15
+      title: 'Screen One',
16
+      navigatorStyle: {
17
+        navBarBackgroundColor: '#4dbce9',
18
+        navBarTextColor: '#ffff00',
19
+        navBarSubtitleTextColor: '#ff0000',
20
+        navBarButtonColor: '#ffffff',
21
+        statusBarTextColorScheme: 'light',
22
+        tabBarBackgroundColor: '#4dbce9',
23
+        tabBarButtonColor: '#ffffff',
24
+        tabBarSelectedButtonColor: '#ffff00'
25
+      }
26
+    },
27
+    {
28
+      label: 'Two',
29
+      screen: 'example.SecondTabScreen',
30
+      icon: require('../img/two.png'),
31
+      selectedIcon: require('../img/two_selected.png'),
32
+      title: 'Screen Two',
33
+      navigatorStyle: {
34
+        tabBarBackgroundColor: '#4dbce9',
35
+      }
36
+    }
37
+  ]
38
+});
39
+// Navigation.startSingleScreenApp({
40
+//   screen: {
41
+//     screen: 'example.FirstTabScreen',
42
+//     title: 'Navigation',
43
+//     navigatorStyle: {
44
+//       navBarBackgroundColor: '#4dbce9',
45
+//       navBarTextColor: '#ffff00',
46
+//       navBarSubtitleTextColor: '#ff0000',
47
+//       navBarButtonColor: '#ffffff',
48
+//       statusBarTextColorScheme: 'light'
49
+//     }
50
+//   },
51
+//   drawer: {
52
+//     left: {
53
+//       screen: 'example.SideMenu'
54
+//     }
55
+//   }
56
+// });

+ 0
- 125
example/src/screens/FirstTabScreen.android.js View File

@@ -1,125 +0,0 @@
1
-import React, {Component} from 'react';
2
-import {
3
-  Text,
4
-  View,
5
-  TouchableHighlight,
6
-  StyleSheet,
7
-  AlertIOS
8
-} from 'react-native';
9
-
10
-export default class FirstTabScreen extends Component {
11
-  static navigatorButtons = {
12
-    leftButtons: [{
13
-      icon: require('../../img/navicon_menu.png'),
14
-      id: 'menu'
15
-    }],
16
-    rightButtons: [
17
-      {
18
-        title: 'Edit',
19
-        id: 'edit'
20
-      },
21
-      {
22
-        icon: require('../../img/navicon_add.png'),
23
-        id: 'add'
24
-      }
25
-    ]
26
-  };
27
-  static navigatorStyle = {
28
-    drawUnderTabBar: true
29
-  };
30
-
31
-  constructor(props) {
32
-    super(props);
33
-    // if you want to listen on navigator events, set this up
34
-    this.props.navigator.setOnNavigatorEvent(this.onNavigatorEvent.bind(this));
35
-  }
36
-
37
-  onNavigatorEvent(event) {
38
-    if (event.id === 'menu') {
39
-      this.props.navigator.toggleDrawer({
40
-        side: 'left',
41
-        animated: true
42
-      });
43
-    }
44
-    if (event.id === 'edit') {
45
-      AlertIOS.alert('NavBar', 'Edit button pressed');
46
-    }
47
-    if (event.id === 'add') {
48
-      AlertIOS.alert('NavBar', 'Add button pressed');
49
-    }
50
-  }
51
-
52
-  render() {
53
-    return (
54
-      <View style={{flex: 1, padding: 20}}>
55
-
56
-        <TouchableHighlight onPress={ this.onPushPress.bind(this) }>
57
-          <Text style={styles.button}>Push Plain Screen</Text>
58
-        </TouchableHighlight>
59
-
60
-        <TouchableHighlight onPress={ this.onPushStyledPress.bind(this) }>
61
-          <Text style={styles.button}>Push Styled Screen</Text>
62
-        </TouchableHighlight>
63
-
64
-        <TouchableHighlight onPress={ this.onModalPress.bind(this) }>
65
-          <Text style={styles.button}>Show Modal Screen</Text>
66
-        </TouchableHighlight>
67
-
68
-        <TouchableHighlight onPress={ this.onLightBoxPress.bind(this) }>
69
-          <Text style={styles.button}>Show LightBox</Text>
70
-        </TouchableHighlight>
71
-
72
-        <TouchableHighlight onPress={ this.onInAppNotificationPress.bind(this) }>
73
-          <Text style={styles.button}>Show In-App Notification</Text>
74
-        </TouchableHighlight>
75
-
76
-      </View>
77
-    );
78
-  }
79
-
80
-  onPushPress() {
81
-    this.props.navigator.push({
82
-      title: "More",
83
-      screen: "example.PushedScreen"
84
-    });
85
-  }
86
-
87
-  onPushStyledPress() {
88
-    this.props.navigator.push({
89
-      title: "Styled",
90
-      screen: "example.StyledScreen"
91
-    });
92
-  }
93
-
94
-  onModalPress() {
95
-    this.props.navigator.showModal({
96
-      title: "Modal",
97
-      screen: "example.ModalScreen"
98
-    });
99
-  }
100
-
101
-  onLightBoxPress() {
102
-    this.props.navigator.showLightBox({
103
-      screen: "example.LightBoxScreen",
104
-      style: {
105
-        backgroundBlur: "dark"
106
-      }
107
-    });
108
-  }
109
-
110
-  onInAppNotificationPress() {
111
-    this.props.navigator.showInAppNotification({
112
-      screen: "example.NotificationScreen"
113
-    });
114
-  }
115
-}
116
-
117
-const styles = StyleSheet.create({
118
-  button: {
119
-    textAlign: 'center',
120
-    fontSize: 18,
121
-    marginBottom: 10,
122
-    marginTop: 10,
123
-    color: 'blue'
124
-  }
125
-});

example/src/screens/FirstTabScreen.ios.js → example/src/screens/FirstTabScreen.js View File

@@ -4,7 +4,8 @@ import {
4 4
   View,
5 5
   TouchableOpacity,
6 6
   StyleSheet,
7
-  AlertIOS
7
+  Alert,
8
+  Platform
8 9
 } from 'react-native';
9 10
 
10 11
 export default class FirstTabScreen extends Component {
@@ -42,17 +43,16 @@ export default class FirstTabScreen extends Component {
42 43
       });
43 44
     }
44 45
     if (event.id === 'edit') {
45
-      AlertIOS.alert('NavBar', 'Edit button pressed');
46
+      Alert.alert('NavBar', 'Edit button pressed');
46 47
     }
47 48
     if (event.id === 'add') {
48
-      AlertIOS.alert('NavBar', 'Add button pressed');
49
+      Alert.alert('NavBar', 'Add button pressed');
49 50
     }
50 51
   }
51 52
 
52 53
   render() {
53 54
     return (
54 55
       <View style={{flex: 1, padding: 20}}>
55
-
56 56
         <TouchableOpacity onPress={ this.onPushPress.bind(this) }>
57 57
           <Text style={styles.button}>Push Plain Screen</Text>
58 58
         </TouchableOpacity>
@@ -65,14 +65,19 @@ export default class FirstTabScreen extends Component {
65 65
           <Text style={styles.button}>Show Modal Screen</Text>
66 66
         </TouchableOpacity>
67 67
 
68
-        <TouchableOpacity onPress={ this.onLightBoxPress.bind(this) }>
69
-          <Text style={styles.button}>Show LightBox</Text>
70
-        </TouchableOpacity>
71
-
72
-        <TouchableOpacity onPress={ this.onInAppNotificationPress.bind(this) }>
73
-          <Text style={styles.button}>Show In-App Notification</Text>
74
-        </TouchableOpacity>
75
-
68
+        {
69
+          Platform.OS === 'ios' ?
70
+            <TouchableOpacity onPress={ this.onLightBoxPress.bind(this) }>
71
+              <Text style={styles.button}>Show LightBox</Text>
72
+            </TouchableOpacity> : false
73
+        }
74
+
75
+        {
76
+          Platform.OS === 'ios' ?
77
+            <TouchableOpacity onPress={ this.onInAppNotificationPress.bind(this) }>
78
+              <Text style={styles.button}>Show In-App Notification</Text>
79
+            </TouchableOpacity> : false
80
+        }
76 81
       </View>
77 82
     );
78 83
   }

+ 6
- 1
example/src/screens/ModalScreen.js View File

@@ -21,7 +21,7 @@ export default class ModalScreen extends Component {
21 21
   }
22 22
   render() {
23 23
     return (
24
-      <View style={{flex: 1, padding: 20}}>
24
+      <View style={styles.container}>
25 25
 
26 26
         <TouchableOpacity onPress={ this.onPushPress.bind(this) }>
27 27
           <Text style={styles.button}>Push Plain Screen</Text>
@@ -68,6 +68,11 @@ export default class ModalScreen extends Component {
68 68
 }
69 69
 
70 70
 const styles = StyleSheet.create({
71
+  container: {
72
+    flex: 1,
73
+    backgroundColor: 'white',
74
+    padding: 20
75
+  },
71 76
   button: {
72 77
     textAlign: 'center',
73 78
     fontSize: 18,

+ 6
- 3
example/src/screens/PushedScreen.js View File

@@ -16,8 +16,7 @@ export default class PushedScreen extends Component {
16 16
   }
17 17
   render() {
18 18
     return (
19
-      <View style={{flex: 1, padding: 20}}>
20
-
19
+      <View style={styles.container}>
21 20
         <TouchableOpacity onPress={ this.onPushPress.bind(this) }>
22 21
           <Text style={styles.button}>Push Plain Screen</Text>
23 22
         </TouchableOpacity>
@@ -37,7 +36,6 @@ export default class PushedScreen extends Component {
37 36
         <TouchableOpacity onPress={ this.onResetToPress.bind(this) }>
38 37
           <Text style={styles.button}>Reset To</Text>
39 38
         </TouchableOpacity>
40
-
41 39
       </View>
42 40
     );
43 41
   }
@@ -68,6 +66,11 @@ export default class PushedScreen extends Component {
68 66
 }
69 67
 
70 68
 const styles = StyleSheet.create({
69
+  container: {
70
+    flex: 1,
71
+    padding: 20,
72
+    backgroundColor: 'white'
73
+  },
71 74
   button: {
72 75
     textAlign: 'center',
73 76
     fontSize: 18,

+ 19
- 7
example/src/screens/SecondTabScreen.js View File

@@ -5,22 +5,29 @@ import {
5 5
   ScrollView,
6 6
   TouchableOpacity,
7 7
   StyleSheet,
8
-  AlertIOS
8
+  Alert
9 9
 } from 'react-native';
10 10
 
11 11
 export default class SecondTabScreen extends Component {
12
-  static navigatorStyle = {
13
-    drawUnderTabBar: true
12
+  static navigatorStyle: {
13
+    drawUnderTabBar: true,
14
+    navBarBackgroundColor: '#4dbce9',
15
+    navBarTextColor: '#ffff00',
16
+    navBarSubtitleTextColor: '#ff0000',
17
+    navBarButtonColor: '#ffffff',
18
+    statusBarTextColorScheme: 'light'
14 19
   };
20
+
15 21
   constructor(props) {
16 22
     super(props);
17 23
     this.buttonsCounter = 0;
18 24
     // if you want to listen on navigator events, set this up
19 25
     this.props.navigator.setOnNavigatorEvent(this.onNavigatorEvent.bind(this));
20 26
   }
27
+
21 28
   render() {
22 29
     return (
23
-      <View style={{flex: 1, padding: 20}}>
30
+      <View style={styles.container}>
24 31
 
25 32
         <TouchableOpacity onPress={ this.onChangeButtonsPress.bind(this) }>
26 33
           <Text style={styles.button}>Change Buttons</Text>
@@ -111,19 +118,24 @@ export default class SecondTabScreen extends Component {
111 118
     // handle a button press
112 119
     if (event.type == 'NavBarButtonPress') {
113 120
       if (event.id == 'edit') {
114
-        AlertIOS.alert('NavBar', 'Dynamic Edit button pressed');
121
+        Alert.alert('NavBar', 'Dynamic Edit button pressed');
115 122
       }
116 123
       if (event.id == 'add') {
117
-        AlertIOS.alert('NavBar', 'Dynamic Add button pressed');
124
+        Alert.alert('NavBar', 'Dynamic Add button pressed');
118 125
       }
119 126
       if (event.id == 'save') {
120
-        AlertIOS.alert('NavBar', 'Dynamic Save button pressed');
127
+        Alert.alert('NavBar', 'Dynamic Save button pressed');
121 128
       }
122 129
     }
123 130
   }
124 131
 }
125 132
 
126 133
 const styles = StyleSheet.create({
134
+  container: {
135
+    flex: 1,
136
+    padding: 20,
137
+    backgroundColor: 'white'
138
+  },
127 139
   button: {
128 140
     textAlign: 'center',
129 141
     fontSize: 18,

+ 19
- 8
example/src/screens/SideMenu.js View File

@@ -14,8 +14,7 @@ export default class SideMenu extends Component {
14 14
   }
15 15
   render() {
16 16
     return (
17
-      <View style={{flex: 1, alignItems: 'center', justifyContent: 'center'}}>
18
-
17
+      <View style={styles.container}>
19 18
         <Text style={styles.title}>Side Menu</Text>
20 19
 
21 20
         <TouchableOpacity onPress={ this.onReplaceTab2Press.bind(this) }>
@@ -25,16 +24,11 @@ export default class SideMenu extends Component {
25 24
         <TouchableOpacity onPress={ this.onModalPress.bind(this) }>
26 25
           <Text style={styles.button}>Show Modal Screen</Text>
27 26
         </TouchableOpacity>
28
-
29 27
       </View>
30 28
     );
31 29
   }
32 30
   onReplaceTab2Press() {
33
-    this.props.navigator.toggleDrawer({
34
-      to: 'closed',
35
-      side: 'left',
36
-      animated: true
37
-    });
31
+    this._toggleDrawer();
38 32
     // push/pop navigator actions affect the navigation stack of the current screen only.
39 33
     // since side menu actions are normally directed at sibling tabs, push/pop will
40 34
     // not help us. the recommended alternative is to use deep links for this purpose
@@ -42,15 +36,32 @@ export default class SideMenu extends Component {
42 36
       link: "tab2/example.PushedScreen"
43 37
     });
44 38
   }
39
+
45 40
   onModalPress() {
41
+    this._toggleDrawer();
46 42
     this.props.navigator.showModal({
47 43
       title: "Modal",
48 44
       screen: "example.ModalScreen"
49 45
     });
50 46
   }
47
+
48
+  _toggleDrawer() {
49
+    this.props.navigator.toggleDrawer({
50
+      to: 'closed',
51
+      side: 'left',
52
+      animated: true
53
+    });
54
+  }
51 55
 }
52 56
 
53 57
 const styles = StyleSheet.create({
58
+  container: {
59
+    flex: 1,
60
+    alignItems: 'center',
61
+    backgroundColor: 'white',
62
+    justifyContent: 'center',
63
+    width: 300
64
+  },
54 65
   title: {
55 66
     textAlign: 'center',
56 67
     fontSize: 18,

+ 23
- 15
example/src/screens/StyledScreen.js View File

@@ -6,7 +6,8 @@ import {
6 6
   TouchableOpacity,
7 7
   Image,
8 8
   StyleSheet,
9
-  AlertIOS
9
+  Alert,
10
+  Platform
10 11
 } from 'react-native';
11 12
 
12 13
 export default class StyledScreen extends Component {
@@ -29,12 +30,10 @@ export default class StyledScreen extends Component {
29 30
   }
30 31
   render() {
31 32
     return (
32
-      <ScrollView style={{flex: 1}}>
33
-
33
+      <ScrollView style={styles.container}>
34 34
         <Image style={{width: undefined, height: 100}} source={require('../../img/colors.png')} />
35 35
 
36 36
         <View style={{padding: 20}}>
37
-
38 37
           <TouchableOpacity onPress={ this.onPushPress.bind(this) }>
39 38
             <Text style={styles.button}>Push Plain Screen</Text>
40 39
           </TouchableOpacity>
@@ -54,7 +53,6 @@ export default class StyledScreen extends Component {
54 53
           <TouchableOpacity onPress={ this.onSetTitleImagePress.bind(this) }>
55 54
             <Text style={styles.button}>Set Title Image</Text>
56 55
           </TouchableOpacity>
57
-
58 56
         </View>
59 57
 
60 58
       </ScrollView>
@@ -62,7 +60,7 @@ export default class StyledScreen extends Component {
62 60
   }
63 61
   onNavigatorEvent(event) {
64 62
     if (event.id == 'compose') {
65
-      AlertIOS.alert('NavBar', 'Compose button pressed');
63
+      Alert.alert('NavBar', 'Compose button pressed');
66 64
     }
67 65
   }
68 66
   onPushPress() {
@@ -82,15 +80,21 @@ export default class StyledScreen extends Component {
82 80
   }
83 81
   
84 82
   onSetSubtitlePress() {
85
-    this.props.navigator.setTitle({
86
-      title: 'title',
87
-      subtitle: 'subtitle',
88
-      navigatorStyle: {
89
-        navBarSubtitleTextColor: '#ff00ff',
90
-        navBarTextColor: '#ffff00'
91
-        
92
-      }
93
-    })
83
+    if (Platform.OS === 'android') {
84
+      this.props.navigator.setSubTitle({
85
+        subtitle: 'Subtitle'
86
+      });
87
+    } else {
88
+      this.props.navigator.setTitle({
89
+        title: 'title',
90
+        subtitle: 'subtitle',
91
+        navigatorStyle: {
92
+          navBarSubtitleTextColor: '#ff00ff',
93
+          navBarTextColor: '#ffff00'
94
+
95
+        }
96
+      })
97
+    }
94 98
   }
95 99
   
96 100
   onSetTitleImagePress() {
@@ -103,6 +107,10 @@ export default class StyledScreen extends Component {
103 107
 }
104 108
 
105 109
 const styles = StyleSheet.create({
110
+  container: {
111
+    flex: 1,
112
+    backgroundColor: 'white'
113
+  },
106 114
   button: {
107 115
     textAlign: 'center',
108 116
     fontSize: 18,

+ 6
- 1
example/src/screens/ThirdTabScreen.js View File

@@ -19,7 +19,7 @@ export default class ThirdTabScreen extends Component {
19 19
   }
20 20
   render() {
21 21
     return (
22
-      <View style={{flex: 1, padding: 20}}>
22
+      <View style={styles.container}>
23 23
 
24 24
         <TouchableOpacity onPress={ this.onPushPress.bind(this) }>
25 25
           <Text style={styles.button}>Push Plain Screen</Text>
@@ -86,6 +86,11 @@ export default class ThirdTabScreen extends Component {
86 86
 }
87 87
 
88 88
 const styles = StyleSheet.create({
89
+  container: {
90
+    flex: 1,
91
+    padding: 20,
92
+    backgroundColor: 'white'
93
+  },
89 94
   button: {
90 95
     textAlign: 'center',
91 96
     fontSize: 18,

+ 2
- 0
example/src/screens/index.android.js View File

@@ -6,6 +6,7 @@ import ThirdTabScreen from './ThirdTabScreen';
6 6
 import PushedScreen from './PushedScreen';
7 7
 import StyledScreen from './StyledScreen';
8 8
 import SideMenu from './SideMenu';
9
+import ModalScreen from './ModalScreen';
9 10
 
10 11
 // register all screens of the app (including internal ones)
11 12
 export function registerScreens() {
@@ -14,5 +15,6 @@ export function registerScreens() {
14 15
   Navigation.registerComponent('example.ThirdTabScreen', () => ThirdTabScreen);
15 16
   Navigation.registerComponent('example.PushedScreen', () => PushedScreen);
16 17
   Navigation.registerComponent('example.StyledScreen', () => StyledScreen);
18
+  Navigation.registerComponent('example.ModalScreen', () => ModalScreen);
17 19
   Navigation.registerComponent('example.SideMenu', () => SideMenu);
18 20
 }

+ 3
- 3
example/src/screens/index.ios.js View File

@@ -5,10 +5,10 @@ import SecondTabScreen from './SecondTabScreen';
5 5
 import ThirdTabScreen from './ThirdTabScreen';
6 6
 import PushedScreen from './PushedScreen';
7 7
 import StyledScreen from './StyledScreen';
8
+import SideMenu from './SideMenu';
8 9
 import ModalScreen from './ModalScreen';
9
-import LightBoxScreen from './LightBoxScreen';
10 10
 import NotificationScreen from './NotificationScreen';
11
-import SideMenu from './SideMenu';
11
+import LightBoxScreen from './LightBoxScreen';
12 12
 
13 13
 // register all screens of the app (including internal ones)
14 14
 export function registerScreens() {
@@ -18,7 +18,7 @@ export function registerScreens() {
18 18
   Navigation.registerComponent('example.PushedScreen', () => PushedScreen);
19 19
   Navigation.registerComponent('example.StyledScreen', () => StyledScreen);
20 20
   Navigation.registerComponent('example.ModalScreen', () => ModalScreen);
21
-  Navigation.registerComponent('example.LightBoxScreen', () => LightBoxScreen);
22 21
   Navigation.registerComponent('example.NotificationScreen', () => NotificationScreen);
23 22
   Navigation.registerComponent('example.SideMenu', () => SideMenu);
23
+  Navigation.registerComponent('example.LightBoxScreen', () => LightBoxScreen);
24 24
 }