Commit 15ee1657 authored by Balasooriya B.M.D.D's avatar Balasooriya B.M.D.D

Merge branch 'Nutrition_Plan_CSS' into 'master'

Modification

See merge request !28
parents 65faf5e0 1b265668
......@@ -105,7 +105,7 @@ export default function Nutrition({ route }) {
const outputValue = response.data.prediction;
const customText = outputTexts[outputValue] || 'Default Text for Other Outputs';
// Format the meal plan text with line breaks
const formattedMealPlan = customText.replace(/;/g, '\n');
const formattedMealPlan = customText.replace(/;/g, '\n\n');
setOtherModelResult(formattedMealPlan);
// setOtherModelResult(customText);
console.log(response.data.prediction);
......
......@@ -2,10 +2,25 @@ import React, { useEffect } 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();
const [email, setEmail] = useState('');
useEffect(() => {
// Retrieve the email from local storage
AsyncStorage.getItem('userEmail')
.then(result => {
if (result) {
setEmail(result);
}
})
.catch(error => {
console.error('Error retrieving email from local storage:', error);
});
}, []);
useEffect(() => {
......@@ -16,7 +31,9 @@ export default function Plan({ route }) {
const savePlanToDatabase = (nutritionPlan) => {
const data = {
nutritionPlan: parseFloat(nutritionPlan),
email:email,
nutritionPlan: nutritionPlan,
};
// Assuming you have a 'nutritionPlans' collection in your database
......@@ -32,8 +49,10 @@ export default function Plan({ route }) {
<ImageBackground source={require("../assets/plan1.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>
......@@ -48,11 +67,11 @@ export default function Plan({ route }) {
const styles = StyleSheet.create({
container: {
flex:1,
flex: 1,
justifyContent: 'center', // Center vertically
alignItems: 'center', // Center horizontally
},
scrollViewContent: {
minHeight: '120%', // Set a minimum height to enable scrolling
},
......@@ -73,10 +92,13 @@ const styles = StyleSheet.create({
fontWeight: 'bold',
marginTop: 16,
},
nutritionPlan: {
fontSize: 16,
marginTop: 8,
textAlign: 'center', // Center the text within the container
},
button: {
backgroundColor: 'transparent',
borderWidth: 2,
......
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