feat: 添加聊天会话页面,支持会话ID和标题显示,优化会话列表和搜索功能
This commit is contained in:
@@ -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,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user