Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | 1x 5x 5x 5x 5x 1x 1x 1x 5x | import { KeyboardAwareScrollView } from 'react-native-keyboard-controller';
import { Pressable, TextInput, View } from 'react-native';
import { useNavigation } from '@react-navigation/native';
import { NativeStackNavigationProp } from '@react-navigation/native-stack';
import { QuickSelect } from '@repo/ui/components/QuickSelect';
import { MoreIcon } from '@repo/ui/icons/More';
import { makeStyles } from '@repo/ui/themes/makeStyles';
import { textStyles } from '@repo/ui/themes/typography';
import {
ReallocationStep,
type ReallocationV2StackParamList,
} from '../ReallocationV2/types';
import { useChooseReason } from './hooks';
import { quickReasonOptions } from './utils';
const ChooseReason = () => {
const styles = useStyles();
const navigation =
useNavigation<NativeStackNavigationProp<ReallocationV2StackParamList>>();
const {
state: {
isOpenReasonInput,
quickReason,
reasonInputValue,
canSubmitReasonInput,
},
actions: {
setReasonInputValue,
openReasonInput,
handleChangeQuickReason,
handleSubmitTextInput,
},
} = useChooseReason();
return (
<>
{isOpenReasonInput ? (
<KeyboardAwareScrollView keyboardShouldPersistTaps="handled">
<TextInput
autoFocus
style={styles.input}
value={reasonInputValue}
submitBehavior="submit"
returnKeyType="done"
enablesReturnKeyAutomatically
onChangeText={setReasonInputValue}
multiline
testID="reason-input"
onSubmitEditing={() => {
Eif (canSubmitReasonInput) {
handleSubmitTextInput();
navigation.navigate(ReallocationStep.PREVIEW);
}
}}
/>
</KeyboardAwareScrollView>
) : (
<View style={styles.container}>
<QuickSelect
options={quickReasonOptions}
value={quickReason}
onChange={handleChangeQuickReason}
testID="choose-reason-quick-select"
/>
<Pressable
accessibilityRole="button"
accessibilityLabel="Open reason input"
testID="more-btn"
style={styles.moreIcon}
onPress={openReasonInput}
>
<MoreIcon />
</Pressable>
</View>
)}
</>
);
};
export default ChooseReason;
const useStyles = makeStyles(theme => ({
container: {
flex: 1,
paddingHorizontal: theme.metrics.spacing[4],
gap: theme.metrics.spacing[6],
backgroundColor: theme.colors.background.pageMuted,
},
moreIcon: {
borderRadius: theme.metrics.borderRadius.pill,
width: theme.metrics.spacing[15],
height: theme.metrics.spacing[15],
},
input: {
padding: theme.metrics.spacing[4],
paddingTop: -16,
...textStyles.content.regular,
},
}));
|