|
@@ -1,52 +1,53 @@
|
1
|
1
|
const React = require('react');
|
2
|
|
-const { PureComponent } = require('react');
|
3
|
|
-
|
4
|
2
|
const { Text, Button, View } = require('react-native');
|
5
|
3
|
const { Navigation } = require('react-native-navigation');
|
6
|
|
-
|
7
|
4
|
const testIDs = require('../testIDs');
|
8
|
5
|
|
9
|
|
-class Alert extends PureComponent {
|
|
6
|
+function Alert({ componentId, title, message }) {
|
|
7
|
+ const onCLickOk = () => Navigation.dismissOverlay(componentId);
|
10
|
8
|
|
11
|
|
- render() {
|
12
|
|
- return (
|
13
|
|
- <View style={styles.root} key={'overlay'}>
|
14
|
|
- <View style={styles.alert}>
|
15
|
|
- <Text style={styles.h1} testID={testIDs.DIALOG_HEADER}>{this.props.title}</Text>
|
16
|
|
- <View style={styles.buttonContainer}>
|
17
|
|
- <Button title='OK' testID={testIDs.OK_BUTTON} onPress={() => this.onCLickOk()} />
|
18
|
|
- </View>
|
19
|
|
- </View>
|
|
9
|
+ return (
|
|
10
|
+ <View style={styles.root} key={'overlay'}>
|
|
11
|
+ <View style={styles.alert}>
|
|
12
|
+ <Text style={styles.title} testID={testIDs.DIALOG_HEADER}>{title}</Text>
|
|
13
|
+ <Text style={styles.message}>{message}</Text>
|
|
14
|
+ <Button title='OK' testID={testIDs.OK_BUTTON} onPress={onCLickOk} />
|
20
|
15
|
</View>
|
21
|
|
- );
|
22
|
|
- }
|
23
|
|
-
|
24
|
|
- onCLickOk() {
|
25
|
|
- Navigation.dismissOverlay(this.props.componentId);
|
26
|
|
- }
|
|
16
|
+ </View>
|
|
17
|
+ );
|
27
|
18
|
}
|
28
|
19
|
|
29
|
20
|
const styles = {
|
30
|
21
|
root: {
|
|
22
|
+ flex: 1,
|
31
|
23
|
justifyContent: 'center',
|
32
|
24
|
alignItems: 'center',
|
33
|
|
- flex: 1
|
|
25
|
+ backgroundColor: '#00000050',
|
34
|
26
|
},
|
35
|
27
|
alert: {
|
36
|
28
|
alignItems: 'center',
|
37
|
|
- backgroundColor: '#efefef',
|
|
29
|
+ backgroundColor: 'whitesmoke',
|
38
|
30
|
width: 250,
|
39
|
|
- height: 100,
|
40
|
|
- elevation: 4
|
|
31
|
+ elevation: 4,
|
|
32
|
+ padding: 16
|
41
|
33
|
},
|
42
|
|
- buttonContainer: {
|
43
|
|
- width: '50%',
|
44
|
|
- alignItems: 'center'
|
45
|
|
- },
|
46
|
|
- h1: {
|
|
34
|
+ title: {
|
47
|
35
|
fontSize: 18,
|
48
|
|
- margin: 10
|
|
36
|
+ },
|
|
37
|
+ message: {
|
|
38
|
+ marginVertical: 8
|
49
|
39
|
}
|
50
|
40
|
};
|
51
|
41
|
|
52
|
|
-module.exports = Alert;
|
|
42
|
+Alert.options = (props) => {
|
|
43
|
+ return ({
|
|
44
|
+ layout: {
|
|
45
|
+ componentBackgroundColor: 'transparent'
|
|
46
|
+ },
|
|
47
|
+ overlay: {
|
|
48
|
+ interceptTouchOutside: true
|
|
49
|
+ }
|
|
50
|
+ });
|
|
51
|
+}
|
|
52
|
+
|
|
53
|
+module.exports = Alert;
|