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 from 'react'
|
2026-04-27 11:58:07 +08:00
|
|
|
|
import { View, Text, StyleSheet, TouchableOpacity, SafeAreaView, Alert, ScrollView, Image } from 'react-native'
|
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 { useNavigation } from '@react-navigation/native'
|
|
|
|
|
|
import type { NativeStackNavigationProp } from '@react-navigation/native-stack'
|
|
|
|
|
|
import { useAuth } from '../../context/AuthContext'
|
|
|
|
|
|
import type { RootStackParams } from '../../navigation/types'
|
|
|
|
|
|
|
|
|
|
|
|
type Nav = NativeStackNavigationProp<RootStackParams>
|
|
|
|
|
|
|
|
|
|
|
|
function Row({ label, value, onPress }: { label: string; value?: string; onPress?(): void }) {
|
|
|
|
|
|
return (
|
|
|
|
|
|
<TouchableOpacity style={styles.row} onPress={onPress} disabled={!onPress} activeOpacity={onPress ? 0.7 : 1}>
|
|
|
|
|
|
<Text style={styles.rowLabel}>{label}</Text>
|
|
|
|
|
|
<View style={styles.rowRight}>
|
|
|
|
|
|
{value !== undefined && <Text style={styles.rowValue} numberOfLines={1}>{value}</Text>}
|
|
|
|
|
|
{onPress && <Text style={styles.arrow}>›</Text>}
|
|
|
|
|
|
</View>
|
|
|
|
|
|
</TouchableOpacity>
|
|
|
|
|
|
)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export default function ProfileScreen() {
|
|
|
|
|
|
const navigation = useNavigation<Nav>()
|
|
|
|
|
|
const { profile, logout } = useAuth()
|
|
|
|
|
|
|
|
|
|
|
|
const confirmLogout = () => {
|
|
|
|
|
|
Alert.alert('退出登录', '确定要退出吗?', [
|
|
|
|
|
|
{ text: '取消', style: 'cancel' },
|
|
|
|
|
|
{ text: '退出', style: 'destructive', onPress: () => logout() },
|
|
|
|
|
|
])
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const genderLabel = (g?: string) => ({ MALE: '男', FEMALE: '女', UNKNOWN: '未设置' }[g ?? 'UNKNOWN'] ?? '未设置')
|
|
|
|
|
|
const letter = (profile?.nickname || profile?.userId || '?').charAt(0).toUpperCase()
|
2026-04-27 11:58:07 +08:00
|
|
|
|
const avatarUri = profile?.avatar || undefined
|
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}>
|
|
|
|
|
|
<ScrollView>
|
|
|
|
|
|
<View style={styles.avatarSection}>
|
2026-04-27 11:58:07 +08:00
|
|
|
|
<TouchableOpacity onPress={() => navigation.navigate('EditProfile')} style={styles.avatarWrapper}>
|
|
|
|
|
|
{avatarUri ? (
|
|
|
|
|
|
<Image source={{ uri: avatarUri }} style={styles.avatarImg} />
|
|
|
|
|
|
) : (
|
|
|
|
|
|
<View style={styles.avatarCircle}>
|
|
|
|
|
|
<Text style={styles.avatarText}>{letter}</Text>
|
|
|
|
|
|
</View>
|
|
|
|
|
|
)}
|
|
|
|
|
|
<View style={styles.avatarEditBadge}>
|
|
|
|
|
|
<Text style={styles.avatarEditIcon}>✎</Text>
|
|
|
|
|
|
</View>
|
|
|
|
|
|
</TouchableOpacity>
|
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
|
|
|
|
<Text style={styles.nickname}>{profile?.nickname ?? '-'}</Text>
|
|
|
|
|
|
<Text style={styles.userId}>@{profile?.userId ?? '-'}</Text>
|
|
|
|
|
|
</View>
|
|
|
|
|
|
|
|
|
|
|
|
<View style={styles.section}>
|
|
|
|
|
|
<Row label="昵称" value={profile?.nickname} onPress={() => navigation.navigate('EditProfile')} />
|
|
|
|
|
|
<View style={styles.sep} />
|
|
|
|
|
|
<Row label="性别" value={genderLabel(profile?.gender)} onPress={() => navigation.navigate('EditProfile')} />
|
|
|
|
|
|
</View>
|
|
|
|
|
|
|
|
|
|
|
|
<TouchableOpacity style={styles.logoutBtn} onPress={confirmLogout}>
|
|
|
|
|
|
<Text style={styles.logoutText}>退出登录</Text>
|
|
|
|
|
|
</TouchableOpacity>
|
|
|
|
|
|
</ScrollView>
|
|
|
|
|
|
</SafeAreaView>
|
|
|
|
|
|
)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const styles = StyleSheet.create({
|
|
|
|
|
|
root: { flex: 1, backgroundColor: '#f5f5f5' },
|
|
|
|
|
|
avatarSection: { alignItems: 'center', paddingTop: 40, paddingBottom: 24, backgroundColor: '#fff', marginBottom: 16 },
|
2026-04-27 11:58:07 +08:00
|
|
|
|
avatarWrapper: { position: 'relative', marginBottom: 12 },
|
|
|
|
|
|
avatarImg: { width: 80, height: 80, borderRadius: 40 },
|
|
|
|
|
|
avatarCircle: { width: 80, height: 80, borderRadius: 40, backgroundColor: '#07C160', 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: 32, fontWeight: '700' },
|
2026-04-27 11:58:07 +08:00
|
|
|
|
avatarEditBadge: {
|
|
|
|
|
|
position: 'absolute',
|
|
|
|
|
|
bottom: 0,
|
|
|
|
|
|
right: 0,
|
|
|
|
|
|
width: 24,
|
|
|
|
|
|
height: 24,
|
|
|
|
|
|
borderRadius: 12,
|
|
|
|
|
|
backgroundColor: '#fff',
|
|
|
|
|
|
borderWidth: 1,
|
|
|
|
|
|
borderColor: '#e0e0e0',
|
|
|
|
|
|
alignItems: 'center',
|
|
|
|
|
|
justifyContent: 'center',
|
|
|
|
|
|
},
|
|
|
|
|
|
avatarEditIcon: { fontSize: 12, color: '#555' },
|
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
|
|
|
|
nickname: { fontSize: 20, fontWeight: '700', color: '#111', marginBottom: 4 },
|
|
|
|
|
|
userId: { fontSize: 13, color: '#888' },
|
|
|
|
|
|
section: { backgroundColor: '#fff', marginBottom: 16 },
|
|
|
|
|
|
row: { flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center', padding: 16 },
|
|
|
|
|
|
rowLabel: { fontSize: 16, color: '#333' },
|
|
|
|
|
|
rowRight: { flexDirection: 'row', alignItems: 'center', gap: 8 },
|
|
|
|
|
|
rowValue: { fontSize: 15, color: '#888', maxWidth: 160 },
|
|
|
|
|
|
arrow: { color: '#ccc', fontSize: 20 },
|
|
|
|
|
|
sep: { height: StyleSheet.hairlineWidth, backgroundColor: '#e0e0e0', marginLeft: 16 },
|
|
|
|
|
|
logoutBtn: { margin: 16, padding: 16, backgroundColor: '#fff', borderRadius: 8, alignItems: 'center' },
|
|
|
|
|
|
logoutText: { color: '#ff3b30', fontSize: 16, fontWeight: '600' },
|
|
|
|
|
|
})
|