Skip to content

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

minor changes in ui

ammarahm-ed731b80c921d6
diff --git a/apps/mobile/src/common/common.js b/apps/mobile/src/common/common.js
index ebce80df4..e91e4a96f 100755
--- a/apps/mobile/src/common/common.js
+++ b/apps/mobile/src/common/common.js
@@ -137,11 +137,11 @@ export const SIZE = {
xxs: 10,
xs: 12,
sm: normalize(15),
- md: normalize(18),
+ md: normalize(17),
lg: normalize(24),
- xl: normalize(28),
- xxl: normalize(32),
- xxxl: normalize(36),
+ xl: normalize(27),
+ xxl: normalize(31),
+ xxxl: normalize(34),
};
export const br = 5; // border radius
diff --git a/apps/mobile/src/components/Menu/index.js b/apps/mobile/src/components/Menu/index.js
index 26dc02459..ad8a96054 100644
--- a/apps/mobile/src/components/Menu/index.js
+++ b/apps/mobile/src/components/Menu/index.js
@@ -22,15 +22,12 @@ import {
setColorScheme,
SIZE,
WEIGHT,
+ ph,
} from '../../common/common';
import {useTracked} from '../../provider';
import {ACTIONS} from '../../provider/actions';
import {eSendEvent} from '../../services/eventManager';
-import {
- eOpenLoginDialog,
- eOpenModalMenu,
- eSendSideMenuOverlayRef,
-} from '../../services/events';
+import {eOpenModalMenu, eSendSideMenuOverlayRef} from '../../services/events';
import NavigationService from '../../services/NavigationService';
export const Menu = ({
@@ -74,12 +71,7 @@ export const Menu = ({
}),
close: true,
},
- {
- name: 'Lists',
- icon: 'list',
- func: () => NavigationService.navigate('Lists'),
- close: true,
- },
+
{
name: 'Favorites',
icon: 'star',
@@ -88,7 +80,16 @@ export const Menu = ({
},
{
- name: 'Dark Mode',
+ name: 'Trash',
+ icon: 'trash',
+ func: () => NavigationService.navigate('Trash'),
+ close: true,
+ },
+ ];
+
+ const listItems2 = [
+ {
+ name: 'Night mode',
icon: 'moon',
func: () => {
if (!colors.night) {
@@ -104,12 +105,6 @@ export const Menu = ({
on: colors.night ? true : false,
close: false,
},
- {
- name: 'Trash',
- icon: 'trash',
- func: () => NavigationService.navigate('Trash'),
- close: true,
- },
{
name: 'Settings',
icon: 'settings',
@@ -124,7 +119,7 @@ export const Menu = ({
height: '100%',
opacity: hide ? 0 : 1,
width: '100%',
- backgroundColor: colors.shade,
+ backgroundColor: 'transparent',
borderRightWidth: noTextMode ? 1 : 0,
borderRightColor: noTextMode ? colors.accent : 'transparent',
}}>
@@ -132,7 +127,7 @@ export const Menu = ({
style={{
minHeight: 2,
width: '100%',
- paddingHorizontal: noTextMode ? 0 : 12,
+ paddingHorizontal: noTextMode ? 0 : ph,
height: DDS.isTab ? 50 : 0,
marginBottom: 0,
alignItems: 'center',
@@ -235,7 +230,7 @@ export const Menu = ({
}}>
<Icon
style={{
- minWidth: noTextMode ? 5 : 30,
+ minWidth: noTextMode ? 5 : 40,
}}
name={item.icon}
color={colors.accent}
@@ -288,7 +283,7 @@ export const Menu = ({
}}>
<Icon
style={{
- minWidth: noTextMode ? 5 : 30,
+ minWidth: noTextMode ? 5 : 40,
}}
name="tag"
color={colors.accent}
@@ -298,7 +293,7 @@ export const Menu = ({
<Text
style={{
fontFamily: WEIGHT.regular,
- fontSize: SIZE.sm,
+ fontSize: SIZE.sm - 1,
color: colors.pri,
}}>
Tags
@@ -473,13 +468,13 @@ export const Menu = ({
<View
style={{
width: '100%',
- justifyContent: noTextMode ? 'center' : 'space-between',
+ justifyContent: noTextMode ? 'center' : 'center',
alignItems: 'center',
alignSelf: 'center',
marginBottom: 15,
- flexDirection: 'row',
+ paddingHorizontal: ph,
}}>
- <TouchableOpacity
+ {/* <TouchableOpacity
onPress={() => {
close();
@@ -496,7 +491,14 @@ export const Menu = ({
alignItems: 'center',
flexDirection: 'row',
}}>
- <Icon name="log-in" color={colors.accent} size={SIZE.lg} />
+ <Icon
+ style={{
+ minWidth: 40,
+ }}
+ name="log-in"
+ color={colors.accent}
+ size={SIZE.lg}
+ />
{noTextMode ? null : (
<Text
@@ -508,45 +510,138 @@ export const Menu = ({
{' '}Login
</Text>
)}
- </TouchableOpacity>
+ </TouchableOpacity> */}
- {/* <Text
- style={{
- fontFamily: WEIGHT.semibold,
- color: colors.accent,
- fontSize: SIZE.md,
- marginTop: 10,
- }}>
- Hi, Ammar!
- </Text>
+ <View
+ style={{
+ width: '100%',
+ }}>
+ {listItems2.map((item, index) => (
+ <TouchableOpacity
+ key={item.name}
+ activeOpacity={opacity / 2}
+ onPress={() => {
+ item.close === false ? null : close();
- <Text
- style={{
- fontFamily: WEIGHT.regular,
- color: colors.accent,
- fontSize: SIZE.xs,
- marginTop: 10,
- }}>
- 80.45/100 MB
- </Text> */}
+ item.func();
+ }}
+ style={{
+ width: '100%',
+ alignSelf: 'center',
+ flexDirection: 'row',
+ justifyContent: noTextMode ? 'center' : 'space-between',
+ alignItems: 'center',
+ paddingBottom: noTextMode ? pv + 2 : normalize(15),
+ paddingTop:
+ index === 0 ? pv : noTextMode ? pv + 2 : normalize(15),
+ }}>
+ <View
+ style={{
+ flexDirection: 'row',
+ alignItems: 'center',
+ }}>
+ <Icon
+ style={{
+ minWidth: noTextMode ? 5 : 40,
+ }}
+ name={item.icon}
+ color={colors.accent}
+ size={SIZE.md}
+ />
+ {noTextMode ? null : (
+ <Text
+ style={{
+ fontFamily: WEIGHT.regular,
+ fontSize: SIZE.sm - 1,
+ color: colors.pri,
+ }}>
+ {item.name}
+ </Text>
+ )}
+ </View>
- {/* <View
- style={{
- borderRadius: 2.5,
- backgroundColor: colors.accent,
- marginTop: 10,
- paddingHorizontal: 5,
- paddingVertical: 2,
- }}>
- <Text
+ {item.switch && !noTextMode ? (
+ <Icon
+ size={SIZE.lg}
+ color={item.on ? colors.accent : colors.icon}
+ name={item.on ? 'toggle-right' : 'toggle-left'}
+ />
+ ) : (
+ undefined
+ )}
+ </TouchableOpacity>
+ ))}
+ </View>
+
+ <View
style={{
- fontFamily: WEIGHT.bold,
- fontSize: SIZE.xxs,
- color: 'white',
+ width: '100%',
+ borderRadius: 5,
+ backgroundColor: colors.shade,
}}>
- Basic User
- </Text>
- </View> */}
+ <View
+ style={{
+ flexDirection: 'row',
+ justifyContent: 'space-between',
+ alignItems: 'center',
+ backgroundColor: colors.accent,
+ borderRadius: 5,
+ paddingHorizontal: 5,
+ paddingVertical: 5,
+ elevation: 2,
+ }}>
+ <Text
+ style={{
+ fontFamily: WEIGHT.regular,
+ color: 'white',
+ fontSize: SIZE.xs,
+ }}>
+ <Icon name="user" /> ammarahmed6506
+ </Text>
+ <Text
+ style={{
+ fontFamily: WEIGHT.regular,
+ fontSize: SIZE.xs,
+ color: 'white',
+ }}>
+ Basic
+ </Text>
+ </View>
+
+ <View
+ style={{
+ flexDirection: 'row',
+ justifyContent: 'space-between',
+ alignItems: 'center',
+
+ paddingHorizontal: 5,
+ paddingVertical: pv,
+ }}>
+ <Text
+ style={{
+ fontFamily: WEIGHT.regular,
+ color: colors.pri,
+ fontSize: SIZE.xxs,
+ }}>
+ <Icon color={colors.accent} name="refresh-ccw" /> Synced 3 mins
+ ago.
+ </Text>
+
+ <TouchableOpacity
+ style={{
+ borderWidth: 1,
+ borderColor: colors.accent,
+ width: 16,
+ height: 16,
+ justifyContent: 'center',
+ alignItems: 'center',
+ borderRadius: 100,
+ paddingTop: 1.5,
+ }}>
+ <Icon size={SIZE.xxs} color={colors.accent} name="check" />
+ </TouchableOpacity>
+ </View>
+ </View>
</View>
</SafeAreaView>
);
diff --git a/apps/mobile/src/components/NotesList/index.js b/apps/mobile/src/components/NotesList/index.js
index 2cea54fa7..3e3080820 100644
--- a/apps/mobile/src/components/NotesList/index.js
+++ b/apps/mobile/src/components/NotesList/index.js
@@ -112,20 +112,12 @@ export const NotesList = ({isGrouped = false}) => {
<Text
style={{
color: colors.icon,
- fontSize: SIZE.md,
+ fontSize: SIZE.sm,
fontFamily: WEIGHT.regular,
- marginTop: 20,
+ marginTop: 35,
}}>
Notes you write will appear here.
</Text>
- <Text
- style={{
- fontSize: SIZE.sm,
- color: colors.icon,
- marginTop: 20,
- }}>
- No notes found
- </Text>
</>
)}
</View>
diff --git a/apps/mobile/src/provider/actions.js b/apps/mobile/src/provider/actions.js
index 46f2a751d..56e55b235 100644
--- a/apps/mobile/src/provider/actions.js
+++ b/apps/mobile/src/provider/actions.js
@@ -14,4 +14,5 @@ export const ACTIONS = {
CURRENT_EDITING_NOTE: 'currentEditingNote',
COLORS: 'colorNotes',
SEARCH_RESULTS: 'searchResults',
+ USER: 'getUser',
};
diff --git a/apps/mobile/src/provider/defaultState.js b/apps/mobile/src/provider/defaultState.js
index 61dc6dc56..2ec890473 100644
--- a/apps/mobile/src/provider/defaultState.js
+++ b/apps/mobile/src/provider/defaultState.js
@@ -11,6 +11,7 @@ export const defaultState = {
pinned: [],
tags: [],
colorNotes: [],
+ user: {},
colors: {
night: false,
bg: 'white',
diff --git a/apps/mobile/src/provider/reducer.js b/apps/mobile/src/provider/reducer.js
index 7e6799aad..5ddcbb3a1 100644
--- a/apps/mobile/src/provider/reducer.js
+++ b/apps/mobile/src/provider/reducer.js
@@ -18,6 +18,13 @@ export const reducer = (state, action) => {
colors: {...action.colors},
};
}
+ case ACTIONS.USER: {
+ let user = action.user;
+ return {
+ ...state,
+ user: user,
+ };
+ }
case ACTIONS.NOTEBOOKS: {
let notebooks = [...db.notebooks.all];
return {
diff --git a/apps/mobile/src/utils/utils.js b/apps/mobile/src/utils/utils.js
index 05fee79a6..64f2734cf 100755
--- a/apps/mobile/src/utils/utils.js
+++ b/apps/mobile/src/utils/utils.js
@@ -49,7 +49,7 @@ export const w = Dimensions.get('window').width;
export const h = Dimensions.get('window').height;
export const ToastEvent = {
- show: (message, type, duration = 10000, func = null, actionText = '') => {
+ show: (message, type, duration = 1000, func = null, actionText = '') => {
eSendEvent(eShowToast, {
message,
type,
diff --git a/apps/mobile/src/views/Login/index.js b/apps/mobile/src/views/Login/index.js
index 86c412b2f..a2fbb52a3 100644
--- a/apps/mobile/src/views/Login/index.js
+++ b/apps/mobile/src/views/Login/index.js
@@ -5,21 +5,39 @@ import {
Text,
TouchableOpacity,
View,
+ ActivityIndicator,
} from 'react-native';
import {TextInput} from 'react-native-gesture-handler';
import {useIsFocused} from 'react-navigation-hooks';
-import {DDS} from '../../../App';
+import {DDS, db} from '../../../App';
import {opacity, pv, SIZE, WEIGHT} from '../../common/common';
import {Header} from '../../components/header';
import {useTracked} from '../../provider';
import {eSendEvent} from '../../services/eventManager';
import {eCloseSideMenu} from '../../services/events';
-import {validateEmail, validatePass} from '../../services/validation';
+import * as Animatable from 'react-native-animatable';
+import {
+ validateEmail,
+ validatePass,
+ validateUsername,
+} from '../../services/validation';
import Icon from 'react-native-vector-icons/Feather';
+import {ToastEvent} from '../../utils/utils';
export const Login = ({navigation}) => {
const [state, dispatch] = useTracked();
const {colors, isLoginNavigator} = state;
+ const _email = createRef();
+ const _pass = createRef();
+ const [status, setStatus] = useState('Logging in...');
+ const _username = createRef();
+ const [loggingIn, setLoggingIn] = useState(false);
+ const [email, setEmail] = useState('');
+ const [password, setPassword] = useState('');
+ const [invalidEmail, setInvalidEmail] = useState(false);
+ const [invalidPassword, setInvalidPassword] = useState(false);
+ const [username, setUsername] = useState('');
+ const [invalidUsername, setInvalidUsername] = useState(false);
const isFocused = useIsFocused();
@@ -53,289 +71,451 @@ export const Login = ({navigation}) => {
};
}, [isFocused]);
- return (
- <SafeAreaView
- style={{
- backgroundColor: colors.bg,
- height: '100%',
- }}>
- <Header
- navigation={navigation}
- isLoginNavigator={isLoginNavigator}
- colors={colors}
- heading="Login"
- />
+ const _logIn = async () => {
+ setLoggingIn(true);
+ _username.current.blur();
+ _pass.current.blur();
- <View
- style={{
- justifyContent: 'center',
- alignItems: 'center',
- width: '100%',
- }}>
- {renderLogin(colors, navigation)}
- </View>
- </SafeAreaView>
- );
-};
+ setTimeout(() => {
+ setStatus('Syncing...');
-Login.navigationOptions = {
- header: null,
- headerStyle: {
- backgroundColor: 'transparent',
- borderBottomWidth: 0,
- height: 0,
- },
-};
+ setTimeout(() => {
+ navigation.navigate('Home');
-export default Login;
+ ToastEvent.show(`Logged in as ${'ammarahmed'}`, 'success');
+ }, 500);
+ }, 300);
-const renderLogin = (colors, navigation) => {
- const _email = createRef();
- const _pass = createRef();
- const [email, setEmail] = useState('');
- const [password, setPassword] = useState('');
- const [invalidEmail, setInvalidEmail] = useState(false);
- const [invalidPassword, setInvalidPassword] = useState(false);
+ return;
+ if (!invalidPassword && !invalidUsername) {
+ try {
+ await db.user.login(username, password);
+ } catch (e) {
+ console.log(e, 'signup');
+ }
+
+ let user;
+
+ try {
+ user = await db.user.user.get();
+ dispatch({type: ACTIONS.USER, user: user});
+ } catch (e) {
+ console.log('e', 'getUSer');
+ }
+
+ console.log(user);
+ } else {
+ ToastEvent.show('Login failed', 'error');
+ }
+ };
return (
- <View
+ <SafeAreaView
style={{
- justifyContent: DDS.isTab ? 'center' : 'flex-start',
- width: DDS.isTab ? '80%' : '100%',
- height: DDS.isTab ? '80%' : '100%',
- alignSelf: 'center',
+ backgroundColor: colors.bg,
+ height: '100%',
}}>
- <View>
- <Text
+ {loggingIn ? (
+ <Animatable.View
+ transition="opacity"
+ useNativeDriver={true}
+ duration={150}
style={{
- textAlign: 'right',
- marginHorizontal: 12,
- fontFamily: WEIGHT.regular,
- textAlignVertical: 'bottom',
-
+ width: '100%',
+ height: '100%',
+ justifyContent: 'center',
+ alignItems: 'center',
+ zIndex: 999,
+ backgroundColor: colors.bg,
+ opacity: 1,
position: 'absolute',
- right: 5,
- top: 2.5,
}}>
- {invalidEmail ? (
- <Icon name="alert-circle" size={SIZE.xs} color={colors.errorText} />
- ) : null}
- </Text>
+ <ActivityIndicator color={colors.accent} size={SIZE.xxxl} />
- <TextInput
- ref={_email}
- onFocus={() => {
- if (!invalidEmail) {
- _email.current.setNativeProps({
- style: {
- borderColor: colors.accent,
- },
- });
- }
- }}
- defaultValue={email}
- onBlur={() => {
- if (!validateEmail(email)) {
- setInvalidEmail(true);
- _email.current.setNativeProps({
- style: {
- color: colors.errorText,
- borderColor: colors.errorText,
- },
- });
- } else {
- _email.current.setNativeProps({
- style: {
- borderColor: colors.nav,
- },
- });
- }
- }}
- textContentType="emailAddress"
- onChangeText={value => {
- setEmail(value);
- if (invalidEmail && validateEmail(email)) {
- setInvalidEmail(false);
- _email.current.setNativeProps({
- style: {
- color: colors.pri,
- borderColor: colors.accent,
- },
- });
- }
- }}
- onSubmitEditing={() => {
- if (!validateEmail(email)) {
- setInvalidEmail(true);
- _email.current.setNativeProps({
- style: {
- color: colors.errorText,
- },
- });
- }
- }}
- style={{
- padding: pv,
- borderWidth: 1.5,
- borderColor: colors.nav,
- marginHorizontal: 12,
- borderRadius: 5,
- fontSize: SIZE.sm,
- fontFamily: WEIGHT.regular,
- }}
- placeholder="Email"
- placeholderTextColor={colors.icon}
- />
-
- <View
- style={{
- marginBottom: 15,
- marginTop: 15,
- }}>
<Text
style={{
- textAlign: 'right',
- marginHorizontal: 12,
+ color: colors.accent,
fontFamily: WEIGHT.regular,
- textAlignVertical: 'bottom',
- position: 'absolute',
- right: 5,
- top: 2.5,
+ fontSize: SIZE.md,
+ marginTop: 10,
}}>
- {invalidPassword ? (
- <Icon
- name="alert-circle"
- size={SIZE.xs}
- color={colors.errorText}
- />
- ) : null}
+ {status}
</Text>
- <TextInput
- ref={_pass}
- onFocus={() => {
- if (!invalidPassword) {
- _pass.current.setNativeProps({
- style: {
- borderColor: colors.accent,
- },
- });
- }
- }}
- defaultValue={password}
- onBlur={() => {
- if (!validatePass(password)) {
- setInvalidPassword(true);
- _pass.current.setNativeProps({
- style: {
- color: colors.errorText,
- borderColor: colors.errorText,
- },
- });
- } else {
- _pass.current.setNativeProps({
- style: {
- borderColor: colors.nav,
- },
- });
- }
- }}
- onChangeText={value => {
- setPassword(value);
+ </Animatable.View>
+ ) : null}
- if (invalidPassword && validatePass(password)) {
- setInvalidPassword(false);
- _pass.current.setNativeProps({
- style: {
- color: colors.pri,
- borderColor: colors.accent,
- },
- });
- }
- }}
- onSubmitEditing={() => {
- if (!validatePass(password)) {
- setInvalidPassword(true);
- _pass.current.setNativeProps({
- style: {
- color: colors.errorText,
- },
- });
- }
- }}
- style={{
- padding: pv,
- borderWidth: 1.5,
- borderColor: colors.nav,
- marginHorizontal: 12,
- borderRadius: 5,
- fontSize: SIZE.sm,
- fontFamily: WEIGHT.regular,
- }}
- secureTextEntry={true}
- placeholder="Password"
- placeholderTextColor={colors.icon}
+ {loggingIn ? null : (
+ <>
+ <Header
+ navigation={navigation}
+ isLoginNavigator={isLoginNavigator}
+ colors={colors}
+ heading="Login"
/>
- </View>
- <TouchableOpacity
- activeOpacity={opacity}
- style={{
- padding: pv,
- backgroundColor: colors.accent,
- borderRadius: 5,
- marginHorizontal: 12,
- marginBottom: 10,
- alignItems: 'center',
- }}>
- <Text
+
+ <View
style={{
- fontSize: SIZE.md,
- fontFamily: WEIGHT.medium,
- color: 'white',
+ justifyContent: 'flex-start',
+ alignItems: 'center',
+ width: '100%',
}}>
- Login
- </Text>
- </TouchableOpacity>
-
- <View
- style={{
- width: '100%',
- flexDirection: 'row',
- justifyContent: 'space-between',
- alignItems: 'center',
- paddingHorizontal: 12,
- }}>
- <TouchableOpacity
- onPress={() => {
- navigation.navigate('Signup');
- }}
- activeOpacity={opacity}
- style={{}}>
- <Text
+ <View
style={{
- fontSize: SIZE.sm - 1,
- fontFamily: WEIGHT.regular,
- color: colors.accent,
- }}>
- Create a New Account
- </Text>
- </TouchableOpacity>
- <TouchableOpacity
- onPress={() => {
- navigation.navigate('ForgotPassword');
- }}
- activeOpacity={opacity}
- style={{}}>
- <Text
- style={{
- fontSize: SIZE.sm - 1,
- fontFamily: WEIGHT.regular,
- color: colors.accent,
+ justifyContent: DDS.isTab ? 'center' : 'space-between',
+ width: DDS.isTab ? '80%' : '100%',
+ height: DDS.isTab ? '80%' : null,
+
+ alignSelf: 'center',
}}>
- Forgot password?
- </Text>
- </TouchableOpacity>
- </View>
- </View>
- </View>
+ <View
+ style={{
+ height: '70%',
+ }}>
+ <Text
+ style={{
+ textAlign: 'right',
+ marginHorizontal: 12,
+ fontFamily: WEIGHT.regular,
+
+ textAlignVertical: 'bottom',
+
+ position: 'absolute',
+ right: 5,
+ top: 2.5,
+ }}>
+ {invalidUsername ? (
+ <Icon
+ name="alert-circle"
+ size={SIZE.xs}
+ color={colors.errorText}
+ />
+ ) : null}
+ </Text>
+
+ <TextInput
+ ref={_username}
+ onFocus={() => {
+ if (!invalidUsername) {
+ _username.current.setNativeProps({
+ style: {
+ borderColor: colors.accent,
+ },
+ });
+ }
+ }}
+ defaultValue={username}
+ onBlur={() => {
+ if (!validateUsername(username)) {
+ setInvalidUsername(true);
+ _username.current.setNativeProps({
+ style: {
+ color: colors.errorText,
+ borderColor: colors.errorText,
+ },
+ });
+ } else {
+ _username.current.setNativeProps({
+ style: {
+ borderColor: colors.nav,
+ },
+ });
+ }
+ }}
+ textContentType="username"
+ onChangeText={value => {
+ setUsername(value);
+
+ if (invalidUsername && validateUsername(username)) {
+ setInvalidUsername(false);
+ _username.current.setNativeProps({
+ style: {
+ color: colors.pri,
+ borderColor: colors.accent,
+ },
+ });
+ }
+ }}
+ onSubmitEditing={() => {
+ if (!validateUsername(username)) {
+ setInvalidUsername(true);
+ _username.current.setNativeProps({
+ style: {
+ color: colors.errorText,
+ },
+ });
+ }
+ }}
+ style={{
+ padding: pv,
+ borderWidth: 1.5,
+ borderColor: colors.nav,
+ marginHorizontal: 12,
+ borderRadius: 5,
+ fontSize: SIZE.sm,
+ fontFamily: WEIGHT.regular,
+ }}
+ placeholder="Username (a-z _- 0-9)"
+ placeholderTextColor={colors.icon}
+ />
+
+ {/* <Text
+ style={{
+ textAlign: 'right',
+ marginHorizontal: 12,
+ fontFamily: WEIGHT.regular,
+ textAlignVertical: 'bottom',
+
+ position: 'absolute',
+ right: 5,
+ top: 2.5,
+ }}>
+ {invalidEmail ? (
+ <Icon name="alert-circle" size={SIZE.xs} color={colors.errorText} />
+ ) : null}
+ </Text>
+
+ <TextInput
+ ref={_email}
+ onFocus={() => {
+ if (!invalidEmail) {
+ _email.current.setNativeProps({
+ style: {
+ borderColor: colors.accent,
+ },
+ });
+ }
+ }}
+ defaultValue={email}
+ onBlur={() => {
+ if (!validateEmail(email)) {
+ setInvalidEmail(true);
+ _email.current.setNativeProps({
+ style: {
+ color: colors.errorText,
+ borderColor: colors.errorText,
+ },
+ });
+ } else {
+ _email.current.setNativeProps({
+ style: {
+ borderColor: colors.nav,
+ },
+ });
+ }
+ }}
+ textContentType="emailAddress"
+ onChangeText={value => {
+ setEmail(value);
+ if (invalidEmail && validateEmail(email)) {
+ setInvalidEmail(false);
+ _email.current.setNativeProps({
+ style: {
+ color: colors.pri,
+ borderColor: colors.accent,
+ },
+ });
+ }
+ }}
+ onSubmitEditing={() => {
+ if (!validateEmail(email)) {
+ setInvalidEmail(true);
+ _email.current.setNativeProps({
+ style: {
+ color: colors.errorText,
+ },
+ });
+ }
+ }}
+ style={{
+ padding: pv,
+ borderWidth: 1.5,
+ borderColor: colors.nav,
+ marginHorizontal: 12,
+ borderRadius: 5,
+ fontSize: SIZE.sm,
+ fontFamily: WEIGHT.regular,
+ }}
+ placeholder="Email"
+ placeholderTextColor={colors.icon}
+ /> */}
+
+ <View
+ style={{
+ marginBottom: 15,
+ marginTop: 15,
+ }}>
+ <Text
+ style={{
+ textAlign: 'right',
+ marginHorizontal: 12,
+ fontFamily: WEIGHT.regular,
+ textAlignVertical: 'bottom',
+ position: 'absolute',
+ right: 5,
+ top: 2.5,
+ }}>
+ {invalidPassword ? (
+ <Icon
+ name="alert-circle"
+ size={SIZE.xs}
+ color={colors.errorText}
+ />
+ ) : null}
+ </Text>
+ <TextInput
+ ref={_pass}
+ onFocus={() => {
+ if (!invalidPassword) {
+ _pass.current.setNativeProps({
+ style: {
+ borderColor: colors.accent,
+ },
+ });
+ }
+ }}
+ defaultValue={password}
+ onBlur={() => {
+ if (!validatePass(password)) {
+ setInvalidPassword(true);
+ _pass.current.setNativeProps({
+ style: {
+ color: colors.errorText,
+ borderColor: colors.errorText,
+ },
+ });
+ } else {
+ _pass.current.setNativeProps({
+ style: {
+ borderColor: colors.nav,
+ },
+ });
+ }
+ }}
+ onChangeText={value => {
+ setPassword(value);
+
+ if (invalidPassword && validatePass(password)) {
+ setInvalidPassword(false);
+ _pass.current.setNativeProps({
+ style: {
+ color: colors.pri,
+ borderColor: colors.accent,
+ },
+ });
+ }
+ }}
+ onSubmitEditing={() => {
+ if (!validatePass(password)) {
+ setInvalidPassword(true);
+ _pass.current.setNativeProps({
+ style: {
+ color: colors.errorText,
+ },
+ });
+ }
+ }}
+ style={{
+ padding: pv,
+ borderWidth: 1.5,
+ borderColor: colors.nav,
+ marginHorizontal: 12,
+ borderRadius: 5,
+ fontSize: SIZE.sm,
+ fontFamily: WEIGHT.regular,
+ }}
+ secureTextEntry={true}
+ placeholder="Password"
+ placeholderTextColor={colors.icon}
+ />
+ {/* <View
+ style={{
+ paddingHorizontal: 12,
+ alignItems: 'flex-end',
+ }}>
+ <TouchableOpacity
+ onPress={() => {
+ navigation.navigate('ForgotPassword');
+ }}
+ activeOpacity={opacity}
+ style={{}}>
+ <Text
+ style={{
+ fontSize: SIZE.xs,
+ fontFamily: WEIGHT.regular,
+ color: colors.accent,
+ height: 25,
+ }}>
+ Forgot password?
+ </Text>
+ </TouchableOpacity>
+ </View> */}
+ </View>
+ <TouchableOpacity
+ activeOpacity={opacity}
+ onPress={_logIn}
+ style={{
+ padding: pv,
+ backgroundColor: colors.accent,
+ borderRadius: 5,
+ marginHorizontal: 12,
+ marginBottom: 10,
+ alignItems: 'center',
+ }}>
+ <Text
+ style={{
+ fontSize: SIZE.md,
+ fontFamily: WEIGHT.medium,
+ color: 'white',
+ }}>
+ Login
+ </Text>
+ </TouchableOpacity>
+ </View>
+
+ <View
+ style={{
+ width: '100%',
+ alignItems: 'center',
+ justifyContent: 'center',
+ }}>
+ <TouchableOpacity
+ onPress={() => {
+ navigation.navigate('Signup');
+ }}
+ activeOpacity={opacity}
+ style={{}}>
+ <Text
+ style={{
+ fontSize: SIZE.xs + 1,
+ fontFamily: WEIGHT.regular,
+ color: colors.pri,
+ height: 25,
+ }}>
+ Don't have an account yet?{' '}
+ <Text
+ style={{
+ color: colors.accent,
+ }}>
+ Register now
+ </Text>
+ </Text>
+ </TouchableOpacity>
+ </View>
+ </View>
+ </View>
+ </>
+ )}
+ </SafeAreaView>
);
};
+
+Login.navigationOptions = {
+ header: null,
+ headerStyle: {
+ backgroundColor: 'transparent',
+ borderBottomWidth: 0,
+ height: 0,
+ },
+};
+
+export default Login;
diff --git a/apps/mobile/src/views/Signup/index.js b/apps/mobile/src/views/Signup/index.js
index 770bba0de..b534d4c10 100644
--- a/apps/mobile/src/views/Signup/index.js
+++ b/apps/mobile/src/views/Signup/index.js
@@ -2,30 +2,35 @@ import React, {createRef, useEffect, useState} from 'react';
import {SafeAreaView, Text, TouchableOpacity, View} from 'react-native';
import {TextInput} from 'react-native-gesture-handler';
import {useIsFocused} from 'react-navigation-hooks';
-import {DDS} from '../../../App';
+import {DDS, db} from '../../../App';
import {opacity, pv, SIZE, WEIGHT} from '../../common/common';
import {Header} from '../../components/header';
import {useTracked} from '../../provider';
import {eSubscribeEvent, eUnSubscribeEvent} from '../../services/eventManager';
import {eLoginDialogNavigateBack} from '../../services/events';
+
+const _email = createRef();
+const _pass = createRef();
+const _username = createRef();
+
import {
validateUsername,
validateEmail,
validatePass,
} from '../../services/validation';
import Icon from 'react-native-vector-icons/Feather';
+import {ToastEvent} from '../../utils/utils';
+import {ACTIONS} from '../../provider/actions';
export const Signup = ({navigation}) => {
const [state, dispatch] = useTracked();
const {colors, isLoginNavigator} = state;
- const _email = createRef();
- const _pass = createRef();
- const _username = createRef();
+
const [email, setEmail] = useState('');
const [password, setPassword] = useState('');
const [username, setUsername] = useState('');
+ const [invalidUsername, setInvalidUsername] = useState(false);
const [invalidEmail, setInvalidEmail] = useState(false);
const [invalidPassword, setInvalidPassword] = useState(false);
- const [invalidUsername, setInvalidUsername] = useState(false);
let isFocused = useIsFocused();
@@ -40,6 +45,29 @@ export const Signup = ({navigation}) => {
};
}, [isFocused]);
+ const _signUp = async () => {
+ if (!invalidEmail && !invalidPassword && !invalidUsername) {
+ try {
+ await db.user.signup(username, email, password);
+ } catch (e) {
+ console.log(e, 'signup');
+ }
+
+ let user;
+
+ try {
+ user = await db.user.user.get();
+ dispatch({type: ACTIONS.USER, user: user});
+ } catch (e) {
+ console.log('e', 'getUSer');
+ }
+
+ console.log(user);
+ } else {
+ ToastEvent.show('Signup failed', 'error');
+ }
+ };
+
return (
<SafeAreaView
style={{
@@ -331,6 +359,7 @@ export const Signup = ({navigation}) => {
</View>
<TouchableOpacity
activeOpacity={opacity}
+ onPress={_signUp}
style={{
padding: pv,
backgroundColor: colors.accent,