瀏覽代碼

Add snackbar to example project

Guy Carmeli 8 年之前
父節點
當前提交
3c0fb47155
共有 1 個文件被更改,包括 19 次插入1 次删除
  1. 19
    1
      example-redux/src/screens/FirstTabScreen.js

+ 19
- 1
example-redux/src/screens/FirstTabScreen.js 查看文件

@@ -5,7 +5,8 @@ import {
5 5
   ScrollView,
6 6
   TouchableOpacity,
7 7
   StyleSheet,
8
-  Alert
8
+  Alert,
9
+  Platform
9 10
 } from 'react-native';
10 11
 import {connect} from 'react-redux';
11 12
 import * as counterActions from '../reducers/counter/actions';
@@ -131,6 +132,13 @@ class FirstTabScreen extends Component {
131 132
           <Text style={styles.button}>Toggle NavBar</Text>
132 133
         </TouchableOpacity>
133 134
 
135
+        {
136
+          Platform.OS === 'android' ?
137
+          <TouchableOpacity onPress={ this.onShowSnackbarPress.bind(this) }>
138
+            <Text style={styles.button}>Show Snackbar</Text>
139
+          </TouchableOpacity> : false
140
+        }
141
+
134 142
         <TouchableOpacity onPress={ this.onSetTitlePress.bind(this) }>
135 143
           <Text style={styles.button}>Set Title</Text>
136 144
         </TouchableOpacity>
@@ -210,6 +218,16 @@ class FirstTabScreen extends Component {
210 218
     });
211 219
   }
212 220
 
221
+  onShowSnackbarPress() {
222
+    this.props.navigator.showSnackbar({
223
+      text: 'Counter: ' + this.props.counter.count,
224
+      actionText: 'Undo',
225
+      actionColor: '#ff0000',
226
+      actionId: 'undo',
227
+      duration: 'indefinite'
228
+    });
229
+  }
230
+
213 231
   onSetTitlePress() {
214 232
     this.props.navigator.setTitle(_.random(0, 100).toString());
215 233
   }