|
|
/*
|
|
|
* @Author: QC.L
|
|
|
* @Date: 2018-09-11 16:07:56
|
|
|
* @Last Modified by: QC.L
|
|
|
* @Last Modified time: 2018-09-11 16:14:40
|
|
|
* @Description 弹框 Alert 效果
|
|
|
*/
|
|
|
'use strict';
|
|
|
|
|
|
import React from 'react';
|
|
|
import ReactNative from 'react-native';
|
|
|
|
|
|
const {
|
|
|
StyleSheet,
|
|
|
Text,
|
|
|
View,
|
|
|
Dimensions,
|
|
|
TouchableOpacity,
|
|
|
Modal,
|
|
|
} = ReactNative;
|
|
|
|
|
|
/**
|
|
|
* 参数1: showStatus 值 sure/cancel
|
|
|
* 参数2: handleAction 要处理的事件
|
|
|
*/
|
|
|
function TipsAlertItem(props) {
|
|
|
return (
|
|
|
<TouchableOpacity style={styles.click} onPress={() => {
|
|
|
props.handleAction && props.handleAction();
|
|
|
}}>
|
|
|
<Text style={styles[props.showStatus]}>{props.children}</Text>
|
|
|
</TouchableOpacity>
|
|
|
);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 参数1: isShow true 显示 false 隐藏
|
|
|
* 参数2: tips 为标题
|
|
|
*/
|
|
|
class TipsAlert extends React.Component {
|
|
|
constructor(props) {
|
|
|
super(props);
|
|
|
this._renderChildren = this._renderChildren.bind(this);
|
|
|
}
|
|
|
|
|
|
_renderChildren(children) {
|
|
|
return children.map((element, index) => {
|
|
|
if (index === children.length) return element
|
|
|
return (
|
|
|
<React.Fragment>
|
|
|
{element}
|
|
|
<View style={{width: 0.5, height: '100%', backgroundColor: '#e0e0e0'}}></View>
|
|
|
</React.Fragment>
|
|
|
)
|
|
|
});
|
|
|
}
|
|
|
|
|
|
render() {
|
|
|
let { children } = this.props;
|
|
|
return (
|
|
|
<Modal
|
|
|
visible={this.props.isShow}
|
|
|
animationType={'none'}
|
|
|
transparent={true}
|
|
|
onRequestClose={() => {}}>
|
|
|
<View style={styles.modalContainer}>
|
|
|
<View style={styles.modalView}>
|
|
|
<View style={styles.confirmTitleContainer}>
|
|
|
<Text style={styles.confirmTitle}>{this.props.tips}</Text>
|
|
|
</View>
|
|
|
<View style={{width: '100%', height: 0.5, backgroundColor: '#e0e0e0'}}/>
|
|
|
<View style={styles.confirmBtnContainer}>
|
|
|
{this._renderChildren(children)}
|
|
|
</View>
|
|
|
</View>
|
|
|
</View>
|
|
|
</Modal>
|
|
|
);
|
|
|
}
|
|
|
};
|
|
|
|
|
|
export { TipsAlert, TipsAlertItem };
|
|
|
|
|
|
let {width, height} = Dimensions.get('window');
|
|
|
|
|
|
let styles = StyleSheet.create({
|
|
|
modalContainer: {
|
|
|
flex: 1,
|
|
|
width: width,
|
|
|
height: height,
|
|
|
alignItems: 'center',
|
|
|
justifyContent: 'center',
|
|
|
backgroundColor: 'rgba(0, 0, 0, 0.4)',
|
|
|
},
|
|
|
modalView: {
|
|
|
width: 270,
|
|
|
borderRadius: 5,
|
|
|
alignItems: 'center',
|
|
|
backgroundColor: '#ffffff',
|
|
|
},
|
|
|
confirmBtnContainer: {
|
|
|
width: '100%',
|
|
|
height: 44.5,
|
|
|
flexDirection: 'row',
|
|
|
justifyContent: 'space-between',
|
|
|
},
|
|
|
confirmTitleContainer: {
|
|
|
alignItems: 'center'
|
|
|
},
|
|
|
confirmTitle: {
|
|
|
paddingTop: 20,
|
|
|
paddingLeft: 30,
|
|
|
paddingRight: 30,
|
|
|
paddingBottom: 20,
|
|
|
color: '#444444',
|
|
|
fontSize: 14,
|
|
|
lineHeight: 24,
|
|
|
textAlign: 'center',
|
|
|
letterSpacing: -0.09,
|
|
|
fontFamily: 'PingFang-SC-Regular',
|
|
|
},
|
|
|
click: {
|
|
|
flex: 1,
|
|
|
alignItems: 'center',
|
|
|
justifyContent: 'center'
|
|
|
},
|
|
|
cancel: {
|
|
|
fontSize: 17,
|
|
|
color: '#444444',
|
|
|
letterSpacing: -0.41,
|
|
|
fontFamily: 'PingFang-SC-Regular',
|
|
|
},
|
|
|
sure: {
|
|
|
fontSize: 17,
|
|
|
color: '#D0021B',
|
|
|
letterSpacing: -0.41,
|
|
|
fontWeight: 'bold'
|
|
|
},
|
|
|
}); |
...
|
...
|
|