Profile Settings

This commit is contained in:
Adolfo Reyna
2022-12-23 00:17:36 -05:00
parent 4c95095882
commit bf0807ba8c
5 changed files with 90 additions and 36 deletions

7
App.js
View File

@@ -20,6 +20,7 @@ import i18n from "./i18nMessages.js";
import NewPostView from './Views/NewPost.js'; import NewPostView from './Views/NewPost.js';
import { TouchableOpacity, View } from 'react-native'; import { TouchableOpacity, View } from 'react-native';
import MenuView from './Views/Menu.js'; import MenuView from './Views/Menu.js';
import ProfileSettings from './Views/ProfileSettings.js';
const Tab = createBottomTabNavigator(); const Tab = createBottomTabNavigator();
@@ -156,7 +157,7 @@ const MainNavigation = () => {
<TouchableOpacity <TouchableOpacity
onPress={props.onPress} onPress={props.onPress}
style={{ style={{
top: -27, top: -17,
justifyContent: 'center', justifyContent: 'center',
alignItems: 'center', alignItems: 'center',
@@ -250,6 +251,10 @@ export default function App() {
name="Search" name="Search"
component={Search} component={Search}
/> />
<Stack.Screen
name="ProfileSettings"
component={ProfileSettings}
/>
<Stack.Screen <Stack.Screen
name="Notifications" name="Notifications"
component={NotificationsView} component={NotificationsView}

View File

@@ -1,38 +1,36 @@
import React from "react"; import React from "react";
import { View } from "react-native"; import { View } from "react-native";
import { Text, List, RadioButton } from "react-native-paper"; import { Text, List, RadioButton } from "react-native-paper";
import { SafeAreaView } from "react-native-safe-area-context";
import i18n from "../i18nMessages.js"; import i18n from "../i18nMessages.js";
import Moment from 'moment'; import Moment from 'moment';
import 'moment/min/locales'; import 'moment/min/locales';
Moment.locale(i18n.locale); Moment.locale(i18n.locale);
let MenuView = ()=>{ let MenuView = ({navigation})=>{
const [value, setValue] = React.useState('es'); const [value, setValue] = React.useState('es');
React.useEffect(()=>{ let changeLang = (locale) =>{
i18n.locale = value; i18n.locale = locale;
Moment.updateLocale(i18n.locale); Moment.locale(locale);
}, [value]) setValue(locale);
}
return ( return (
<View> <View>
<List.Section title="User Actions"> <List.Section title="User Actions">
<List.Item title="Profile" onPress={()=>{navigation.navigate("ProfileSettings")}} left={props => <List.Icon {...props} icon="person" />} />
<List.Item title="Settings" left={props => <List.Icon {...props} icon="settings" />} /> <List.Item title="Settings" left={props => <List.Icon {...props} icon="settings" />} />
<List.Item title="Sign out" left={props => <List.Icon {...props} icon="logout" />} /> <List.Item title="Sign out" left={props => <List.Icon {...props} icon="logout" />} />
</List.Section>
<List.Section title="Fellowship App">
<List.Item title="About" left={props => <List.Icon {...props} icon="more" />} /> <List.Item title="About" left={props => <List.Icon {...props} icon="more" />} />
</List.Section> </List.Section>
<View> <View style={{padding: 10}}>
<RadioButton.Group onValueChange={newValue => setValue(newValue)} value={value}> <Text>Lenguage:</Text>
<View> <RadioButton.Group onValueChange={newValue => changeLang(newValue)} value={value}>
<Text>Español</Text> <RadioButton.Item value="es" label="Español"/>
<RadioButton value="es" /> <RadioButton.Item value="en" label="English"/>
</View>
<View>
<Text>English</Text>
<RadioButton value="en" />
</View>
</RadioButton.Group> </RadioButton.Group>
</View> </View>
</View> </View>

51
Views/ProfileSettings.js Normal file
View File

@@ -0,0 +1,51 @@
import React from "react";
import { View } from "react-native";
import { Text, TextInput, RadioButton, Divider } from "react-native-paper";
import i18n from "../i18nMessages.js";
import Moment from 'moment';
import 'moment/min/locales';
import ProfileCardHorizontal from "../components/ProfileCardHorizontal.js";
Moment.locale(i18n.locale);
import { useSnapshot } from 'valtio';
import GlobalState from '../contexts/GlobalState.js';
let ProfileSettings = ()=>{
const gState = useSnapshot(GlobalState);
const viewer = gState.me;
return (
<View style={{
padding: 10
}}>
<Text style={{marginBottom:10, fontSize:20}}>Profile Settings</Text>
<View style={{flexDirection:"row", justifyContent:"space-between"}}>
<TextInput
label="First Name"
style={{width:"48%", backgroundColor:"rgba(0,0,0,0)"}}
value={gState.me.profile.firstName}
//onChangeText={text => setText(text)}
/>
<TextInput
label="Last Name"
style={{width:"48%", backgroundColor:"rgba(0,0,0,0)"}}
value={gState.me.profile.lastName}
//onChangeText={text => setText(text)}
/>
</View>
<TextInput
label="Description"
style={{backgroundColor:"rgba(0,0,0,0)"}}
multiline={true}
numberOfLines={3}
value={gState.me.profile.description}
//onChangeText={text => setText(text)}
/>
<Divider />
<View style={{paddingTop: 10}}>
<ProfileCardHorizontal profileObj={gState.me} skipFollow={true} skiptOnPress={true} />
</View>
</View>
)
}
export default ProfileSettings;

View File

@@ -40,12 +40,11 @@ const Search = () => {
return (<ProfileCardHorizontal profileid={item} />); return (<ProfileCardHorizontal profileid={item} />);
}); });
return ( return (
<SafeAreaView style={{ flex: 1 }}> <SafeAreaView style={{ flex: 1, backgroundColor: "#edf2f7", }}>
<Searchbar <Searchbar
placeholder="Search Users" placeholder="Search Users"
onChangeText={onChangeSearch} onChangeText={onChangeSearch}
value={searchQuery} value={searchQuery}
elevation={3}
/> />
{ {
searchQuery.length ? searchQuery.length ?
@@ -56,16 +55,14 @@ const Search = () => {
renderItem={renderProfile} renderItem={renderProfile}
keyExtractor={item => item._id} keyExtractor={item => item._id}
/> : /> :
<>
<Text>Current Following:</Text>
<FlatList <FlatList
contentContainerStyle={styles.container} contentContainerStyle={styles.container}
numColumns={1} numColumns={1}
data={viewer.following} data={viewer.following}
renderItem={renderFollowing} renderItem={renderFollowing}
keyExtractor={item => item} keyExtractor={item => item}
ListHeaderComponent={<Text style={{fontSize:20, padding:10, alignSelf: "center"}}>Current Following</Text>}
/> />
</>
} }
</SafeAreaView> </SafeAreaView>
) )

View File

@@ -28,7 +28,7 @@ const getName = async (key) => {
} }
} }
let ProfileCardHorizontal = ({ profileid, hideIcon, profileObj }) => { let ProfileCardHorizontal = ({ profileid, hideIcon, profileObj, skipFollow, skiptOnPress }) => {
let [profile, setProfile] = useState(profileObj || {}); let [profile, setProfile] = useState(profileObj || {});
const navigation = useNavigation(); const navigation = useNavigation();
@@ -54,13 +54,14 @@ let ProfileCardHorizontal = ({ profileid, hideIcon, profileObj }) => {
let photoUrl = profile.profile?.photo ? 'https://social.emmint.com/' + profile.profile.photo : DefaultPhoto; let photoUrl = profile.profile?.photo ? 'https://social.emmint.com/' + profile.profile.photo : DefaultPhoto;
const onPress = () => { const onPress = () => {
if(skiptOnPress) return 0;
return navigation.navigate('Profile', { profileid: profile._id }) return navigation.navigate('Profile', { profileid: profile._id })
} }
return ( return (
<Card style={styles.content} mode="elevated"> <Card style={styles.content} mode="elevated">
<Card.Content> <Card.Content>
<View style={{ flexDirection: "row" }}> <View style={{ flexDirection: "row", alignItems: "center" }}>
<View onPress={onPress}> <View onPress={onPress}>
<Avatar.Image size={75} source={{ uri: photoUrl }} /> <Avatar.Image size={75} source={{ uri: photoUrl }} />
</View> </View>
@@ -74,6 +75,7 @@ let ProfileCardHorizontal = ({ profileid, hideIcon, profileObj }) => {
</View> </View>
</View> </View>
{skipFollow ? <></> :
<View style={{ <View style={{
position: "absolute", position: "absolute",
top: 0, top: 0,
@@ -86,6 +88,7 @@ let ProfileCardHorizontal = ({ profileid, hideIcon, profileObj }) => {
}}> }}>
<FollowButton profile={profile._id ? profile : { _id: profileid }} /> <FollowButton profile={profile._id ? profile : { _id: profileid }} />
</View> </View>
}
</Card.Content> </Card.Content>
</Card> </Card>
); );