From 6e8113e109f89d0a81641563f2c6c16ece6ff31a Mon Sep 17 00:00:00 2001 From: jinyaqiu Date: Mon, 4 Aug 2025 20:14:43 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=8F=B3=E6=BB=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/(tabs)/ask.tsx | 179 +++++++++++++++++++++++++-------------------- 1 file changed, 101 insertions(+), 78 deletions(-) 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()} + /> + + + + {/* 输入框区域 */} + + + + + + + ); }