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 | 2x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 1x 5x 5x 1x 5x 2x | import { useCallback, useEffect } from 'react';
import { StyleSheet, View } from 'react-native';
import { useFocusEffect, useRoute } from '@react-navigation/native';
import { useTheme } from '@repo/ui/themes/ThemeContext';
import { SCREENS } from '@repo/constants/screens';
import { RequestResolvedCard } from '@/components';
import { useChatActionsSelector, useChatStateSelector } from '@/contexts';
import type { AppStackScreenProps } from '@/types/navigation';
type CreateRequestSuccessProps = AppStackScreenProps<typeof SCREENS.CREATE_REQUEST_SUCCESS>;
interface SuccessParams {
message?: string;
}
export const CreateRequestSuccessScreen = ({ navigation }: CreateRequestSuccessProps) => {
const { theme } = useTheme();
const fabOffset = useChatStateSelector(s => s.fabOffset);
const setFabOffset = useChatActionsSelector(a => a.setFabOffset);
useEffect(() => {
navigation.setOptions({
headerLeft: () => null,
gestureEnabled: false,
});
const unsubscribe = navigation.addListener('beforeRemove', e => {
if (e.data.action.type === 'NAVIGATE' || e.data.action.type === 'RESET') {
return;
}
e.preventDefault();
});
return unsubscribe;
}, [navigation]);
const route = useRoute();
const { message } = (route.params as SuccessParams) || {};
const handlePress = () => {
navigation.reset({
index: 0,
routes: [{ name: SCREENS.HOME }],
});
};
useFocusEffect(
useCallback(() => {
if (fabOffset !== 0) {
setFabOffset(0);
}
}, [fabOffset, setFabOffset]),
);
return (
<View style={[styles.container, { backgroundColor: theme.colors.background.page }]}>
<RequestResolvedCard text={message || 'YOUR REQUEST HAS BEEN SENT'} onPress={handlePress} />
</View>
);
};
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
},
});
|