Browse Source

Add snackbar to example project

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

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

5
   ScrollView,
5
   ScrollView,
6
   TouchableOpacity,
6
   TouchableOpacity,
7
   StyleSheet,
7
   StyleSheet,
8
-  Alert
8
+  Alert,
9
+  Platform
9
 } from 'react-native';
10
 } from 'react-native';
10
 import {connect} from 'react-redux';
11
 import {connect} from 'react-redux';
11
 import * as counterActions from '../reducers/counter/actions';
12
 import * as counterActions from '../reducers/counter/actions';
131
           <Text style={styles.button}>Toggle NavBar</Text>
132
           <Text style={styles.button}>Toggle NavBar</Text>
132
         </TouchableOpacity>
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
         <TouchableOpacity onPress={ this.onSetTitlePress.bind(this) }>
142
         <TouchableOpacity onPress={ this.onSetTitlePress.bind(this) }>
135
           <Text style={styles.button}>Set Title</Text>
143
           <Text style={styles.button}>Set Title</Text>
136
         </TouchableOpacity>
144
         </TouchableOpacity>
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
   onSetTitlePress() {
231
   onSetTitlePress() {
214
     this.props.navigator.setTitle(_.random(0, 100).toString());
232
     this.props.navigator.setTitle(_.random(0, 100).toString());
215
   }
233
   }