diff --git a/src/components/Authentication/LoginScreen.tsx b/src/components/Authentication/LoginScreen.tsx index e99cbf6..2cd6dd2 100644 --- a/src/components/Authentication/LoginScreen.tsx +++ b/src/components/Authentication/LoginScreen.tsx @@ -1,156 +1,172 @@ -import React from "react"; -import { TextInput, StyleSheet, View, Text, ImageBackground, TouchableOpacity, Image } from "react-native"; -import NavStyles from '../../styles/NavStyles'; -import Button from "react-native-button"; - -interface AppProps { - navigation: any; -} -interface State { - username: string | null; - password: string | null; -} - -export default class LoginScreen extends React.Component { - static navigationOptions = { - title: "Login", - ...NavStyles - }; - - constructor(props) { - super(props); - - this.state = { - username: '', - password: '', - }; - } - - render() { - const bgImage = require("../../../assets/splash.png"); - return ( - - - - Welcome To frindi - - this.setState({ username })} - placeholder={'Username'} - style={styles.input} - /> - this.setState({ password })} - placeholder={'Password'} - secureTextEntry={true} - style={styles.input} - /> - - - - - this.props.navigation.navigate('ActivityScreen')} - > - - - this.props.navigation.navigate('ActivityScreen')} - > - - - this.props.navigation.navigate('ActivityScreen')} - > - - - - - - ); - } -} - - -const styles = StyleSheet.create({ - container: { - flex: 1, - alignItems: "center", - justifyContent: "center", - paddingTop: 230, - flexDirection: "column" - }, - socialContainer: { - flex: 0.8, - alignItems: "flex-end", - paddingVertical:60, - position:"relative", - flexDirection: "row" - }, - ssoButtonHolder: { - borderColor:'rgba(0,0,0,0.2)', - width:80, - height:60, - borderRadius:50, - }, - ssoIcon: { - borderColor:'rgba(0,0,0,0.2)', - width:60, - height:60, - }, - input: { - width: 350, - height: 44, - padding: 10, - borderRadius: 25, - borderWidth: 1, - borderColor: 'white', - marginBottom: 10, - }, - text: { - padding: 20, - color: "white", - fontSize: 32 - }, - button: { - alignContent: "center", - alignItems: "center", - fontSize: 16, - textAlignVertical: "center", - borderRadius: 2, - width: 200, - height: 35, - marginVertical: 8 - }, - background: { - height: "100%", - width: "100%" - } -}); +import React from "react"; +import { TextInput, StyleSheet, View, Text, ImageBackground, TouchableOpacity, Image } from "react-native"; +import NavStyles from '../../styles/NavStyles'; +import Button from "react-native-button"; + +interface AppProps { + navigation: any; +} +interface State { + username: string | null; + password: string | null; +} + +const required = (value) => (value || typeof value === "number" ? undefined : "Required"); +const maxLength = (max) => (value) => + value && value.length > max ? `Must be ${max} characters or less` : undefined; +const minLength = (min) => (value) => + value && value.length < min ? `Must be ${min} characters or more` : undefined; + +const email = (value) => + value && !/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i.test(value) + ? "Invalid email address" + : undefined; + +const maxLength256 = maxLength(256); +const minLength2 = minLength(2); + +export default class LoginScreen extends React.Component { + static navigationOptions = { + title: "Login", + ...NavStyles + }; + + constructor(props) { + super(props); + + this.state = { + username: '', + password: '', + }; + } + + render() { + const bgImage = require("../../../assets/splash.png"); + return ( + + + + Welcome To frindi + + this.setState({ username })} + placeholder={'Username'} + style={styles.input} + validate={[email, required, maxLength256, minLength2]} + /> + this.setState({ password })} + placeholder={'Password'} + secureTextEntry={true} + style={styles.input} + validate={[required]} + /> + + + + + this.props.navigation.navigate('ActivityScreen')} + > + + + this.props.navigation.navigate('ActivityScreen')} + > + + + this.props.navigation.navigate('ActivityScreen')} + > + + + + + + ); + } +} + + +const styles = StyleSheet.create({ + container: { + flex: 1, + alignItems: "center", + justifyContent: "center", + paddingTop: 230, + flexDirection: "column" + }, + socialContainer: { + flex: 0.8, + alignItems: "flex-end", + paddingVertical:60, + position:"relative", + flexDirection: "row" + }, + ssoButtonHolder: { + borderColor:'rgba(0,0,0,0.2)', + width:80, + height:60, + borderRadius:50, + }, + ssoIcon: { + borderColor:'rgba(0,0,0,0.2)', + width:60, + height:60, + }, + input: { + width: 350, + height: 44, + padding: 10, + borderRadius: 25, + borderWidth: 1, + borderColor: 'white', + marginBottom: 10, + }, + text: { + padding: 20, + color: "white", + fontSize: 32 + }, + button: { + alignContent: "center", + alignItems: "center", + fontSize: 16, + textAlignVertical: "center", + borderRadius: 2, + width: 200, + height: 35, + marginVertical: 8 + }, + background: { + height: "100%", + width: "100%" + } +});