integrate: login signup

parent 0a075d5b
......@@ -19,9 +19,9 @@ export default function App() {
<NavigationContainer>
<Drawer.Navigator initialRouteName="Authntications">
<Drawer.Screen name="Authentications" component={AuthStack} />
<Drawer.Screen name="Agripreneurs" component={homeStack} />
{/* <Drawer.Screen name="Agripreneurs" component={homeStack} /> */}
{/* <Drawer.Screen name="MainTab" component={MainTabScreen} /> */}
<Drawer.Screen name="About Us" component={AboutUs} />
{/* <Drawer.Screen name="About Us" component={AboutUs} /> */}
</Drawer.Navigator>
</NavigationContainer>
);
......
......@@ -5,6 +5,10 @@ import { Ionicons } from "@expo/vector-icons";
import { SignIn } from "../screen/SignIn";
import { SignUp } from "../screen/SignUp";
import { HomeScreen } from "../screen/HomeScreen";
import { Leaderboard } from "../screen/Leaderboard";
import { PriceScreen } from "../screen/PriceScreen";
import { gamification } from "../screen/gamification";
import { AboutUs } from "../screen/AboutUs";
const Stack = createStackNavigator();
......@@ -44,6 +48,38 @@ export function AuthStack({ navigation }) {
headerTitleAlign: "center",
}}
/>
<Stack.Screen
name="Leaderboard"
component={Leaderboard}
options={{
title: "Leaderboard Page",
headerTitleAlign: "center",
}}
/>
<Stack.Screen
name="PriceScreen"
component={PriceScreen}
options={{
title: "Discounted/Price Page",
headerTitleAlign: "center",
}}
/>
<Stack.Screen
name="gamification"
component={gamification}
options={{
title: "Gamification Page",
headerTitleAlign: "center",
}}
/>
<Stack.Screen
name="AboutUs"
component={AboutUs}
options={{
title: "About Page",
headerTitleAlign: "center",
}}
/>
</Stack.Navigator>
);
}
\ No newline at end of file
......@@ -12,6 +12,7 @@ import {
Ionicons,
} from "@expo/vector-icons";
import { MaterialIcons } from '@expo/vector-icons';
// import BottomTabNavigator from '../Navigations/BottomTabNavigator'
export function HomeScreen({ navigation }) {
//to diable the yellow box warning on the simulator
......@@ -63,8 +64,9 @@ export function HomeScreen({ navigation }) {
<Text style={styles.heading2}>
All Right Reserved.
</Text>
{/* <BottomTabNavigator/> */}
</ImageBackground>
</View>
</View>
);
}
......
import React, {useState, useEffect} from "react";
import React, { useState, useEffect } from "react";
import {
StyleSheet,
Button,
......@@ -10,7 +10,7 @@ import {
} from "react-native";
import { Entypo } from "@expo/vector-icons";
import axios from "axios";
import { State } from "react-native-gesture-handler";
export function SignIn({ navigation }) {
......@@ -19,46 +19,50 @@ export function SignIn({ navigation }) {
password: "",
isValidUser: true,
isValidPassword: true,
check_textinputChange: false
check_textinputChange: false,
});
const textInputChange = (val) => {
if( val.trim().length >= 4) {
setData({
...data,
username: val,
check_textInputChange: true,
isValidUser: true
});
if (val.trim().length >= 4) {
setData({
...data,
email: val,
check_textInputChange: true,
isValidUser: true,
});
} else {
setData({
...data,
email: val,
check_textInputChange: false,
isValidUser: false,
});
}
else {
setData({
...data,
username: val,
check_textInputChange: false,
isValidUser: false
});
}
}
};
const handlePasswordChange = (val) => {
if( val.trim().length >= 6 ) {
const handlePasswordChange = (val) => {
if (val.trim().length >= 3) {
setData({
...data,
password: val,
isValidPassword: true
...data,
password: val,
isValidPassword: true,
});
} else {
} else {
setData({
...data,
password: val,
isValidPassword: false
...data,
password: val,
isValidPassword: false,
});
}
}
}
};
const form = new FormData ();
form.append("email", data.email)
form.append("password", data.password)
console.log(form)
return (
<View style={styles.container}>
......@@ -75,9 +79,7 @@ const handlePasswordChange = (val) => {
<Entypo name="user" size={30} color="white" />
<TextInput
style={styles.input1}
onChangeText={(val) =>
textInputChange(val)
}
onChangeText={(val) => textInputChange(val)}
placeholder="Enter Email" //dummy@abc.com
placeholderTextColor="#8b9cb5"
keyboardType="email-address"
......@@ -89,9 +91,11 @@ const handlePasswordChange = (val) => {
blurOnSubmit={false}
/>
</View>
{ data.isValidUser ? null :
<Text style={styles.errorMsg}>Email must be 4 characters long</Text>
}
{data.isValidUser ? null : (
<Text style={styles.errorMsg}>
Email must be 4 characters long
</Text>
)}
</View>
<View style={styles.SectionStyle}>
......@@ -99,9 +103,7 @@ const handlePasswordChange = (val) => {
<Entypo name="lock" size={30} color="white" />
<TextInput
style={styles.input1}
onChangeText={(val) =>
handlePasswordChange(val)
}
onChangeText={(val) => handlePasswordChange(val)}
placeholder="Enter Password" //12345
placeholderTextColor="#8b9cb5"
// ref={passwordInputRef}
......@@ -110,15 +112,31 @@ const handlePasswordChange = (val) => {
secureTextEntry={true}
/>
</View>
{ data.isValidPassword ? null :
<Text style={styles.errorMsg}>Password must be 6 characters long.</Text>
}
{data.isValidPassword ? null : (
<Text style={styles.errorMsg}>
Password must be 6 characters long.
</Text>
)}
</View>
<View style={styles.buttons}>
<TouchableOpacity
style={styles.buttonSub}
activeOpacity={0.5}
onPress={() => navigation.navigate("HomeScreen")}
onPress={() =>
axios.post("http://192.168.8.126:5000/login", form)
.then(function (response) {
const stngobj = JSON.stringify(response.data)
console.log(stngobj + "logged");
alert("Successfully Logged in")
navigation.navigate("HomeScreen")
// return response;
})
.catch(function (error) {
console.log(error);
})
}
>
<Text style={styles.buttonTextStyle}>LOGIN</Text>
{/* <ImageBackground source={require('../assets/loginex.jpg')} style={styles.imagebutton}/> */}
......@@ -232,9 +250,9 @@ const styles = StyleSheet.create({
justifyContent: "center",
borderRadius: 8,
},
errorMsg:{
color: 'black',
fontSize: 14,
alignSelf:"center"
}
errorMsg: {
color: "black",
fontSize: 14,
alignSelf: "center",
},
});
......@@ -45,26 +45,40 @@ export function SignUp({ navigation }) {
<Formik
initialValues={{ name: '', email: '', password: '', district: '' }}
validationSchema={reviewSchema}
onSubmit={(values, actions) => {
// console.log(values);
onSubmit= { (values, actions) => {
// console.log(actions.submitForm())
// await actions.submitForm()
console.log(values);
// actions.submitForm();
const valuesToBeSent = JSON.stringify({
"name": values.name,
"email": values.email,
"password": values.password,
"district": values.district,
})
// const valuesToBeSent = JSON.stringify({
// "name": values.name,
// "email": values.email,
// "password": values.password,
// "district": values.district,
// })
// console.log("")
const form = new FormData ();
form.append("name", values.name)
form.append("email", values.email)
form.append("password", values.password)
form.append("district", values.district)
axios.post('http://192.168.8.126:5000/users', valuesToBeSent)
// axios.get('http://192.168.8.126:5000/getUsers')
axios({
method:"POST",
url: "http://192.168.8.126:5000/users",
data: form
})
.then(function (response){
console.log(response)
console.log("abc" + response)
actions.resetForm();
// return response;
})
.catch(function(error){
console.log(error)
})
actions.resetForm();
// useEffect(() => {
// axios.post('http://192.168.8.126:5000/users', {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment