Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2021-090 frontend
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
2021-090
2021-090 frontend
Commits
50f8c0e6
Commit
50f8c0e6
authored
Sep 23, 2021
by
IT18111170-Silva S.H.I
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
integrate: login signup
parent
0a075d5b
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
136 additions
and
66 deletions
+136
-66
App.js
App.js
+2
-2
Navigations/AuthStack.js
Navigations/AuthStack.js
+36
-0
screen/HomeScreen.js
screen/HomeScreen.js
+3
-1
screen/SignIn.js
screen/SignIn.js
+69
-51
screen/SignUp.js
screen/SignUp.js
+26
-12
No files found.
App.js
View file @
50f8c0e6
...
...
@@ -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
>
);
...
...
Navigations/AuthStack.js
View file @
50f8c0e6
...
...
@@ -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
screen/HomeScreen.js
View file @
50f8c0e6
...
...
@@ -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
>
);
}
...
...
screen/SignIn.js
View file @
50f8c0e6
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
"
,
}
,
});
screen/SignUp.js
View file @
50f8c0e6
...
...
@@ -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', {
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment