Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
TMP-23-068
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
TMP-23-068
TMP-23-068
Commits
039d7906
Commit
039d7906
authored
Oct 31, 2023
by
Balasooriya B.M.D.D
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into UI_Changes
parents
534d704b
b206dcc7
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
215 additions
and
207 deletions
+215
-207
App.js
App.js
+2
-2
assets/signNew.png
assets/signNew.png
+0
-0
screens/BMI.js
screens/BMI.js
+2
-0
screens/MedicineWelcome.js
screens/MedicineWelcome.js
+9
-1
screens/Nutrition.js
screens/Nutrition.js
+81
-143
screens/Plan.js
screens/Plan.js
+46
-34
screens/Sidebar.js
screens/Sidebar.js
+6
-3
screens/Signin.js
screens/Signin.js
+54
-17
screens/Signup.js
screens/Signup.js
+14
-6
screens/USWelcome.js
screens/USWelcome.js
+1
-1
No files found.
App.js
View file @
039d7906
...
...
@@ -6,7 +6,7 @@ import { StyleSheet, Text, View } from 'react-native';
import
registerNNPushToken
from
'
native-notify
'
;
import
TabNavigator
from
"
./navigation/TabNavigator
"
;
import
U
sImage
from
"
./screens/CaptureImage
"
;
import
U
S
from
"
./screens/CaptureImage
"
;
import
Prescription
from
"
./screens/CapturePrescription
"
;
import
Sidebar
from
"
./screens/Sidebar
"
;
import
Nutrition
from
"
./screens/Nutrition
"
...
...
@@ -51,7 +51,7 @@ export default function App() {
>
<
Stack
.
Screen
name
=
"
TabNavigator
"
component
=
{
TabNavigator
}
/
>
<
Stack
.
Screen
name
=
"
Nutrition
"
component
=
{
Nutrition
}
/
>
<
Stack
.
Screen
name
=
"
U
sImage
"
component
=
{
UsImage
}
/
>
<
Stack
.
Screen
name
=
"
U
S
"
component
=
{
US
}
/
>
<
Stack
.
Screen
name
=
"
Prescription
"
component
=
{
Prescription
}
/
>
<
Stack
.
Screen
name
=
"
Sidebar
"
component
=
{
Sidebar
}
/
>
<
Stack
.
Screen
name
=
"
ChatbotScreen
"
component
=
{
ChatbotScreen
}
/
>
...
...
assets/signNew.png
0 → 100644
View file @
039d7906
1.37 MB
screens/BMI.js
View file @
039d7906
...
...
@@ -41,6 +41,7 @@ const BMI = () => {
placeholder
=
"
Enter Weight (in kg)
"
onChangeText
=
{
setWeight
}
keyboardType
=
"
numeric
"
required
/>
<
Text
style
=
{
styles
.
label
}
>
Height
<
/Text
>
<
TextInput
...
...
@@ -48,6 +49,7 @@ const BMI = () => {
placeholder
=
"
Enter Height (in cm)
"
onChangeText
=
{
setHeight
}
keyboardType
=
"
numeric
"
required
/>
<
TouchableOpacity
style
=
{
styles
.
button
}
onPress
=
{
navigateToBmiCalculator
}
>
<
Text
style
=
{
styles
.
buttonText
}
>
Calculate
BMI
<
/Text
>
...
...
screens/MedicineWelcome.js
View file @
039d7906
...
...
@@ -11,6 +11,11 @@ export default function MedicineWelcome () {
navigation
.
navigate
(
"
Prescription
"
);
};
const
navigateToMedicineRecord
=
()
=>
{
navigation
.
navigate
(
"
MyMed
"
);
};
return
(
...
...
@@ -20,7 +25,10 @@ export default function MedicineWelcome () {
<
View
style
=
{
styles
.
actionButtons
}
>
<
TouchableOpacity
style
=
{
styles
.
actionButton
}
onPress
=
{
navigateToMedicine
}
>
<
Text
style
=
{
styles
.
buttonText
}
>
Medicine
Tracker
<
/Text
>
<
Text
style
=
{
styles
.
buttonText
}
>
Extract
Medicine
Names
<
/Text
>
<
/TouchableOpacity
>
<
TouchableOpacity
style
=
{[
styles
.
actionButton
,
{
marginTop
:
20
}]}
onPress
=
{
navigateToMedicineRecord
}
>
<
Text
style
=
{
styles
.
buttonText
}
>
My
Med
Records
<
/Text
>
<
/TouchableOpacity
>
<
/View
>
...
...
screens/Nutrition.js
View file @
039d7906
import
React
,
{
useState
}
from
'
react
'
;
import
{
Button
,
Image
,
Text
,
View
,
TextInput
,
ScrollView
,
StyleSheet
,
TouchableOpacity
,
ImageBackground
}
from
'
react-native
'
;
import
{
Button
,
Image
,
Text
,
View
,
TextInput
,
ScrollView
,
ImageBackground
,
StyleSheet
,
TouchableOpacity
}
from
'
react-native
'
;
import
*
as
ImagePicker
from
'
expo-image-picker
'
;
import
axios
from
'
axios
'
;
import
{
useNavigation
}
from
"
@react-navigation/native
"
;
export
default
function
Nutrition
({
route
})
{
const
[
imageCBC
,
setImageCBC
]
=
useState
(
null
);
const
[
imageOGTT
,
setImageOGTT
]
=
useState
(
null
);
const
[
resultCBC
,
setResultCBC
]
=
useState
(
''
);
const
[
resultOGTT
,
setResultOGTT
]
=
useState
(
''
);
//const [bmi, setBMI] = useState('');
const
[
otherModelResult
,
setOtherModelResult
]
=
useState
(
''
);
const
navigation
=
useNavigation
();
const
{
bmi
}
=
route
.
params
;
const
[
isPlanButtonVisible
,
setIsPlanButtonVisible
]
=
useState
(
false
);
const
[
isDataReady
,
setIsDataReady
]
=
useState
(
false
);
const
pickImage
=
async
(
reportType
)
=>
{
const
{
status
}
=
await
ImagePicker
.
requestMediaLibraryPermissionsAsync
();
...
...
@@ -44,7 +42,7 @@ export default function Nutrition({ route }) {
name
:
'
image.jpg
'
,
});
const
apiUrl
=
reportType
===
'
CBC
'
?
'
http
://192.168.1.100:5004/extract_hemoglobin
'
:
'
http://192.168.1.100:5004
/extract_glucose
'
;
const
apiUrl
=
reportType
===
'
CBC
'
?
'
http
s://nutrtition-predict-1004-bd09336777f6.herokuapp.com/extract_hemoglobin
'
:
'
https://nutrtition-predict-1004-bd09336777f6.herokuapp.com
/extract_glucose
'
;
axios
.
post
(
apiUrl
,
formData
,
{
headers
:
{
...
...
@@ -69,28 +67,17 @@ export default function Nutrition({ route }) {
}
};
/*
const sendToOtherModel = () => {
const
sendToOtherModel
=
()
=>
{
if
(
!
resultCBC
||
!
resultOGTT
||
!
bmi
)
{
alert
(
'
Please provide Hemoglobin, Glucose, and BMI values.
'
);
return
;
}
*/
const
sendToOtherModel
=
()
=>
{
// Check if at least one of the required data is available
if
(
resultCBC
||
resultOGTT
||
bmi
)
{
setIsDataReady
(
true
);
}
else
{
alert
(
'
Please provide Hemoglobin, Glucose, or BMI values.
'
);
}
console
.
log
(
parseFloat
(
resultCBC
));
console
.
log
(
parseFloat
(
resultOGTT
));
console
.
log
(
parseFloat
(
bmi
));
const
apiUrl
=
'
http
://192.168.1.100:5005
/predict
'
;
// Replace with the actual API endpoint URL of the other model
const
apiUrl
=
'
http
s://planpredictdeploy.azurewebsites.net
/predict
'
;
// Replace with the actual API endpoint URL of the other model
axios
.
post
(
apiUrl
,
{
...
...
@@ -121,13 +108,10 @@ export default function Nutrition({ route }) {
const
formattedMealPlan
=
customText
.
replace
(
/;/g
,
'
\n
'
);
setOtherModelResult
(
formattedMealPlan
);
// setOtherModelResult(customText);
// Set the state variable to make the "Get Nutrition Plan" button visible
setIsPlanButtonVisible
(
true
);
console
.
log
(
response
.
data
.
prediction
);
})
.
catch
(
error
=>
{
console
.
error
(
'
Error sending data to other model:
'
,
error
);
alert
(
'
Error occurred while sending data to other model.
'
);
});
};
...
...
@@ -139,103 +123,73 @@ export default function Nutrition({ route }) {
};
return
(
<
ScrollView
contentContainerStyle
=
{
styles
.
scrollViewContent
}
>
<
ImageBackground
source
=
{
require
(
"
../assets/nutrition.png
"
)}
resizeMode
=
"
cover
"
style
=
{
styles
.
image
}
>
<
View
style
=
{{
flex
:
1
}}
>
<
View
style
=
{
styles
.
container
}
>
<
View
style
=
{
styles
.
subContainer
}
>
<
Text
style
=
{
styles
.
heading
}
>
Upload
Your
Blood
Report
<
/Text
>
<
Text
style
=
{
styles
.
description
}
>
(
*
Please
Upload
Fasting
Blood
Sugar
(
OGTT
-
FBS
)
or
Full
Blood
Count
(
FBC
)
Report
)
<
/Text
>
<
View
style
=
{
styles
.
imageCBCContainer
}
>
<
Button
title
=
"
Pick CBC image
"
onPress
=
{()
=>
pickImage
(
'
CBC
'
)}
/
>
{
imageCBC
&&
<
Image
source
=
{{
uri
:
imageCBC
}}
style
=
{{
width
:
200
,
height
:
200
}}
/>
}
{
resultCBC
&&
<
Text
style
=
{
styles
.
labelText
}
>
Hemoglobin
:{
resultCBC
}
<
/Text>
}
<
/View
>
<
View
style
=
{
styles
.
imageOGTTContainer
}
>
<
Button
title
=
"
Pick OGTT image
"
onPress
=
{()
=>
pickImage
(
'
OGTT
'
)}
/
>
{
imageOGTT
&&
<
Image
source
=
{{
uri
:
imageOGTT
}}
style
=
{{
width
:
200
,
height
:
200
}}
/>
}
{
resultOGTT
&&
<
Text
style
=
{
styles
.
labelText
}
>
Glucose
:{
resultOGTT
}
<
/Text>
}
<
/View>
<
View
style
=
{
styles
.
bmiContainer
}
>
<
Text
style
=
{
styles
.
bmiText
}
>
BMI
:
<
/Text
>
<
TextInput
placeholder
=
"
Enter BMI
"
onChangeText
=
{(
text
)
=>
setBMI
(
text
)}
value
=
{
bmi
?
bmi
.
toString
()
:
""
}
// Set the BMI value from the route
keyboardType
=
"
numeric
"
style
=
{
styles
.
labelText
}
editable
=
{
false
}
// Make the TextInput read-only
/
>
<
/View
>
<
TouchableOpacity
style
=
{
styles
.
selectButton
}
onPress
=
{
sendToOtherModel
}
>
<
Text
style
=
{
styles
.
buttonText
}
>
Save
<
/Text
>
<
/TouchableOpacity
>
{
/* Conditionally render the "Get Nutrition Plan" button */
}
{
isPlanButtonVisible
&&
(
<
TouchableOpacity
style
=
{
styles
.
navibutton
}
onPress
=
{
navigateToPlan
}
>
<
Text
style
=
{
styles
.
buttonText
}
>
Get
Nutrition
Plan
<
/Text
>
<
/TouchableOpacity
>
)}
<
/View
>
<
/View
>
<
/View
>
<
/ImageBackground>
<
/ScrollView
>
);
}
<
ScrollView
contentContainerStyle
=
{{
flexGrow
:
1
}}
>
<
ImageBackground
source
=
{
require
(
"
../assets/backnew.png
"
)}
resizeMode
=
"
cover
"
style
=
{
styles
.
image
}
>
<
View
style
=
{
styles
.
overlay
}
>
<
View
style
=
{{
flex
:
1
,
alignItems
:
'
center
'
,
justifyContent
:
'
center
'
}}
>
<
Button
title
=
"
Pick CBC image
"
onPress
=
{()
=>
pickImage
(
'
CBC
'
)}
/
>
{
imageCBC
&&
<
Image
source
=
{{
uri
:
imageCBC
}}
style
=
{{
width
:
200
,
height
:
200
}}
/>
}
{
resultCBC
&&
<
Text
>
Hemoglobin
:{
resultCBC
}
<
/Text>
}
<
Button
title
=
"
Pick OGTT image
"
onPress
=
{()
=>
pickImage
(
'
OGTT
'
)}
/
>
{
imageOGTT
&&
<
Image
source
=
{{
uri
:
imageOGTT
}}
style
=
{{
width
:
200
,
height
:
200
}}
/>
}
{
resultOGTT
&&
<
Text
>
Glucose
:{
resultOGTT
}
<
/Text>
}
<
TextInput
placeholder
=
"
Enter BMI
"
onChangeText
=
{
text
=>
setBMI
(
text
)}
value
=
{
bmi
}
keyboardType
=
"
numeric
"
/>
<
TextInput
placeholder
=
"
Enter BMI
"
onChangeText
=
{(
text
)
=>
setBMI
(
text
)}
value
=
{
bmi
?
bmi
.
toString
()
:
""
}
// Set the BMI value from the route
keyboardType
=
"
numeric
"
editable
=
{
false
}
// Make the TextInput read-only
/
>
<
TouchableOpacity
style
=
{
styles
.
button
}
onPress
=
{
sendToOtherModel
}
>
<
Text
style
=
{
styles
.
buttonText
}
>
Save
<
/Text
>
<
/TouchableOpacity
>
<
TouchableOpacity
style
=
{
styles
.
navibutton
}
onPress
=
{
navigateToPlan
}
>
<
Text
style
=
{
styles
.
buttonText
}
>
Get
Nutrition
Plan
<
/Text
>
<
/TouchableOpacity
>
<
/View
>
<
/View
>
<
/ImageBackground
>
<
/ScrollView
>
);
}
const
styles
=
StyleSheet
.
create
({
container
:
{
backgroundColor
:
"
#FFEBFA
"
,
flex
:
1
,
},
subContainer
:
{
padding
:
15
,
borderRadius
:
15
,
marginTop
:
15
,
marginLeft
:
15
,
marginRight
:
15
,
flex
:
1
,
},
scrollViewContent
:
{
minHeight
:
'
120%
'
,
// Set a minimum height to enable scrolling
image
:
{
flex
:
1
,
justifyContent
:
'
center
'
,
},
imageCBCContainer
:
{
marginTop
:
40
,
// Add some margin between the button and the description
alignItems
:
'
center
'
,
// Center the images horizontally
},
imageOGTTContainer
:{
marginTop
:
40
,
alignItems
:
'
center
'
,
// Center the images horizontally
},
bmiContainer
:{
marginTop
:
40
,
fontWeight
:
"
bold
"
,
fontSize
:
12
,
},
labelText
:{
fontWeight
:
"
bold
"
,
color
:
"
black
"
,
fontSize
:
15
,
overlay
:
{
flex
:
1
,
backgroundColor
:
'
rgba(0, 0, 0, 0.3)
'
,
padding
:
20
,
justifyContent
:
'
center
'
,
alignItems
:
"
center
"
,
},
bmiText
:{
fontWeight
:
"
bold
"
,
fontSize
:
20
,
button
:
{
backgroundColor
:
"
pink
"
,
borderRadius
:
5
,
padding
:
10
,
marginTop
:
60
,
width
:
200
,
},
navibutton
:{
...
...
@@ -243,42 +197,26 @@ const styles = StyleSheet.create({
borderRadius
:
5
,
padding
:
10
,
marginTop
:
30
,
width
:
"
100%
"
,
alignItems
:
"
center
"
,
justifyContent
:
"
center
"
,
width
:
200
,
},
selectButton
:
{
borderRadius
:
10
,
marginTop
:
40
,
width
:
"
100%
"
,
height
:
47
,
backgroundColor
:
"
#FF9DD2
"
,
alignItems
:
"
center
"
,
justifyContent
:
"
center
"
,
buttonText
:
{
color
:
"
white
"
,
fontWeight
:
"
bold
"
,
textAlign
:
"
center
"
,
fontSize
:
16
,
},
buttonText
:
{
color
:
"
black
"
,
fontSize
:
18
,
label
:
{
fontSize
:
24
,
fontWeight
:
"
bold
"
,
marginBottom
:
10
,
},
heading
:
{
marginTop
:
50
,
marginLeft
:
60
,
color
:
"
black
"
,
fontSize
:
35
,
result
:
{
fontSize
:
36
,
fontWeight
:
"
bold
"
,
alignItems
:
"
center
"
color
:
"
black
"
,
// You can style the color based on BMI ranges
},
});
description
:{
marginTop
:
10
,
marginLeft
:
50
,
color
:
"
black
"
,
fontSize
:
15
,
align
:
"
right
"
,
}
})
\ No newline at end of file
screens/Plan.js
View file @
039d7906
import
React
,
{
useEffect
}
from
'
react
'
;
import
{
View
,
Text
,
Image
,
ScrollView
,
TouchableOpacity
,
StyleSheet
,
ImageBackground
}
from
'
react-native
'
;
import
{
firebase
}
from
'
../config
'
;
// Make sure to import 'firestore' and 'firebase' correctly.
import
{
View
,
Text
,
TouchableOpacity
,
StyleSheet
,
ImageBackground
,
ScrollView
}
from
'
react-native
'
;
import
{
useNavigation
}
from
'
@react-navigation/native
'
;
import
{
firestore
,
firebase
}
from
'
../config
'
;
// Make sure to import 'firestore' and 'firebase' correctly.
export
default
function
Plan
({
route
})
{
// Extract nutritionPlan from route.params
const
{
nutritionPlan
}
=
route
.
params
;
const
navigation
=
useNavigation
();
// Function to save the nutritionPlan to Firestor
const
savePlanToDatabase
=
async
(
nutritionPlan
)
=>
{
try
{
const
timestamp
=
firebase
.
firestore
.
FieldValue
.
serverTimestamp
();
const
data
=
{
nutritionPlan
:
nutritionPlan
,
date
:
timestamp
,
};
useEffect
(()
=>
{
savePlanToDatabase
();
},
[]);
const
docRef
=
await
firebase
.
firestore
().
collection
(
"
mealPlans
"
).
add
(
data
);
console
.
log
(
"
Meal plan saved with ID:
"
,
docRef
.
id
);
}
catch
(
error
)
{
console
.
error
(
'
Error saving Nutrition Plan to Firestore:
'
,
error
);
}
}
// Function to save the nutritionPlan to Firestore
const
savePlanToDatabase
=
(
nutritionPlan
)
=>
{
const
data
=
{
nutritionPlan
:
parseFloat
(
nutritionPlan
),
};
// Assuming you have a 'nutritionPlans' collection in your database
firebase
.
firestore
().
collection
(
"
nutritionPlans
"
).
add
(
data
);
};
return
(
<
ScrollView
contentContainerStyle
=
{
styles
.
container
}
>
<
ImageBackground
source
=
{
require
(
"
../assets/plan1.png
"
)}
resizeMode
=
"
cover
"
style
=
{
styles
.
image
}
>
<
View
style
=
{
styles
.
overlay
}
>
{
/* Nutrition Plan */
}
<
Text
style
=
{
styles
.
title
}
>
Nutrition
Plan
:
<
/Text
>
return
(
<
ScrollView
contentContainerStyle
=
{
styles
.
scrollViewContent
}
>
<
View
style
=
{
styles
.
container
}
>
<
ImageBackground
source
=
{
require
(
"
../assets/plan1.png
"
)}
resizeMode
=
"
cover
"
style
=
{
styles
.
image
}
>
<
View
style
=
{
styles
.
overlay
}
>
<
Text
style
=
{
styles
.
nutritionPlan
}
>
{
nutritionPlan
}
<
/Text
>
{
/* Save Plan Button */
}
<
TouchableOpacity
style
=
{
styles
.
button
}
onPress
=
{
savePlanToDatabase
}
>
<
Text
>
Save
Plan
<
/Text
>
{
/* Save Plan Button */
}
<
TouchableOpacity
style
=
{
styles
.
button
}
onPress
=
{
savePlanToDatabase
}
>
<
Text
style
=
{
styles
.
buttonText
}
>
Save
Plan
<
/Text
>
<
/TouchableOpacity
>
<
/View
>
<
/ImageBackground
>
<
/View
>
<
/ScrollView
>
);
}
const
styles
=
StyleSheet
.
create
({
container
:
{
padding
:
16
,
flex
:
1
,
},
scrollViewContent
:
{
minHeight
:
'
120%
'
,
// Set a minimum height to enable scrolling
},
image
:
{
...
...
@@ -72,13 +78,19 @@ const styles = StyleSheet.create({
marginTop
:
8
,
},
button
:
{
backgroundColor
:
"
#FF9DD2
"
,
backgroundColor
:
'
transparent
'
,
borderWidth
:
2
,
borderColor
:
'
#FF9DD2
'
,
// Pink border color
padding
:
12
,
borderRadius
:
8
,
alignItems
:
'
center
'
,
marginTop
:
16
,
},
buttonText
:
{
color
:
'
white
'
,
color
:
'
black
'
,
fontWeight
:
'
bold
'
,
fontSize
:
20
,
},
});
screens/Sidebar.js
View file @
039d7906
...
...
@@ -12,13 +12,16 @@ const Sidebar = () => {
if
(
tabIndex
===
0
)
{
navigation
.
navigate
(
"
UserProfile
"
);
}
if
(
tabIndex
===
1
){
navigation
.
navigate
(
"
Med
H
ome
"
);
navigation
.
navigate
(
"
Med
icineWelc
ome
"
);
}
if
(
tabIndex
===
2
){
navigation
.
navigate
(
"
WelcomeScreen
"
);
}
if
(
tabIndex
===
3
){
navigation
.
navigate
(
"
bmi
"
);
navigation
.
navigate
(
"
NutritionWelcome
"
);
}
if
(
tabIndex
===
4
){
navigation
.
navigate
(
"
UsImage
"
);
navigation
.
navigate
(
"
USWelcome
"
);
}
if
(
tabIndex
===
5
){
navigation
.
navigate
(
"
MoodWelcome
"
);
}
...
...
screens/Signin.js
View file @
039d7906
import
React
,
{
useState
,
useEffect
}
from
'
react
'
;
import
{
View
,
Text
,
TextInput
,
Button
,
StyleSheet
}
from
'
react-native
'
;
import
{
View
,
Text
,
TextInput
,
Button
,
StyleSheet
,
ImageBackground
,
ScrollView
}
from
'
react-native
'
;
import
{
useNavigation
}
from
'
@react-navigation/native
'
;
import
{
firebase
}
from
'
../config
'
;
import
{
registerIndieID
,
unregisterIndieDevice
}
from
'
native-notify
'
;
...
...
@@ -56,17 +56,13 @@ const SignIn = () => {
}
},
[
email
]);
const
handleSignIn
=
()
=>
{
// Implement your sign-in logic here
// Compare the provided email and password with data in the users array
//const user = users.find((user) => user.email === email && user.password === password);
console
.
log
(
'
Email entered:
'
,
email
);
console
.
log
(
'
Password entered:
'
,
password
);
const
user
=
users
.
find
((
user
)
=>
user
.
email
.
trim
()
===
email
.
trim
()
&&
user
.
password
===
password
);
if
(
user
)
{
if
(
email
&&
password
)
{
// Perform sign-in logic when both email and password are provided
console
.
log
(
'
Sign In successful
'
);
// Save the email to local storage
AsyncStorage
.
setItem
(
'
userEmail
'
,
email
)
.
then
(()
=>
{
...
...
@@ -75,14 +71,16 @@ const SignIn = () => {
.
catch
(
error
=>
{
console
.
error
(
'
Error saving email to local storage:
'
,
error
);
});
// After successful sign-in, navigate to the desired screen
navigation
.
navigate
(
'
TabNavigator
'
);
}
else
{
// If either email or password is missing, display an error message to the user
console
.
error
(
'
Invalid credentials
'
);
// Handle and display the error to the user
}
};
const
goToSignUp
=
()
=>
{
navigation
.
navigate
(
'
Signup
'
);
...
...
@@ -140,13 +138,19 @@ useEffect(() => {
},
[]);
return
(
<
ScrollView
contentContainerStyle
=
{
styles
.
scrollViewContent
}
>
<
View
style
=
{
styles
.
container
}
>
<
ImageBackground
source
=
{
require
(
"
../assets/signNew.png
"
)}
resizeMode
=
"
cover
"
style
=
{
styles
.
image
}
>
<
View
style
=
{
styles
.
overlay
}
>
<
View
style
=
{
styles
.
subcontainer
}
>
<
Text
style
=
{
styles
.
label
}
>
Email
<
/Text
>
<
TextInput
style
=
{
styles
.
input
}
placeholder
=
"
Enter your email
"
value
=
{
email
}
onChangeText
=
{(
text
)
=>
setEmail
(
text
)}
required
/>
<
Text
style
=
{
styles
.
label
}
>
Password
<
/Text
>
...
...
@@ -156,12 +160,19 @@ useEffect(() => {
value
=
{
password
}
onChangeText
=
{(
text
)
=>
setPassword
(
text
)}
secureTextEntry
required
/>
<
View
style
=
{
styles
.
subcontainerbut
}
>
<
Button
title
=
"
Sign In
"
onPress
=
{
handleSignIn
}
/
>
<
Text
style
=
{
styles
.
signUpText
}
>
Don
'
t have an account? Sign Up</Text>
<Button title="Sign Up" onPress={goToSignUp} />
</View>
</View>
</View>
</ImageBackground>
</View>
</ScrollView>
);
};
...
...
@@ -169,21 +180,47 @@ useEffect(() => {
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent:
'
center
'
,
alignItems:
'
center
'
,
margin: 20,
},
subcontainer:{
marginTop: -250,
},
scrollViewContent: {
minHeight:
'
120
%
'
, // Set a minimum height to enable scrolling
},
subcontainerbut:{
marginTop: 20,
},
image: {
flex: 1,
justifyContent:
'
center
'
,
},
overlay: {
flex: 1,
backgroundColor:
'
rgba
(
0
,
0
,
0
,
0.3
)
'
,
padding: 80,
justifyContent:
'
center
'
,
},
label: {
fontSize: 16,
marginBottom: 5,
},
input: {
width:
'
100
%
'
,
height: 40,
borderWidth: 1,
borderColor:
'
gray
'
,
margin
Bottom
: 10,
padding: 10,
margin
Top
: 10,
},
signUpText: {
marginTop: 10,
...
...
screens/Signup.js
View file @
039d7906
...
...
@@ -93,7 +93,8 @@ const Signup = ({ route }) => {
value
=
{
userName
}
onChangeText
=
{(
text
)
=>
setUserName
(
text
)}
maxLength
=
{
MAX_LENGTH
}
style
=
{
styles
.
input
}
style
=
{[
styles
.
input
,
{
width
:
300
}]}
required
/>
<
/View
>
<
View
style
=
{
styles
.
container
}
>
...
...
@@ -102,7 +103,8 @@ const Signup = ({ route }) => {
value
=
{
email
}
onChangeText
=
{(
text
)
=>
setEmail
(
text
)}
keyboardType
=
"
email-address
"
style
=
{
styles
.
input
}
style
=
{[
styles
.
input
,
{
width
:
300
}]}
required
/>
<
/View
>
<
View
style
=
{
styles
.
container
}
>
...
...
@@ -111,7 +113,8 @@ const Signup = ({ route }) => {
value
=
{
phone
}
onChangeText
=
{(
text
)
=>
setPhone
(
text
)}
keyboardType
=
"
numeric
"
style
=
{
styles
.
input
}
style
=
{[
styles
.
input
,
{
width
:
300
}]}
required
/>
<
/View
>
<
View
style
=
{
styles
.
container
}
>
...
...
@@ -119,14 +122,15 @@ const Signup = ({ route }) => {
placeholder
=
"
Password
"
value
=
{
password
}
onChangeText
=
{(
password
)
=>
setPassword
(
password
)}
style
=
{
styles
.
input
}
style
=
{[
styles
.
input
,
{
width
:
300
}]}
required
/>
<
/View
>
<
View
>
<
Button
title
=
"
Sign Up
"
onPress
=
{
saveUserData
}
/
>
<
/View
>
<
View
>
<
Button
title
=
"
Sign In
"
style
=
{
styles
.
signi
n
}
onPress
=
{
handleSignIn
}
/
>
<
Button
title
=
"
Sign In
"
style
=
{
styles
.
actionButto
n
}
onPress
=
{
handleSignIn
}
/
>
<
/View
>
<
/View
>
...
...
@@ -164,7 +168,7 @@ const styles = StyleSheet.create({
borderWidth
:
1
,
borderColor
:
'
gray
'
,
padding
:
10
,
marginBottom
:
2
0
,
marginBottom
:
1
0
,
},
body
:
{
flex
:
1
,
...
...
@@ -177,6 +181,10 @@ const styles = StyleSheet.create({
color
:
"
#633974
"
,
fontWeight
:
'
bold
'
,
},
actionButton
:{
marginTop
:
20
}
,
});
export
default
Signup
;
\ No newline at end of file
screens/USWelcome.js
View file @
039d7906
...
...
@@ -8,7 +8,7 @@ export default function USWelcome () {
const
navigation
=
useNavigation
();
const
navigateToUS
=
()
=>
{
navigation
.
navigate
(
"
Us
Image
"
);
navigation
.
navigate
(
"
Us
"
);
};
...
...
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