1- import { FC , useState , useEffect } from ' react' ;
1+ import { FC , useState , useEffect } from " react" ;
22import {
33 View ,
44 TouchableOpacity ,
55 Text ,
66 GestureResponderEvent ,
7- StyleSheet ,
8- Dimensions ,
9- Button ,
10- } from 'react-native' ;
7+ } from "react-native" ;
118
12- import * as Animatable from ' react-native-animatable' ;
9+ import * as Animatable from " react-native-animatable" ;
1310
14- import styles from './styles'
11+ import styles from "./styles" ;
12+
13+ // ADD OTHER PROPS LIKE CONFIRM STYLES, CANCEL STYLES,OTHER STYLES AS PROPS TO SUPPORT DYNAMIC STYLING, CHANGE TITLE, SUBTTILE FROM STRING TO REACT COMPONENTS FOR MORE CUSTOMIZATION OPTIONS, DARK AND LIGHT MODE, LINEARGRADIENT(OPTIONAL), BACKDROP (CLOSE WHEN CLICKED OUTSIDE DIALOG).
1514
1615interface DialogProps {
1716 visible : boolean ;
17+ title : string ;
18+ subtitle : string ;
1819 closeDialog : ( event : GestureResponderEvent ) => void ;
1920 confirm : ( event : GestureResponderEvent ) => void ;
21+ confirmText : string ;
22+ titleStyle ?: Object ;
23+ cancelStyle ?: Object ;
24+ confirmStyle ?: Object ;
25+ subtitleStyle ?: Object ;
26+ cancelTextStyle ?: Object ;
27+ cancelText : string ;
28+ confirmTextStyle ?: Object ;
2029}
2130
22- const Dialog : FC < DialogProps > = ( { visible, closeDialog, confirm } ) => {
31+ const Dialog : FC < DialogProps > = ( {
32+ visible,
33+ title,
34+ subtitle,
35+ closeDialog,
36+ confirm,
37+ confirmText,
38+ confirmTextStyle,
39+ titleStyle,
40+ cancelStyle,
41+ confirmStyle,
42+ subtitleStyle,
43+ cancelTextStyle,
44+ cancelText,
45+ } ) => {
2346 const [ visiblest , setvisible ] = useState ( visible ) ;
2447
2548 useEffect ( ( ) => {
@@ -34,20 +57,27 @@ const Dialog: FC<DialogProps> = ({ visible, closeDialog, confirm }) => {
3457
3558 if ( visiblest ) {
3659 return (
37- < View style = { styles . dialog } >
60+ < View style = { styles . dialog } onTouchEnd = { closeDialog } >
3861 < Animatable . View
39- animation = { visible ? ' zoomIn' : ' zoomOut' }
62+ animation = { visible ? " zoomIn" : " zoomOut" }
4063 style = { styles . dialogbox }
41- duration = { 250 } >
42- < Text style = { styles . warning } > Are you Sure?</ Text >
43- < Text > This action cannot be reverted.</ Text >
64+ duration = { 250 }
65+ >
66+ < Text style = { [ styles . warning , titleStyle ] } > { title } </ Text >
67+ < Text style = { subtitleStyle } > { subtitle } </ Text >
4468
4569 < View style = { styles . card } >
46- < TouchableOpacity onPress = { closeDialog } style = { styles . cancel } >
47- < Text > Cancel</ Text >
70+ < TouchableOpacity
71+ onPress = { closeDialog }
72+ style = { [ styles . cancel , cancelStyle ] }
73+ >
74+ < Text style = { cancelTextStyle } > { cancelText } </ Text >
4875 </ TouchableOpacity >
49- < TouchableOpacity onPress = { confirm } style = { styles . confirm } >
50- < Text > Delete</ Text >
76+ < TouchableOpacity
77+ onPress = { confirm }
78+ style = { [ styles . confirm , confirmStyle ] }
79+ >
80+ < Text style = { confirmTextStyle } > { confirmText } </ Text >
5181 </ TouchableOpacity >
5282 </ View >
5383 </ Animatable . View >
@@ -58,5 +88,4 @@ const Dialog: FC<DialogProps> = ({ visible, closeDialog, confirm }) => {
5888 return < > </ > ;
5989} ;
6090
61-
6291export default Dialog ;
0 commit comments