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 React, { useCallback, useEffect, useState } from 'react'
|
|
|
|
|
import {
|
2026-04-27 11:58:07 +08:00
|
|
|
View, Text, FlatList, StyleSheet, TouchableOpacity, SafeAreaView, ActivityIndicator, Alert, Image,
|
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
|
|
|
} from 'react-native'
|
|
|
|
|
import { useNavigation, useFocusEffect } from '@react-navigation/native'
|
|
|
|
|
import type { NativeStackScreenProps } from '@react-navigation/native-stack'
|
|
|
|
|
import { ImSDK } from '@xuqm/rn-sdk'
|
|
|
|
|
import { demoApi, type UserProfile } from '../../api/demo'
|
|
|
|
|
import type { RootStackParams } from '../../navigation/types'
|
|
|
|
|
|
|
|
|
|
type Props = NativeStackScreenProps<RootStackParams, 'GroupMembers'>
|
|
|
|
|
|
|
|
|
|
export default function GroupMembersScreen({ route }: Props) {
|
|
|
|
|
const { groupId, groupName } = route.params
|
|
|
|
|
const navigation = useNavigation()
|
|
|
|
|
const [members, setMembers] = useState<UserProfile[]>([])
|
|
|
|
|
const [loading, setLoading] = useState(true)
|
|
|
|
|
|
|
|
|
|
const load = useCallback(async () => {
|
|
|
|
|
setLoading(true)
|
|
|
|
|
try {
|
|
|
|
|
const groups = await ImSDK.listGroups()
|
|
|
|
|
const group = groups.find(g => g.id === groupId)
|
|
|
|
|
if (!group) return
|
2026-04-27 11:58:07 +08:00
|
|
|
let ids: string[]
|
|
|
|
|
try { ids = JSON.parse(group.memberIds || '[]') }
|
|
|
|
|
catch { ids = group.memberIds ? group.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
|
|
|
const profiles = await Promise.all(
|
|
|
|
|
ids.map(async id => {
|
|
|
|
|
const res = await demoApi.searchUsers(id)
|
|
|
|
|
return res.find(u => u.userId === id) ?? { userId: id, nickname: id, avatar: '', gender: 'UNKNOWN' as const, status: '' }
|
|
|
|
|
})
|
|
|
|
|
)
|
|
|
|
|
setMembers(profiles)
|
|
|
|
|
} catch {
|
|
|
|
|
/* silently fail */
|
|
|
|
|
} finally {
|
|
|
|
|
setLoading(false)
|
|
|
|
|
}
|
|
|
|
|
}, [groupId])
|
|
|
|
|
|
|
|
|
|
useFocusEffect(useCallback(() => { load() }, [load]))
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<SafeAreaView style={styles.root}>
|
|
|
|
|
{loading
|
|
|
|
|
? <ActivityIndicator style={{ flex: 1 }} color="#07C160" />
|
|
|
|
|
: (
|
|
|
|
|
<FlatList
|
|
|
|
|
data={members}
|
|
|
|
|
keyExtractor={u => u.userId}
|
|
|
|
|
renderItem={({ item }) => {
|
|
|
|
|
const letter = (item.nickname || item.userId).charAt(0).toUpperCase()
|
|
|
|
|
return (
|
|
|
|
|
<View style={styles.row}>
|
2026-04-27 11:58:07 +08:00
|
|
|
{item.avatar ? (
|
|
|
|
|
<Image source={{ uri: item.avatar }} style={styles.avatar} />
|
|
|
|
|
) : (
|
|
|
|
|
<View style={[styles.avatar, styles.avatarFallback]}>
|
|
|
|
|
<Text style={styles.avatarText}>{letter}</Text>
|
|
|
|
|
</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
|
|
|
<View style={styles.body}>
|
|
|
|
|
<Text style={styles.name}>{item.nickname}</Text>
|
|
|
|
|
<Text style={styles.uid}>@{item.userId}</Text>
|
|
|
|
|
</View>
|
|
|
|
|
</View>
|
|
|
|
|
)
|
|
|
|
|
}}
|
|
|
|
|
ItemSeparatorComponent={() => <View style={styles.sep} />}
|
|
|
|
|
ListHeaderComponent={<Text style={styles.count}>{members.length} 名成员</Text>}
|
|
|
|
|
/>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
</SafeAreaView>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const styles = StyleSheet.create({
|
|
|
|
|
root: { flex: 1, backgroundColor: '#f5f5f5' },
|
|
|
|
|
count: { padding: 12, fontSize: 13, color: '#888', backgroundColor: '#f5f5f5' },
|
|
|
|
|
row: { flexDirection: 'row', alignItems: 'center', padding: 12, backgroundColor: '#fff' },
|
2026-04-27 11:58:07 +08:00
|
|
|
avatar: { width: 44, height: 44, borderRadius: 8, marginRight: 12 },
|
|
|
|
|
avatarFallback: { backgroundColor: '#5856d6', alignItems: 'center', justifyContent: 'center' },
|
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
|
|
|
avatarText: { color: '#fff', fontSize: 17, fontWeight: '600' },
|
|
|
|
|
body: { flex: 1 },
|
|
|
|
|
name: { fontSize: 16, fontWeight: '500', color: '#111' },
|
|
|
|
|
uid: { fontSize: 13, color: '#888', marginTop: 2 },
|
|
|
|
|
sep: { height: StyleSheet.hairlineWidth, backgroundColor: '#e0e0e0', marginLeft: 68 },
|
|
|
|
|
})
|