1+ import React , { Component } from 'react' ;
2+ import PropTypes from 'prop-types' ;
3+ import { View , Text , TouchableOpacity , StyleSheet } from "react-native" ;
4+ import PopupDialog , { SlideAnimation , DialogTitle , ScaleAnimation , DialogButton } from 'react-native-popup-dialog' ;
5+
6+ const dialogTitle = props => < DialogTitle { ...props } /> ;
7+ //const dialogTitle = () => null;
8+ class PopupDialogView extends Component {
9+ render ( ) {
10+ return (
11+ < PopupDialog { ...this . props } dialogStyle = { { overflow :'hidden' } } >
12+ { this . props . children }
13+ < View style = { { flexDirection :'row' , position :'absolute' , bottom :0 } } >
14+ {
15+ this . props . cancelBtn && < TouchableOpacity
16+ activeOpacity = { .6 }
17+ onPress = { this . props . cancelBtn . onPress }
18+ style = { [ styles . container , { backgroundColor :this . props . cancelBtn . bgColor } ] }
19+ >
20+ < Text style = { styles . buttonTitle } > { this . props . cancelBtn . title } </ Text >
21+ </ TouchableOpacity >
22+ }
23+ {
24+ this . props . confirmBtn && < TouchableOpacity
25+ activeOpacity = { .6 }
26+ disabled = { this . props . confirmBtn . disabled }
27+ onPress = { this . props . confirmBtn . onPress }
28+ style = { [ styles . container , { backgroundColor :this . props . confirmBtn . bgColor } ] }
29+ >
30+ < Text style = { styles . buttonTitle } > { this . props . confirmBtn . title } </ Text >
31+ </ TouchableOpacity >
32+ }
33+
34+ </ View >
35+ </ PopupDialog >
36+ ) ;
37+ }
38+ }
39+ const scaleAnimation = new ScaleAnimation ( ) ;
40+ const actions = [ ] ;
41+ PopupDialog . propTypes = {
42+ width :PropTypes . number ,
43+ height :PropTypes . number ,
44+ show :PropTypes . bool . isRequired ,
45+ dismissOnTouchOutside :PropTypes . bool ,
46+ dialogAnimation :PropTypes . object ,
47+ dialogTitle :PropTypes . element ,
48+ actions :PropTypes . arrayOf ( PropTypes . element ) ,
49+ //children:PropTypes.element.isRequired,
50+ confirmBtn :PropTypes . object ,
51+ cancelBtn :PropTypes . object ,
52+ overlayOpacity :PropTypes . number ,
53+ overlayBackgroundColor :PropTypes . string
54+ }
55+ PopupDialog . defaultProps = {
56+ width :.9 ,
57+ height :300 ,
58+ show :false ,
59+ dismissOnTouchOutside :false ,
60+ dialogAnimation : scaleAnimation ,
61+ dialogTitle : null ,
62+ actions :actions ,
63+ confirmBtn :null ,
64+ cancelBtn :null ,
65+ overlayOpacity :.7 ,
66+ overlayBackgroundColor :'#000'
67+ }
68+ const styles = StyleSheet . create ( {
69+ container : {
70+ justifyContent :'center' ,
71+ alignItems :'center' ,
72+ height :45 ,
73+ flex :1 ,
74+ } ,
75+ buttonTitle :{
76+ color :'#fff' ,
77+ fontSize :16
78+ }
79+ } ) ;
80+ export default PopupDialogView
0 commit comments