-
Notifications
You must be signed in to change notification settings - Fork 3.1k
/
Copy pathDecisionModal.tsx
79 lines (66 loc) · 2.42 KB
/
DecisionModal.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import React from 'react';
import {View} from 'react-native';
import useThemeStyles from '@hooks/useThemeStyles';
import CONST from '@src/CONST';
import Button from './Button';
import Header from './Header';
import Modal from './Modal';
import Text from './Text';
type DecisionModalProps = {
/** Title describing purpose of modal */
title: string;
/** Modal subtitle/description */
prompt?: string;
/** Text content used in first button */
firstOptionText?: string;
/** Text content used in second button */
secondOptionText: string;
/** onSubmit callback fired after clicking on first button */
onFirstOptionSubmit?: () => void;
/** onSubmit callback fired after clicking on second button */
onSecondOptionSubmit: () => void;
/** Is the window width narrow, like on a mobile device? */
isSmallScreenWidth: boolean;
/** Callback for closing modal */
onClose: () => void;
/** Whether modal is visible */
isVisible: boolean;
};
function DecisionModal({title, prompt = '', firstOptionText, secondOptionText, onFirstOptionSubmit, onSecondOptionSubmit, isSmallScreenWidth, onClose, isVisible}: DecisionModalProps) {
const styles = useThemeStyles();
return (
<Modal
onClose={onClose}
isVisible={isVisible}
type={isSmallScreenWidth ? CONST.MODAL.MODAL_TYPE.BOTTOM_DOCKED : CONST.MODAL.MODAL_TYPE.CONFIRM}
>
<View style={[styles.m5]}>
<View>
<View style={[styles.flexRow, styles.mb4]}>
<Header
title={title}
containerStyles={[styles.alignItemsCenter]}
/>
</View>
<Text>{prompt}</Text>
</View>
{!!firstOptionText && (
<Button
success
style={[styles.mt4]}
onPress={onFirstOptionSubmit}
pressOnEnter
text={firstOptionText}
/>
)}
<Button
style={[styles.mt3, styles.noSelect]}
onPress={onSecondOptionSubmit}
text={secondOptionText}
/>
</View>
</Modal>
);
}
DecisionModal.displayName = 'DecisionModal';
export default DecisionModal;