import React, { useContext, useEffect } from 'react'; import { Image, Platform, ScrollView, StyleSheet, Text, TouchableOpacity, View, } from 'react-native'; import { SafeAreaView, useSafeAreaInsets } from 'react-native-safe-area-context'; import { useTheme, version } from 'stream-chat-react-native'; import { USERS } from '../ChatUsers'; import { AppContext } from '../context/AppContext'; import { RightArrow } from '../icons/RightArrow'; import { StreamLogo } from '../icons/StreamLogo'; import { Settings } from '../icons/Settings'; import AsyncStore from '../utils/AsyncStore'; import type { StackNavigationProp } from '@react-navigation/stack'; import type { UserSelectorParamList } from '../types'; const styles = StyleSheet.create({ avatarImage: { borderRadius: 20, height: 40, width: 40, }, container: { flex: 1, }, contentContainer: { flexGrow: 1, }, footerText: { textAlign: 'center', }, nameContainer: { marginLeft: 8, }, rightArrow: { alignItems: 'center', flex: 1, flexDirection: 'row', justifyContent: 'flex-end', marginRight: 12, }, scrollContainer: { flex: 1, overflow: 'visible', }, subTitle: { fontSize: 14, marginTop: 13, }, title: { fontSize: 22, fontWeight: '600', marginTop: 20, }, titleContainer: { alignItems: 'center', paddingBottom: 31, paddingTop: 34, }, userContainer: { alignItems: 'center', borderBottomWidth: 1, flexDirection: 'row', paddingHorizontal: 8, paddingVertical: 12, }, userName: { fontSize: 16, fontWeight: '600', }, }); export type UserSelectorScreenNavigationProp = StackNavigationProp< UserSelectorParamList, 'UserSelectorScreen' >; type Props = { navigation: UserSelectorScreenNavigationProp; }; export const UserSelectorScreen: React.FC = ({ navigation }) => { const { theme: { colors: { black, border, grey, grey_gainsboro, grey_whisper, white_snow }, }, } = useTheme(); const { switchUser } = useContext(AppContext); const { bottom } = useSafeAreaInsets(); useEffect(() => { AsyncStore.setItem('@stream-rn-sampleapp-user-id', ''); }, []); return ( Welcome to Stream Chat Select a user to try the {Platform.OS === 'ios' ? 'iOS' : 'Android'} sdk: {Object.values(USERS).map((u, index) => ( { switchUser(u.id); }} style={[styles.userContainer, { borderBottomColor: border }]} testID='user-selector-button' > {u.name} Stream test account ))} { navigation.navigate('AdvancedUserSelectorScreen'); }} style={[styles.userContainer, { borderBottomColor: border }]} > Advanced Options Custom settings Stream SDK v{version} ); };