Bläddra i källkod

Update example-redux

Guy Carmeli 8 år sedan
förälder
incheckning
7ce28fd2be

+ 6
- 1
example-redux/src/screens/FirstTabScreen.js Visa fil

@@ -21,7 +21,8 @@ class FirstTabScreen extends Component {
21 21
     navigationBarColor: '#303F9F',
22 22
     tabSelectedTextColor: '#FFA000',
23 23
     tabNormalTextColor: '#FFC107',
24
-    tabIndicatorColor: '#FFA000'
24
+    tabIndicatorColor: '#FFA000',
25
+    drawUnderTabBar: true
25 26
   };
26 27
 
27 28
   static navigatorButtons = {
@@ -54,6 +55,10 @@ class FirstTabScreen extends Component {
54 55
         Alert.alert('NavBar', 'Add button pressed');
55 56
         break;
56 57
 
58
+      case 'selectedTabChanged':
59
+        console.log('selectedTabChanged ' + event.position);
60
+        break;
61
+
57 62
       default:
58 63
         console.log('Unhandled event ' + event.id);
59 64
         break;

+ 13
- 1
example-redux/src/screens/PushedScreen.js Visa fil

@@ -12,6 +12,7 @@ import {connect} from 'react-redux';
12 12
 import * as counterActions from '../reducers/counter/actions';
13 13
 
14 14
 const leftButtons = ['back', 'cancel', 'accept', 'sideMenu'];
15
+let bottomTabsVisible = true;
15 16
 
16 17
 // this is a traditional React component connected to the redux store
17 18
 class PushedScreen extends Component {
@@ -53,7 +54,6 @@ class PushedScreen extends Component {
53 54
   }
54 55
 
55 56
   onNavigatorEvent(event) {
56
-    console.log('onNavigatorEvent ' + event.id);
57 57
     switch (event.id) {
58 58
       case 'cancel':
59 59
         Alert.alert('NavBar', 'Cancel button pressed');
@@ -109,6 +109,10 @@ class PushedScreen extends Component {
109 109
           <Text style={styles.button}>Change Left Button</Text>
110 110
         </TouchableOpacity>
111 111
 
112
+        <TouchableOpacity onPress={ this.onToggleBottomTabsPress.bind(this) }>
113
+          <Text style={styles.button}>Toggle BottomTabs</Text>
114
+        </TouchableOpacity>
115
+
112 116
         <TextInput style={{height: 40, borderColor: 'gray', borderWidth: 1}}/>
113 117
 
114 118
         <Text style={{fontWeight: '500'}}>String prop: {this.props.str}</Text>
@@ -206,6 +210,14 @@ class PushedScreen extends Component {
206 210
     this.currentBackButton += 1;
207 211
     this.currentBackButton = this.currentBackButton % 4;
208 212
   }
213
+
214
+  onToggleBottomTabsPress() {
215
+    this.props.navigator.toggleTabs({
216
+      to: bottomTabsVisible ? 'shown' : 'hidden',
217
+      animated: true
218
+    });
219
+    bottomTabsVisible = !bottomTabsVisible;
220
+  }
209 221
 }
210 222
 
211 223
 const styles = StyleSheet.create({