Skip to content

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

add login screen

thewisefarmerr1042d12a32be
diff --git a/apps/mobile/App.js b/apps/mobile/App.js
index 389a0589f..434c9669e 100644
--- a/apps/mobile/App.js
+++ b/apps/mobile/App.js
@@ -13,7 +13,8 @@ import {
import {COLOR_SCHEME, SIZE, opacity, WEIGHT} from './src/common/common';
import Icon from 'react-native-vector-icons/Ionicons';
import ActionButton from 'react-native-action-button';
-
+import Storage from 'notes-core/sync/storage';
+import StorageInterface from './src/utils/storage';
const App = () => {
const [colors, setColors] = useState(COLOR_SCHEME);
const [fab, setFab] = useState(true);
@@ -96,3 +97,5 @@ const App = () => {
};
export default App;
+
+export const storage = new Storage(StorageInterface);
diff --git a/apps/mobile/ios/Podfile.lock b/apps/mobile/ios/Podfile.lock
index 981c1cb7e..48e01a56d 100644
--- a/apps/mobile/ios/Podfile.lock
+++ b/apps/mobile/ios/Podfile.lock
@@ -221,6 +221,8 @@ PODS:
- ReactCommon/jscallinvoker (= 0.61.4)
- rn-fetch-blob (0.11.2):
- React-Core
+ - RNCAsyncStorage (1.6.3):
+ - React
- RNGestureHandler (1.5.0):
- React
- RNReanimated (1.4.0):
@@ -261,6 +263,7 @@ DEPENDENCIES:
- ReactCommon/jscallinvoker (from `../node_modules/react-native/ReactCommon`)
- ReactCommon/turbomodule/core (from `../node_modules/react-native/ReactCommon`)
- rn-fetch-blob (from `../node_modules/rn-fetch-blob`)
+ - "RNCAsyncStorage (from `../node_modules/@react-native-community/async-storage`)"
- RNGestureHandler (from `../node_modules/react-native-gesture-handler`)
- RNReanimated (from `../node_modules/react-native-reanimated`)
- RNScreens (from `../node_modules/react-native-screens`)
@@ -324,6 +327,8 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native/ReactCommon"
rn-fetch-blob:
:path: "../node_modules/rn-fetch-blob"
+ RNCAsyncStorage:
+ :path: "../node_modules/@react-native-community/async-storage"
RNGestureHandler:
:path: "../node_modules/react-native-gesture-handler"
RNReanimated:
@@ -363,6 +368,7 @@ SPEC CHECKSUMS:
React-RCTVibration: 0f76400ee3cec6edb9c125da49fed279340d145a
ReactCommon: a6a294e7028ed67b926d29551aa9394fd989c24c
rn-fetch-blob: f525a73a78df9ed5d35e67ea65e79d53c15255bc
+ RNCAsyncStorage: 3c304d1adfaea02ec732ac218801cb13897aa8c0
RNGestureHandler: a4ddde1ffc6e590c8127b8b7eabfdade45475c74
RNReanimated: b2ab0b693dddd2339bd2f300e770f6302d2e960c
RNScreens: f28b48b8345f2f5f39ed6195518291515032a788
diff --git a/apps/mobile/src/common/common.js b/apps/mobile/src/common/common.js
index f20e5e6a9..d6f22875d 100755
--- a/apps/mobile/src/common/common.js
+++ b/apps/mobile/src/common/common.js
@@ -1,3 +1,4 @@
+import Storage from '../utils/storage';
//COLOR SCHEME
export function setColorScheme(
diff --git a/apps/mobile/src/services/NavigationService.js b/apps/mobile/src/services/NavigationService.js
index 1cc048f95..ed5569345 100755
--- a/apps/mobile/src/services/NavigationService.js
+++ b/apps/mobile/src/services/NavigationService.js
@@ -8,6 +8,7 @@ import Folders from '../views/Folders';
import Favorites from '../views/Favorites';
import ListsEditor from '../views/ListsEditor';
import ReminderEditor from '../views/ReminderEditor';
+import Login from '../views/Login';
const TopLevelNavigator = createStackNavigator(
{
@@ -35,6 +36,9 @@ const TopLevelNavigator = createStackNavigator(
ReminderEditor: {
screen: ReminderEditor,
},
+ Login: {
+ screen: Login,
+ },
},
{
initialRouteName: 'Home',
diff --git a/apps/mobile/src/utils/storage.js b/apps/mobile/src/utils/storage.js
new file mode 100644
index 000000000..a7145a092
--- /dev/null
+++ b/apps/mobile/src/utils/storage.js
@@ -0,0 +1,19 @@
+import AsyncStorage from '@react-native-community/async-storage';
+
+async function read(key) {
+ return await AsyncStorage.getItem(key);
+}
+
+async function write(key, data) {
+ return await AsyncStorage.setItem(key, data);
+}
+
+function remove(key) {
+ AsyncStorage.removeItem(key);
+}
+
+function clear() {
+ AsyncStorage.clear();
+}
+
+export default {read, write, remove, clear};
diff --git a/apps/mobile/src/utils/utils.js b/apps/mobile/src/utils/utils.js
index c476c86ec..27c8ba24f 100755
--- a/apps/mobile/src/utils/utils.js
+++ b/apps/mobile/src/utils/utils.js
@@ -2,8 +2,8 @@ export const getElevation = elevation => {
return {
elevation,
shadowColor: 'black',
- shadowOffset: {width: 0, height: 0.4 * elevation},
- shadowOpacity: 0.1,
- shadowRadius: 0.8 * elevation,
+ shadowOffset: {width: 0.3 * elevation, height: 0.5 * elevation},
+ shadowOpacity: 0.2,
+ shadowRadius: 0.7 * elevation,
};
};
diff --git a/apps/mobile/src/views/Editor/index.js b/apps/mobile/src/views/Editor/index.js
index 278bad835..7cafa9780 100755
--- a/apps/mobile/src/views/Editor/index.js
+++ b/apps/mobile/src/views/Editor/index.js
@@ -25,16 +25,32 @@ import WebView from 'react-native-webview';
import Icon from 'react-native-vector-icons/Ionicons';
import {useForceUpdate} from '../ListsEditor';
import {NavigationEvents} from 'react-navigation';
+import {storage} from '../../../App';
const w = Dimensions.get('window').width;
const h = Dimensions.get('window').height;
-const saveText = (type, title, content) => {
+
+const saveText = async (type, title, content) => {
let data = {
type,
title,
- headline: content.slice(0, 60),
- timestamp: Date.now(),
+ headline:
+ content.text.length < 80 ? content.text : content.text.slice(0, 80),
+ content,
+ favorite: false,
+ 'date-created': Date.now(),
+ 'last-edited': Date.now(),
+ length: content.text.length,
+ pinned: false,
+ size: 0,
+ colors: [],
+ tags: [],
+ folders: [],
};
+
+ await storage.write('notes', [data]);
+
+ console.log(await storage.read('notes'));
};
const Editor = ({navigation}) => {
@@ -42,8 +58,9 @@ const Editor = ({navigation}) => {
const [keyboardHeight, setKeyboardHeight] = useState(0);
let EditorWebView = createRef();
const _textRender = createRef();
- let _heading = '';
- let _text = '';
+
+ let content, title, headline;
+
let keyboardDidShowListener;
let keyboardDidHideListener;
@@ -61,8 +78,8 @@ const Editor = ({navigation}) => {
function onChangeText(data) {
if (data !== '') {
- let m = JSON.parse(data);
- console.log(m);
+ content = JSON.parse(data);
+ saveText('note', title, content);
}
}
@@ -101,6 +118,9 @@ const Editor = ({navigation}) => {
paddingVertical: 0,
marginTop: Platform.OS == 'ios' ? h * 0.01 : h * 0.04,
}}
+ onChangeText={value => {
+ title = value;
+ }}
/>
<WebView
diff --git a/apps/mobile/src/views/Editor/web/texteditor.html b/apps/mobile/src/views/Editor/web/texteditor.html
index 9c5a022f0..eb0cafe2e 100644
--- a/apps/mobile/src/views/Editor/web/texteditor.html
+++ b/apps/mobile/src/views/Editor/web/texteditor.html
@@ -1100,20 +1100,17 @@
const editor = new Quill('#editor', {
modules: {
toolbar: [
- [{header: [ 2, 3, 4, 5, 6, false]}],
- ['bold', 'italic', 'underline', 'strike'], // toggled buttons
- ['link', 'image', 'video'],
- ['blockquote', 'code-block'],
+ [{header:1},{header:2}],
+ [{size: ['small', false, 'large', 'huge']}], // custom dropdown
+ ['bold', 'italic','image'], // toggled buttons
[{list: 'ordered'}, {list: 'bullet'}],
+ [{header: [3, 4, 5, 6]}],
+ [{align: []}],
+ [{color: []}, {background: []}], // dropdown with defaults from theme
+ ['underline', 'strike','blockquote', 'code-block'],
[{script: 'sub'}, {script: 'super'}], // superscript/subscript
[{indent: '-1'}, {indent: '+1'}], // outdent/indent
[{direction: 'rtl'}], // text direction
-
- [{size: ['small', false, 'large', 'huge']}], // custom dropdown
-
- [{color: []}, {background: []}], // dropdown with defaults from theme
- [{align: []}],
-
['clean'],
],
imageCompressor: {
diff --git a/apps/mobile/src/views/Folders/index.js b/apps/mobile/src/views/Folders/index.js
index 4cfeb2a36..f1cd4e1c4 100644
--- a/apps/mobile/src/views/Folders/index.js
+++ b/apps/mobile/src/views/Folders/index.js
@@ -49,7 +49,7 @@ export const Folders = ({navigation}) => {
color: colors.pri,
fontFamily: WEIGHT.bold,
}}>
- Folders
+ Notebooks
</Text>
<Icon name="md-more" color={colors.icon} size={SIZE.xxl} />
</View>
@@ -94,11 +94,11 @@ export const Folders = ({navigation}) => {
<Text
style={{
fontFamily: WEIGHT.regular,
- fontSize: SIZE.lg,
+ fontSize: SIZE.md,
color: 'white',
opacity: 0.5,
}}>
- {item.Qty} Files
+ {item.Qty} Notes
</Text>
</View>
<Text
diff --git a/apps/mobile/src/views/ForgotPassword/index.js b/apps/mobile/src/views/ForgotPassword/index.js
new file mode 100644
index 000000000..e69de29bb
diff --git a/apps/mobile/src/views/Home/index.js b/apps/mobile/src/views/Home/index.js
index f27fb4cdb..8117b4586 100755
--- a/apps/mobile/src/views/Home/index.js
+++ b/apps/mobile/src/views/Home/index.js
@@ -44,22 +44,50 @@ export const Home = ({navigation}) => {
}}>
<View
style={{
- height: '25%',
width: '100%',
- justifyContent: 'center',
+ justifyContent: 'flex-start',
+ paddingHorizontal: '5%',
alignItems: 'center',
alignSelf: 'center',
backgroundColor: 'white',
+ marginBottom: 20,
}}>
<Image
style={{
width: 80,
height: 80,
borderRadius: 100,
+ marginRight: 10,
}}
source={require('../../assets/images/img.png')}
/>
- <Text
+
+ <TouchableOpacity
+ onPress={() => {
+ NavigationService.navigate('Login');
+ }}
+ activeOpacity={opacity}
+ style={{
+ paddingVertical: pv - 5,
+ paddingHorizontal: ph,
+ borderRadius: 5,
+ justifyContent: 'center',
+ alignItems: 'center',
+ marginTop: 20,
+ borderColor: colors.accent,
+ backgroundColor: colors.bg,
+ borderWidth: 1,
+ }}>
+ <Text
+ style={{
+ fontFamily: WEIGHT.regular,
+ color: colors.accent,
+ }}>
+ Log in to Sync
+ </Text>
+ </TouchableOpacity>
+
+ {/* <Text
style={{
fontFamily: WEIGHT.semibold,
color: colors.accent,
@@ -77,9 +105,9 @@ export const Home = ({navigation}) => {
marginTop: 10,
}}>
80.45/100 MB
- </Text>
+ </Text> */}
- <View
+ {/* <View
style={{
borderRadius: 2.5,
backgroundColor: colors.accent,
@@ -95,7 +123,7 @@ export const Home = ({navigation}) => {
}}>
Basic User
</Text>
- </View>
+ </View> */}
</View>
<View
@@ -119,10 +147,20 @@ export const Home = ({navigation}) => {
func: () => NavigationService.navigate('Favorites'),
},
{
- name: 'Folders',
+ name: 'Notebooks',
icon: 'md-folder',
func: () => NavigationService.navigate('Folders'),
},
+ {
+ name: 'Tags',
+ icon: 'md-folder',
+ func: () => {},
+ },
+ {
+ name: 'Colors',
+ icon: 'md-folder',
+ func: () => {},
+ },
]}
keyExtractor={(item, index) => item.name}
renderItem={({item, index}) => (
diff --git a/apps/mobile/src/views/Login/index.js b/apps/mobile/src/views/Login/index.js
new file mode 100644
index 000000000..dd4c7cf16
--- /dev/null
+++ b/apps/mobile/src/views/Login/index.js
@@ -0,0 +1,183 @@
+import React, {useEffect, useState} from 'react';
+import {
+ ScrollView,
+ View,
+ Text,
+ TouchableOpacity,
+ Dimensions,
+ Image,
+ SafeAreaView,
+ Platform,
+ DeviceEventEmitter,
+} 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/Ionicons';
+import {Reminder} from '../../components/Reminder';
+import {ListItem} from '../../components/ListItem';
+import {getElevation} from '../../utils/utils';
+import {FlatList, TextInput} from 'react-native-gesture-handler';
+import {NavigationEvents} from 'react-navigation';
+
+const w = Dimensions.get('window').width;
+const h = Dimensions.get('window').height;
+
+export const Login = ({navigation}) => {
+ const [colors, setColors] = useState(COLOR_SCHEME);
+
+ useEffect(() => {
+ DeviceEventEmitter.emit('hide');
+ return () => {
+ DeviceEventEmitter.emit('show');
+ };
+ });
+
+ return (
+ <SafeAreaView>
+ <NavigationEvents
+ onWillFocus={() => {
+ DeviceEventEmitter.emit('hide');
+ }}
+ />
+ <View
+ style={{
+ flexDirection: 'row',
+ justifyContent: 'space-between',
+ alignItems: 'center',
+ paddingHorizontal: '5%',
+ marginTop: Platform.OS == 'ios' ? h * 0.02 : h * 0.04,
+ marginBottom: h * 0.04,
+ }}>
+ <Text
+ style={{
+ fontSize: SIZE.xxl,
+ color: colors.pri,
+ fontFamily: WEIGHT.bold,
+ }}>
+ Log in
+ </Text>
+ </View>
+
+ <View>
+ <TextInput
+ style={{
+ padding: pv,
+ backgroundColor: colors.navbg,
+ marginHorizontal: '5%',
+ borderRadius: 5,
+ fontSize: SIZE.md,
+ fontFamily: WEIGHT.regular,
+ marginBottom: 20,
+ }}
+ placeholder="Email"
+ placeholderTextColor={colors.icon}
+ />
+ <TextInput
+ style={{
+ padding: pv,
+ backgroundColor: colors.navbg,
+ marginHorizontal: '5%',
+ borderRadius: 5,
+ fontSize: SIZE.md,
+ fontFamily: WEIGHT.regular,
+ marginBottom: 20,
+ }}
+ placeholder="Password"
+ placeholderTextColor={colors.icon}
+ />
+
+ <TouchableOpacity
+ activeOpacity={opacity}
+ style={{
+ padding: pv,
+ backgroundColor: colors.accent,
+ borderRadius: 5,
+ marginHorizontal: '5%',
+ marginBottom: 10,
+ }}>
+ <Text
+ style={{
+ fontSize: SIZE.md,
+ fontFamily: WEIGHT.regular,
+ color: 'white',
+ }}>
+ Log in
+ </Text>
+ </TouchableOpacity>
+
+ <TouchableOpacity
+ activeOpacity={opacity}
+ style={{
+ alignItems: 'flex-end',
+ marginHorizontal: '5%',
+ }}>
+ <Text
+ style={{
+ fontSize: SIZE.sm,
+ fontFamily: WEIGHT.regular,
+ color: colors.accent,
+ }}>
+ Forgot password?
+ </Text>
+ </TouchableOpacity>
+ </View>
+
+ <View
+ style={{
+ height: h * 0.25,
+ position: 'absolute',
+ top: h * 0.75,
+ justifyContent: 'center',
+ width: '100%',
+ }}>
+ <TouchableOpacity
+ activeOpacity={opacity}
+ style={{
+ alignItems: 'center',
+ width: '100%',
+ marginBottom: 20,
+ }}>
+ <Text
+ style={{
+ fontSize: SIZE.md,
+ fontFamily: WEIGHT.regular,
+ color: colors.accent,
+ }}>
+ Login with G
+ </Text>
+ </TouchableOpacity>
+
+ <TouchableOpacity
+ activeOpacity={opacity}
+ style={{
+ alignItems: 'center',
+ width: '100%',
+ }}>
+ <Text
+ style={{
+ fontSize: SIZE.sm,
+ fontFamily: WEIGHT.regular,
+ color: colors.accent,
+ }}>
+ Create a New Account
+ </Text>
+ </TouchableOpacity>
+ </View>
+ </SafeAreaView>
+ );
+};
+
+Login.navigationOptions = {
+ header: null,
+};
+
+export default Login;
diff --git a/apps/mobile/src/views/Signup/index.js b/apps/mobile/src/views/Signup/index.js
new file mode 100644
index 000000000..e69de29bb