Browse Source

Change buttons on tab selected

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

+ 32
- 1
example-redux/src/screens/FirstTabScreen.js View File

56
         break;
56
         break;
57
 
57
 
58
       case 'selectedTabChanged':
58
       case 'selectedTabChanged':
59
-        console.log('selectedTabChanged ' + event.position);
59
+        this.onTabSelected(event.position);
60
         break;
60
         break;
61
 
61
 
62
       default:
62
       default:
65
     }
65
     }
66
   }
66
   }
67
 
67
 
68
+  onTabSelected(position) {
69
+    console.log('selectedTabChanged ' + position);
70
+    let rightButtons;
71
+
72
+    switch(position) {
73
+      case 0:
74
+        rightButtons = [
75
+          {
76
+            id: 'account',
77
+            icon: require('../../img/ic_account_box_.png')
78
+          }
79
+        ];
80
+        break;
81
+
82
+      case 1:
83
+        rightButtons = [
84
+          {
85
+            id: 'account',
86
+            icon: require('../../img/ic_add_alert.png')
87
+          }
88
+        ];
89
+        break;
90
+
91
+      default:
92
+        rightButtons = [];
93
+        break;
94
+    }
95
+
96
+    this.props.navigator.setButtons({rightButtons});
97
+  }
98
+
68
   render() {
99
   render() {
69
     return (
100
     return (
70
       <View style={{flex: 1, padding: 20}}>
101
       <View style={{flex: 1, padding: 20}}>