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 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 | 3x 8x 8x 8x 8x 8x 8x 8x 8x 1x 2x 1x 1x 8x | import { useMemo } from 'react';
import { KeyboardAwareScrollView } from 'react-native-keyboard-controller';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
import Svg, { Path } from 'react-native-svg';
import { Image, Modal, Text, TextInput, TouchableOpacity, View } from 'react-native';
import { ChevronLeftIcon } from '@repo/ui/icons/ChevronLeft';
import { makeStyles } from '@repo/ui/themes/makeStyles';
import { useTheme } from '@repo/ui/themes/ThemeContext';
import { textStyles } from '@repo/ui/themes/typography';
import { isAndroid } from '@repo/utils/platform';
import { SCREEN_WIDTH } from '@/utils/dimensions';
import { ASSETS } from '@/constants/assets';
interface Props {
note: string;
isOpen: boolean;
noteInputRef?: React.RefObject<TextInput | null>;
isNoteValid: boolean;
onChangeNote: (text: string) => void;
onReject: () => void;
onSubmit: () => void;
}
export const SubmitRejectModal = ({
isOpen,
note,
noteInputRef,
isNoteValid,
onChangeNote,
onReject,
onSubmit,
}: Props) => {
const { theme } = useTheme();
const styles = useStyles();
const scale = SCREEN_WIDTH / 375;
const insets = useSafeAreaInsets();
const dynamicStyles = useMemo(
() => ({
modalContainerPadding: {
paddingTop: 56,
paddingHorizontal: theme.metrics.spacing[4],
},
circleContainer: {
position: 'absolute' as const,
right: theme.metrics.spacing[1],
top: -theme.metrics.spacing[10] * scale,
},
circleWrapper: {
width: theme.metrics.spacing[75] * scale,
height: theme.metrics.spacing[62.5] * scale,
},
borderCircleTransform: {
transform: [{ translateX: 16 }, { translateY: -16 }],
},
whiteCircleContent: {
justifyContent: 'flex-end' as const,
},
textContainerPadding: {
paddingBottom: theme.metrics.spacing[17.5] * scale,
gap: theme.metrics.spacing[4],
paddingTop: theme.metrics.spacing[3],
},
titleTextSize: {
fontSize: theme.metrics.textSize[24] * scale,
},
svgContainer: {
position: 'absolute' as const,
alignSelf: 'center' as const,
bottom: -theme.metrics.spacing[7.5] * scale,
},
mascotImage: {
position: 'absolute' as const,
zIndex: 20,
width: theme.metrics.spacing[44.5] * scale,
height: theme.metrics.spacing[47.25] * scale,
top: theme.metrics.spacing[45] * scale,
left: -theme.metrics.spacing[7.5] * scale,
},
inputContainerTop: {
top: theme.metrics.spacing[75] * scale,
},
}),
[scale, theme],
);
const marginTop = isAndroid() ? -insets.top + 15 : 0;
return (
<Modal visible={isOpen} transparent animationType="slide">
<View
style={[styles.modalContainer, dynamicStyles.modalContainerPadding, { marginTop }]}
testID="submit-reject-modal-container"
>
<TouchableOpacity
onPress={onReject}
accessibilityRole="button"
accessibilityLabel="Go back"
accessibilityHint="Back to Pending Request list"
className="p-3"
>
<ChevronLeftIcon color={theme.colors.icon.primary} />
</TouchableOpacity>
<View style={dynamicStyles.circleContainer}>
<View style={dynamicStyles.circleWrapper}>
<View style={[styles.borderCircle, dynamicStyles.borderCircleTransform]} />
<View style={[styles.whiteCircle, dynamicStyles.whiteCircleContent]}>
<View style={[styles.textContainer, dynamicStyles.textContainerPadding]}>
<Text style={[styles.titleText, dynamicStyles.titleTextSize, textStyles.title]}>
PLEASE PROVIDE THE{'\n'}REASON FOR YOUR{'\n'}DECISION
</Text>
</View>
<View style={dynamicStyles.svgContainer}>
<Svg width="32" height="47" viewBox="0 0 32 47" fill="none">
<Path
d="M-6.52859e-05 46.514C10.9736 38.5982 5.69035 18.7053 1.67705 9.74832C13.2092 1.75496 35.243 -8.82195 31.1206 12.8173C26.9983 34.4565 8.65586 44.2981 -6.52859e-05 46.514Z"
fill={theme.colors.white}
/>
</Svg>
</View>
</View>
</View>
<Image
source={ASSETS.IMAGES.HEART_MASCOT}
style={dynamicStyles.mascotImage}
resizeMode="contain"
/>
</View>
<TouchableOpacity
style={[styles.inputContainer, dynamicStyles.inputContainerTop]}
activeOpacity={1}
onPress={() => {
noteInputRef?.current?.focus();
}}
testID="input-container"
>
<KeyboardAwareScrollView
bottomOffset={theme.metrics.spacing[50]}
keyboardShouldPersistTaps="always"
nestedScrollEnabled={true}
>
<TextInput
style={styles.textInput}
ref={noteInputRef}
value={note}
multiline
onChangeText={onChangeNote}
blurOnSubmit={true}
submitBehavior="submit"
returnKeyType="done"
enablesReturnKeyAutomatically
onSubmitEditing={() => {
if (isNoteValid) {
noteInputRef?.current?.blur();
onSubmit();
}
}}
/>
</KeyboardAwareScrollView>
</TouchableOpacity>
</View>
</Modal>
);
};
const useStyles = makeStyles(theme => ({
modalContainer: {
flex: 1,
backgroundColor: theme.colors.background.modal,
overflow: 'hidden',
},
borderCircle: {
position: 'absolute',
width: theme.metrics.sizing.full,
height: theme.metrics.sizing.full,
borderRadius: theme.metrics.borderRadius.circle,
borderWidth: theme.metrics.borderWidth.default,
borderColor: theme.colors.border.primary,
zIndex: 10,
},
whiteCircle: {
width: theme.metrics.sizing.full,
height: theme.metrics.sizing.full,
borderRadius: theme.metrics.borderRadius.circle,
backgroundColor: theme.colors.background.secondary,
},
textContainer: {
alignItems: 'center',
},
titleText: {
color: theme.colors.text.primary,
textAlign: 'center',
},
inputContainer: {
backgroundColor: theme.colors.background.secondary,
borderTopLeftRadius: theme.metrics.borderRadius[4],
borderTopRightRadius: theme.metrics.borderRadius[4],
flex: 1,
position: 'absolute',
left: theme.metrics.spacing[6],
right: theme.metrics.spacing[6],
bottom: theme.metrics.spacing[0],
zIndex: 30,
},
textInput: {
fontSize: theme.metrics.textSize[16],
padding: theme.metrics.spacing[3],
color: theme.colors.text.primary,
},
}));
|