Преглед изворни кода

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

+ 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');