Bläddra i källkod

Add toggle navBar to example-redux

Guy Carmeli 8 år sedan
förälder
incheckning
cc425f0c72
1 ändrade filer med 14 tillägg och 0 borttagningar
  1. 14
    0
      example-redux/src/screens/FirstTabScreen.js

+ 14
- 0
example-redux/src/screens/FirstTabScreen.js Visa fil

@@ -10,6 +10,8 @@ import {
10 10
 import { connect } from 'react-redux';
11 11
 import * as counterActions from '../reducers/counter/actions';
12 12
 
13
+let navBarVisiable = true;
14
+
13 15
 // this is a traditional React component connected to the redux store
14 16
 class FirstTabScreen extends Component {
15 17
   static navigatorStyle = {
@@ -77,6 +79,10 @@ class FirstTabScreen extends Component {
77 79
           <Text style={styles.button}>Modal Screen</Text>
78 80
         </TouchableOpacity>
79 81
 
82
+        <TouchableOpacity onPress={ this.onToggleNavBarPress.bind(this) }>
83
+          <Text style={styles.button}>Toggle NavBar</Text>
84
+        </TouchableOpacity>
85
+
80 86
         <Text style={{fontWeight: '500'}}>String prop: {this.props.str}</Text>
81 87
         <Text style={{fontWeight: '500'}}>Number prop: {this.props.num}</Text>
82 88
         <Text style={{fontWeight: '500'}}>Object prop: {this.props.obj.str}</Text>
@@ -126,6 +132,14 @@ class FirstTabScreen extends Component {
126 132
       }
127 133
     });
128 134
   }
135
+
136
+  onToggleNavBarPress() {
137
+    navBarVisiable = !navBarVisiable;
138
+    this.props.navigator.toggleNavBar({
139
+      to: navBarVisiable ? 'shown' : 'hidden',
140
+      animated: true
141
+    });
142
+  }
129 143
 }
130 144
 
131 145
 const styles = StyleSheet.create({