import React, {useEffect, useState, createRef} from 'react'; import { ScrollView, View, Text, TouchableOpacity, SafeAreaView, Platform, FlatList, DeviceEventEmitter, } from 'react-native'; import NavigationService from '../../services/NavigationService'; import { COLOR_SCHEME, SIZE, br, ph, pv, opacity, FONT, WEIGHT, COLOR_SCHEME_DARK, setColorScheme, COLOR_SCHEME_LIGHT, clearThemeUpdateListener, onThemeUpdate, } from '../../common/common'; import Icon from 'react-native-vector-icons/Feather'; import {getElevation, w, h, Toast} from '../../utils/utils'; import AsyncStorage from '@react-native-community/async-storage'; import {useForceUpdate} from '../../views/ListsEditor'; export const Menu = ({close = () => {}, hide, update = () => {}}) => { const [colors, setColors] = useState(COLOR_SCHEME); const forceUpdate = useForceUpdate(); useEffect(() => { onThemeUpdate(() => { forceUpdate(); }); return () => { clearThemeUpdateListener(() => { forceUpdate(); }); }; }, []); return ( NavigationService.navigate('Home'), close: true, }, { name: 'Notebooks', icon: 'book', func: () => NavigationService.navigate('Folders', { title: 'Notebooks', }), close: true, }, { name: 'Lists', icon: 'list', func: () => NavigationService.navigate('Lists'), close: true, }, { name: 'Favorites', icon: 'star', func: () => NavigationService.navigate('Favorites'), close: true, }, { name: 'Dark Mode', icon: 'moon', func: () => { if (!colors.night) { AsyncStorage.setItem( 'theme', JSON.stringify(COLOR_SCHEME_DARK), ); setColorScheme(COLOR_SCHEME_DARK); } else { AsyncStorage.setItem( 'theme', JSON.stringify(COLOR_SCHEME_LIGHT), ); setColorScheme(COLOR_SCHEME_LIGHT); } }, switch: true, on: colors.night ? true : false, close: false, }, { name: 'Trash', icon: 'trash', func: () => NavigationService.navigate('Trash'), close: true, }, { name: 'Settings', icon: 'settings', func: () => NavigationService.navigate('Settings'), close: true, }, ]} keyExtractor={(item, index) => item.name} renderItem={({item, index}) => ( { item.close === false ? null : close(); item.func(); }} style={{ width: '100%', alignSelf: 'center', flexDirection: 'row', justifyContent: 'space-between', alignItems: 'flex-end', paddingHorizontal: ph, paddingVertical: 15, }}> {item.name} {item.switch ? ( ) : ( undefined )} )} /> { close(); NavigationService.navigate('Tags'); }} style={{ width: '100%', alignSelf: 'center', flexDirection: 'row', justifyContent: 'space-between', alignItems: 'flex-end', paddingHorizontal: ph, marginTop: 15, }}> Tags View All {[ 'home', 'office', 'work', 'book_notes', 'poem', 'lists', 'water', ].map(item => ( { close(); NavigationService.navigate('Notes', { heading: item, }); }} style={{ flexDirection: 'row', justifyContent: 'flex-start', alignItems: 'center', margin: 5, }}> #{item} ))} {['red', 'yellow', 'green', 'blue', 'purple', 'orange', 'gray'].map( item => ( ), )} {/* Upgrade to Pro */} { close(); NavigationService.navigate('Login'); }} activeOpacity={opacity} style={{ paddingVertical: pv, paddingHorizontal: ph, borderRadius: 5, width: '100%', justifyContent: 'center', alignItems: 'center', borderColor: colors.accent, backgroundColor: colors.accent, borderWidth: 1, }}> Login to Sync {/* Hi, Ammar! 80.45/100 MB */} {/* Basic User */} ); };