aboutsummaryrefslogtreecommitdiffstats
path: root/components/Menu.jsx
diff options
context:
space:
mode:
Diffstat (limited to 'components/Menu.jsx')
-rw-r--r--components/Menu.jsx71
1 files changed, 71 insertions, 0 deletions
diff --git a/components/Menu.jsx b/components/Menu.jsx
new file mode 100644
index 0000000..bc883e4
--- /dev/null
+++ b/components/Menu.jsx
@@ -0,0 +1,71 @@
+import { StyleSheet, Text, View } from 'react-native';
+import AsyncStorage from '@react-native-async-storage/async-storage';
+
+const Menu = ({ session, setSession, setEdit, showError, saveNote }) => {
+ const logout = async () => {
+ try {
+ await AsyncStorage.clear();
+ setSession(null)
+ } catch(e) {
+ showError('Error while logging out')
+ }
+ }
+
+ return (
+ <View style={styles.menu}>
+ {
+ saveNote
+ ? (
+ <>
+ <Text
+ style={styles.menuText}
+ onPress={() => setEdit(null)}
+ >
+ Back
+ </Text>
+ <Text
+ style={styles.menuText}
+ onPress={saveNote}
+ >
+ Save
+ </Text>
+ </>
+ ) : (
+ <>
+ <Text
+ style={styles.menuText}
+ onPress={() => setEdit({})}
+ >
+ New Note
+ </Text>
+ <Text style={styles.menuText}>{session.email}</Text>
+ <Text
+ style={styles.menuText}
+ onPress={logout}
+ >
+ Logout
+ </Text>
+ </>
+ )
+ }
+ </View>
+ )
+}
+
+const styles = StyleSheet.create({
+ menu: {
+ backgroundColor: 'lightgrey',
+ height: 55,
+ width: '100%',
+ flexDirection: 'row',
+ alignItems: 'flex-end',
+ justifyContent: 'space-between',
+ padding: 10,
+ },
+ menuText: {
+ fontWeight: 'bold',
+ paddingHorizontal: 10,
+ },
+});
+
+export default Menu