Skip to content

Commit

Permalink
Merge branch 'main' into Testing-Brian
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianW2301 committed Apr 24, 2023
2 parents c099b6f + a8ec1bd commit 7207f94
Show file tree
Hide file tree
Showing 10 changed files with 112 additions and 114 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# # Life React
# Life React

LifeReact is a lifestyle app that allows users to keep track of your calorie intake by providing a persistent, interactive food diary. All nutritional information is pulled directly from the USDA to ensure a high degree of accuracy. Users can also view dynamic updates on their progress towards their calorie goal from the home screen.

Expand Down
2 changes: 2 additions & 0 deletions Screens/AutoAuth.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export default function AutoAuth({ navigation: { navigate } }) {
}
};

// Rendering AutoAuth component
return (
<View style={styles.container}>
<TouchableOpacity
Expand Down Expand Up @@ -79,6 +80,7 @@ export default function AutoAuth({ navigation: { navigate } }) {
);
}

// Defining styles using StyleSheet
const styles = StyleSheet.create({
container: {
flex: 1,
Expand Down
60 changes: 25 additions & 35 deletions Screens/EntryDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ import { TextInput } from 'react-native-paper';
import { StackActions, useNavigation} from '@react-navigation/native';
import { COLORS } from '../constants/colors.js'




const FoodDetails = ({route}) => {
const navigation = useNavigation();
const {food, meal} = route.params
Expand All @@ -26,8 +23,8 @@ const FoodDetails = ({route}) => {
routes: [{ name: 'Diary' }],
});
}

const RemoveFood = () =>{

let index = meal.indexOf(food)
meal.splice(index,1)
console.log(meal)
Expand All @@ -37,6 +34,7 @@ const FoodDetails = ({route}) => {
});
}

// Rendering EntryDetails component
return(
<ScrollView style={{ backgroundColor: COLORS.green}}>
<Text style={{ backgroundColor: COLORS.green, textAlign:"center", fontWeight:'bold', fontSize:20}}>{food.description}</Text>
Expand Down Expand Up @@ -97,48 +95,40 @@ const FoodDetails = ({route}) => {
)
}

// Defining styles using StyleSheet
const styles = StyleSheet.create({
container: {
flex: 1,
marginTop: 8,
backgroundColor: COLORS.green

},

textRight:{
marginRight: '5%',
fontSize: 20
},
textInputRight: {
backgroundColor: COLORS.cream,
marginRight: '5%',
},

textLeft:{
textRight:{
marginRight: '5%',
fontSize: 20
},
textInputRight: {
backgroundColor: COLORS.cream,
marginRight: '5%',
},
textLeft:{
flex:1,
paddingLeft: "5%",
fontWeight:"bold",
fontSize: 20
},

flexrow:{

},
flexrow:{
flexDirection: 'row',
paddingTop:10,
paddingBottom: 10
},
tab:{
backgroundColor: COLORS.blue,
borderRadius: 100,
marginTop:30,
height: 30,
width: '50%',
alignSelf:'center'


}

});

export default FoodDetails
},
tab:{
backgroundColor: COLORS.blue,
borderRadius: 100,
marginTop:30,
height: 30,
width: '50%',
alignSelf:'center'
}
});

export default FoodDetails
50 changes: 21 additions & 29 deletions Screens/FoodDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import { DiaryContext } from '../Contexts/DiaryContext';
import { StackActions, useNavigation} from '@react-navigation/native';
import { COLORS } from '../constants/colors.js'



const FoodDetails = ({route, navigation}) => {
const {food, meal} = route.params
const [servings, setServings] = useState(1);
Expand All @@ -27,8 +25,9 @@ const FoodDetails = ({route, navigation}) => {
index: 0,
routes: [{ name: 'Diary' }],
});
//navigation.navigate("Diary")
}

// Rendering FoodDetails component
return(
<ScrollView style={{ backgroundColor: COLORS.green}}>
<Text style={{ backgroundColor: COLORS.green, textAlign:"center", fontWeight:'bold', fontSize:20}}>{food.description}</Text>
Expand Down Expand Up @@ -80,35 +79,31 @@ const FoodDetails = ({route, navigation}) => {
)
}

