aboutsummaryrefslogtreecommitdiffstats
path: root/components/Menu.jsx
diff options
context:
space:
mode:
Diffstat (limited to 'components/Menu.jsx')
-rw-r--r--components/Menu.jsx93
1 files changed, 49 insertions, 44 deletions
diff --git a/components/Menu.jsx b/components/Menu.jsx
index 519fe94..f380c62 100644
--- a/components/Menu.jsx
+++ b/components/Menu.jsx
@@ -1,49 +1,54 @@
import { StyleSheet, Text, View } from 'react-native';
-import { handleLogout } from '../helpers'
+import { handleLogout, SORT } from '../helpers'
-const Menu = ({ session, setSession, setEdit, showError, saveNote }) => (
- <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}
- >
- Sort
- </Text>
- <Text
- style={styles.menuText}
- onPress={() => handleLogout({ session, setSession, showError })}
- >
- {session.email}
- </Text>
- </>
- )
- }
- </View>
-)
+const Menu = ({ session, setSession, setEdit, showError, saveNote, sort, setSort }) => {
+ const changeSort = () => sort < SORT.length-1 ? setSort(sort+1) : setSort(0)
+
+ 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}
+ onPress={changeSort}
+ >
+ {SORT[sort]}
+ </Text>
+ <Text
+ style={styles.menuText}
+ onPress={() => handleLogout({ session, setSession, showError })}
+ >
+ {session.email}
+ </Text>
+ </>
+ )
+ }
+ </View>
+ )
+}
const styles = StyleSheet.create({
menu: {