-
Notifications
You must be signed in to change notification settings - Fork 427
/
Copy pathCommonConfirmModal.js
113 lines (103 loc) · 4.12 KB
/
CommonConfirmModal.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/**
* Created by guoshuyu on 2017/11/12.
*/
import React, {Component} from 'react';
import {
Text,
View,
TouchableOpacity,
} from 'react-native';
import PropTypes from 'prop-types';
import styles, {screenWidth, screenHeight} from "../../style/index"
import * as Constant from "../../style/constant"
import I18n from '../../style/i18n'
import Modal from './ModalBox';
import {Actions} from "react-native-router-flux";
/**
* 确认弹出模态框
*/
class CommonConfirmModal extends Component {
constructor(props) {
super(props);
this.onClose = this.onClose.bind(this);
this.text = this.props.text;
}
componentDidMount() {
if (this.refs.loginModal)
this.refs.loginModal.open();
}
componentWillUnmount() {
}
onClose() {
Actions.pop();
return true;
}
render() {
let width = screenWidth - 100;
return (
<Modal ref={"loginModal"}
style={[{height: screenHeight, width: screenWidth, backgroundColor: "#F0000000"}]}
position={"center"}
onClosed={this.onClose}
backdrop={this.props.backExit}
backButtonClose={false}
swipeToClose={this.props.backExit}
backdropOpacity={0.8}>
<View style={[styles.centered, {flex: 1,}]}>
<View style={[{borderRadius: 3, backgroundColor: Constant.white}, styles.centered]}>
<View style={[styles.flexDirectionRowNotFlex, {marginTop: 10, paddingBottom: 10},
{backgroundColor: Constant.white, width: width}, styles.centered]}>
<Text
style={[styles.normalText, {fontWeight: 'bold'}]}>{this.props.titleText}</Text>
</View>
<View style={[{
marginHorizontal: Constant.normalMarginEdge,
}]}>
<Text
style={[styles.normalText, {
padding: Constant.normalMarginEdge,
}]}>{this.props.text}</Text>
</View>
<View
style={[styles.flexDirectionRowNotFlex, {
paddingVertical: Constant.normalMarginEdge,
width: width
}]}>
<TouchableOpacity
style={[styles.flex, styles.centerH, {borderBottomLeftRadius: 3,}]}
onPress={() => {
Actions.pop();
}}>
<Text style={[styles.subNormalText, {fontWeight: 'bold'}]}>{I18n("cancel")}</Text>
</TouchableOpacity>
<TouchableOpacity
style={[styles.flex, styles.centerH, {
borderLeftWidth: 1,
borderLeftColor: Constant.miWhite,
borderBottomRightRadius: 3,
},]}
onPress={() => {
if (this.text && this.text.trim().length > 0) {
Actions.pop();
this.props.textConfirm && this.props.textConfirm(this.text);
}
}}>
<Text style={[styles.normalText, {fontWeight: 'bold'}]}>{I18n("ok")}</Text>
</TouchableOpacity>
</View>
</View>
</View>
</Modal>
)
}
}
CommonConfirmModal.propTypes = {
text: PropTypes.string,
titleText: PropTypes.string,
textConfirm: PropTypes.func,
};
CommonConfirmModal.defaultProps = {
text: '',
titleText: '',
};
export default CommonConfirmModal;