// Defining styles using StyleSheet
const styles = StyleSheet.create({
container: {
flex: 1,
marginTop: 8,
backgroundColor: COLORS.green

},

container: {
flex: 1,
marginTop: 8,
backgroundColor: COLORS.green
},
textRight:{
marginRight: '5%',
fontSize: 20
marginRight: '5%',
fontSize: 20
},
textInputRight: {
backgroundColor: COLORS.cream,
marginRight: '5%',
},

},
textLeft:{
flex:1,
paddingLeft: "5%",
fontWeight:"bold",
fontSize: 20
flex:1,
paddingLeft: "5%",
fontWeight:"bold",
fontSize: 20
},

flexrow:{

flexDirection: 'row',
paddingTop:10,
paddingBottom: 10
flexrow:{
flexDirection: 'row',
paddingTop:10,
paddingBottom: 10
},
tab:{
backgroundColor: COLORS.blue,
Expand All @@ -117,11 +112,8 @@ const styles = StyleSheet.create({
height: 30,
width: '50%',
alignSelf:'center'


}

});
}
});

export default FoodDetails

7 changes: 1 addition & 6 deletions Screens/FoodSearchScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@ import fetch from 'node-fetch';
import SearchResult from '../components/SearchResult';
import { COLORS } from '../constants/colors.js'


const FoodSearchScreen = ({route}) => {
const [results, setResults ] = useState([])
const query = useRef("")
const {meal} = route.params


const getUSDA = async (data) => {
let dataNoSpace = data.trim().replace(' ','%20')
if(dataNoSpace != ''){
Expand Down Expand Up @@ -60,10 +58,9 @@ const Search = ({foods}) =>{
</View>
</TouchableWithoutFeedback>
)


}

// Defining styles using StyleSheet
const styles = StyleSheet.create({
default:{
backgroundColor: COLORS.green,
Expand All @@ -78,6 +75,4 @@ const styles = StyleSheet.create({
}
})



export default FoodSearchScreen
24 changes: 20 additions & 4 deletions Screens/Home.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@ import { COLORS } from '../constants/colors.js'
import { useFocusEffect} from '@react-navigation/native';
import CalorieTracker from "../components/CalorieGoal";




// Define and export the Home component
export default function Home({ navigation }) {
let uid
let cal

// Defining and initializing state variables
const [name, setName] = React.useState("");
const [type, setType] = React.useState("Email");
const [calorieGoal, setCalorieGoal] = React.useState(2000);
Expand All @@ -37,6 +36,17 @@ export default function Home({ navigation }) {
}
const getDb = async () => {
uid = await AsyncStorage.getItem("uid");

// Getting the user's diary from the getDiary function
let newDiary = await getDiary()

// Setting the state variables with the retrieved data
setDiary(newDiary);
setCalorieGoal(2000)
setCaloriesConsumed(newDiary.getEntry(new Date().toDateString()).getCalorieTotal())
console.log("UUID: " + uid)

// Getting the user details from the database
try{
let user = await getDoc(doc(db, "users", uid));
setType(user.data().signinType || "Email");
Expand All @@ -54,12 +64,16 @@ export default function Home({ navigation }) {
}

};

// A function to navigate to another screen
const nav = (name) =>{
navigation.reset({
index: 0,
routes: [{ name: name }],
});
}

// Function to log out the user and revoke the authentication token
const log = async () => {
if (type == "Email") {
await AsyncStorage.removeItem("uid");
Expand All @@ -76,6 +90,7 @@ export default function Home({ navigation }) {
}
};

// Rendering Home component
return (
<View style={styles.container}>
<Text style={styles.Home}>Home</Text>
Expand All @@ -86,6 +101,7 @@ export default function Home({ navigation }) {
);
}

// Defining styles using StyleSheet
const styles = StyleSheet.create({
container: {
flex: 1,
Expand Down
9 changes: 9 additions & 0 deletions Screens/Loading.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/**
* Loading screen to display when the app is launched
*/
import React, { useEffect } from "react";
import AsyncStorage from "@react-native-async-storage/async-storage";
import { View, ActivityIndicator, Text, Image, StyleSheet } from "react-native";
Expand All @@ -7,19 +10,24 @@ const Loading = ({ navigation}) => {
useEffect(() => {
getUser();
});

// A function to navigate to another screen
const nav = (name) =>{
navigation.reset({
index: 0,
routes: [{ name: name }],
});
}

// Function to get the user ID from async storage and navigate to another screen
const getUser = async () => {
let uid = await AsyncStorage.getItem("uid");
console.log("loading screen id:" + uid)
if (uid !== null) nav('Home');
else nav('Auth');
};

// Rendering Loading component
return (
<View style={styles.container}>
<Image source={require('../assets/splash.png')} style={styles.logo} />
Expand All @@ -29,6 +37,7 @@ const Loading = ({ navigation}) => {
);
};

// Defining styles using StyleSheet
const styles = StyleSheet.create({
container: {
flex: 1,
Expand Down
Loading

0 comments on commit 7207f94

Please sign in to comment.