From 44c5bf0eea3dcc816a315793f686e7719e58784d Mon Sep 17 00:00:00 2001 From: Adolfo Reyna Date: Thu, 22 Dec 2022 14:48:17 -0500 Subject: [PATCH] Reorganize all the navigators --- App.js | 87 +++++++++++++++++++++++++-------------------------- Views/Feed.js | 34 +++++++++----------- Views/Menu.js | 43 +++++++++++++++++++++++++ 3 files changed, 100 insertions(+), 64 deletions(-) create mode 100644 Views/Menu.js diff --git a/App.js b/App.js index badd3f7..207ba78 100644 --- a/App.js +++ b/App.js @@ -3,7 +3,7 @@ import React, { useState, useRef, useEffect } from 'react'; import { NavigationContainer } from '@react-navigation/native'; import { createNativeStackNavigator } from '@react-navigation/native-stack'; import { createBottomTabNavigator } from '@react-navigation/bottom-tabs'; -import { Provider as PaperProvider, DefaultTheme, } from 'react-native-paper'; +import { Provider as PaperProvider, DefaultTheme, Appbar, Button, } from 'react-native-paper'; import MaterialIcons from 'react-native-vector-icons/MaterialIcons'; import Login from "./Views/Login.js" import Feed from "./Views/Feed.js" @@ -19,6 +19,7 @@ import API from './API.js'; import i18n from "./i18nMessages.js"; import NewPostView from './Views/NewPost.js'; import { TouchableOpacity, View } from 'react-native'; +import MenuView from './Views/Menu.js'; const Tab = createBottomTabNavigator(); @@ -114,10 +115,6 @@ const MainNavigation = () => { { /> ( - + ), header: () => { <> }, }} @@ -178,28 +175,6 @@ const MainNavigation = () => { }} /> ( - - ), - header: () => { <> }, - }} - /> - ( - - ), - header: () => { <> }, - }} - /> - {/* { header: () => { <> }, }} /> - + ( + + ), + header: () => { <> }, + }} + /> + {/* { header: () => { <> }, }} />*/} + ) } @@ -232,30 +219,40 @@ export default function App() { icon: props => , }} theme={theme}> - - + + { + return ( + + {props.navigation.canGoBack() ? { + props.navigation.goBack(); + }} /> : <>} + + {props.navigation.navigate("Search")}} /> + {props.navigation.navigate("Notifications")}} /> + + ) + }, + }}> { <> }, - }} /> + + diff --git a/Views/Feed.js b/Views/Feed.js index b0c0816..056eb0d 100644 --- a/Views/Feed.js +++ b/Views/Feed.js @@ -71,24 +71,21 @@ let Feed = ({ navigation, route }) => { return ( - - - - item._id || item.createdAt} - ListHeaderComponent={ setPosts([newPost, ...Posts])} />} - refreshing={Posts.length === 0} - onRefresh={() => { - API.getPosts().then(setPosts); - }} - initialNumToRender={3} - maxToRenderPerBatch={3} - removeClippedSubviews={true} - /> - - + + item._id || item.createdAt} + //ListHeaderComponent={ setPosts([newPost, ...Posts])} />} + refreshing={Posts.length === 0} + onRefresh={() => { + API.getPosts().then(setPosts); + }} + initialNumToRender={3} + maxToRenderPerBatch={3} + removeClippedSubviews={true} + style={styles.container} + /> ); } @@ -97,7 +94,6 @@ export default Feed; const styles = StyleSheet.create({ container: { - flex: 1, backgroundColor: "#edf2f7", }, }); diff --git a/Views/Menu.js b/Views/Menu.js new file mode 100644 index 0000000..e0ce081 --- /dev/null +++ b/Views/Menu.js @@ -0,0 +1,43 @@ +import React from "react"; +import { View } from "react-native"; +import { Text, List, RadioButton } from "react-native-paper"; +import { SafeAreaView } from "react-native-safe-area-context"; +import i18n from "../i18nMessages.js"; +import Moment from 'moment'; + + +let MenuView = ()=>{ + const [value, setValue] = React.useState('es'); + + React.useEffect(()=>{ + i18n.locale = value; + Moment.updateLocale(i18n.locale); + }, [value]) + + return ( + + + } + expanded={true} + > + } /> + + } /> + + setValue(newValue)} value={value}> + + EspaƱol + + + + English + + + + + ) +} + +export default MenuView; \ No newline at end of file