feat: 添加聊天会话页面,支持会话ID和标题显示,优化会话列表和搜索功能

This commit is contained in:
2026-03-09 08:25:51 +07:00
parent 212b3fa8de
commit db4ee293d2
7 changed files with 225 additions and 31 deletions

View File

@@ -1,5 +1,5 @@
import { FlashList } from "@shopify/flash-list";
import { StyleSheet, Text, View } from "react-native";
import { RefreshControl, StyleSheet, Text, View } from "react-native";
import { ConversationListItem } from "@/features/im/components/conversation-list-item";
import type { ConversationItem } from "@/features/im/types/conversation";
@@ -7,40 +7,45 @@ import type { ConversationItem } from "@/features/im/types/conversation";
type ConversationListProps = {
data: ConversationItem[];
isLoading?: boolean;
isRefreshing?: boolean;
onRefresh?: () => void;
onPressItem?: (item: ConversationItem) => void;
};
export function ConversationList({
data,
isLoading = false,
isRefreshing = false,
onRefresh,
onPressItem,
}: ConversationListProps) {
if (isLoading) {
return (
<View style={styles.emptyContainer}>
<Text style={styles.emptyTitle}>...</Text>
</View>
);
}
if (data.length === 0) {
return (
<View style={styles.emptyContainer}>
<Text style={styles.emptyTitle}></Text>
<Text style={styles.emptyHint}></Text>
</View>
);
}
return (
<FlashList
alwaysBounceVertical
bounces
contentInsetAdjustmentBehavior="automatic"
contentContainerStyle={styles.contentContainer}
data={data}
keyExtractor={(item) => item.id}
ListEmptyComponent={
<View style={styles.emptyContainer}>
<Text style={styles.emptyTitle}>{isLoading ? "会话加载中..." : "暂无会话"}</Text>
{!isLoading && <Text style={styles.emptyHint}></Text>}
</View>
}
onRefresh={onRefresh}
refreshControl={
<RefreshControl
colors={["#00D48C"]}
onRefresh={onRefresh}
refreshing={isRefreshing}
tintColor="#00D48C"
/>
}
renderItem={({ item }) => (
<ConversationListItem item={item} onPress={onPressItem} />
)}
refreshing={isRefreshing}
showsVerticalScrollIndicator={false}
/>
);
@@ -48,6 +53,7 @@ export function ConversationList({
const styles = StyleSheet.create({
contentContainer: {
flexGrow: 1,
paddingBottom: 28,
paddingTop: 16,
},