Browse Source

Add toggle navBar to example-redux

Guy Carmeli 8 years ago
parent
commit
cc425f0c72
1 changed files with 14 additions and 0 deletions
  1. 14
    0
      example-redux/src/screens/FirstTabScreen.js

+ 14
- 0
example-redux/src/screens/FirstTabScreen.js View File

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
 
12
 
13
+let navBarVisiable = true;
14
+
13
 // this is a traditional React component connected to the redux store
15
 // this is a traditional React component connected to the redux store
14
 class FirstTabScreen extends Component {
16
 class FirstTabScreen extends Component {
15
   static navigatorStyle = {
17
   static navigatorStyle = {
77
           <Text style={styles.button}>Modal Screen</Text>
79
           <Text style={styles.button}>Modal Screen</Text>
78
         </TouchableOpacity>
80
         </TouchableOpacity>
79
 
81
 
82
+        <TouchableOpacity onPress={ this.onToggleNavBarPress.bind(this) }>
83
+          <Text style={styles.button}>Toggle NavBar</Text>
84
+        </TouchableOpacity>
85
+
80
         <Text style={{fontWeight: '500'}}>String prop: {this.props.str}</Text>
86
         <Text style={{fontWeight: '500'}}>String prop: {this.props.str}</Text>
81
         <Text style={{fontWeight: '500'}}>Number prop: {this.props.num}</Text>
87
         <Text style={{fontWeight: '500'}}>Number prop: {this.props.num}</Text>
82
         <Text style={{fontWeight: '500'}}>Object prop: {this.props.obj.str}</Text>
88
         <Text style={{fontWeight: '500'}}>Object prop: {this.props.obj.str}</Text>
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
 const styles = StyleSheet.create({
145
 const styles = StyleSheet.create({