Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

add general and account settings

ammarahm-ed35a5701c05e0
diff --git a/apps/mobile/src/assets/images/user.jpg b/apps/mobile/src/assets/images/user.jpg
new file mode 100644
index 000000000..5a5d4e673
Binary files /dev/null and b/apps/mobile/src/assets/images/user.jpg differ
diff --git a/apps/mobile/src/components/AddNotebookDialog/index.js b/apps/mobile/src/components/AddNotebookDialog/index.js
index 7547dc3e7..b23a3d663 100644
--- a/apps/mobile/src/components/AddNotebookDialog/index.js
+++ b/apps/mobile/src/components/AddNotebookDialog/index.js
@@ -23,23 +23,27 @@ import {
} from '../../common/common';
import Icon from 'react-native-vector-icons/Feather';
-import {getElevation, h, w, timeSince} from '../../utils/utils';
+import {getElevation, h, w, timeSince, ToastEvent} from '../../utils/utils';
import {FlatList, TextInput} from 'react-native-gesture-handler';
import {useForceUpdate} from '../../views/ListsEditor';
+import {storage} from '../../../App';
-const refs = [];
+let refs = [];
export const AddNotebookDialog = ({visible, close}) => {
const [colors, setColors] = useState(COLOR_SCHEME);
- const [topicsToAdd, setTopicsToAdd] = useState(['']);
+ const [topics, setTopics] = useState(['']);
+ const [title, setTitle] = useState(null);
const forceUpdate = useForceUpdate();
+
let listRef = createRef();
let prevItem = null;
let prevIndex = null;
let currentSelectedItem = null;
+ let description = 'my first notebook';
const onSubmit = (text, index, willFocus = true) => {
- let oldData = topicsToAdd;
+ let oldData = topics;
oldData[index] = text;
if (
@@ -49,8 +53,7 @@ export const AddNotebookDialog = ({visible, close}) => {
) {
oldData.push('');
}
-
- setTopicsToAdd(oldData);
+ setTopics(oldData);
forceUpdate();
currentSelectedItem = null;
@@ -70,15 +73,14 @@ export const AddNotebookDialog = ({visible, close}) => {
const onFocus = index => {
currentSelectedItem = index;
if (currentSelectedItem) {
- let oldData = topicsToAdd;
+ let oldData = topics;
oldData[prevIndex] = prevItem;
if (oldData.length === prevIndex + 1) {
oldData.push('');
}
prevIndex = null;
prevItem = null;
- setTopicsToAdd(oldData);
- console.log(oldData);
+ setTopics(oldData);
forceUpdate();
}
};
@@ -87,16 +89,33 @@ export const AddNotebookDialog = ({visible, close}) => {
prevItem = text;
};
const onDelete = index => {
- console.log('deleting');
- let listData = topicsToAdd;
+ let listData = topics;
if (listData.length === 1) return;
refs.splice(index, 1);
listData.splice(index, 1);
- console.log(refs, listData);
- setTopicsToAdd(listData);
+
+ setTopics(listData);
forceUpdate();
};
+ const addNewNotebook = async () => {
+ if (!title)
+ return ToastEvent.show('Title is required', 'error', 3000, () => {}, '');
+
+ await storage.addNotebook({
+ title,
+ description,
+ topics,
+ });
+ ToastEvent.show('New notebook added', 'success', 3000, () => {}, '');
+ setTopics(['']);
+ prevIndex = null;
+ prevItem = null;
+ currentSelectedItem = null;
+ refs = [];
+ close(true);
+ };
+
return (
<Modal
visible={visible}
@@ -151,6 +170,9 @@ export const AddNotebookDialog = ({visible, close}) => {
marginTop: 20,
marginBottom: 10,
}}
+ onChangeText={value => {
+ setTitle(value);
+ }}
placeholder="Title of notebook"
placeholderTextColor={colors.icon}
/>
@@ -164,7 +186,7 @@ export const AddNotebookDialog = ({visible, close}) => {
</Text>
<FlatList
- data={topicsToAdd}
+ data={topics}
ref={listRef}
removeClippedSubviews={false}
enableEmptySections={false}
@@ -195,6 +217,9 @@ export const AddNotebookDialog = ({visible, close}) => {
}}>
<TouchableOpacity
activeOpacity={opacity}
+ onPress={async () => {
+ await addNewNotebook();
+ }}
style={{
paddingVertical: pv,
paddingHorizontal: ph,
@@ -219,10 +244,11 @@ export const AddNotebookDialog = ({visible, close}) => {
<TouchableOpacity
activeOpacity={opacity}
onPress={() => {
- setTopicsToAdd(['']);
+ setTopics(['']);
prevIndex = null;
prevItem = null;
currentSelectedItem = null;
+ refs = [];
close();
}}
style={{
diff --git a/apps/mobile/src/components/NotebookItem/index.js b/apps/mobile/src/components/NotebookItem/index.js
index 0fd21de20..a5f627904 100644
--- a/apps/mobile/src/components/NotebookItem/index.js
+++ b/apps/mobile/src/components/NotebookItem/index.js
@@ -1,7 +1,7 @@
import React, {useEffect, useState} from 'react';
import {View, Text, TouchableOpacity} from 'react-native';
import NavigationService from '../../services/NavigationService';
-
+import Menu, {MenuItem, MenuDivider} from 'react-native-material-menu';
import {
COLOR_SCHEME,
SIZE,
@@ -13,19 +13,23 @@ import {
WEIGHT,
} from '../../common/common';
import Icon from 'react-native-vector-icons/Feather';
+import {w} from '../../utils/utils';
export const NotebookItem = ({
item,
index,
colors,
hideMore,
+ topic,
isTopic = false,
}) => {
+ let setMenuRef = {};
return (
<TouchableOpacity
+ activeOpacity={opacity}
onPress={() => {
NavigationService.navigate('Notebook', {
notebook: item,
- title: hideMore ? 'Choose topic' : item.name,
+ title: hideMore ? 'Choose topic' : item.title,
isMove: hideMore ? true : false,
hideMore: hideMore ? true : false,
});
@@ -51,8 +55,46 @@ export const NotebookItem = ({
color: colors.pri,
maxWidth: '100%',
}}>
- {item.name}
+ {item.title}
</Text>
+ {isTopic ? null : (
+ <Text
+ style={{
+ fontFamily: WEIGHT.regular,
+ fontSize: SIZE.xs + 1,
+ color: colors.pri,
+ maxWidth: '100%',
+ }}>
+ {item.description}
+ </Text>
+ )}
+
+ {isTopic ? null : (
+ <View
+ style={{
+ flexDirection: 'row',
+ alignItems: 'center',
+ marginTop: 5,
+ }}>
+ {Object.keys(item.topics)
+ .slice(0, 3)
+ .map(topic => (
+ <Text
+ style={{
+ borderRadius: 5,
+ backgroundColor: colors.accent,
+ color: 'white',
+ marginRight: 5,
+ fontFamily: WEIGHT.regular,
+ fontSize: SIZE.xxs,
+ paddingHorizontal: ph / 2,
+ paddingVertical: pv / 4,
+ }}>
+ {topic}
+ </Text>
+ ))}
+ </View>
+ )}
<Text
style={{
@@ -60,12 +102,70 @@ export const NotebookItem = ({
fontSize: SIZE.xs,
paddingTop: pv / 2,
}}>
+ {isTopic ? null : (
+ <Text
+ style={{
+ color: colors.accent,
+ }}>
+ {new Date(item.dateCreated).toDateString().substring(4)} {' '}
+ </Text>
+ )}
15 notes
</Text>
</View>
{hideMore ? null : (
- <Icon name="more-vertical" size={SIZE.lg} color={colors.icon} />
+ <Menu
+ style={{
+ borderRadius: 5,
+ }}
+ ref={ref => (setMenuRef[index] = ref)}
+ button={
+ <TouchableOpacity
+ style={{
+ width: w * 0.05,
+ justifyContent: 'center',
+ minHeight: 70,
+ alignItems: 'center',
+ }}
+ onPress={() => setMenuRef[index].show()}>
+ <Icon name="more-vertical" size={SIZE.lg} color={colors.icon} />
+ </TouchableOpacity>
+ }>
+ <MenuItem
+ onPress={() => {
+ setVisible(true);
+ setMenuRef[index].hide();
+ }}
+ textStyle={{
+ color: colors.pri,
+
+ fontFamily: WEIGHT.regular,
+ fontSize: SIZE.sm,
+ }}>
+ <Icon name="trash" size={SIZE.sm} color={colors.icon} />
+ {' '}Delete
+ </MenuItem>
+ <MenuDivider />
+
+ <MenuItem
+ disabled={true}
+ textStyle={{
+ color: colors.icon,
+
+ fontFamily: WEIGHT.regular,
+ fontSize: SIZE.xs,
+ }}
+ style={{
+ paddingVertical: 0,
+ margin: 0,
+ height: 30,
+ paddingBottom: 10,
+ }}>
+ Created on:{' '}
+ {new Date(item.dateCreated).toISOString().slice(0, 10)}
+ </MenuItem>
+ </Menu>
)}
{hideMore && isTopic ? (
<TouchableOpacity
diff --git a/apps/mobile/src/components/Recents/index.js b/apps/mobile/src/components/Recents/index.js
index 07041df79..eef1540cc 100644
--- a/apps/mobile/src/components/Recents/index.js
+++ b/apps/mobile/src/components/Recents/index.js
@@ -65,6 +65,7 @@ export const RecentList = ({update}) => {
</Text>
</View>
}
+ keyExtractor={(item, index) => item.dateCreated.toString()}
renderItem={({item, index}) => <NoteItem item={item} index={index} />}
/>
</>
diff --git a/apps/mobile/src/components/SearchInput/index.js b/apps/mobile/src/components/SearchInput/index.js
index 3023f4fe4..5c955cf97 100644
--- a/apps/mobile/src/components/SearchInput/index.js
+++ b/apps/mobile/src/components/SearchInput/index.js
@@ -51,7 +51,7 @@ export const Search = props => {
props.onBlur;
}}
numberOfLines={1}
- placeholder="Search your notes"
+ placeholder={props.placeholder}
placeholderTextColor={colors.icon}
/>
<Icon
diff --git a/apps/mobile/src/services/NavigationService.js b/apps/mobile/src/services/NavigationService.js
index cf80ef708..b72f0906c 100755
--- a/apps/mobile/src/services/NavigationService.js
+++ b/apps/mobile/src/services/NavigationService.js
@@ -17,6 +17,7 @@ import Notes from '../views/Notes';
import Tags from '../views/Tags';
import Notebook from '../views/Notebook';
import Move from '../views/Move';
+import AccountSettings from '../views/AccountSettings';
const TopLevelNavigator = createStackNavigator(
{
@@ -71,6 +72,9 @@ const TopLevelNavigator = createStackNavigator(
Move: {
screen: Move,
},
+ AccountSettings: {
+ screen: AccountSettings,
+ },
},
{
initialRouteName: 'Home',
diff --git a/apps/mobile/src/views/AccountSettings/index.js b/apps/mobile/src/views/AccountSettings/index.js
new file mode 100644
index 000000000..8a86fa8d7
--- /dev/null
+++ b/apps/mobile/src/views/AccountSettings/index.js
@@ -0,0 +1,175 @@
+import React, {useEffect, useState} from 'react';
+import {
+ ScrollView,
+ View,
+ Text,
+ TouchableOpacity,
+ Dimensions,
+ Image,
+ SafeAreaView,
+ Platform,
+ FlatList,
+} from 'react-native';
+import NavigationService from '../../services/NavigationService';
+import {
+ COLOR_SCHEME,
+ SIZE,
+ br,
+ ph,
+ pv,
+ opacity,
+ FONT,
+ WEIGHT,
+} from '../../common/common';
+import Icon from 'react-native-vector-icons/Feather';
+import {Reminder} from '../../components/Reminder';
+import {ListItem} from '../../components/ListItem';
+import {Header} from '../../components/header';
+import NoteItem from '../../components/NoteItem';
+
+const w = Dimensions.get('window').width;
+const h = Dimensions.get('window').height;
+
+export const AccountSettings = ({navigation}) => {
+ const [colors, setColors] = useState(COLOR_SCHEME);
+
+ return (
+ <SafeAreaView
+ style={{
+ height: '100%',
+ }}>
+ <Header colors={colors} heading="" canGoBack={true} />
+
+ <View
+ style={{
+ justifyContent: 'center',
+ alignItems: 'center',
+
+ alignSelf: 'center',
+ }}>
+ <Image
+ source={require('../../assets/images/user.jpg')}
+ style={{
+ width: 120,
+ height: 120,
+ borderRadius: 100,
+ }}
+ />
+ <Text
+ style={{
+ color: colors.pri,
+ fontFamily: WEIGHT.regular,
+ fontSize: SIZE.lg,
+ marginTop: 10,
+ }}>
+ Alex's Account
+ </Text>
+ <Text
+ style={{
+ color: 'white',
+ fontFamily: WEIGHT.regular,
+ fontSize: SIZE.sm,
+ marginTop: 10,
+ backgroundColor: colors.accent,
+ borderRadius: 5,
+ padding: 5,
+ paddingVertical: 2.5,
+ marginBottom: 20,
+ }}>
+ Pro
+ </Text>
+ </View>
+ <FlatList
+ data={['Subscription Status', 'Space Used', 'E-to-E Encryption']}
+ ListHeaderComponent={
+ <TouchableOpacity
+ activeOpacity={opacity}
+ style={{
+ borderRadius: 5,
+ width: '90%',
+ marginHorizontal: '5%',
+ paddingHorizontal: ph,
+ borderWidth: 1,
+ borderColor: '#f0f0f0',
+ paddingVertical: pv + 5,
+ flexDirection: 'row',
+ justifyContent: 'space-between',
+ alignItems: 'center',
+ marginBottom: 10,
+ backgroundColor: colors.bg,
+ }}>
+ <Text
+ style={{
+ fontSize: SIZE.md,
+ fontFamily: WEIGHT.regular,
+ color: colors.pri,
+ }}>
+ Backup notes
+ </Text>
+ </TouchableOpacity>
+ }
+ renderItem={({item, index}) => (
+ <TouchableOpacity
+ activeOpacity={opacity}
+ style={{
+ borderBottomWidth: 1,
+ width: '90%',
+ marginHorizontal: '5%',
+ borderBottomColor: '#f0f0f0',
+ paddingVertical: pv + 5,
+ flexDirection: 'row',
+ paddingHorizontal: ph,
+ justifyContent: 'space-between',
+ alignItems: 'center',
+ }}>
+ <Text
+ style={{
+ fontSize: SIZE.md,
+ fontFamily: WEIGHT.regular,
+ }}>
+ {item}
+ </Text>
+ <Text
+ style={{
+ fontSize: SIZE.sm,
+ fontFamily: WEIGHT.regular,
+ }}>
+ 100/90
+ </Text>
+ </TouchableOpacity>
+ )}
+ />
+ <TouchableOpacity
+ activeOpacity={opacity}
+ style={{
+ borderRadius: 5,
+ width: '90%',
+ marginHorizontal: '5%',
+ paddingHorizontal: ph,
+
+ paddingVertical: pv + 5,
+ flexDirection: 'row',
+ justifyContent: 'space-between',
+ alignItems: 'center',
+ marginBottom: 10,
+ backgroundColor: colors.accent,
+ }}>
+ <Text
+ style={{
+ fontSize: SIZE.md,
+ fontFamily: WEIGHT.regular,
+ color: 'white',
+ }}>
+ Logout
+ </Text>
+ <Icon size={SIZE.lg} color="white" name="log-out" />
+ </TouchableOpacity>
+ </SafeAreaView>
+ );
+};
+
+AccountSettings.navigationOptions = {
+ header: null,
+};
+
+export default AccountSettings;
diff --git a/apps/mobile/src/views/Folders/index.js b/apps/mobile/src/views/Folders/index.js
index 1fb431fea..816be35fa 100644
--- a/apps/mobile/src/views/Folders/index.js
+++ b/apps/mobile/src/views/Folders/index.js
@@ -31,6 +31,7 @@ import {useForceUpdate} from '../ListsEditor';
import {AddNotebookDialog} from '../../components/AddNotebookDialog';
import {NotebookItem} from '../../components/NotebookItem';
import {Search} from '../../components/SearchInput';
+import {storage} from '../../../App';
export const Folders = ({navigation}) => {
const [colors, setColors] = useState(COLOR_SCHEME);
@@ -38,6 +39,11 @@ export const Folders = ({navigation}) => {
const [notebooks, setNotebooks] = useState([]);
const params = navigation.state.params;
+ useEffect(() => {
+ setNotebooks(storage.getNotebooks());
+ console.log(storage.getNotebooks());
+ }, []);
+
return (
<SafeAreaView
style={{
@@ -45,7 +51,12 @@ export const Folders = ({navigation}) => {
}}>
<AddNotebookDialog
visible={addNotebook}
- close={() => setAddNotebook(false)}
+ close={newNotes => {
+ setAddNotebook(false);
+ if (newNotes) {
+ setNotebooks(storage.getNotebooks());
+ }
+ }}
/>
<KeyboardAvoidingView
style={{
@@ -77,12 +88,14 @@ export const Folders = ({navigation}) => {
size={SIZE.xxl}
/>
</View>
- <Search />
+ <Search placeholder="Search in notebooks" />
+
<FlatList
style={{
width: '100%',
}}
data={notebooks}
+ keyExtractor={(item, index) => item.dateCreated.toString()}
renderItem={({item, index}) => (
<NotebookItem
hideMore={params.hideMore}
diff --git a/apps/mobile/src/views/Home/index.js b/apps/mobile/src/views/Home/index.js
index b5e144991..b0a72fdda 100755
--- a/apps/mobile/src/views/Home/index.js
+++ b/apps/mobile/src/views/Home/index.js
@@ -114,6 +114,7 @@ export const Home = ({navigation}) => {
<Search
onChangeText={onChangeText}
onSubmitEditing={onSubmitEditing}
+ placeholder="Search your notes"
onBlur={onBlur}
onFocus={onFocus}
clearSearch={clearSearch}
diff --git a/apps/mobile/src/views/Notebook/index.js b/apps/mobile/src/views/Notebook/index.js
index dd1ec5de9..163f6eda2 100644
--- a/apps/mobile/src/views/Notebook/index.js
+++ b/apps/mobile/src/views/Notebook/index.js
@@ -51,20 +51,7 @@ export const Notebook = ({navigation}) => {
style={{
width: '100%',
}}
- data={[
- {
- name: 'Class Notes',
- Qty: '8',
- },
- {
- name: 'Notes of water tabs',
- Qty: '3',
- },
- {
- name: 'My Lists',
- Qty: '3',
- },
- ]}
+ data={params.notebook.topics}
ListHeaderComponent={
<>
{params.hideMore ? null : (
diff --git a/apps/mobile/src/views/Settings/index.js b/apps/mobile/src/views/Settings/index.js
index 0135905e3..f3f9b7f3e 100644
--- a/apps/mobile/src/views/Settings/index.js
+++ b/apps/mobile/src/views/Settings/index.js
@@ -37,37 +37,38 @@ export const Settings = ({navigation}) => {
<Header colors={colors} heading="Settings" canGoBack={false} />
<FlatList
- data={['Sync']}
+ data={['Sync', 'Dark Mode', 'Sunset to Sunrise']}
ListHeaderComponent={
- <FlatList
- data={['My Account']}
- ListHeaderComponent={<FlatList />}
- renderItem={({item, index}) => (
- <TouchableOpacity
- activeOpacity={opacity}
+ <View>
+ <TouchableOpacity
+ activeOpacity={opacity}
+ onPress={() => {
+ NavigationService.navigate('AccountSettings');
+ }}
+ style={{
+ borderWidth: 1,
+ borderRadius: 5,
+ width: '90%',
+ marginHorizontal: '5%',
+ paddingHorizontal: ph,
+ borderColor: '#f0f0f0',
+ paddingVertical: pv + 5,
+ flexDirection: 'row',
+ justifyContent: 'space-between',
+ alignItems: 'center',
+ marginBottom: 10,
+ backgroundColor: colors.bg,
+ }}>
+ <Text
style={{
- borderWidth: 1,
- borderRadius: 5,
- width: '90%',
- marginHorizontal: '5%',
- paddingHorizontal: ph,
- borderColor: '#f0f0f0',
- paddingVertical: pv + 5,
- flexDirection: 'row',
- justifyContent: 'space-between',
- alignItems: 'center',
- marginBottom: 15,
+ fontSize: SIZE.md,
+ fontFamily: WEIGHT.regular,
+ color: colors.pri,
}}>
- <Text
- style={{
- fontSize: SIZE.md,
- fontFamily: WEIGHT.regular,
- }}>
- {item}
- </Text>
- </TouchableOpacity>
- )}
- />
+ My Account
+ </Text>
+ </TouchableOpacity>
+ </View>
}
renderItem={({item, index}) => (
<TouchableOpacity
@@ -94,6 +95,134 @@ export const Settings = ({navigation}) => {
</TouchableOpacity>
)}
/>
+
+ <View
+ style={{
+ borderBottomWidth: 1,
+ width: '90%',
+ marginHorizontal: '5%',
+ borderBottomColor: '#f0f0f0',
+ paddingVertical: pv + 5,
+
+ paddingHorizontal: ph,
+ justifyContent: 'space-between',
+ alignItems: 'flex-start',
+ }}>
+ <Text
+ style={{
+ fontSize: SIZE.md,
+ fontFamily: WEIGHT.regular,
+ }}>
+ Accent Color
+ </Text>
+
+ <ScrollView
+ contentContainerStyle={{
+ flexDirection: 'row',
+ flexWrap: 'wrap',
+ marginTop: 10,
+ }}>
+ {[
+ '#e6194b',
+ '#3cb44b',
+ '#ffe119',
+ '#1790F3',
+ '#f58231',
+ '#911eb4',
+ '#46f0f0',
+ '#f032e6',
+ '#bcf60c',
+ '#fabebe',
+ ].map(item => (
+ <TouchableOpacity
+ style={{
+ flexDirection: 'row',
+ justifyContent: 'flex-start',
+ alignItems: 'center',
+ marginRight: 10,
+ marginVertical: 5,
+ }}>
+ <View
+ style={{
+ width: 45,
+ height: 45,
+ backgroundColor: item,
+ borderRadius: 100,
+ justifyContent: 'center',
+ alignItems: 'center',
+ }}>
+ <Icon size={SIZE.lg} color="white" name="check" />
+ </View>
+ </TouchableOpacity>
+ ))}
+ </ScrollView>
+ </View>
+
+ <TouchableOpacity
+ activeOpacity={opacity}
+ style={{
+ borderBottomWidth: 1,
+ width: '90%',
+ marginHorizontal: '5%',
+ borderBottomColor: '#f0f0f0',
+ paddingVertical: pv + 5,
+ flexDirection: 'row',
+ paddingHorizontal: ph,
+ justifyContent: 'space-between',
+ alignItems: 'center',
+ }}>
+ <Text
+ style={{
+ fontSize: SIZE.md,
+ fontFamily: WEIGHT.regular,
+ }}>
+ Terms of Service
+ </Text>
+ </TouchableOpacity>
+
+ <TouchableOpacity
+ activeOpacity={opacity}
+ style={{
+ borderBottomWidth: 1,
+ width: '90%',
+ marginHorizontal: '5%',
+ borderBottomColor: '#f0f0f0',
+ paddingVertical: pv + 5,
+ flexDirection: 'row',
+ paddingHorizontal: ph,
+ justifyContent: 'space-between',
+ alignItems: 'center',
+ }}>
+ <Text
+ style={{
+ fontSize: SIZE.md,
+ fontFamily: WEIGHT.regular,
+ }}>
+ Privacy Policy
+ </Text>
+ </TouchableOpacity>
+
+ <TouchableOpacity
+ activeOpacity={opacity}
+ style={{
+ borderBottomWidth: 1,
+ width: '90%',
+ marginHorizontal: '5%',
+ borderBottomColor: '#f0f0f0',
+ paddingVertical: pv + 5,
+ flexDirection: 'row',
+ paddingHorizontal: ph,
+ justifyContent: 'space-between',
+ alignItems: 'center',
+ }}>
+ <Text
+ style={{
+ fontSize: SIZE.md,
+ fontFamily: WEIGHT.regular,
+ }}>
+ About Notes.
+ </Text>
+ </TouchableOpacity>
</SafeAreaView>
);
};