ソースを参照

Added Toast component to playground

While it's not used at the moment, we can use it at some point in Overlay e2e or for debugging purposes.
Guy Carmeli 4 年 前
コミット
4e0d6be997
共有5 個のファイルを変更した70 個の追加1 個の削除を含む
  1. 2
    1
      playground/src/commons/Colors.js
  2. 1
    0
      playground/src/screens/Alert.js
  3. 1
    0
      playground/src/screens/Screens.js
  4. 65
    0
      playground/src/screens/Toast.js
  5. 1
    0
      playground/src/screens/index.js

+ 2
- 1
playground/src/commons/Colors.js ファイルの表示

@@ -1,5 +1,6 @@
1 1
 module.exports = {
2 2
   background: '#e8e8e8',
3 3
   primary: '#5847ff',
4
-  secondary: '#FFC249'
4
+  secondary: '#FFC249',
5
+  accent: '#65C888'
5 6
 }

+ 1
- 0
playground/src/screens/Alert.js ファイルの表示

@@ -33,6 +33,7 @@ const styles = {
33 33
   },
34 34
   title: {
35 35
     fontSize: 18,
36
+    alignSelf: 'flex-start'
36 37
   },
37 38
   message: {
38 39
     marginVertical: 8

+ 1
- 0
playground/src/screens/Screens.js ファイルの表示

@@ -104,6 +104,7 @@ module.exports = {
104 104
   StatusBarOptions,
105 105
   StatusBarFirstTab,
106 106
   TopBarBackground: 'TopBarBackground',
107
+  Toast: 'Toast',
107 108
   FlatListScreen: 'FlatListScreen',
108 109
   Alert: 'Alert',
109 110
   Orientation: 'Orientation',

+ 65
- 0
playground/src/screens/Toast.js ファイルの表示

@@ -0,0 +1,65 @@
1
+const React = require('react');
2
+const { View, Text, StyleSheet, TouchableOpacity } = require('react-native');
3
+const Colors = require('../commons/Colors');
4
+const Navigation = require('../services/Navigation');
5
+
6
+const Toast = function ({componentId}) {
7
+  return (
8
+    <View style={styles.root}>
9
+      <View style={styles.toast}>
10
+        <Text style={styles.text}>This a very important message!</Text>
11
+        <TouchableOpacity style={styles.button} onPress={() => Navigation.dismissOverlay(componentId)}>
12
+          <Text style={styles.buttonText}>OK</Text>
13
+        </TouchableOpacity>
14
+      </View>
15
+    </View>
16
+  )
17
+}
18
+
19
+const styles = StyleSheet.create({
20
+  root: {
21
+    flex: 1,
22
+    flexDirection: 'column-reverse',
23
+    backgroundColor: 0x3e434aa1
24
+    // backgroundColor: 'red'
25
+  },
26
+  toast: {
27
+    elevation: 2,
28
+    flexDirection: 'row',
29
+    height: 40,
30
+    margin: 16,
31
+    borderRadius: 20,
32
+    backgroundColor: Colors.accent,
33
+    alignItems: 'center',
34
+    justifyContent: 'space-between'
35
+  },
36
+  text: {
37
+    color: 'white',
38
+    fontSize: 16,
39
+    marginLeft: 16
40
+  },
41
+  button: {
42
+    marginRight: 16
43
+  },
44
+  buttonText: {
45
+    color: 'white',
46
+    fontSize: 16,
47
+    fontWeight: 'bold'
48
+  }
49
+});
50
+
51
+Toast.options = {
52
+  statusBar: {
53
+    drawBehind: true,
54
+    backgroundColor: 0x3e434aa1,
55
+    style: 'light'
56
+  },
57
+  layout: {
58
+    componentBackgroundColor: 'transparent'
59
+  },
60
+  overlay: {
61
+    interceptTouchOutside: false
62
+  }
63
+}
64
+
65
+module.exports = Toast;

+ 1
- 0
playground/src/screens/index.js ファイルの表示

@@ -44,6 +44,7 @@ function registerScreens() {
44 44
   Navigation.registerComponent(Screens.StatusBarOptions, () => require('./StatusBarOptionsScreen'));
45 45
   Navigation.registerComponent(Screens.StatusBarFirstTab, () => require('./StatusBarFirstTab'));
46 46
   Navigation.registerComponent(Screens.TopBarBackground, () => require('../components/TopBarBackground'));
47
+  Navigation.registerComponent(Screens.Toast, () => require('./Toast'));
47 48
 
48 49
   const { ContextProvider } = require('../context');
49 50
   const ContextScreen = require('./ContextScreen');