Files
notesnook/apps/mobile/src/components/LoginDialog/index.js

808 lines
25 KiB
JavaScript
Raw Normal View History

2020-09-14 12:17:06 +05:00
import CheckBox from '@react-native-community/checkbox';
2020-09-19 16:02:21 +05:00
import React, {createRef, useEffect, useState} from 'react';
2020-11-02 20:50:07 +05:00
import {Modal, Text, TouchableOpacity, View} from 'react-native';
2020-09-19 16:02:21 +05:00
import {TextInput} from 'react-native-gesture-handler';
import {useSafeAreaInsets} from 'react-native-safe-area-context';
2020-09-14 11:43:07 +05:00
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
2020-09-19 16:02:21 +05:00
import {Button} from '../../components/Button';
2020-09-14 11:43:07 +05:00
import Seperator from '../../components/Seperator';
2020-09-19 16:02:21 +05:00
import {Toast} from '../../components/Toast';
2020-10-13 17:02:14 +05:00
import {Actions} from '../../provider/Actions';
2020-09-19 16:02:21 +05:00
import {useTracked} from '../../provider/index';
2020-11-02 20:50:07 +05:00
import {DDS} from '../../services/DeviceDetection';
2020-09-14 12:33:04 +05:00
import {
2020-10-26 12:01:05 +05:00
eSendEvent,
eSubscribeEvent,
eUnSubscribeEvent,
ToastEvent,
2020-10-13 17:02:14 +05:00
} from '../../services/EventManager';
2020-09-14 11:43:07 +05:00
import {
validateEmail,
validatePass,
2020-09-19 16:02:21 +05:00
validateUsername,
2020-10-13 17:02:14 +05:00
} from '../../services/Validation';
import {getElevation} from '../../utils';
2020-10-26 12:01:05 +05:00
import {db} from '../../utils/DB';
2020-11-02 20:50:07 +05:00
import {
eOpenLoginDialog,
eOpenRecoveryKeyDialog,
eStartSyncer,
refreshNotesPage,
} from '../../utils/Events';
import {opacity, pv, SIZE, WEIGHT} from '../../utils/SizeUtils';
2020-10-28 15:52:15 +05:00
import {sleep} from '../../utils/TimeUtils';
2020-11-02 20:50:07 +05:00
import {ActionIcon} from '../ActionIcon';
import {Loading} from '../Loading';
2020-01-23 23:18:15 +05:00
2020-09-14 11:43:07 +05:00
const LoginDialog = () => {
const [state, dispatch] = useTracked();
const colors = state.colors;
2020-09-14 12:33:04 +05:00
const [visible, setVisible] = useState(false);
2020-09-14 12:17:06 +05:00
const [status, setStatus] = useState('Logging you in');
2020-09-14 11:43:07 +05:00
const [loggingIn, setLoggingIn] = useState(false);
const [email, setEmail] = useState(null);
const [password, setPassword] = useState(null);
const [invalidEmail, setInvalidEmail] = useState(false);
const [invalidPassword, setInvalidPassword] = useState(false);
const [username, setUsername] = useState(null);
const [invalidUsername, setInvalidUsername] = useState(false);
const [secureEntry, setSecureEntry] = useState(true);
const [confirmPassword, setConfirmPassword] = useState(false);
2020-09-14 12:17:06 +05:00
const [key, setKey] = useState('abc123');
2020-09-14 11:43:07 +05:00
const [passwordReEnter, setPasswordReEnter] = useState(null);
const [failed, setFailed] = useState(false);
const [signingIn, setSigningIn] = useState(false);
const [login, setLogin] = useState(true);
const [userConsent, setUserConsent] = useState(false);
const _email = createRef();
const _pass = createRef();
const _username = createRef();
const _passConfirm = createRef();
const _passContainer = createRef();
2020-09-14 12:33:04 +05:00
const insets = useSafeAreaInsets();
useEffect(() => {
eSubscribeEvent(eOpenLoginDialog, open);
return () => {
eUnSubscribeEvent(eOpenLoginDialog, open);
};
}, []);
2020-01-23 23:18:15 +05:00
2020-09-14 11:43:07 +05:00
function open() {
setVisible(true);
2020-01-23 23:18:15 +05:00
}
2020-09-14 11:43:07 +05:00
const close = () => {
2020-09-27 10:15:19 +05:00
_email.current?.clear();
_pass.current?.clear();
_passConfirm.current?.clear();
_username.current?.clear();
2020-09-14 11:43:07 +05:00
setVisible(false);
2020-09-27 10:15:19 +05:00
setUsername(null);
setPassword(null);
setConfirmPassword(null);
setKey(null);
setLogin(true);
setUserConsent(false);
setEmail(false);
setLoggingIn(false);
2020-09-14 11:43:07 +05:00
};
2020-01-23 23:18:15 +05:00
2020-09-14 11:43:07 +05:00
const loginUser = async () => {
if (
!password ||
password.length < 8 ||
!username ||
invalidPassword ||
invalidUsername
) {
2020-09-14 13:34:55 +05:00
ToastEvent.show('username or password is invalid', 'error', 'local');
2020-09-14 11:43:07 +05:00
return;
}
2020-09-14 13:34:55 +05:00
2020-09-14 11:43:07 +05:00
setLoggingIn(true);
_username.current.blur();
_pass.current.blur();
2020-09-24 09:42:12 +05:00
setStatus('Logging in');
2020-09-14 11:43:07 +05:00
try {
let res = await db.user.login(username.toLowerCase(), password);
console.log(res, username, password);
} catch (e) {
setTimeout(() => {
2020-09-14 13:34:55 +05:00
ToastEvent.show(e.message, 'error', 'local');
2020-09-14 11:43:07 +05:00
setLoggingIn(false);
}, 500);
return;
}
try {
2020-09-24 09:42:12 +05:00
let user = await db.user.get();
2020-10-28 15:52:15 +05:00
if (!user) throw new Error('Username or passoword incorrect!');
2020-10-28 11:26:49 +05:00
setStatus('Syncing your notes');
2020-10-13 17:02:14 +05:00
dispatch({type: Actions.USER, user: user});
2020-09-14 11:43:07 +05:00
await db.sync();
eSendEvent(eStartSyncer);
2020-10-13 17:02:14 +05:00
dispatch({type: Actions.ALL});
2020-09-14 11:43:07 +05:00
eSendEvent(refreshNotesPage);
2020-11-02 20:50:07 +05:00
close();
2020-09-14 13:34:55 +05:00
ToastEvent.show(`Logged in as ${username}`, 'success', 'local');
2020-09-14 11:43:07 +05:00
} catch (e) {
2020-09-24 09:42:12 +05:00
ToastEvent.show(e.message, 'error', 'local');
} finally {
2020-09-14 11:43:07 +05:00
setLoggingIn(false);
}
};
2020-09-14 12:43:15 +05:00
const validateInfo = () => {
if (!password || !email || !username || !passwordReEnter) {
ToastEvent.show('All fields are required', 'error', 'local');
return false;
}
if (!confirmPassword) {
ToastEvent.show('Passwords do not match', 'error', 'local');
return false;
}
2020-10-28 11:26:49 +05:00
console.log(invalidEmail, invalidPassword, invalidUsername);
if (invalidEmail && invalidPassword && invalidUsername) {
2020-09-14 12:43:15 +05:00
ToastEvent.show('Signup information is invalid', 'error', 'local');
return false;
}
if (!userConsent) {
ToastEvent.show(
'You must agree to our terms of service and privacy policy.',
'error',
'local',
5000,
() => {
setUserConsent(true);
signupUser();
ToastEvent.hide();
},
'I Agree',
);
return false;
}
2020-10-28 11:26:49 +05:00
return true;
2020-09-14 12:43:15 +05:00
};
2020-09-14 11:43:07 +05:00
const signupUser = async () => {
2020-10-26 12:01:05 +05:00
if (!validateInfo()) return;
2020-09-14 11:43:07 +05:00
setSigningIn(true);
2020-09-14 12:33:04 +05:00
setStatus('Creating your account');
2020-09-14 11:43:07 +05:00
try {
await db.user.signup(username, email, password);
} catch (e) {
setSigningIn(false);
setFailed(true);
ToastEvent.show('Signup failed, Network Error', 'error', 'local');
return;
}
let user;
try {
2020-09-24 09:17:14 +05:00
user = await db.user.get();
2020-09-14 12:33:04 +05:00
setStatus('Setting up crenditials');
2020-10-13 17:02:14 +05:00
dispatch({type: Actions.USER, user: user});
2020-09-14 11:43:07 +05:00
eSendEvent(eStartSyncer);
2020-10-28 11:26:49 +05:00
close();
await sleep(500);
2020-10-28 15:52:15 +05:00
eSendEvent(eOpenRecoveryKeyDialog, true);
2020-09-14 11:43:07 +05:00
} catch (e) {
setFailed(true);
ToastEvent.show('Login Failed, try again', 'error', 'local');
2020-10-28 11:26:49 +05:00
} finally {
setSigningIn(false);
2020-09-14 11:43:07 +05:00
}
};
return (
<Modal
animated={true}
animationType={DDS.isTab ? 'fade' : 'slide'}
2020-09-14 12:33:04 +05:00
statusBarTranslucent={true}
2020-09-14 11:43:07 +05:00
onRequestClose={close}
visible={visible}
transparent={true}>
2020-09-14 12:33:04 +05:00
<View
2020-09-14 11:43:07 +05:00
style={{
2020-09-14 12:33:04 +05:00
opacity: 1,
2020-09-14 11:43:07 +05:00
flex: 1,
paddingTop: DDS.isTab ? 0 : insets.top,
2020-09-14 11:43:07 +05:00
backgroundColor: DDS.isTab ? 'rgba(0,0,0,0.3)' : colors.bg,
width: '100%',
height: '100%',
alignSelf: 'center',
justifyContent: 'center',
alignItems: 'center',
2020-10-28 11:26:49 +05:00
overflow: 'hidden',
2020-09-14 11:43:07 +05:00
}}>
{DDS.isTab ? (
2020-01-23 23:18:15 +05:00
<TouchableOpacity
2020-09-14 11:43:07 +05:00
onPress={close}
2020-01-23 23:18:15 +05:00
style={{
width: '100%',
height: '100%',
position: 'absolute',
zIndex: 1,
}}
/>
2020-09-14 11:43:07 +05:00
) : null}
<View
style={{
2020-10-26 12:01:05 +05:00
height:
DDS.isTab && !DDS.isSmallTab
? login
? '70%'
: '80%'
: DDS.isSmallTab
? login
? '50%'
: '65%'
: '100%',
width: DDS.isTab ? 500 : '100%',
2020-09-14 11:43:07 +05:00
backgroundColor: colors.bg,
2020-09-14 12:17:06 +05:00
justifyContent: 'center',
borderRadius: DDS.isTab ? 5 : 0,
zIndex: 10,
2020-10-26 12:01:05 +05:00
...getElevation(DDS.isTab ? 5 : 0),
2020-09-14 11:43:07 +05:00
}}>
2020-09-14 13:34:55 +05:00
<Toast context="local" />
2020-09-14 12:17:06 +05:00
{loggingIn || signingIn ? (
2020-10-26 12:01:05 +05:00
<View
style={{
backgroundColor: !colors.night
? 'rgba(0,0,0,0.2)'
: 'rgba(255,255,255,0.2)',
zIndex: 10,
position: 'absolute',
justifyContent: 'center',
alignItems: 'center',
width: '100%',
height: '100%',
}}>
<Loading
tagline={status}
customStyle={{
alignSelf: 'center',
backgroundColor: colors.bg,
...getElevation(5),
borderRadius: 5,
width: '80%',
height: 100,
}}
/>
</View>
) : null}
2020-10-28 11:26:49 +05:00
{DDS.isTab ? null : (
<ActionIcon
name="arrow-left"
size={SIZE.xxxl}
onPress={() => {
close();
}}
customStyle={{
width: 40,
height: 40,
position: 'absolute',
top: 0,
marginBottom: 15,
zIndex: 10,
left: 0,
2020-11-02 20:50:07 +05:00
marginLeft: 7,
marginTop: 5,
2020-10-28 11:26:49 +05:00
}}
color={colors.heading}
/>
)}
<View
style={{
justifyContent: 'center',
width: '100%',
height: '100%',
alignSelf: 'center',
paddingHorizontal: 12,
}}>
2020-10-26 12:01:05 +05:00
<View
style={{
2020-10-28 11:26:49 +05:00
marginBottom: 25,
2020-10-26 12:01:05 +05:00
}}>
<Text
2020-09-14 11:43:07 +05:00
style={{
2020-10-28 11:26:49 +05:00
color: colors.accent,
2020-10-26 12:01:05 +05:00
fontFamily: WEIGHT.bold,
fontSize: SIZE.xxxl,
}}>
2020-11-02 20:50:07 +05:00
{login ? 'Login' : 'Sign Up'}
2020-10-28 11:26:49 +05:00
{'\n'}
2020-09-14 11:43:07 +05:00
<Text
style={{
2020-10-28 11:26:49 +05:00
color: colors.icon,
fontSize: SIZE.md,
2020-09-14 11:43:07 +05:00
fontFamily: WEIGHT.regular,
}}>
2020-10-28 11:26:49 +05:00
{login
? 'Get all your notes from other devices'
: 'Create an account to access notes anywhere.'}
{}
2020-09-14 11:43:07 +05:00
</Text>
2020-10-26 12:01:05 +05:00
</Text>
2020-10-28 11:26:49 +05:00
</View>
<>
<TextInput
ref={_username}
onFocus={() => {
if (!invalidUsername) {
2020-11-02 23:13:56 +05:00
_username.current?.setNativeProps({
2020-10-28 11:26:49 +05:00
style: {
borderColor: colors.accent,
},
});
}
}}
autoCapitalize="none"
defaultValue={username}
onBlur={() => {
if (!validateUsername(username) && username?.length > 0) {
setInvalidUsername(true);
2020-11-02 23:13:56 +05:00
_username.current?.setNativeProps({
2020-10-28 11:26:49 +05:00
style: {
color: colors.errorText,
borderColor: colors.errorText,
},
});
} else {
setInvalidUsername(false);
2020-11-02 23:13:56 +05:00
_username.current?.setNativeProps({
2020-10-28 11:26:49 +05:00
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,
},
});
}
2020-10-26 12:01:05 +05:00
}}
style={{
2020-10-28 11:26:49 +05:00
paddingHorizontal: pv,
height: 50,
2020-11-02 20:50:07 +05:00
borderBottomWidth: 1,
2020-10-28 11:26:49 +05:00
borderColor: colors.nav,
fontSize: SIZE.sm,
fontFamily: WEIGHT.regular,
color: colors.pri,
}}
placeholder="Username (a-z _- 0-9)"
placeholderTextColor={colors.icon}
/>
{invalidUsername ? (
2020-09-14 11:43:07 +05:00
<Text
style={{
2020-10-28 11:26:49 +05:00
textAlign: 'right',
fontFamily: WEIGHT.regular,
textAlignVertical: 'bottom',
fontSize: SIZE.xs,
marginTop: 2.5,
2020-09-14 11:43:07 +05:00
}}>
2020-10-28 11:26:49 +05:00
<Icon
name="alert-circle-outline"
size={SIZE.xs}
color={colors.errorText}
/>{' '}
Username is invalid
2020-09-14 11:43:07 +05:00
</Text>
2020-10-28 11:26:49 +05:00
) : null}
</>
<Seperator />
{login ? null : (
<>
<TextInput
ref={_email}
onFocus={() => {
if (!invalidEmail) {
_email.current.setNativeProps({
style: {
borderColor: colors.accent,
},
});
}
}}
autoCapitalize="none"
defaultValue={email}
onBlur={() => {
if (!validateEmail(email) && email?.length > 0) {
setInvalidEmail(true);
2020-11-02 23:13:56 +05:00
_email.current?.setNativeProps({
2020-10-28 11:26:49 +05:00
style: {
color: colors.errorText,
borderColor: colors.errorText,
},
});
} else {
setInvalidEmail(false);
2020-11-02 23:13:56 +05:00
_email.current?.setNativeProps({
2020-10-28 11:26:49 +05:00
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,
},
});
}
}}
2020-10-28 11:26:49 +05:00
onSubmitEditing={() => {
if (!validateEmail(email)) {
setInvalidEmail(true);
_email.current.setNativeProps({
style: {
color: colors.errorText,
},
});
}
}}
2020-10-28 11:26:49 +05:00
style={{
paddingHorizontal: pv,
height: 50,
2020-11-02 20:50:07 +05:00
borderBottomWidth: 1,
2020-10-28 11:26:49 +05:00
borderColor: colors.nav,
fontSize: SIZE.sm,
fontFamily: WEIGHT.regular,
color: colors.pri,
}}
placeholder="Email"
placeholderTextColor={colors.icon}
/>
2020-10-28 11:26:49 +05:00
{invalidEmail ? (
2020-09-14 11:43:07 +05:00
<Text
style={{
2020-10-28 11:26:49 +05:00
textAlign: 'right',
fontFamily: WEIGHT.regular,
textAlignVertical: 'bottom',
fontSize: SIZE.xs,
marginTop: 2.5,
2020-09-14 11:43:07 +05:00
}}>
2020-10-28 11:26:49 +05:00
<Icon
name="alert-circle-outline"
size={SIZE.xs}
color={colors.errorText}
/>{' '}
Email is invalid
2020-09-14 12:17:06 +05:00
</Text>
2020-10-28 11:26:49 +05:00
) : null}
2020-09-19 16:02:21 +05:00
<Seperator />
2020-10-28 11:26:49 +05:00
</>
)}
2020-09-19 16:02:21 +05:00
2020-10-28 11:26:49 +05:00
<View
ref={_passContainer}
style={{
2020-11-02 20:50:07 +05:00
borderBottomWidth: 1,
2020-10-28 11:26:49 +05:00
borderColor: colors.nav,
paddingHorizontal: 10,
flexDirection: 'row',
justifyContent: 'space-between',
alignItems: 'center',
}}>
<TextInput
ref={_pass}
onFocus={() => {
if (!invalidPassword) {
_passContainer.current?.setNativeProps({
style: {
borderColor: colors.accent,
},
});
}
}}
autoCapitalize="none"
defaultValue={password}
onBlur={() => {
if (!validatePass(password) && password?.length > 0) {
setInvalidPassword(true);
2020-11-02 23:13:56 +05:00
_pass.current?.setNativeProps({
2020-10-28 11:26:49 +05:00
style: {
color: colors.errorText,
},
});
_passContainer.current?.setNativeProps({
style: {
borderColor: colors.errorText,
},
});
} else {
setInvalidPassword(false);
_passContainer.current?.setNativeProps({
style: {
2020-09-14 11:43:07 +05:00
borderColor: colors.nav,
2020-10-28 11:26:49 +05:00
},
});
}
}}
onChangeText={(value) => {
setPassword(value);
if (invalidPassword && validatePass(password)) {
setInvalidPassword(false);
_pass.current.setNativeProps({
style: {
2020-09-27 10:15:19 +05:00
color: colors.pri,
2020-10-28 11:26:49 +05:00
},
});
}
}}
onSubmitEditing={() => {
if (!validatePass(password)) {
setInvalidPassword(true);
_pass.current.setNativeProps({
style: {
color: colors.errorText,
},
});
}
}}
style={{
paddingHorizontal: 0,
height: 50,
fontSize: SIZE.sm,
fontFamily: WEIGHT.regular,
width: '85%',
maxWidth: '85%',
color: colors.pri,
}}
secureTextEntry={secureEntry}
placeholder="Password (6+ characters)"
placeholderTextColor={colors.icon}
/>
<Icon
name="eye"
size={20}
onPress={() => {
setSecureEntry(!secureEntry);
}}
style={{
width: 25,
}}
color={secureEntry ? colors.icon : colors.accent}
/>
</View>
{invalidPassword ? (
<Text
style={{
textAlign: 'right',
fontFamily: WEIGHT.regular,
textAlignVertical: 'bottom',
fontSize: SIZE.xs,
marginTop: 2.5,
}}>
<Icon
name="alert-circle-outline"
size={SIZE.xs}
color={colors.errorText}
/>{' '}
Password is invalid
</Text>
) : null}
<Seperator />
{login ? null : (
<>
<TextInput
ref={_passConfirm}
editable={password && !invalidPassword ? true : false}
defaultValue={passwordReEnter}
autoCapitalize="none"
onChangeText={(value) => {
setPasswordReEnter(value);
if (value !== password) {
setConfirmPassword(false);
_passConfirm.current.setNativeProps({
style: {
borderColor: colors.errorText,
},
});
_pass.current.setNativeProps({
style: {
borderColor: colors.errorText,
},
});
} else {
setConfirmPassword(true);
_passConfirm.current.setNativeProps({
style: {
borderColor: colors.accent,
},
});
_pass.current.setNativeProps({
style: {
borderColor: colors.accent,
},
});
}
}}
onFocus={() => {
_passConfirm.current.setNativeProps({
style: {
borderColor: colors.accent,
},
});
}}
2020-09-14 12:17:06 +05:00
style={{
2020-10-28 11:26:49 +05:00
paddingHorizontal: pv,
2020-11-02 20:50:07 +05:00
borderBottomWidth: 1,
2020-10-28 11:26:49 +05:00
height: 50,
2020-09-14 12:17:06 +05:00
borderColor: colors.nav,
2020-10-28 11:26:49 +05:00
fontSize: SIZE.sm,
fontFamily: WEIGHT.regular,
color: colors.pri,
}}
secureTextEntry={secureEntry}
placeholder="Confirm Password"
placeholderTextColor={colors.icon}
/>
2020-09-14 11:43:07 +05:00
2020-10-28 11:26:49 +05:00
{password && !invalidPassword && !confirmPassword ? (
2020-09-14 12:17:06 +05:00
<Text
style={{
textAlign: 'right',
fontFamily: WEIGHT.regular,
textAlignVertical: 'bottom',
fontSize: SIZE.xs,
marginTop: 2.5,
}}>
<Icon
name="alert-circle-outline"
size={SIZE.xs}
color={colors.errorText}
/>{' '}
2020-10-28 11:26:49 +05:00
Passwords do not match
2020-09-14 12:17:06 +05:00
</Text>
) : null}
2020-10-28 11:26:49 +05:00
</>
)}
2020-11-02 20:50:07 +05:00
2020-10-28 11:26:49 +05:00
{login ? null : (
2020-11-02 20:50:07 +05:00
<>
<Seperator />
<TouchableOpacity
onPress={() => {
setUserConsent(!userConsent);
2020-09-14 12:17:06 +05:00
}}
2020-11-02 20:50:07 +05:00
activeOpacity={0.7}
2020-09-14 12:17:06 +05:00
style={{
2020-11-02 20:50:07 +05:00
flexDirection: 'row',
width: '100%',
alignItems: 'center',
height: 40,
2020-09-14 12:17:06 +05:00
}}>
2020-11-02 20:50:07 +05:00
<Icon
size={SIZE.lg}
color={userConsent ? colors.accent : colors.icon}
name={
userConsent
? 'check-circle-outline'
: 'checkbox-blank-circle-outline'
}
/>
2020-10-28 11:26:49 +05:00
<Text
style={{
2020-11-02 20:50:07 +05:00
fontSize: SIZE.xs,
fontFamily: WEIGHT.regular,
color: colors.pri,
maxWidth: '90%',
marginLeft: 10,
2020-09-14 11:43:07 +05:00
}}>
2020-11-02 20:50:07 +05:00
By signing up you agree to our{' '}
<Text
style={{
color: colors.accent,
}}>
terms of service{' '}
</Text>
and{' '}
<Text
style={{
color: colors.accent,
}}>
privacy policy.
</Text>
2020-09-14 11:43:07 +05:00
</Text>
2020-11-02 20:50:07 +05:00
</TouchableOpacity>
</>
2020-10-28 11:26:49 +05:00
)}
2020-11-02 20:50:07 +05:00
2020-10-28 11:26:49 +05:00
{login ? null : <Seperator />}
<View
style={{
width: '100%',
}}>
<Button
title={login ? 'Login' : 'Create Account'}
onPress={login ? loginUser : signupUser}
width="100%"
2020-11-02 20:50:07 +05:00
fontSize={SIZE.md}
2020-10-28 11:26:49 +05:00
height={50}
/>
</View>
<TouchableOpacity
onPress={() => {
setLogin(!login);
}}
activeOpacity={opacity}
style={{
alignSelf: 'center',
marginTop: DDS.isTab ? 35 : 70,
height: DDS.isTab ? null : 50,
}}>
<Text
style={{
fontSize: SIZE.xs + 1,
fontFamily: WEIGHT.regular,
color: colors.pri,
height: 25,
}}>
{!login
? 'Already have an account? '
: "Don't have an account? "}
<Text
style={{
color: colors.accent,
}}>
{!login ? 'Login' : 'Sign up now'}
</Text>
</Text>
</TouchableOpacity>
</View>
2020-09-14 11:43:07 +05:00
</View>
2020-09-14 12:33:04 +05:00
</View>
2020-09-14 11:43:07 +05:00
</Modal>
);
};
2020-01-23 23:18:15 +05:00
export default LoginDialog;