2026-04-28 20:11:38 +08:00
|
|
|
|
import React, { useCallback, useRef, useState } from 'react'
|
feat: complete production chat demo — all screens, real media, SDK remote init
- App.tsx: replaced dev console with AuthProvider + AppNavigator
- Auth: Login, Register, ResetPassword screens via demo-service
- Conversations: reactive WatermelonDB subscription with user profile enrichment
- Chat: SingleChat + GroupChat with full media (image/video/audio/file), revoke, pull-up load more
- Contacts: local contacts list + UserSearch with debounced fuzzy search
- Groups: GroupList, CreateGroup (fuzzy member picker), GroupMembers, GroupSettings
- Profile: view + EditProfile (nickname, gender)
- MessageSearch: local DB full-text search across conversations
- ChatInput: text, 20-emoji picker, image/video/audio/file send, tap-to-record audio
- DisconnectBanner: connection status with reconnect
- AuthContext: uses await XuqmSDK.initialize({ appId, serverUrl }) for remote config
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-25 16:41:54 +08:00
|
|
|
|
import {
|
2026-04-28 20:11:38 +08:00
|
|
|
|
View, Text, TextInput, FlatList, StyleSheet, TouchableOpacity, SafeAreaView,
|
feat: complete production chat demo — all screens, real media, SDK remote init
- App.tsx: replaced dev console with AuthProvider + AppNavigator
- Auth: Login, Register, ResetPassword screens via demo-service
- Conversations: reactive WatermelonDB subscription with user profile enrichment
- Chat: SingleChat + GroupChat with full media (image/video/audio/file), revoke, pull-up load more
- Contacts: local contacts list + UserSearch with debounced fuzzy search
- Groups: GroupList, CreateGroup (fuzzy member picker), GroupMembers, GroupSettings
- Profile: view + EditProfile (nickname, gender)
- MessageSearch: local DB full-text search across conversations
- ChatInput: text, 20-emoji picker, image/video/audio/file send, tap-to-record audio
- DisconnectBanner: connection status with reconnect
- AuthContext: uses await XuqmSDK.initialize({ appId, serverUrl }) for remote config
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-25 16:41:54 +08:00
|
|
|
|
ActivityIndicator,
|
|
|
|
|
|
} from 'react-native'
|
|
|
|
|
|
import { useNavigation, useFocusEffect } from '@react-navigation/native'
|
|
|
|
|
|
import type { NativeStackNavigationProp } from '@react-navigation/native-stack'
|
|
|
|
|
|
import { ImSDK } from '@xuqm/rn-sdk'
|
|
|
|
|
|
import type { ImGroup } from '@xuqm/rn-sdk'
|
|
|
|
|
|
import type { RootStackParams } from '../../navigation/types'
|
|
|
|
|
|
|
|
|
|
|
|
type Nav = NativeStackNavigationProp<RootStackParams>
|
|
|
|
|
|
|
2026-04-27 11:58:07 +08:00
|
|
|
|
function parseMemberIds(memberIds: string): string[] {
|
|
|
|
|
|
try { return JSON.parse(memberIds || '[]') }
|
|
|
|
|
|
catch { return memberIds ? memberIds.split(',').filter(Boolean) : [] }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
feat: complete production chat demo — all screens, real media, SDK remote init
- App.tsx: replaced dev console with AuthProvider + AppNavigator
- Auth: Login, Register, ResetPassword screens via demo-service
- Conversations: reactive WatermelonDB subscription with user profile enrichment
- Chat: SingleChat + GroupChat with full media (image/video/audio/file), revoke, pull-up load more
- Contacts: local contacts list + UserSearch with debounced fuzzy search
- Groups: GroupList, CreateGroup (fuzzy member picker), GroupMembers, GroupSettings
- Profile: view + EditProfile (nickname, gender)
- MessageSearch: local DB full-text search across conversations
- ChatInput: text, 20-emoji picker, image/video/audio/file send, tap-to-record audio
- DisconnectBanner: connection status with reconnect
- AuthContext: uses await XuqmSDK.initialize({ appId, serverUrl }) for remote config
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-25 16:41:54 +08:00
|
|
|
|
function GroupRow({ group, onPress }: { group: ImGroup; onPress(): void }) {
|
|
|
|
|
|
const letter = (group.name || 'G').charAt(0).toUpperCase()
|
|
|
|
|
|
return (
|
|
|
|
|
|
<TouchableOpacity style={styles.row} onPress={onPress} activeOpacity={0.7}>
|
|
|
|
|
|
<View style={styles.avatar}><Text style={styles.avatarText}>{letter}</Text></View>
|
|
|
|
|
|
<View style={styles.body}>
|
|
|
|
|
|
<Text style={styles.name}>{group.name}</Text>
|
2026-04-27 11:58:07 +08:00
|
|
|
|
<Text style={styles.memberCount}>{parseMemberIds(group.memberIds).length} 人</Text>
|
feat: complete production chat demo — all screens, real media, SDK remote init
- App.tsx: replaced dev console with AuthProvider + AppNavigator
- Auth: Login, Register, ResetPassword screens via demo-service
- Conversations: reactive WatermelonDB subscription with user profile enrichment
- Chat: SingleChat + GroupChat with full media (image/video/audio/file), revoke, pull-up load more
- Contacts: local contacts list + UserSearch with debounced fuzzy search
- Groups: GroupList, CreateGroup (fuzzy member picker), GroupMembers, GroupSettings
- Profile: view + EditProfile (nickname, gender)
- MessageSearch: local DB full-text search across conversations
- ChatInput: text, 20-emoji picker, image/video/audio/file send, tap-to-record audio
- DisconnectBanner: connection status with reconnect
- AuthContext: uses await XuqmSDK.initialize({ appId, serverUrl }) for remote config
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-25 16:41:54 +08:00
|
|
|
|
</View>
|
|
|
|
|
|
<Text style={styles.arrow}>›</Text>
|
|
|
|
|
|
</TouchableOpacity>
|
|
|
|
|
|
)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export default function GroupListScreen() {
|
|
|
|
|
|
const navigation = useNavigation<Nav>()
|
|
|
|
|
|
const [groups, setGroups] = useState<ImGroup[]>([])
|
|
|
|
|
|
const [loading, setLoading] = useState(true)
|
2026-04-28 20:11:38 +08:00
|
|
|
|
const [keyword, setKeyword] = useState('')
|
|
|
|
|
|
const debounceRef = useRef<ReturnType<typeof setTimeout> | null>(null)
|
feat: complete production chat demo — all screens, real media, SDK remote init
- App.tsx: replaced dev console with AuthProvider + AppNavigator
- Auth: Login, Register, ResetPassword screens via demo-service
- Conversations: reactive WatermelonDB subscription with user profile enrichment
- Chat: SingleChat + GroupChat with full media (image/video/audio/file), revoke, pull-up load more
- Contacts: local contacts list + UserSearch with debounced fuzzy search
- Groups: GroupList, CreateGroup (fuzzy member picker), GroupMembers, GroupSettings
- Profile: view + EditProfile (nickname, gender)
- MessageSearch: local DB full-text search across conversations
- ChatInput: text, 20-emoji picker, image/video/audio/file send, tap-to-record audio
- DisconnectBanner: connection status with reconnect
- AuthContext: uses await XuqmSDK.initialize({ appId, serverUrl }) for remote config
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-25 16:41:54 +08:00
|
|
|
|
|
2026-04-28 20:11:38 +08:00
|
|
|
|
const fetchGroups = useCallback(async (text = keyword) => {
|
feat: complete production chat demo — all screens, real media, SDK remote init
- App.tsx: replaced dev console with AuthProvider + AppNavigator
- Auth: Login, Register, ResetPassword screens via demo-service
- Conversations: reactive WatermelonDB subscription with user profile enrichment
- Chat: SingleChat + GroupChat with full media (image/video/audio/file), revoke, pull-up load more
- Contacts: local contacts list + UserSearch with debounced fuzzy search
- Groups: GroupList, CreateGroup (fuzzy member picker), GroupMembers, GroupSettings
- Profile: view + EditProfile (nickname, gender)
- MessageSearch: local DB full-text search across conversations
- ChatInput: text, 20-emoji picker, image/video/audio/file send, tap-to-record audio
- DisconnectBanner: connection status with reconnect
- AuthContext: uses await XuqmSDK.initialize({ appId, serverUrl }) for remote config
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-25 16:41:54 +08:00
|
|
|
|
setLoading(true)
|
|
|
|
|
|
try {
|
2026-04-28 20:11:38 +08:00
|
|
|
|
const list = text.trim()
|
|
|
|
|
|
? await ImSDK.searchGroups(text.trim())
|
|
|
|
|
|
: await ImSDK.listGroups()
|
feat: complete production chat demo — all screens, real media, SDK remote init
- App.tsx: replaced dev console with AuthProvider + AppNavigator
- Auth: Login, Register, ResetPassword screens via demo-service
- Conversations: reactive WatermelonDB subscription with user profile enrichment
- Chat: SingleChat + GroupChat with full media (image/video/audio/file), revoke, pull-up load more
- Contacts: local contacts list + UserSearch with debounced fuzzy search
- Groups: GroupList, CreateGroup (fuzzy member picker), GroupMembers, GroupSettings
- Profile: view + EditProfile (nickname, gender)
- MessageSearch: local DB full-text search across conversations
- ChatInput: text, 20-emoji picker, image/video/audio/file send, tap-to-record audio
- DisconnectBanner: connection status with reconnect
- AuthContext: uses await XuqmSDK.initialize({ appId, serverUrl }) for remote config
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-25 16:41:54 +08:00
|
|
|
|
setGroups(list)
|
|
|
|
|
|
} catch {
|
|
|
|
|
|
/* silently fail */
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
setLoading(false)
|
|
|
|
|
|
}
|
2026-04-28 20:11:38 +08:00
|
|
|
|
}, [keyword])
|
feat: complete production chat demo — all screens, real media, SDK remote init
- App.tsx: replaced dev console with AuthProvider + AppNavigator
- Auth: Login, Register, ResetPassword screens via demo-service
- Conversations: reactive WatermelonDB subscription with user profile enrichment
- Chat: SingleChat + GroupChat with full media (image/video/audio/file), revoke, pull-up load more
- Contacts: local contacts list + UserSearch with debounced fuzzy search
- Groups: GroupList, CreateGroup (fuzzy member picker), GroupMembers, GroupSettings
- Profile: view + EditProfile (nickname, gender)
- MessageSearch: local DB full-text search across conversations
- ChatInput: text, 20-emoji picker, image/video/audio/file send, tap-to-record audio
- DisconnectBanner: connection status with reconnect
- AuthContext: uses await XuqmSDK.initialize({ appId, serverUrl }) for remote config
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-25 16:41:54 +08:00
|
|
|
|
|
2026-04-28 20:11:38 +08:00
|
|
|
|
const handleSearch = useCallback((text: string) => {
|
|
|
|
|
|
setKeyword(text)
|
|
|
|
|
|
if (debounceRef.current) clearTimeout(debounceRef.current)
|
|
|
|
|
|
debounceRef.current = setTimeout(() => {
|
|
|
|
|
|
fetchGroups(text)
|
|
|
|
|
|
}, 300)
|
|
|
|
|
|
}, [fetchGroups])
|
|
|
|
|
|
|
|
|
|
|
|
useFocusEffect(useCallback(() => {
|
|
|
|
|
|
fetchGroups()
|
|
|
|
|
|
}, [fetchGroups]))
|
feat: complete production chat demo — all screens, real media, SDK remote init
- App.tsx: replaced dev console with AuthProvider + AppNavigator
- Auth: Login, Register, ResetPassword screens via demo-service
- Conversations: reactive WatermelonDB subscription with user profile enrichment
- Chat: SingleChat + GroupChat with full media (image/video/audio/file), revoke, pull-up load more
- Contacts: local contacts list + UserSearch with debounced fuzzy search
- Groups: GroupList, CreateGroup (fuzzy member picker), GroupMembers, GroupSettings
- Profile: view + EditProfile (nickname, gender)
- MessageSearch: local DB full-text search across conversations
- ChatInput: text, 20-emoji picker, image/video/audio/file send, tap-to-record audio
- DisconnectBanner: connection status with reconnect
- AuthContext: uses await XuqmSDK.initialize({ appId, serverUrl }) for remote config
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-25 16:41:54 +08:00
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
|
<SafeAreaView style={styles.root}>
|
|
|
|
|
|
<View style={styles.header}>
|
|
|
|
|
|
<Text style={styles.title}>群聊</Text>
|
|
|
|
|
|
<TouchableOpacity style={styles.createBtn} onPress={() => navigation.navigate('CreateGroup')}>
|
|
|
|
|
|
<Text style={styles.createBtnText}>+ 创建</Text>
|
|
|
|
|
|
</TouchableOpacity>
|
|
|
|
|
|
</View>
|
2026-04-28 20:11:38 +08:00
|
|
|
|
<View style={styles.searchBar}>
|
|
|
|
|
|
<TextInput
|
|
|
|
|
|
style={styles.searchInput}
|
|
|
|
|
|
placeholder="搜索群名称或群号"
|
|
|
|
|
|
value={keyword}
|
|
|
|
|
|
onChangeText={handleSearch}
|
|
|
|
|
|
clearButtonMode="while-editing"
|
|
|
|
|
|
/>
|
|
|
|
|
|
</View>
|
feat: complete production chat demo — all screens, real media, SDK remote init
- App.tsx: replaced dev console with AuthProvider + AppNavigator
- Auth: Login, Register, ResetPassword screens via demo-service
- Conversations: reactive WatermelonDB subscription with user profile enrichment
- Chat: SingleChat + GroupChat with full media (image/video/audio/file), revoke, pull-up load more
- Contacts: local contacts list + UserSearch with debounced fuzzy search
- Groups: GroupList, CreateGroup (fuzzy member picker), GroupMembers, GroupSettings
- Profile: view + EditProfile (nickname, gender)
- MessageSearch: local DB full-text search across conversations
- ChatInput: text, 20-emoji picker, image/video/audio/file send, tap-to-record audio
- DisconnectBanner: connection status with reconnect
- AuthContext: uses await XuqmSDK.initialize({ appId, serverUrl }) for remote config
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-25 16:41:54 +08:00
|
|
|
|
{loading
|
2026-04-28 20:11:38 +08:00
|
|
|
|
? <ActivityIndicator style={styles.loading} color="#07C160" />
|
feat: complete production chat demo — all screens, real media, SDK remote init
- App.tsx: replaced dev console with AuthProvider + AppNavigator
- Auth: Login, Register, ResetPassword screens via demo-service
- Conversations: reactive WatermelonDB subscription with user profile enrichment
- Chat: SingleChat + GroupChat with full media (image/video/audio/file), revoke, pull-up load more
- Contacts: local contacts list + UserSearch with debounced fuzzy search
- Groups: GroupList, CreateGroup (fuzzy member picker), GroupMembers, GroupSettings
- Profile: view + EditProfile (nickname, gender)
- MessageSearch: local DB full-text search across conversations
- ChatInput: text, 20-emoji picker, image/video/audio/file send, tap-to-record audio
- DisconnectBanner: connection status with reconnect
- AuthContext: uses await XuqmSDK.initialize({ appId, serverUrl }) for remote config
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-25 16:41:54 +08:00
|
|
|
|
: (
|
|
|
|
|
|
<FlatList
|
|
|
|
|
|
data={groups}
|
|
|
|
|
|
keyExtractor={g => g.id}
|
|
|
|
|
|
renderItem={({ item }) => (
|
|
|
|
|
|
<GroupRow
|
|
|
|
|
|
group={item}
|
|
|
|
|
|
onPress={() => navigation.navigate('GroupChat', { groupId: item.id, groupName: item.name })}
|
|
|
|
|
|
/>
|
|
|
|
|
|
)}
|
|
|
|
|
|
ItemSeparatorComponent={() => <View style={styles.sep} />}
|
|
|
|
|
|
ListEmptyComponent={<View style={styles.empty}><Text style={styles.emptyText}>还没有群聊</Text></View>}
|
|
|
|
|
|
/>
|
|
|
|
|
|
)
|
|
|
|
|
|
}
|
|
|
|
|
|
</SafeAreaView>
|
|
|
|
|
|
)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const styles = StyleSheet.create({
|
|
|
|
|
|
root: { flex: 1, backgroundColor: '#f5f5f5' },
|
|
|
|
|
|
header: { flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center', padding: 16, backgroundColor: '#fff', borderBottomWidth: StyleSheet.hairlineWidth, borderBottomColor: '#e0e0e0' },
|
|
|
|
|
|
title: { fontSize: 18, fontWeight: '700', color: '#111' },
|
|
|
|
|
|
createBtn: { paddingHorizontal: 12, paddingVertical: 6, backgroundColor: '#07C160', borderRadius: 6 },
|
|
|
|
|
|
createBtnText: { color: '#fff', fontSize: 13, fontWeight: '600' },
|
2026-04-28 20:11:38 +08:00
|
|
|
|
searchBar: { margin: 12, backgroundColor: '#fff', borderRadius: 8, paddingHorizontal: 12, borderWidth: 1, borderColor: '#e0e0e0' },
|
|
|
|
|
|
searchInput: { fontSize: 15, paddingVertical: 10 },
|
|
|
|
|
|
loading: { flex: 1 },
|
feat: complete production chat demo — all screens, real media, SDK remote init
- App.tsx: replaced dev console with AuthProvider + AppNavigator
- Auth: Login, Register, ResetPassword screens via demo-service
- Conversations: reactive WatermelonDB subscription with user profile enrichment
- Chat: SingleChat + GroupChat with full media (image/video/audio/file), revoke, pull-up load more
- Contacts: local contacts list + UserSearch with debounced fuzzy search
- Groups: GroupList, CreateGroup (fuzzy member picker), GroupMembers, GroupSettings
- Profile: view + EditProfile (nickname, gender)
- MessageSearch: local DB full-text search across conversations
- ChatInput: text, 20-emoji picker, image/video/audio/file send, tap-to-record audio
- DisconnectBanner: connection status with reconnect
- AuthContext: uses await XuqmSDK.initialize({ appId, serverUrl }) for remote config
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-25 16:41:54 +08:00
|
|
|
|
row: { flexDirection: 'row', alignItems: 'center', padding: 12, backgroundColor: '#fff' },
|
|
|
|
|
|
avatar: { width: 46, height: 46, borderRadius: 8, backgroundColor: '#5856d6', alignItems: 'center', justifyContent: 'center', marginRight: 12 },
|
|
|
|
|
|
avatarText: { color: '#fff', fontSize: 18, fontWeight: '600' },
|
|
|
|
|
|
body: { flex: 1 },
|
|
|
|
|
|
name: { fontSize: 16, fontWeight: '500', color: '#111' },
|
|
|
|
|
|
memberCount: { fontSize: 13, color: '#888', marginTop: 2 },
|
|
|
|
|
|
arrow: { color: '#ccc', fontSize: 20 },
|
|
|
|
|
|
sep: { height: StyleSheet.hairlineWidth, backgroundColor: '#e0e0e0', marginLeft: 70 },
|
|
|
|
|
|
empty: { alignItems: 'center', paddingTop: 80 },
|
|
|
|
|
|
emptyText: { color: '#bbb', fontSize: 15 },
|
|
|
|
|
|
})
|