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 | 1x 7x 7x 7x 2x 1x 7x | import { KeyboardAwareScrollView } from 'react-native-keyboard-controller';
import { Pressable, TextInput, View } from 'react-native';
import { BriefReason } from '@repo/ui/components/ReasonSelector';
import { MoreIcon } from '@repo/ui/icons/More';
import { makeStyles } from '@repo/ui/themes/makeStyles';
import { textStyles } from '@repo/ui/themes/typography';
import { useChooseReason } from './hooks';
import { quickReasons } from './utils';
const ChooseReason = () => {
const styles = useStyles();
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={() => {
if (canSubmitReasonInput) {
handleSubmitTextInput();
}
}}
/>
</KeyboardAwareScrollView>
) : (
<View style={styles.container}>
<BriefReason
reasons={quickReasons}
value={quickReason || ''}
onChange={handleChangeQuickReason}
/>
<Pressable
accessibilityRole="button"
accessibilityLabel="Open reason input"
testID="more-btn"
onPress={openReasonInput}
>
<MoreIcon />
</Pressable>
</View>
)}
</>
);
};
export default ChooseReason;
const useStyles = makeStyles(theme => ({
container: {
alignItems: 'center',
marginTop: theme.metrics.spacing[6],
gap: theme.metrics.spacing[11],
},
input: {
padding: theme.metrics.spacing[6],
...textStyles.content.regular,
},
}));
|