-
Notifications
You must be signed in to change notification settings - Fork 3k
/
Copy pathProcessMoneyRequestHoldMenu.tsx
75 lines (65 loc) · 2.65 KB
/
ProcessMoneyRequestHoldMenu.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
import {useNavigation} from '@react-navigation/native';
import React, {useEffect, useRef} from 'react';
import {View} from 'react-native';
import useLocalize from '@hooks/useLocalize';
import useThemeStyles from '@hooks/useThemeStyles';
import type AnchorAlignment from '@src/types/utils/AnchorAlignment';
import Button from './Button';
import HoldMenuSectionList from './HoldMenuSectionList';
import type {PopoverAnchorPosition} from './Modal/types';
import Popover from './Popover';
import Text from './Text';
import TextPill from './TextPill';
type ProcessMoneyRequestHoldMenuProps = {
/** Whether the content is visible */
isVisible: boolean;
/** Method to trigger when pressing outside of the popover menu to close it */
onClose: () => void;
/** Method to trigger when pressing confirm button */
onConfirm: () => void;
/** The anchor position of the popover menu */
anchorPosition?: PopoverAnchorPosition;
/** The anchor alignment of the popover menu */
anchorAlignment?: AnchorAlignment;
};
function ProcessMoneyRequestHoldMenu({isVisible, onClose, onConfirm, anchorPosition, anchorAlignment}: ProcessMoneyRequestHoldMenuProps) {
const {translate} = useLocalize();
const styles = useThemeStyles();
const popoverRef = useRef(null);
const navigation = useNavigation();
useEffect(() => {
const unsub = navigation.addListener('beforeRemove', () => {
onClose();
});
return unsub;
}, [navigation, onClose]);
return (
<Popover
isVisible={isVisible}
onClose={onClose}
anchorPosition={anchorPosition}
anchorRef={popoverRef}
anchorAlignment={anchorAlignment}
disableAnimation={false}
withoutOverlay={false}
shouldCloseWhenBrowserNavigationChanged={false}
>
<View style={[styles.mh5, styles.mv5]}>
<View style={[styles.flexRow, styles.alignItemsCenter, styles.mb5]}>
<Text style={[styles.textHeadline, styles.mr2]}>{translate('iou.holdEducationalTitle')}</Text>
<TextPill textStyles={styles.holdRequestInline}>{translate('violations.hold')}</TextPill>
</View>
<HoldMenuSectionList />
<Button
success
style={[styles.mt5]}
text={translate('common.buttonConfirm')}
onPress={onConfirm}
large
/>
</View>
</Popover>
);
}
ProcessMoneyRequestHoldMenu.displayName = 'ProcessMoneyRequestHoldMenu';
export default ProcessMoneyRequestHoldMenu;