BuyWhat/src/components/Dialog.js

54 lines
1.3 KiB
JavaScript

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;