Browse Source

Add test methods to FirstTabScreen

Guy Carmeli 8 years ago
parent
commit
6947710316
2 changed files with 13 additions and 4 deletions
  1. 1
    1
      example-redux/src/app.js
  2. 12
    3
      example-redux/src/screens/FirstTabScreen.js

+ 1
- 1
example-redux/src/app.js View File

37
       case 'login':
37
       case 'login':
38
         Navigation.startSingleScreenApp({
38
         Navigation.startSingleScreenApp({
39
           screen: {
39
           screen: {
40
-            screen: 'example.ListScreen',
40
+            screen: 'example.FirstTabScreen',
41
             title: 'Login',
41
             title: 'Login',
42
             navigatorStyle: {}
42
             navigatorStyle: {}
43
           },
43
           },

+ 12
- 3
example-redux/src/screens/FirstTabScreen.js View File

9
 } from 'react-native';
9
 } from 'react-native';
10
 import {connect} from 'react-redux';
10
 import {connect} from 'react-redux';
11
 import * as counterActions from '../reducers/counter/actions';
11
 import * as counterActions from '../reducers/counter/actions';
12
+import _ from 'lodash';
12
 
13
 
13
-let navBarVisiable = true;
14
+let topBarVisible = true;
14
 
15
 
15
 // this is a traditional React component connected to the redux store
16
 // this is a traditional React component connected to the redux store
16
 class FirstTabScreen extends Component {
17
 class FirstTabScreen extends Component {
83
           <Text style={styles.button}>Toggle NavBar</Text>
84
           <Text style={styles.button}>Toggle NavBar</Text>
84
         </TouchableOpacity>
85
         </TouchableOpacity>
85
 
86
 
87
+        <TouchableOpacity onPress={ this.onSetTitlePress.bind(this) }>
88
+          <Text style={styles.button}>Set Title</Text>
89
+        </TouchableOpacity>
90
+
86
         <Text style={{fontWeight: '500'}}>String prop: {this.props.str}</Text>
91
         <Text style={{fontWeight: '500'}}>String prop: {this.props.str}</Text>
87
         <Text style={{fontWeight: '500'}}>Number prop: {this.props.num}</Text>
92
         <Text style={{fontWeight: '500'}}>Number prop: {this.props.num}</Text>
88
         <Text style={{fontWeight: '500'}}>Object prop: {this.props.obj.str}</Text>
93
         <Text style={{fontWeight: '500'}}>Object prop: {this.props.obj.str}</Text>
134
   }
139
   }
135
 
140
 
136
   onToggleNavBarPress() {
141
   onToggleNavBarPress() {
137
-    navBarVisiable = !navBarVisiable;
142
+    topBarVisible = !topBarVisible;
138
     this.props.navigator.toggleNavBar({
143
     this.props.navigator.toggleNavBar({
139
-      to: navBarVisiable ? 'shown' : 'hidden',
144
+      to: topBarVisible ? 'shown' : 'hidden',
140
       animated: true
145
       animated: true
141
     });
146
     });
142
   }
147
   }
148
+
149
+  onSetTitlePress() {
150
+    this.props.navigator.setTitle(_.random(0, 100).toString());
151
+  }
143
 }
152
 }
144
 
153
 
145
 const styles = StyleSheet.create({
154
 const styles = StyleSheet.create({