๐ Fix page stack bug
Changes
1 file changed, +7 -3
MODIFY
app/modal.tsx
+7 -3
@@ -1,7 +1,7 @@
1
1
import React, { useRef } from 'react';
2
2
import { StyleSheet, TouchableOpacity, Platform, Dimensions, Keyboard } from 'react-native';
3
3
import { ThemedView } from '@/components/themed-view';
4
-import { router } from 'expo-router';
4
+import { router, useRouter } from 'expo-router';
5
5
import { Gesture, GestureDetector } from 'react-native-gesture-handler';
6
6
import Animated, {
7
7
useSharedValue,
@@ -23,7 +23,11 @@
23
23
24
24
const handleClose = () => {
25
25
taskFormRef.current?.handleSave();
26
- router.dismiss();
26
+ if (router.canDismiss()) {
27
+ router.dismiss();
28
+ } else if (router.canGoBack()) {
29
+ router.back();
30
+ }
27
31
};
28
32
29
33
const dismissKeyboard = () => {
@@ -64,7 +68,7 @@
64
68
<Animated.View style={[styles.modal, animatedStyle]}>
65
69
<ThemedView style={styles.handle} />
66
70
<ThemedView style={{ flex: 1, backgroundColor: colors.background }}>
67
- <TaskForm ref={taskFormRef} id="new" onSave={() => router.dismiss()} />
71
+ <TaskForm ref={taskFormRef} id="new" onSave={handleClose} />
68
72
</ThemedView>
69
73
</Animated.View>
70
74
</GestureDetector>