-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
37 changed files
with
470 additions
and
631 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import React from 'react'; | ||
import { TouchableOpacity, Image, StyleSheet } from 'react-native'; | ||
import { getStatusBarHeight } from 'react-native-status-bar-height'; | ||
|
||
export default function BackButton({ goBack }) { | ||
return ( | ||
<TouchableOpacity onPress={goBack} style={styles.container}> | ||
<Image | ||
style={styles.image} | ||
source={require('./arrow_back.png')} | ||
/> | ||
</TouchableOpacity> | ||
) | ||
} | ||
|
||
const styles = StyleSheet.create({ | ||
container: { | ||
position: 'absolute', | ||
top: 10 + getStatusBarHeight(), | ||
left: 4, | ||
}, | ||
image: { | ||
width: 24, | ||
height: 24, | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import React from 'react'; | ||
import { ImageBackground, StyleSheet, KeyboardAvoidingView } from 'react-native'; | ||
import { theme } from './Theme'; | ||
|
||
export default function Background({ children }) { | ||
return ( | ||
<ImageBackground | ||
source={require('./background_dot.png')} | ||
resizeMode="repeat" | ||
style={styles.background} | ||
> | ||
<KeyboardAvoidingView style={styles.container} behavior="padding"> | ||
{children} | ||
</KeyboardAvoidingView> | ||
</ImageBackground> | ||
) | ||
} | ||
|
||
const styles = StyleSheet.create({ | ||
background: { | ||
flex: 1, | ||
width: '100%', | ||
backgroundColor: theme.colors.surface, | ||
}, | ||
container: { | ||
flex: 1, | ||
padding: 20, | ||
width: '100%', | ||
maxWidth: 340, | ||
alignSelf: 'center', | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import React from 'react'; | ||
import { StyleSheet } from 'react-native'; | ||
import { Button as PaperButton } from 'react-native-paper'; | ||
import { theme } from './Theme.js'; | ||
|
||
export default function Button({ mode, style, ...props }) { | ||
return ( | ||
<PaperButton | ||
style={[ | ||
styles.button, | ||
mode === 'outlined' && { | ||
backgroundColor: theme.colors.surface, | ||
borderColor: theme.colors.text, | ||
}, | ||
style, | ||
]} | ||
labelStyle={styles.text} | ||
mode={mode} | ||
{...props} | ||
/> | ||
) | ||
} | ||
|
||
const styles = StyleSheet.create({ | ||
button: { | ||
width: '100%', | ||
marginVertical: 10, | ||
paddingVertical: 2, | ||
}, | ||
text: { | ||
fontWeight: 'bold', | ||
fontSize: 15, | ||
lineHeight: 26, | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import React from 'react'; | ||
import { StyleSheet } from 'react-native'; | ||
import { Text } from 'react-native-paper'; | ||
import { theme } from './Theme'; | ||
|
||
export default function Header(props) { | ||
return <Text style={styles.header} {...props} /> | ||
} | ||
|
||
const styles = StyleSheet.create({ | ||
header: { | ||
fontSize: 21, | ||
color: theme.colors.primary, | ||
fontWeight: 'bold', | ||
paddingVertical: 12, | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
import React, { useState } from 'react' | ||
import { TouchableOpacity, StyleSheet, View } from 'react-native' | ||
import { Text } from 'react-native-paper' | ||
import Background from './Background.js'; | ||
import Logo from './Logo.js'; | ||
import Header from './Header.js'; | ||
import Button from './Button.js'; | ||
import TextInput from './TextInput.js'; | ||
import BackButton from './BackButton.js'; | ||
import { theme } from './Theme.js'; | ||
import { emailValidator } from './emailValidator.js'; | ||
import { passwordValidator } from './passwordValidator.js'; | ||
|
||
export default function LoginScreen({ navigation }) { | ||
const [email, setEmail] = useState({ value: '', error: '' }) | ||
const [password, setPassword] = useState({ value: '', error: '' }) | ||
|
||
const onLoginPressed = () => { | ||
const emailError = emailValidator(email.value) | ||
const passwordError = passwordValidator(password.value) | ||
if (emailError || passwordError) { | ||
setEmail({ ...email, error: emailError }) | ||
setPassword({ ...password, error: passwordError }) | ||
return | ||
} | ||
navigation.reset({ | ||
index: 0, | ||
routes: [{ name: 'Dashboard' }], | ||
}) | ||
} | ||
|
||
return ( | ||
<Background> | ||
<BackButton goBack={navigation.goBack} /> | ||
<Logo /> | ||
<Header>Welcome back.</Header> | ||
<TextInput | ||
label="Email" | ||
returnKeyType="next" | ||
value={email.value} | ||
onChangeText={(text) => setEmail({ value: text, error: '' })} | ||
error={!!email.error} | ||
errorText={email.error} | ||
autoCapitalize="none" | ||
autoCompleteType="email" | ||
textContentType="emailAddress" | ||
keyboardType="email-address" | ||
/> | ||
<TextInput | ||
label="Password" | ||
returnKeyType="done" | ||
value={password.value} | ||
onChangeText={(text) => setPassword({ value: text, error: '' })} | ||
error={!!password.error} | ||
errorText={password.error} | ||
secureTextEntry | ||
/> | ||
<View style={styles.forgotPassword}> | ||
<TouchableOpacity | ||
onPress={() => navigation.navigate('ResetPasswordScreen')} | ||
> | ||
<Text style={styles.forgot}>Forgot your password?</Text> | ||
</TouchableOpacity> | ||
</View> | ||
<Button mode="contained" onPress={onLoginPressed}> | ||
Login | ||
</Button> | ||
<View style={styles.row}> | ||
<Text>Don’t have an account? </Text> | ||
<TouchableOpacity onPress={() => navigation.replace('RegisterScreen')}> | ||
<Text style={styles.link}>Sign up</Text> | ||
</TouchableOpacity> | ||
</View> | ||
</Background> | ||
) | ||
} | ||
|
||
const styles = StyleSheet.create({ | ||
forgotPassword: { | ||
width: '100%', | ||
alignItems: 'flex-end', | ||
marginBottom: 24, | ||
}, | ||
row: { | ||
flexDirection: 'row', | ||
marginTop: 4, | ||
}, | ||
forgot: { | ||
fontSize: 13, | ||
color: theme.colors.text, | ||
}, | ||
link: { | ||
fontWeight: 'bold', | ||
color: theme.colors.primary, | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import React from 'react'; | ||
import { Image, StyleSheet } from 'react-native'; | ||
export default function Logo() { | ||
return <Image source={require('./logo.png')} style={styles.image} /> | ||
} | ||
|
||
const styles = StyleSheet.create({ | ||
image: { | ||
width: 200, | ||
height: 80, | ||
marginBottom: 8, | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import React from 'react'; | ||
import { StyleSheet } from 'react-native'; | ||
import { Text } from 'react-native-paper'; | ||
|
||
export default function Paragraph(props) { | ||
return <Text style={styles.text} {...props} /> | ||
} | ||
|
||
const styles = StyleSheet.create({ | ||
text: { | ||
fontSize: 15, | ||
lineHeight: 21, | ||
textAlign: 'center', | ||
marginBottom: 12, | ||
}, | ||
}) |
Oops, something went wrong.