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
34b410ae
Commit
34b410ae
authored
Nov 01, 2023
by
Balasooriya B.M.D.D
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'Nutrion_Emotion_UI' into 'master'
commit See merge request
!32
parents
de679caa
e427e9cf
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
210 additions
and
267 deletions
+210
-267
screens/MoodDetection.js
screens/MoodDetection.js
+103
-222
screens/Nutrition.js
screens/Nutrition.js
+37
-11
screens/Plan.js
screens/Plan.js
+36
-28
screens/PreviousPlan.js
screens/PreviousPlan.js
+34
-6
No files found.
screens/MoodDetection.js
View file @
34b410ae
This diff is collapsed.
Click to expand it.
screens/Nutrition.js
View file @
34b410ae
This diff is collapsed.
Click to expand it.
screens/Plan.js
View file @
34b410ae
import
React
,
{
useEffect
}
from
'
react
'
;
import
React
,
{
use
State
,
use
Effect
}
from
'
react
'
;
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.
import
AsyncStorage
from
'
@react-native-async-storage/async-storage
'
;
export
default
function
Plan
({
route
})
{
const
{
nutritionPlan
}
=
route
.
params
;
const
navigation
=
useNavigation
();
...
...
@@ -22,37 +23,46 @@ export default function Plan({ route }) {
});
},
[]);
useEffect
(()
=>
{
savePlanToDatabase
();
},
[]);
// When nutritionPlan is available, save it to Firestore
if
(
nutritionPlan
)
{
savePlanToDatabase
(
nutritionPlan
);
}
},
[
nutritionPlan
]);
// Function to save the nutritionPlan to Firestore
const
savePlanToDatabase
=
(
nutritionPlan
)
=>
{
const
data
=
{
email
:
email
,
nutritionPlan
:
nutritionPlan
,
const
savePlanToDatabase
=
(
nutritionPlan
)
=>
{
const
timestamp
=
firebase
.
firestore
.
FieldValue
.
serverTimestamp
();
const
data
=
{
date
:
timestamp
,
email
:
email
,
nutritionPlan
:
nutritionPlan
,
};
};
// Assuming you have a 'nutritionPlans' collection in your database
firebase
.
firestore
().
collection
(
"
nutritionPlans
"
).
add
(
data
);
};
try
{
const
docRef
=
firebase
.
firestore
()
.
collection
(
'
nutritionPlans
'
)
.
add
(
data
);
}
catch
(
error
)
{
}
};
return
(
<
ScrollView
contentContainerStyle
=
{
styles
.
scrollViewContent
}
>
<
View
style
=
{
styles
.
container
}
>
<
ImageBackground
source
=
{
require
(
"
../assets/plan
1
.png
"
)}
resizeMode
=
"
cover
"
style
=
{
styles
.
image
}
>
<
ImageBackground
source
=
{
require
(
"
../assets/plan
2
.png
"
)}
resizeMode
=
"
cover
"
style
=
{
styles
.
image
}
>
<
View
style
=
{
styles
.
overlay
}
>
<
View
>
<
Text
style
=
{
styles
.
nutritionPlan
}
>
{
nutritionPlan
}
<
/Text
>
<
/View
>
{
/* Save Plan Button */
}
<
TouchableOpacity
style
=
{
styles
.
button
}
onPress
=
{
savePlanToDatabase
}
>
<
Text
style
=
{
styles
.
buttonText
}
>
Save
Plan
<
/Text
>
...
...
@@ -67,18 +77,19 @@ export default function Plan({ route }) {
const
styles
=
StyleSheet
.
create
({
container
:
{
flex
:
1
,
justifyContent
:
'
center
'
,
// Center vertically
alignItems
:
'
center
'
,
// Center horizontally
},
flex
:
1
,
},
scrollViewContent
:
{
minHeight
:
'
1
2
0%
'
,
// Set a minimum height to enable scrolling
minHeight
:
'
1
5
0%
'
,
// Set a minimum height to enable scrolling
},
image
:
{
flex
:
1
,
justifyContent
:
'
center
'
,
},
overlay
:
{
...
...
@@ -92,13 +103,10 @@ const styles = StyleSheet.create({
fontWeight
:
'
bold
'
,
marginTop
:
16
,
},
nutritionPlan
:
{
fontSize
:
16
,
marginTop
:
8
,
textAlign
:
'
center
'
,
// Center the text within the container
marginTop
:
500
,
},
button
:
{
backgroundColor
:
'
transparent
'
,
borderWidth
:
2
,
...
...
screens/PreviousPlan.js
View file @
34b410ae
import
{
ImageBackground
,
StyleSheet
,
Text
,
View
,
TouchableOpacity
}
from
'
react-native
'
;
import
React
,
{
Component
}
from
'
react
'
import
{
ImageBackground
,
StyleSheet
,
Text
,
View
,
FlatList
}
from
'
react-native
'
;
import
{
firestore
,
firebase
}
from
'
../config
'
;
// Make sure to import 'firestore' and 'firebase' correctly.
import
React
,
{
useState
,
useEffect
}
from
'
react
'
;
export
default
function
PreviousPlan
()
{
const
[
mealPlans
,
setMealPlans
]
=
useState
([]);
useEffect
(()
=>
{
// Fetch meal plans from Firestore
const
fetchMealPlans
=
async
()
=>
{
try
{
const
mealPlansSnapshot
=
await
firebase
.
firestore
().
collection
(
'
nutritionPlans
'
).
get
();
const
mealPlanData
=
mealPlansSnapshot
.
docs
.
map
(
doc
=>
doc
.
data
());
setMealPlans
(
mealPlanData
);
}
catch
(
error
)
{
console
.
error
(
'
Error fetching meal plans:
'
,
error
);
}
};
fetchMealPlans
();
},
[]);
return
(
<
View
style
=
{
styles
.
container
}
>
<
ImageBackground
source
=
{
require
(
"
../assets/plan2.png
"
)}
resizeMode
=
"
cover
"
style
=
{
styles
.
image
}
>
<
View
style
=
{
styles
.
overlay
}
>
<
View
style
=
{
styles
.
nutritionPlan
}
>
<
FlatList
data
=
{
mealPlans
}
keyExtractor
=
{(
item
,
index
)
=>
index
.
toString
()}
renderItem
=
{({
item
})
=>
(
<
View
style
=
{
styles
.
mealPlanItem
}
>
<
Text
style
=
{
styles
.
mealPlanText
}
>
{
item
.
nutritionPlan
}
<
/Text
>
<
/View
>
)}
/
>
<
/View
>
<
/View
>
<
/ImageBackground
>
<
/View
>
...
...
@@ -37,6 +61,10 @@ const styles = StyleSheet.create({
justifyContent
:
'
center
'
,
},
nutritionPlan
:
{
fontSize
:
16
,
marginTop
:
350
,
},
actionButtons
:
{
...
...
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