SelectModal.js
2.64 KB
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
import React, { Component } from 'react';
import {
View,
Text,
StyleSheet,
TouchableOpacity,
Image,
Modal
} from 'react-native';
import { width, height } from "../utils/getSize";
export default class SelectModal extends Component {
render(){
return(
<Modal
animationType='fade' // 淡入淡出
transparent={true} // 透明
visible={this.props.isShow} // 根据isModal决定是否显示
onRequestClose ={() => {
this.props.modalClose&&this.props.modalClose();
}}>
<View style={styles.modalContainer}>
<View style={styles.modalLayout}>
<Text style={styles.modalTitle}>{this.props.modalTitle}</Text>
<TouchableOpacity
activeOpacity={0.8}
style={styles.modalConfirm}
onPress={()=>{
this.props.confirmPress&&this.props.confirmPress();
}}>
<Text style={styles.confirmText}>是</Text>
</TouchableOpacity>
<TouchableOpacity
activeOpacity={0.8}
style={[styles.modalConfirm,{borderBottomColor: 'transparent',}]}
onPress={()=>{
this.props.cancelPress&&this.props.cancelPress();
}}>
<Text style={styles.confirmText}>否</Text>
</TouchableOpacity>
</View>
</View>
</Modal>
)
}
}
const styles = StyleSheet.create({
modalContainer:{
flex:1,
backgroundColor:'rgba(0, 0, 0, 0.5)',
alignItems:'center',
justifyContent:'center'
},
modalLayout:{
width:width * 0.8,
backgroundColor:'#ffffff',
alignItems:'center',
borderRadius:3,
},
modalTitle:{
fontSize:18,
fontWeight:'bold',
marginTop:20
},
modalConfirm:{
paddingTop:20,
borderWidth: 1,
borderBottomWidth:1,
borderRightColor: 'transparent',
borderBottomColor: '#dddddd',
borderTopColor: 'transparent',
borderLeftColor: 'transparent',
flexDirection:'row',
width:width * 0.8,
justifyContent:'center',
alignItems:'center',
paddingBottom:20,
},
confirmText:{
fontSize:16,
textAlign:'center'
}
})