parent
9f9f8affe0
commit
f03870e882
@ -0,0 +1,54 @@
|
||||
import React from 'react';
|
||||
import { View, Text, Button, TouchableOpacity, Dimensions } from 'react-native';
|
||||
const width = Dimensions.get('window').width;
|
||||
const height = Dimensions.get('window').height;
|
||||
|
||||
const Dialog = ({ show, obj, onButtonPress }) => {
|
||||
if (!show) return null;
|
||||
return (
|
||||
<View style={{
|
||||
position: 'absolute',
|
||||
top: 0,
|
||||
left: 0,
|
||||
width,
|
||||
height,
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center',
|
||||
zIndex: 500,
|
||||
backgroundColor: 'rgba(0,0,0,0.4)'
|
||||
}}>
|
||||
<View style={{
|
||||
width: width * 0.7,
|
||||
backgroundColor: '#fff',
|
||||
minHeight: 100,
|
||||
borderRadius: 10
|
||||
}}>
|
||||
<View style={{
|
||||
alignItems: 'center',
|
||||
paddingTop: 10,
|
||||
flex: 1
|
||||
}}>
|
||||
<Text>{obj}</Text>
|
||||
</View>
|
||||
<View style={{
|
||||
borderTopColor: '#000',
|
||||
borderTopWidth: 1,
|
||||
borderStyle: 'solid'
|
||||
}}>
|
||||
<TouchableOpacity style={{
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
paddingTop: 5,
|
||||
paddingBottom: 5,
|
||||
paddingLeft: 10,
|
||||
paddingRight: 10
|
||||
}} onPress={() => onButtonPress()}>
|
||||
<Text>OK</Text>
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
export default Dialog;
|
@ -0,0 +1,17 @@
|
||||
import React from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
import Dialog from '../components/Dialog';
|
||||
import { removeDialog } from '../actions';
|
||||
|
||||
const mapStateToProps = (state) => ({
|
||||
obj: state.ui.dialog[0] || null,
|
||||
show: state.ui.dialog.length > 0
|
||||
});
|
||||
|
||||
const mapDispatchToProps = (dispatch, ownProps) => ({
|
||||
onButtonPress: () => {
|
||||
dispatch(removeDialog());
|
||||
}
|
||||
});
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(Dialog);
|
Loading…
Reference in new issue