Bläddra i källkod

Add test methods to FirstTabScreen

Guy Carmeli 8 år sedan
förälder
incheckning
6947710316
2 ändrade filer med 13 tillägg och 4 borttagningar
  1. 1
    1
      example-redux/src/app.js
  2. 12
    3
      example-redux/src/screens/FirstTabScreen.js

+ 1
- 1
example-redux/src/app.js Visa fil

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

+ 12
- 3
example-redux/src/screens/FirstTabScreen.js Visa fil

@@ -9,8 +9,9 @@ import {
9 9
 } from 'react-native';
10 10
 import {connect} from 'react-redux';
11 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 16
 // this is a traditional React component connected to the redux store
16 17
 class FirstTabScreen extends Component {
@@ -83,6 +84,10 @@ class FirstTabScreen extends Component {
83 84
           <Text style={styles.button}>Toggle NavBar</Text>
84 85
         </TouchableOpacity>
85 86
 
87
+        <TouchableOpacity onPress={ this.onSetTitlePress.bind(this) }>
88
+          <Text style={styles.button}>Set Title</Text>
89
+        </TouchableOpacity>
90
+
86 91
         <Text style={{fontWeight: '500'}}>String prop: {this.props.str}</Text>
87 92
         <Text style={{fontWeight: '500'}}>Number prop: {this.props.num}</Text>
88 93
         <Text style={{fontWeight: '500'}}>Object prop: {this.props.obj.str}</Text>
@@ -134,12 +139,16 @@ class FirstTabScreen extends Component {
134 139
   }
135 140
 
136 141
   onToggleNavBarPress() {
137
-    navBarVisiable = !navBarVisiable;
142
+    topBarVisible = !topBarVisible;
138 143
     this.props.navigator.toggleNavBar({
139
-      to: navBarVisiable ? 'shown' : 'hidden',
144
+      to: topBarVisible ? 'shown' : 'hidden',
140 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 154
 const styles = StyleSheet.create({