Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Validation in React Native

import React, { useState } from "react";
import { View, StyleSheet, TouchableOpacity } from "react-native";

import {
  Avatar,
  Center,
  Image,
  Text,
  Input,
  Icon,
  Button,
  Stack,
  Checkbox,
  Divider,
  Flex,
  NativeBaseProvider
} from "native-base";
import { LinearGradient } from "expo-linear-gradient";
import { AntDesign } from "@expo/vector-icons";
import { Entypo } from "@expo/vector-icons";
import { Feather } from "@expo/vector-icons";

const Main = () => {
  const [state, setState] = useState({
    email: "",
    emailError: "",
    password: "",
  });
  const emailValidator = () => {
    if (state.email == "") {
      setState({...state, emailError: "Email Field canot be empty" });
    } else {
      setState({...state, emailError: "" });
    }
  };
  return (
    <NativeBaseProvider> 
    <LinearGradient height="100%" colors={["#4c669f", "#3b5998", "#192f6a"]}>
      <View>
        <Center>
          <Image
            source={''}
            alt="Logo"
            style={styles.image}
          />
          <Text fontSize="4xl" style={styles.title}>
            Login Form
          </Text>

          <Input
            placeholder="Email"
            onChangeText={(text) => {
              setState({ email: text });
            }}
            onBlur={() => emailValidator()}
            variant="rounded"
            marginX={10}
            marginY={5}
            InputLeftElement={
              <Icon
                as={<AntDesign name="user" size={24} />}
                size={5}
                ml="2"
                color="red.900"
              />
            }
          />
          <Text style={styles.error}>{state.emailError}</Text>
          <Input
            placeholder="Password"
            secureTextEntry={true}
            onChangeText={(text) => {
              setState({ password: text });
            }}
            variant="rounded"
            marginX={10}
            InputLeftElement={
              <Icon
                as={<Entypo name="lock-open" size={24} />}
                size={5}
                ml="2"
                color="red.900"
              />
            }
          />
          <Button
            colorScheme="primary"
            mt={7}
            fontSize={20}
            size="lg"
            onPress={() => {
              console.log("hello");
            }}
          >
            Login
          </Button>
        </Center>
        <Center>
          <Stack direction="row" space="2" mt={6}>
            <Checkbox size="sm" color="blue.50">
              <Text fontSize="md" style={{ color: "white" }}>
                Remember Password
              </Text>
            </Checkbox>
            <Text fontSize="md" ml={10} style={styles.forget}>
              Forget Password
            </Text>
          </Stack>
          <Divider mt={5} width={350} />

          <Text style={{ paddingTop: 10, fontWeight: "bold", color: "white" }}>
            If you don't Have an accout ?
          </Text>
          <TouchableOpacity style={styles.areadyButton}>
            <Text style={styles.alreadyText}>Create An Account</Text>
          </TouchableOpacity>
          <Divider w={290} bg="indigo.500" thickness={4} />
          <Text fontSize="md" style={styles.other}>
            Or Login With
          </Text>
          <Flex direction="row" h="58" p="4">
            <TouchableOpacity>
              <AntDesign name="google" size={25} color="red" />
            </TouchableOpacity>
            <Divider
              bg="emerald.500"
              thickness="5"
              mx="3"
              orientation="vertical"
            />
            <TouchableOpacity>
              <Feather name="facebook" size={25} color="white" />
            </TouchableOpacity>
            <Divider
              bg="indigo.500"
              thickness="5"
              mx="3"
              orientation="vertical"
            />
            <TouchableOpacity>
              <Feather name="twitter" size={25} color="blue" />
            </TouchableOpacity>
          </Flex>
        </Center>
      </View>
    </LinearGradient>
    </NativeBaseProvider>
  );
};

export default Main;

const styles = StyleSheet.create({
  image: {
    height: 110,
    width: 110,
    borderRadius: 100,
    marginTop: 25,
  },
  title: {
    paddingTop: 10,
    fontWeight: "bold",
  },
  areadyButton: {
    marginVertical: 20,
  },
  alreadyText: {
    padding: 15,
    paddingLeft: 30,
    paddingRight: 30,
    fontSize: 15,
    fontWeight: "bold",
    borderWidth: 1,
    borderColor: "white",
    color: "#397eed",
    borderRadius: 35,
  },
  createAccountButton: {
    marginTop: 30,
  },
  createAccountText: {
    color: "white",
    fontSize: 19,
  },
  texts: {
    color: "white",
  },
  forget: {
    color: "white",
  },
  other: {
    paddingVertical: 10,
    color: "white",
    fontWeight: "bold",
    color: "orange",
  },
  error: {
    color: "red",
  },
});
Comment

PREVIOUS NEXT
Code Example
Javascript :: svg css viewbox 
Javascript :: entypo icons react native 
Javascript :: running a function in a function javascript 
Javascript :: display for sometime only session flash message in laravel with javascript 
Javascript :: nuxt store watch 
Javascript :: angular how to run code every time you route 
Javascript :: como eliminar un elemento del dom con javascript 
Javascript :: super class js 
Javascript :: discord js embeded message hyperlink 
Javascript :: null + undefined 
Javascript :: different uniqid usage 
Javascript :: jquery select selected get data name 
Javascript :: popper.js and jquery 
Javascript :: check the number is palindrome or not 
Javascript :: set exit node tor 
Javascript :: how to push two values in array at once 
Javascript :: eval set global scope 
Javascript :: javascript timestamp conversion 
Javascript :: react scroll on top while transition 
Javascript :: useEffect : react 
Javascript :: saving react code messing up in vsc 
Javascript :: javascript check if undefined or null or empty string 
Javascript :: javascript add 1 to each element in array 
Javascript :: how to pass headers in axios 
Javascript :: add onclick javascript dynamically 
Javascript :: jsp date 
Javascript :: js string to blob 
Javascript :: external css not working in jsp 
Javascript :: npm koa 
Javascript :: one component to another component in vuejs trigger function 
ADD CONTENT
Topic
Content
Source link
Name
5+6 =