修复环境变量,UI问题
This commit is contained in:
@@ -3,6 +3,7 @@ import { useLocalSearchParams } from 'expo-router';
|
||||
import { Mic, Pause, Play, PlusCircle, Type, X } from 'lucide-react-native';
|
||||
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
||||
import type {
|
||||
LayoutChangeEvent,
|
||||
NativeSyntheticEvent,
|
||||
TextInputContentSizeChangeEventData,
|
||||
} from 'react-native';
|
||||
@@ -669,6 +670,8 @@ export default function ConversationScreen() {
|
||||
const [isKeyboardVisible, setIsKeyboardVisible] = useState(false);
|
||||
const [keyboardHeight, setKeyboardHeight] = useState(0);
|
||||
const listRef = useRef<FlatList>(null);
|
||||
/** 底部输入区(含连接提示 + 输入条)高度,用于多行输入增高时把列表滚到底,避免挡住最新消息 */
|
||||
const composerBlockHeightRef = useRef<number | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
const onShow = (e: { endCoordinates: { height: number } }) => {
|
||||
@@ -707,6 +710,25 @@ export default function ConversationScreen() {
|
||||
}
|
||||
}, [startRecording, t]);
|
||||
|
||||
const scrollListToEndAfterComposerLayout = useCallback(() => {
|
||||
InteractionManager.runAfterInteractions(() => {
|
||||
requestAnimationFrame(() => {
|
||||
listRef.current?.scrollToEnd({ animated: true });
|
||||
});
|
||||
});
|
||||
}, []);
|
||||
|
||||
const onComposerBlockLayout = useCallback(
|
||||
(e: LayoutChangeEvent) => {
|
||||
const h = e.nativeEvent.layout.height;
|
||||
const prev = composerBlockHeightRef.current;
|
||||
if (prev !== null && Math.abs(h - prev) < 1) return;
|
||||
composerBlockHeightRef.current = h;
|
||||
scrollListToEndAfterComposerLayout();
|
||||
},
|
||||
[scrollListToEndAfterComposerLayout],
|
||||
);
|
||||
|
||||
const handleSend = () => {
|
||||
const text = input.trim();
|
||||
if (!text) return;
|
||||
@@ -822,6 +844,7 @@ export default function ConversationScreen() {
|
||||
paddingBottom: composerZeroBottomInset ? 0 : insets.bottom,
|
||||
},
|
||||
]}
|
||||
onLayout={onComposerBlockLayout}
|
||||
>
|
||||
{showConnectionNotice ? (
|
||||
<View style={styles.connectionNotice}>
|
||||
|
||||
Reference in New Issue
Block a user