diff --git a/app/(tabs)/ask.tsx b/app/(tabs)/ask.tsx
index 5644c98..2a15ace 100644
--- a/app/(tabs)/ask.tsx
+++ b/app/(tabs)/ask.tsx
@@ -20,6 +20,8 @@ import {
TouchableOpacity,
View
} from 'react-native';
+import { Gesture, GestureDetector } from "react-native-gesture-handler";
+import { runOnJS } from 'react-native-reanimated';
import { useSafeAreaInsets } from "react-native-safe-area-context";
export default function AskScreen() {
@@ -46,6 +48,25 @@ export default function AskScreen() {
}
}, []);
+ const updateState = (value: string) => {
+ console.log('Received in JS:', value);
+ // 更新 React 状态或路由
+ router.replace(value);
+ };
+ // 右滑
+ const gesture = Gesture.Pan()
+ .onEnd((event) => {
+ const { translationX } = event;
+ const threshold = 100; // 滑动阈值
+
+ if (translationX > threshold) {
+ // 从左向右滑动,跳转页面
+ runOnJS(router.replace)("memo-list");
+ }
+ })
+ .minPointers(1)
+ .activeOffsetX([-10, 10]); // 在 X 方向触发的范围
+
useEffect(() => {
if (!isHello && userMessages.length > 0) {
scrollToEnd();
@@ -236,86 +257,88 @@ export default function AskScreen() {
);
return (
-
- {/* 导航栏 */}
-
- {
- try {
- if (TextInput.State?.currentlyFocusedInput) {
- const input = TextInput.State.currentlyFocusedInput();
- if (input) input.blur();
+
+
+ {/* 导航栏 */}
+
+ {
+ try {
+ if (TextInput.State?.currentlyFocusedInput) {
+ const input = TextInput.State.currentlyFocusedInput();
+ if (input) input.blur();
+ }
+ } catch (error) {
+ console.log('失去焦点失败:', error);
}
- } catch (error) {
- console.log('失去焦点失败:', error);
- }
- Keyboard.dismiss();
- router.push('/memo-list');
- }}
- >
-
-
- { router.push('/owner') }}>MemoWake
-
-
-
-
- {/* 欢迎页面 */}
-
-
-
-
- {/* 聊天页面 */}
-
- scrollToEnd()}
- />
-
-
-
- {/* 输入框区域 */}
-
-
-
+ Keyboard.dismiss();
+ router.push('/memo-list');
+ }}
+ >
+
+
+ { router.push('/owner') }}>MemoWake
+
-
-
+
+
+ {/* 欢迎页面 */}
+
+
+
+
+ {/* 聊天页面 */}
+
+ scrollToEnd()}
+ />
+
+
+
+ {/* 输入框区域 */}
+
+
+
+
+
+
+
);
}