/** * Sample React Native App * https://github.com/facebook/react-native * * Generated with the TypeScript template * https://github.com/react-native-community/react-native-template-typescript * * @format */ import React, { useRef } from 'react'; import { SafeAreaView, StyleSheet, ScrollView, View, Text, StatusBar, Image, TextInput, Button, Alert, TouchableOpacity, } from 'react-native'; import { Header, LearnMoreLinks, Colors, DebugInstructions, ReloadInstructions, } from 'react-native/Libraries/NewAppScreen'; import LinearGradient from 'react-native-linear-gradient'; declare const global: {HermesInternal: null | {}}; const App = () => { const passwordInput = useRef(); const [data, setData] = React.useState({ username: '', password: '', isValidUser: true, isValidPassword: true, }) const validUserCheck = (val:string) => { var validLength:boolean = val.trim().length >= 6 if (validLength) { setData({ ...data, isValidUser: true }); } else { setData({ ...data, isValidUser: false }) } } const handleUsernameUpdate = (val:string) => { var validLength:boolean = val.trim().length >= 6 if (validLength) { setData({ ...data, username: val, isValidUser: true }) } else { setData({ ...data, username: val, isValidUser: false }) } } const handlePasswordUpdate = (val:string) => { var validLength:boolean = val.trim().length >= 8 if (validLength) { setData({ ...data, password: val, isValidPassword: true }) } else { setData({ ...data, password: val, isValidPassword: false }) } } const handleLogin = () => { if (data.isValidUser && data.isValidPassword) { Alert.alert(`My favorite Girl Scout Cookies are taggalongs! What are yours ${data.username}?`) } } return ( <> handleUsernameUpdate(user)} defaultValue={data.username} onEndEditing={(val) => validUserCheck(val.nativeEvent.text)} onSubmitEditing={() => {passwordInput.current.focus()}} blurOnSubmit={false} /> { data.isValidUser ? null : Username must be at least 6 characters long. } handlePasswordUpdate(pass)} defaultValue={data.password} onSubmitEditing={() => handleLogin()} ref={passwordInput} secureTextEntry={true} /> { data.isValidPassword ? null : Password must be at least 8 characters long. } Alert.alert("tagg! You're it!")}> Forgot password handleLogin()}> Let's Start! New to tagg? Alert.alert("I get the tagg flip it and tumble it.")}>Get started! ); }; const styles = StyleSheet.create({ container: { flex: 1, backgroundColor: 'transparent', }, linearGradient: { flex: 1, alignItems: 'center', }, logo: { top: 165, width: 215, height: 149, }, credentials: { top: 190, width: 248, height: 40, fontSize: 20, color: '#FFFFFF', borderColor: '#FFFDFD', borderWidth: 2, borderRadius: 20, paddingLeft: 13, marginVertical: 15, }, forgotPassword: { top: 190, left: -60, }, forgotPasswordText: { fontSize: 15, color: '#FFFFFF', textDecorationLine: 'underline', }, start: { top: 195, width: 144, height: 36, justifyContent: 'center', alignItems: 'center', backgroundColor: '#FFFFFF', borderRadius: 20, marginTop: 15 }, startText: { fontSize: 15, color: '#78A0EF', fontWeight: 'bold', }, getStarted: { color: '#FFFFFF', textDecorationLine: 'underline' }, newUser: { top: 240, color: '#F4DDFF', }, invalidCredentials: { top: 180, color: '#F4DDFF' } }); export default App;