-
Notifications
You must be signed in to change notification settings - Fork 3k
/
EditRequestAmountPage.js
66 lines (56 loc) · 2.34 KB
/
EditRequestAmountPage.js
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
import {useFocusEffect} from '@react-navigation/native';
import PropTypes from 'prop-types';
import React, {useCallback, useRef} from 'react';
import HeaderWithBackButton from '@components/HeaderWithBackButton';
import ScreenWrapper from '@components/ScreenWrapper';
import useLocalize from '@hooks/useLocalize';
import * as DeviceCapabilities from '@libs/DeviceCapabilities';
import CONST from '@src/CONST';
import MoneyRequestAmountForm from './iou/steps/MoneyRequestAmountForm';
const propTypes = {
/** Transaction default amount value */
defaultAmount: PropTypes.number.isRequired,
/** Transaction default currency value */
defaultCurrency: PropTypes.string.isRequired,
/** Callback to fire when the Save button is pressed */
onSubmit: PropTypes.func.isRequired,
/** Callback to fire when we press on the currency */
onNavigateToCurrency: PropTypes.func.isRequired,
};
function EditRequestAmountPage({defaultAmount, defaultCurrency, onNavigateToCurrency, onSubmit}) {
const {translate} = useLocalize();
const textInput = useRef(null);
const focusTimeoutRef = useRef(null);
useFocusEffect(
useCallback(() => {
focusTimeoutRef.current = setTimeout(() => textInput.current && textInput.current.focus(), CONST.ANIMATED_TRANSITION);
return () => {
if (!focusTimeoutRef.current) {
return;
}
clearTimeout(focusTimeoutRef.current);
};
}, []),
);
return (
<ScreenWrapper
includeSafeAreaPaddingBottom={false}
shouldEnableKeyboardAvoidingView={false}
shouldEnableMinHeight={DeviceCapabilities.canUseTouchScreen()}
testID={EditRequestAmountPage.displayName}
>
<HeaderWithBackButton title={translate('iou.amount')} />
<MoneyRequestAmountForm
buttonTranslationText="common.save"
currency={defaultCurrency}
amount={defaultAmount}
ref={(e) => (textInput.current = e)}
onCurrencyButtonPress={onNavigateToCurrency}
onSubmitButtonPress={onSubmit}
/>
</ScreenWrapper>
);
}
EditRequestAmountPage.propTypes = propTypes;
EditRequestAmountPage.displayName = 'EditRequestAmountPage';
export default EditRequestAmountPage;