Adding change of profiles and Profile on tab bar
This commit is contained in:
70
Views/SelectProfile.js
Normal file
70
Views/SelectProfile.js
Normal file
@@ -0,0 +1,70 @@
|
||||
import React from "react";
|
||||
import { View, ImageBackground, ScrollView } from "react-native";
|
||||
import { Text, List, RadioButton } from "react-native-paper";
|
||||
import i18n from "../i18nMessages.js";
|
||||
import Moment from 'moment';
|
||||
import 'moment/min/locales';
|
||||
Moment.locale(i18n.locale);
|
||||
import API from '../API.js';
|
||||
import { useSnapshot } from 'valtio';
|
||||
import GlobalState from '../contexts/GlobalState.js';
|
||||
import ProfileCardHorizontal from "../components/ProfileCardHorizontal.js";
|
||||
|
||||
|
||||
let MenuView = ({ navigation }) => {
|
||||
const [value, setValue] = React.useState('es');
|
||||
const [myProfiles, setMyProfiles] = React.useState([]);
|
||||
const gState = useSnapshot(GlobalState);
|
||||
const viewer = gState.me;
|
||||
|
||||
React.useEffect(() => {
|
||||
let subscribed = true;
|
||||
let getData = async () => {
|
||||
const r = await API.getMyProfiles();
|
||||
if (!subscribed) return;
|
||||
console.log("profiles", r)
|
||||
setMyProfiles(r);
|
||||
}
|
||||
getData();
|
||||
return () => {
|
||||
subscribed = false;
|
||||
}
|
||||
}, []);
|
||||
|
||||
let changeLang = (locale) => {
|
||||
i18n.locale = locale;
|
||||
Moment.locale(locale);
|
||||
setValue(locale);
|
||||
}
|
||||
|
||||
return (
|
||||
<ScrollView>
|
||||
<ImageBackground source={require("../assets/settings.png")}
|
||||
style={{ paddingTop: 10 }}
|
||||
imageStyle={{ resizeMode: "contain", opacity: 0.05 }}
|
||||
>
|
||||
<List.Section title="Current Profile">
|
||||
<ProfileCardHorizontal profileObj={viewer} skipFollow={true} skiptOnPress={true} />
|
||||
</List.Section>
|
||||
<List.Section title="User Actions">
|
||||
<List.Item title={i18n.t('message.profile')} onPress={() => { navigation.navigate("ProfileSettings") }} left={props => <List.Icon {...props} icon="person" />} />
|
||||
<List.Item title={i18n.t('message.settings')} left={props => <List.Icon {...props} icon="settings" />} />
|
||||
<List.Item title={i18n.t('message.logout')} onPress={() => { navigation.navigate("Logout") }} left={props => <List.Icon {...props} icon="logout" />} />
|
||||
</List.Section>
|
||||
<List.Section title="Fellowship App">
|
||||
<List.Item title={i18n.t('message.invite')} onPress={() => { navigation.navigate("Invite") }} left={props => <List.Icon {...props} icon="person-add" />} />
|
||||
<List.Item title={i18n.t('message.about')} left={props => <List.Icon {...props} icon="more" />} />
|
||||
</List.Section>
|
||||
<View style={{ padding: 10 }}>
|
||||
<Text>Language:</Text>
|
||||
<RadioButton.Group onValueChange={newValue => changeLang(newValue)} value={value}>
|
||||
<RadioButton.Item value="es" label="Español" />
|
||||
<RadioButton.Item value="en" label="English" />
|
||||
</RadioButton.Group>
|
||||
</View>
|
||||
</ImageBackground>
|
||||
</ScrollView>
|
||||
)
|
||||
}
|
||||
|
||||
export default MenuView;
|
||||
Reference in New Issue
Block a user