chore: 注释

This commit is contained in:
Junhui Chen 2025-08-06 15:34:42 +08:00
parent 7d59e20f39
commit 17a3e146ce

View File

@ -19,8 +19,7 @@ import {
TouchableOpacity,
View
} from 'react-native';
import { Gesture, GestureDetector } from "react-native-gesture-handler";
import Animated, { runOnJS, useAnimatedStyle, useSharedValue, withTiming } from 'react-native-reanimated';
import Animated, { useAnimatedStyle, useSharedValue, withTiming } from 'react-native-reanimated';
import { useSafeAreaInsets } from "react-native-safe-area-context";
export default function AskScreen() {
@ -42,60 +41,60 @@ export default function AskScreen() {
}>();
// 创建一个可复用的滚动函数
const scrollToEnd = useCallback((animated = true) => {
if (chatListRef.current) {
setTimeout(() => chatListRef.current?.scrollToEnd({ animated }), 100);
}
}, []);
// const scrollToEnd = useCallback((animated = true) => {
// if (chatListRef.current) {
// setTimeout(() => chatListRef.current?.scrollToEnd({ animated }), 100);
// }
// }, []);
// 右滑
const gesture = Gesture.Pan()
.onEnd((event) => {
const { translationX } = event;
const threshold = 100; // 滑动阈值
// 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 方向触发的范围
// if (translationX > threshold) {
// // 从左向右滑动,跳转页面
// runOnJS(router.replace)("/memo-list");
// }
// })
// .minPointers(1)
// .activeOffsetX([-10, 10]); // 在 X 方向触发的范围
useEffect(() => {
if (!isHello && userMessages.length > 0) {
scrollToEnd();
}
}, [userMessages, isHello, scrollToEnd]);
// useEffect(() => {
// if (!isHello && userMessages.length > 0) {
// scrollToEnd();
// }
// }, [userMessages, isHello, scrollToEnd]);
useEffect(() => {
const keyboardDidShowListener = Keyboard.addListener(
'keyboardDidShow',
(e) => {
setTimeout(() => {
if (!isHello) {
scrollToEnd();
}
}, 100);
}
);
// useEffect(() => {
// const keyboardDidShowListener = Keyboard.addListener(
// 'keyboardDidShow',
// (e) => {
// setTimeout(() => {
// if (!isHello) {
// scrollToEnd();
// }
// }, 100);
// }
// );
const keyboardDidHideListener = Keyboard.addListener(
'keyboardDidHide',
() => {
setTimeout(() => {
if (!isHello) {
scrollToEnd(false);
}
}, 100);
}
);
// const keyboardDidHideListener = Keyboard.addListener(
// 'keyboardDidHide',
// () => {
// setTimeout(() => {
// if (!isHello) {
// scrollToEnd(false);
// }
// }, 100);
// }
// );
return () => {
keyboardDidShowListener.remove();
keyboardDidHideListener.remove();
};
}, [isHello]);
// return () => {
// keyboardDidShowListener.remove();
// keyboardDidHideListener.remove();
// };
// }, [isHello]);
useFocusEffect(
useCallback(() => {
@ -219,13 +218,13 @@ export default function AskScreen() {
}
}, [sessionId, newSession]);
useEffect(() => {
if (!isHello) {
// 不再自动关闭键盘,让用户手动控制
// 这里可以添加其他需要在隐藏hello界面时执行的逻辑
scrollToEnd(false);
}
}, [isHello]);
// useEffect(() => {
// if (!isHello) {
// // 不再自动关闭键盘,让用户手动控制
// // 这里可以添加其他需要在隐藏hello界面时执行的逻辑
// scrollToEnd(false);
// }
// }, [isHello]);
useFocusEffect(
useCallback(() => {
@ -237,7 +236,7 @@ export default function AskScreen() {
);
return (
<GestureDetector gesture={gesture}>
// <GestureDetector gesture={gesture}>
<View style={[styles.container, { paddingTop: insets.top, paddingBottom: insets.bottom }]}>
{/* 导航栏 */}
<View style={[styles.navbar, isHello && styles.hiddenNavbar]}>
@ -283,7 +282,7 @@ export default function AskScreen() {
style={styles.chatContainer}
contentContainerStyle={styles.chatContentContainer}
showsVerticalScrollIndicator={false}
onContentSizeChange={() => scrollToEnd()}
// onContentSizeChange={() => scrollToEnd()}
/>
</Animated.View>
</View>
@ -304,7 +303,7 @@ export default function AskScreen() {
</View>
</KeyboardAvoidingView>
</View >
</GestureDetector>
// </GestureDetector >
);
}