2019-12-21 11:12:55 +05:00
|
|
|
import React from 'react';
|
2019-12-04 11:40:59 +05:00
|
|
|
import {
|
|
|
|
|
ScrollView,
|
|
|
|
|
View,
|
|
|
|
|
Text,
|
|
|
|
|
TouchableOpacity,
|
|
|
|
|
Platform,
|
2020-01-07 18:14:36 +05:00
|
|
|
StatusBar,
|
2019-12-04 11:40:59 +05:00
|
|
|
} from 'react-native';
|
|
|
|
|
import NavigationService from '../../services/NavigationService';
|
|
|
|
|
import {
|
|
|
|
|
SIZE,
|
|
|
|
|
pv,
|
|
|
|
|
opacity,
|
|
|
|
|
WEIGHT,
|
2019-12-07 12:05:15 +05:00
|
|
|
COLOR_SCHEME_DARK,
|
|
|
|
|
COLOR_SCHEME_LIGHT,
|
2020-01-17 21:06:15 +05:00
|
|
|
ACCENT,
|
|
|
|
|
COLOR_SCHEME,
|
|
|
|
|
setColorScheme,
|
2019-12-04 11:40:59 +05:00
|
|
|
} from '../../common/common';
|
|
|
|
|
import Icon from 'react-native-vector-icons/Feather';
|
2019-12-09 08:53:45 +05:00
|
|
|
import {AnimatedSafeAreaView} from '../../views/Home';
|
2020-01-14 20:48:03 +05:00
|
|
|
import FastStorage from 'react-native-fast-storage';
|
2020-01-17 21:06:15 +05:00
|
|
|
import {useTracked, ACTIONS} from '../../provider';
|
|
|
|
|
|
2019-12-07 12:05:15 +05:00
|
|
|
export const Menu = ({close = () => {}, hide, update = () => {}}) => {
|
2020-01-17 21:26:01 +05:00
|
|
|
const [state, dispatch] = useTracked();
|
|
|
|
|
const {colors} = state;
|
2020-01-17 00:23:16 +05:00
|
|
|
|
|
|
|
|
// todo
|
|
|
|
|
|
2020-01-17 21:06:15 +05:00
|
|
|
function changeColorScheme(colors = COLOR_SCHEME, accent = ACCENT) {
|
|
|
|
|
let newColors = setColorScheme(colors, accent);
|
|
|
|
|
StatusBar.setBarStyle(newColors.night ? 'light-content' : 'dark-content');
|
|
|
|
|
|
|
|
|
|
dispatch({type: ACTIONS.THEME, colors: newColors});
|
|
|
|
|
}
|
2019-12-07 12:05:15 +05:00
|
|
|
|
2020-01-10 18:46:07 +05:00
|
|
|
const listItems = [
|
|
|
|
|
{
|
|
|
|
|
name: 'Home',
|
|
|
|
|
icon: 'home',
|
|
|
|
|
func: () => NavigationService.push('Home'),
|
|
|
|
|
close: true,
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
name: 'Notebooks',
|
|
|
|
|
icon: 'book',
|
|
|
|
|
func: () =>
|
|
|
|
|
NavigationService.push('Folders', {
|
|
|
|
|
title: 'Notebooks',
|
|
|
|
|
canGoBack: false,
|
|
|
|
|
}),
|
|
|
|
|
close: true,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'Lists',
|
|
|
|
|
icon: 'list',
|
|
|
|
|
func: () => NavigationService.push('Lists'),
|
|
|
|
|
close: true,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'Favorites',
|
|
|
|
|
icon: 'star',
|
|
|
|
|
func: () => NavigationService.push('Favorites'),
|
|
|
|
|
close: true,
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
name: 'Dark Mode',
|
|
|
|
|
icon: 'moon',
|
|
|
|
|
func: () => {
|
|
|
|
|
if (!colors.night) {
|
2020-01-14 20:48:03 +05:00
|
|
|
FastStorage.setItem('theme', JSON.stringify({night: true}));
|
2020-01-10 18:46:07 +05:00
|
|
|
changeColorScheme(COLOR_SCHEME_DARK);
|
|
|
|
|
} else {
|
2020-01-14 20:48:03 +05:00
|
|
|
FastStorage.setItem('theme', JSON.stringify({night: false}));
|
2020-01-10 18:46:07 +05:00
|
|
|
|
|
|
|
|
changeColorScheme(COLOR_SCHEME_LIGHT);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
switch: true,
|
|
|
|
|
on: colors.night ? true : false,
|
|
|
|
|
close: false,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'Trash',
|
|
|
|
|
icon: 'trash',
|
|
|
|
|
func: () => NavigationService.push('Trash'),
|
|
|
|
|
close: true,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'Settings',
|
|
|
|
|
icon: 'settings',
|
|
|
|
|
func: () => NavigationService.push('Settings'),
|
|
|
|
|
close: true,
|
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
|
2019-12-07 12:05:15 +05:00
|
|
|
return (
|
2019-12-09 08:53:45 +05:00
|
|
|
<AnimatedSafeAreaView
|
|
|
|
|
transition="backgroundColor"
|
2020-01-08 11:53:38 +05:00
|
|
|
duration={400}
|
2019-12-07 12:05:15 +05:00
|
|
|
style={{
|
2019-12-04 11:40:59 +05:00
|
|
|
height: '100%',
|
2019-12-07 12:05:15 +05:00
|
|
|
opacity: hide ? 0 : 1,
|
2019-12-21 10:38:40 +05:00
|
|
|
backgroundColor: colors.shade,
|
2019-12-04 11:40:59 +05:00
|
|
|
}}>
|
2019-12-10 22:03:39 +05:00
|
|
|
<View
|
|
|
|
|
style={{
|
|
|
|
|
height: 2,
|
|
|
|
|
width: '100%',
|
|
|
|
|
marginBottom: 5,
|
2020-01-07 18:14:36 +05:00
|
|
|
marginTop: Platform.OS == 'ios' ? 0 : StatusBar.currentHeight - 10,
|
2019-12-10 22:03:39 +05:00
|
|
|
}}
|
|
|
|
|
/>
|
2019-12-14 16:00:16 +05:00
|
|
|
|
2019-12-07 12:05:15 +05:00
|
|
|
<ScrollView
|
2020-01-09 19:49:06 +05:00
|
|
|
contentContainerStyle={{minHeight: '80%'}}
|
2020-01-08 11:53:38 +05:00
|
|
|
showsVerticalScrollIndicator={false}>
|
2019-12-07 12:05:15 +05:00
|
|
|
<View>
|
2020-01-10 18:46:07 +05:00
|
|
|
<View>
|
|
|
|
|
{listItems.map(item => (
|
2019-12-07 12:05:15 +05:00
|
|
|
<TouchableOpacity
|
2020-01-10 18:46:07 +05:00
|
|
|
key={item.name}
|
2020-01-07 16:26:30 +05:00
|
|
|
activeOpacity={opacity / 2}
|
2019-12-07 12:05:15 +05:00
|
|
|
onPress={() => {
|
|
|
|
|
item.close === false ? null : close();
|
2019-12-11 01:10:04 +05:00
|
|
|
|
2019-12-07 12:05:15 +05:00
|
|
|
item.func();
|
|
|
|
|
}}
|
2019-12-04 11:40:59 +05:00
|
|
|
style={{
|
2019-12-07 12:05:15 +05:00
|
|
|
width: '100%',
|
|
|
|
|
alignSelf: 'center',
|
2019-12-04 11:40:59 +05:00
|
|
|
flexDirection: 'row',
|
2019-12-07 12:05:15 +05:00
|
|
|
justifyContent: 'space-between',
|
2019-12-14 16:00:16 +05:00
|
|
|
alignItems: 'center',
|
2019-12-10 16:32:04 +05:00
|
|
|
paddingHorizontal: '5%',
|
2019-12-14 16:00:16 +05:00
|
|
|
paddingVertical: pv + 5,
|
2019-12-04 11:40:59 +05:00
|
|
|
}}>
|
2019-12-07 12:05:15 +05:00
|
|
|
<View
|
2019-12-04 11:40:59 +05:00
|
|
|
style={{
|
2019-12-07 12:05:15 +05:00
|
|
|
flexDirection: 'row',
|
2019-12-14 16:00:16 +05:00
|
|
|
alignItems: 'center',
|
2019-12-04 11:40:59 +05:00
|
|
|
}}>
|
2019-12-07 12:05:15 +05:00
|
|
|
<Icon
|
|
|
|
|
style={{
|
|
|
|
|
width: 30,
|
|
|
|
|
}}
|
|
|
|
|
name={item.icon}
|
2019-12-21 10:38:40 +05:00
|
|
|
color={colors.pri}
|
2019-12-07 12:05:15 +05:00
|
|
|
size={SIZE.md}
|
|
|
|
|
/>
|
|
|
|
|
<Text
|
|
|
|
|
style={{
|
2019-12-14 16:00:16 +05:00
|
|
|
fontFamily: WEIGHT.regular,
|
|
|
|
|
fontSize: SIZE.sm,
|
2019-12-07 12:05:15 +05:00
|
|
|
color: colors.pri,
|
|
|
|
|
}}>
|
|
|
|
|
{item.name}
|
|
|
|
|
</Text>
|
|
|
|
|
</View>
|
|
|
|
|
{item.switch ? (
|
|
|
|
|
<Icon
|
|
|
|
|
size={SIZE.lg}
|
|
|
|
|
color={item.on ? colors.accent : colors.icon}
|
|
|
|
|
name={item.on ? 'toggle-right' : 'toggle-left'}
|
|
|
|
|
/>
|
|
|
|
|
) : (
|
|
|
|
|
undefined
|
|
|
|
|
)}
|
|
|
|
|
</TouchableOpacity>
|
2020-01-10 18:46:07 +05:00
|
|
|
))}
|
|
|
|
|
</View>
|
2019-12-04 11:40:59 +05:00
|
|
|
|
2019-12-07 12:05:15 +05:00
|
|
|
<TouchableOpacity
|
2020-01-07 16:26:30 +05:00
|
|
|
activeOpacity={opacity / 2}
|
2019-12-07 12:05:15 +05:00
|
|
|
onPress={() => {
|
|
|
|
|
close();
|
|
|
|
|
NavigationService.navigate('Tags');
|
|
|
|
|
}}
|
2019-12-04 11:40:59 +05:00
|
|
|
style={{
|
2019-12-07 12:05:15 +05:00
|
|
|
width: '100%',
|
|
|
|
|
alignSelf: 'center',
|
2019-12-04 11:40:59 +05:00
|
|
|
flexDirection: 'row',
|
2019-12-07 12:05:15 +05:00
|
|
|
justifyContent: 'space-between',
|
2019-12-04 11:40:59 +05:00
|
|
|
alignItems: 'flex-end',
|
2019-12-10 16:32:04 +05:00
|
|
|
paddingHorizontal: '5%',
|
2019-12-07 12:05:15 +05:00
|
|
|
marginTop: 15,
|
2019-12-04 11:40:59 +05:00
|
|
|
}}>
|
2019-12-07 12:05:15 +05:00
|
|
|
<View
|
2019-12-04 11:40:59 +05:00
|
|
|
style={{
|
|
|
|
|
flexDirection: 'row',
|
|
|
|
|
justifyContent: 'flex-start',
|
2019-12-14 16:00:16 +05:00
|
|
|
alignItems: 'center',
|
2019-12-04 11:40:59 +05:00
|
|
|
}}>
|
2019-12-07 12:05:15 +05:00
|
|
|
<Icon
|
|
|
|
|
style={{
|
|
|
|
|
width: 30,
|
|
|
|
|
}}
|
|
|
|
|
name="tag"
|
2019-12-21 11:12:55 +05:00
|
|
|
color={colors.pri}
|
2019-12-07 12:05:15 +05:00
|
|
|
size={SIZE.md}
|
|
|
|
|
/>
|
2019-12-04 11:40:59 +05:00
|
|
|
<Text
|
|
|
|
|
style={{
|
2019-12-14 16:00:16 +05:00
|
|
|
fontFamily: WEIGHT.regular,
|
|
|
|
|
fontSize: SIZE.sm,
|
2019-12-07 12:05:15 +05:00
|
|
|
color: colors.pri,
|
2019-12-04 11:40:59 +05:00
|
|
|
}}>
|
2019-12-07 12:05:15 +05:00
|
|
|
Tags
|
2019-12-04 11:40:59 +05:00
|
|
|
</Text>
|
2019-12-07 12:05:15 +05:00
|
|
|
</View>
|
|
|
|
|
</TouchableOpacity>
|
2019-12-04 11:40:59 +05:00
|
|
|
|
2020-01-08 11:53:38 +05:00
|
|
|
<View
|
|
|
|
|
style={{
|
2019-12-07 12:05:15 +05:00
|
|
|
flexDirection: 'row',
|
|
|
|
|
flexWrap: 'wrap',
|
|
|
|
|
paddingHorizontal: '5%',
|
|
|
|
|
marginBottom: 0,
|
|
|
|
|
}}>
|
|
|
|
|
{[
|
|
|
|
|
'home',
|
|
|
|
|
'office',
|
|
|
|
|
'work',
|
|
|
|
|
'book_notes',
|
|
|
|
|
'poem',
|
|
|
|
|
'lists',
|
|
|
|
|
'water',
|
|
|
|
|
].map(item => (
|
2019-12-04 11:40:59 +05:00
|
|
|
<TouchableOpacity
|
2020-01-10 18:46:07 +05:00
|
|
|
key={item}
|
2020-01-07 16:26:30 +05:00
|
|
|
activeOpacity={opacity / 2}
|
2019-12-07 12:05:15 +05:00
|
|
|
onPress={() => {
|
|
|
|
|
close();
|
|
|
|
|
NavigationService.navigate('Notes', {
|
|
|
|
|
heading: item,
|
|
|
|
|
});
|
|
|
|
|
}}
|
2019-12-04 11:40:59 +05:00
|
|
|
style={{
|
|
|
|
|
flexDirection: 'row',
|
|
|
|
|
justifyContent: 'flex-start',
|
|
|
|
|
alignItems: 'center',
|
2019-12-14 16:00:16 +05:00
|
|
|
padding: 7,
|
|
|
|
|
paddingLeft: 3.5,
|
2019-12-04 11:40:59 +05:00
|
|
|
}}>
|
2019-12-07 12:05:15 +05:00
|
|
|
<Text
|
2019-12-04 11:40:59 +05:00
|
|
|
style={{
|
2019-12-07 12:05:15 +05:00
|
|
|
fontFamily: WEIGHT.regular,
|
2020-01-01 00:04:59 +05:00
|
|
|
fontSize: SIZE.xs + 1,
|
2019-12-07 12:05:15 +05:00
|
|
|
color: colors.icon,
|
|
|
|
|
}}>
|
|
|
|
|
#{item}
|
|
|
|
|
</Text>
|
2019-12-04 11:40:59 +05:00
|
|
|
</TouchableOpacity>
|
2019-12-07 12:05:15 +05:00
|
|
|
))}
|
2020-01-08 11:53:38 +05:00
|
|
|
</View>
|
2019-12-04 11:40:59 +05:00
|
|
|
|
2020-01-08 11:53:38 +05:00
|
|
|
<View
|
|
|
|
|
style={{
|
2019-12-04 11:40:59 +05:00
|
|
|
flexDirection: 'row',
|
2019-12-07 12:05:15 +05:00
|
|
|
flexWrap: 'wrap',
|
|
|
|
|
paddingHorizontal: '5%',
|
|
|
|
|
marginBottom: 15,
|
2019-12-04 11:40:59 +05:00
|
|
|
}}>
|
2019-12-07 12:05:15 +05:00
|
|
|
{['red', 'yellow', 'green', 'blue', 'purple', 'orange', 'gray'].map(
|
|
|
|
|
item => (
|
|
|
|
|
<TouchableOpacity
|
2020-01-10 18:46:07 +05:00
|
|
|
key={item}
|
2020-01-07 16:26:30 +05:00
|
|
|
activeOpacity={opacity / 2}
|
2019-12-07 12:05:15 +05:00
|
|
|
style={{
|
|
|
|
|
flexDirection: 'row',
|
|
|
|
|
justifyContent: 'flex-start',
|
|
|
|
|
alignItems: 'center',
|
|
|
|
|
margin: 5,
|
|
|
|
|
}}>
|
|
|
|
|
<View
|
|
|
|
|
style={{
|
2019-12-14 16:00:16 +05:00
|
|
|
width: 35,
|
|
|
|
|
height: 35,
|
2019-12-07 12:05:15 +05:00
|
|
|
backgroundColor: item,
|
|
|
|
|
borderRadius: 100,
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
</TouchableOpacity>
|
|
|
|
|
),
|
|
|
|
|
)}
|
2020-01-08 11:53:38 +05:00
|
|
|
</View>
|
2019-12-07 12:05:15 +05:00
|
|
|
</View>
|
2019-12-04 11:40:59 +05:00
|
|
|
|
2019-12-07 12:05:15 +05:00
|
|
|
{/* <View
|
2019-12-04 11:40:59 +05:00
|
|
|
style={{
|
2019-12-07 12:05:15 +05:00
|
|
|
backgroundColor: '#F3A712',
|
|
|
|
|
width: '90%',
|
|
|
|
|
alignSelf: 'center',
|
2019-12-04 11:40:59 +05:00
|
|
|
borderRadius: 5,
|
2019-12-07 12:05:15 +05:00
|
|
|
flexDirection: 'row',
|
|
|
|
|
justifyContent: 'space-between',
|
2019-12-04 11:40:59 +05:00
|
|
|
alignItems: 'center',
|
2019-12-07 12:05:15 +05:00
|
|
|
height: 40,
|
|
|
|
|
paddingHorizontal: ph,
|
|
|
|
|
marginVertical: 10,
|
2019-12-04 11:40:59 +05:00
|
|
|
}}>
|
|
|
|
|
<Text
|
|
|
|
|
style={{
|
|
|
|
|
fontFamily: WEIGHT.medium,
|
|
|
|
|
color: 'white',
|
|
|
|
|
}}>
|
2019-12-07 12:05:15 +05:00
|
|
|
Upgrade to Pro
|
2019-12-04 11:40:59 +05:00
|
|
|
</Text>
|
|
|
|
|
|
2019-12-07 12:05:15 +05:00
|
|
|
<View
|
|
|
|
|
style={{
|
|
|
|
|
...getElevation(5),
|
|
|
|
|
paddingHorizontal: ph,
|
|
|
|
|
backgroundColor: 'white',
|
|
|
|
|
paddingVertical: pv - 8,
|
|
|
|
|
borderRadius: 5,
|
|
|
|
|
}}>
|
|
|
|
|
<Icon name="star" color="#FCBA04" size={SIZE.lg} />
|
|
|
|
|
</View>
|
|
|
|
|
</View> */}
|
2020-01-08 11:53:38 +05:00
|
|
|
</ScrollView>
|
|
|
|
|
<View
|
|
|
|
|
style={{
|
|
|
|
|
width: '100%',
|
|
|
|
|
justifyContent: 'space-between',
|
|
|
|
|
alignItems: 'center',
|
|
|
|
|
alignSelf: 'center',
|
|
|
|
|
marginBottom: 20,
|
|
|
|
|
flexDirection: 'row',
|
|
|
|
|
backgroundColor: colors.bg,
|
|
|
|
|
}}>
|
|
|
|
|
<TouchableOpacity
|
|
|
|
|
onPress={() => {
|
|
|
|
|
close();
|
2019-12-04 11:40:59 +05:00
|
|
|
|
2020-01-08 11:53:38 +05:00
|
|
|
NavigationService.navigate('Login');
|
|
|
|
|
}}
|
|
|
|
|
activeOpacity={opacity / 2}
|
2019-12-04 11:40:59 +05:00
|
|
|
style={{
|
2020-01-08 11:53:38 +05:00
|
|
|
paddingVertical: pv + 5,
|
2019-12-07 12:05:15 +05:00
|
|
|
paddingHorizontal: '5%',
|
2020-01-08 11:53:38 +05:00
|
|
|
backgroundColor: colors.shade,
|
|
|
|
|
width: '100%',
|
|
|
|
|
justifyContent: 'flex-start',
|
2019-12-07 12:05:15 +05:00
|
|
|
alignItems: 'center',
|
|
|
|
|
flexDirection: 'row',
|
2019-12-04 11:40:59 +05:00
|
|
|
}}>
|
2020-01-08 11:53:38 +05:00
|
|
|
<Icon name="log-in" color={colors.accent} size={SIZE.lg} />
|
2019-12-07 12:05:15 +05:00
|
|
|
|
2020-01-08 11:53:38 +05:00
|
|
|
<Text
|
2019-12-04 11:40:59 +05:00
|
|
|
style={{
|
2020-01-08 11:53:38 +05:00
|
|
|
fontFamily: WEIGHT.regular,
|
|
|
|
|
color: colors.accent,
|
|
|
|
|
fontSize: SIZE.md,
|
2019-12-04 11:40:59 +05:00
|
|
|
}}>
|
2020-01-08 11:53:38 +05:00
|
|
|
{' '}Login
|
|
|
|
|
</Text>
|
|
|
|
|
</TouchableOpacity>
|
2019-12-07 12:05:15 +05:00
|
|
|
|
2020-01-08 11:53:38 +05:00
|
|
|
{/* <Text
|
2019-12-07 12:05:15 +05:00
|
|
|
style={{
|
|
|
|
|
fontFamily: WEIGHT.semibold,
|
|
|
|
|
color: colors.accent,
|
|
|
|
|
fontSize: SIZE.md,
|
|
|
|
|
marginTop: 10,
|
|
|
|
|
}}>
|
|
|
|
|
Hi, Ammar!
|
|
|
|
|
</Text>
|
|
|
|
|
|
|
|
|
|
<Text
|
|
|
|
|
style={{
|
|
|
|
|
fontFamily: WEIGHT.regular,
|
|
|
|
|
color: colors.accent,
|
|
|
|
|
fontSize: SIZE.xs,
|
|
|
|
|
marginTop: 10,
|
|
|
|
|
}}>
|
|
|
|
|
80.45/100 MB
|
|
|
|
|
</Text> */}
|
|
|
|
|
|
2020-01-08 11:53:38 +05:00
|
|
|
{/* <View
|
2019-12-07 12:05:15 +05:00
|
|
|
style={{
|
|
|
|
|
borderRadius: 2.5,
|
|
|
|
|
backgroundColor: colors.accent,
|
|
|
|
|
marginTop: 10,
|
|
|
|
|
paddingHorizontal: 5,
|
|
|
|
|
paddingVertical: 2,
|
|
|
|
|
}}>
|
|
|
|
|
<Text
|
|
|
|
|
style={{
|
|
|
|
|
fontFamily: WEIGHT.bold,
|
|
|
|
|
fontSize: SIZE.xxs,
|
|
|
|
|
color: 'white',
|
|
|
|
|
}}>
|
|
|
|
|
Basic User
|
|
|
|
|
</Text>
|
|
|
|
|
</View> */}
|
2020-01-08 11:53:38 +05:00
|
|
|
</View>
|
2019-12-09 08:53:45 +05:00
|
|
|
</AnimatedSafeAreaView>
|
2019-12-07 12:05:15 +05:00
|
|
|
);
|
|
|
|
|
};
|