Merge branch 'master' into WORK-RHA2
continuous-integration/drone/push Build is passing Details

pull/23/head
Rayhân HASSOU 1 year ago
commit b98fe71167

@ -18,8 +18,8 @@ export default function App() {
<ThemeProvider> <ThemeProvider>
<ColorProvider> <ColorProvider>
<NavigationContainer> <NavigationContainer>
<Tab.Navigator initialRouteName='HOME' tabBar={ (props) => <BottomBar {...props}/> }> <Tab.Navigator initialRouteName='HOME' tabBar={ (props) => <BottomBar {...props}/>}>
<Tab.Screen name='PROFILES' component={ProfilesStackScreen} options={{ headerShown: false, title: 'Profiles' }} /> <Tab.Screen name='PROFILES' component={ProfilesStackScreen} options={{ headerShown: false, title: 'Profiles' }}/>
<Tab.Screen name='HOME' component={HomeStackScreen} options={{ headerShown: false, title: 'Home' }}/> <Tab.Screen name='HOME' component={HomeStackScreen} options={{ headerShown: false, title: 'Home' }}/>
<Tab.Screen name='COOKING' component={CookingStackScreen} options={{ headerShown: false, title: 'Cooking' }}/> <Tab.Screen name='COOKING' component={CookingStackScreen} options={{ headerShown: false, title: 'Cooking' }}/>
</Tab.Navigator> </Tab.Navigator>

@ -18,7 +18,7 @@ export default class RecipesService implements IRecipesService {
async getRecipeById(id: number): Promise<Recipes | null>{ async getRecipeById(id: number): Promise<Recipes | null>{
try { try {
const response = await axios.get(`${this.API_URL}/${id}`); const response = await axios.get(`${this.API_URL}/${id}`);
console.log(response); //console.log(response.name);
return response.data as Recipes; return response.data as Recipes;
} catch (error) { } catch (error) {
throw new Error('Erreur lors de la récupération des ingrédients : ' + error.message); throw new Error('Erreur lors de la récupération des ingrédients : ' + error.message);

@ -5,6 +5,8 @@ import { createNativeStackNavigator } from '@react-navigation/native-stack';
import IngredientSelection from '../screens/IngredientSelection'; import IngredientSelection from '../screens/IngredientSelection';
import { HeaderTitle } from './Utils'; import { HeaderTitle } from './Utils';
import ThemeContext from '../theme/ThemeContext'; import ThemeContext from '../theme/ThemeContext';
import RecipeSuggestion from '../screens/RecipeSuggestion';
import RecipeDetails from '../screens/RecipeDetails';
const CookingStack = createNativeStackNavigator() const CookingStack = createNativeStackNavigator()
@ -23,6 +25,26 @@ export default function CookingStackScreen() {
) )
}} }}
/> />
<CookingStack.Screen
name='RecipeSuggestion'
component={RecipeSuggestion}
options={{
headerStyle: {backgroundColor: theme === 'light' ? '#F2F0E4' : '#3F3C42'},
headerTitle: () => (
<HeaderTitle title='Recipe Suggestion'/>
)
}}
/>
<CookingStack.Screen
name='RecipeDetails'
component={RecipeDetails}
options={{
headerStyle: {backgroundColor: theme === 'light' ? '#F2F0E4' : '#3F3C42'},
headerTitle: () => (
<HeaderTitle title='Recipe Details'/>
)
}}
/>
</CookingStack.Navigator> </CookingStack.Navigator>
) )
} }

@ -1,4 +1,4 @@
import React, { useContext, useState } from 'react'; import React, { useContext, useState, useEffect } from 'react';
import { StyleSheet, View, Text, Pressable, Image, ScrollView } from 'react-native'; import { StyleSheet, View, Text, Pressable, Image, ScrollView } from 'react-native';
import {LinearGradient} from 'expo-linear-gradient'; import {LinearGradient} from 'expo-linear-gradient';
import {SafeAreaProvider} from 'react-native-safe-area-context'; import {SafeAreaProvider} from 'react-native-safe-area-context';
@ -11,17 +11,51 @@ import ColorContext from '../theme/ColorContext';
import bracketLeft from '../assets/images/angle_bracket_left.png'; import bracketLeft from '../assets/images/angle_bracket_left.png';
import bracketRight from '../assets/images/angle_bracket_right.png'; import bracketRight from '../assets/images/angle_bracket_right.png';
import AsyncStorage from '@react-native-async-storage/async-storage';
import EventEmitter from './EventEmitter';
export default function HomePage({ navigation, props }) { export default function HomePage({ navigation, props }) {
const {colors} = useContext(ColorContext); const {colors} = useContext(ColorContext);
const profiles = [ const profilesHand = [
{name: "Johnny Silverhand", avatar: "plus_small.png", isActive: "flex"}, {name: "Johnny Silverhand", avatar: "plus_small.png", isActive: "flex"},
{name: "Panam Palmer", avatar: "plus_small.png", isActive: "none"}, {name: "Panam Palmer", avatar: "plus_small.png", isActive: "none"},
{name: "Goro Takemura", avatar: "plus_small.png", isActive: "none"}, {name: "Goro Takemura", avatar: "plus_small.png", isActive: "none"},
{name: "David Martinez", avatar: "plus_small.png", isActive: "flex"}, {name: "David Martinez", avatar: "plus_small.png", isActive: "flex"},
] ]
const [profiles, setProfiles] = useState([{name: "None", avatar: "plus_small.png", isActive: "none"}]);
console.log(profiles, profiles.length)
const handleGetProfiles = async () => {
try {
const existingProfiles = await AsyncStorage.getItem('profiles');
return JSON.parse(existingProfiles) || [];
} catch (error) {
console.log(error);
return [];
}
}
const fetchProfiles = async () => {
const existingProfiles = await handleGetProfiles();
setProfiles(existingProfiles);
};
const subscription = EventEmitter.addListener('profileAdded', async () => {
fetchProfiles();
});
useEffect(() => {
fetchProfiles();
console.log(profiles.length)
if(profiles.length == 0){
setProfiles([{name: "None", avatar: "plus_small.png", isActive: "none"}])
console.log("Je passe ici")
}
console.log(profiles)
}, []);
const ingredientList = [{title: "Carrot"}, {title: "Potato"}, {title: "Peach"}] const ingredientList = [{title: "Carrot"}, {title: "Potato"}, {title: "Peach"}]
const [cpt, setCpt] = useState(0); const [cpt, setCpt] = useState(0);
@ -178,9 +212,9 @@ export default function HomePage({ navigation, props }) {
</View> </View>
</View> </View>
<View style={{marginTop: "4%"}}/> <View style={{marginTop: "4%"}}/>
<ValidateButton title="Change Selected Ingredients" image="cook.png" colour={colors.buttonDetail} backColour={colors.buttonBackground} todo={() => navigation.navigate('IngredientSelection')}/> <ValidateButton title="Change Selected Ingredients" image="cook.png" colour={colors.buttonDetail} backColour={colors.buttonBackground} todo={ () => console.log('Chnge Selected Ingredient')}/>
<View style={{marginTop: "3%"}}/> <View style={{marginTop: "3%"}}/>
<ValidateButton title="Search Recipes" image="search.png" colour={colors.buttonDetail} backColour={colors.buttonBackground} todo={() => navigation.navigate('RecipeSuggestion')}/> <ValidateButton title="Search Recipes" image="search.png" colour={colors.buttonDetail} backColour={colors.buttonBackground} todo={ () => console.log('Go and search for recipe')}/>
</View> </View>
<View style={{marginBottom: "20%"}}/> <View style={{marginBottom: "20%"}}/>
</LinearGradient> </LinearGradient>

@ -3,7 +3,6 @@ import { View, StyleSheet, Text, Image, Pressable, ActivityIndicator, FlatList,
import { SafeAreaProvider } from 'react-native-safe-area-context'; import { SafeAreaProvider } from 'react-native-safe-area-context';
import { Searchbar } from 'react-native-paper'; import { Searchbar } from 'react-native-paper';
import FoodElementText from '../components/FoodElementText'; import FoodElementText from '../components/FoodElementText';
import plus from '../assets/images/plus.png'; import plus from '../assets/images/plus.png';
import moins from '../assets/images/minus.png'; import moins from '../assets/images/minus.png';
import Ingredient from '../Models/Ingredient'; import Ingredient from '../Models/Ingredient';
@ -20,7 +19,7 @@ export default function IngredientSelection(props) {
const ingredientService = new IngredientService(); const ingredientService = new IngredientService();
const {colors} = useContext(ColorContext); const {colors} = useContext(ColorContext);
const [availableSize, setAvailableSize] = useState(0); const [availableSize, setAvailableSize] = useState(0);
const [listVisibility, setListVisibility] = useState("none"); const [listVisibility, setListVisibility] = useState("flex");
const [availableVisibility, setAvailableVisibility] = useState("none"); const [availableVisibility, setAvailableVisibility] = useState("none");
const [searchQuery, setSearchQuery] = useState(''); const [searchQuery, setSearchQuery] = useState('');
@ -57,6 +56,7 @@ const loadIngredients = async () => {
}; };
useEffect(() => { useEffect(() => {
console.log("Je passe ici (Ingredient Selection)")
loadIngredients(); loadIngredients();
}, []); }, []);

@ -8,27 +8,36 @@ import Recipes from '../Models/Recipes';
import { LinearGradient } from 'expo-linear-gradient'; import { LinearGradient } from 'expo-linear-gradient';
import ListWithoutSelect from '../components/ListWithoutSelect'; import ListWithoutSelect from '../components/ListWithoutSelect';
import ColorContext from '../theme/ColorContext'; import ColorContext from '../theme/ColorContext';
import Ingredient from '../Models/Ingredient';
export default function RecipeDetails(props) { export default function RecipeDetails(props) {
const {colors} = useContext(ColorContext); const {colors} = useContext(ColorContext);
const [isLoading, setIsLoading] = useState(true); const [isLoading, setIsLoading] = useState(true)
const [response, setResponse] = useState<Recipes | undefined>(undefined);
const ingredientList = [new Ingredient(3, "Carrot"), new Ingredient(4, "Potato"), new Ingredient(5, "Peach")]
const [response, setResponse] = useState<Recipes>(new Recipes (120, "Carrot", "Delicious", 90, ["Fork", "Fish", "Knife"], ingredientList))
const recipesService = new RecipesService(); const recipesService = new RecipesService();
const loadRecipe = async () => { const loadRecipe = async () => {
try { try {
const recipe = await recipesService.getRecipeById(props.id); const recipe = await recipesService.getRecipeById(120);
console.log("Recipe.name: "+recipe.name)
setResponse(recipe); setResponse(recipe);
console.log("Response.name: "+response.name)
} catch (error) { } catch (error) {
console.log(error); console.log(error);
} finally { } finally{
setIsLoading(false); setIsLoading(false)
} }
}; };
useEffect(() => { useEffect(() => {
console.log("Je passe ici (useEffect)")
loadRecipe(); loadRecipe();
}, []); }, []);
@ -58,7 +67,7 @@ export default function RecipeDetails(props) {
alignItems: 'center', alignItems: 'center',
justifyContent: 'center', justifyContent: 'center',
borderRadius: 20, borderRadius: 20,
backgroundColor: '#F2F0E4', backgroundColor: colors.cardBackground,
padding: "3%", padding: "3%",
marginHorizontal: "3%", marginHorizontal: "3%",
borderWidth: 1, borderWidth: 1,
@ -75,12 +84,12 @@ export default function RecipeDetails(props) {
}, },
filters: { filters: {
fontSize: 20, fontSize: 20,
color: '#ACA279', color: colors.cardElementBorder,
flex: 1, flex: 1,
}, },
nbSelected: { nbSelected: {
fontSize: 11, fontSize: 11,
color: "#3F3C42", color: colors.cardDetail,
textAlign: "right", textAlign: "right",
}, },
}); });
@ -88,7 +97,7 @@ export default function RecipeDetails(props) {
return ( return (
<SafeAreaProvider> <SafeAreaProvider>
<ScrollView> <ScrollView>
<LinearGradient colors={['#2680AA', '#59BDCD']} style={[styles.linearGradient, {minHeight: useWindowDimensions().height}]}> <LinearGradient colors={[colors.primary, colors.primaryComplement]} style={[styles.linearGradient, {minHeight: useWindowDimensions().height}]}>
<View style={{marginTop: "6%"}}> <View style={{marginTop: "6%"}}>
<RecipeElementReduce <RecipeElementReduce
title={response.name} title={response.name}

@ -167,14 +167,6 @@ export default function RecipeSuggestion(props) {
duration="17 min" duration="17 min"
navigateDetails={goDetails}/> navigateDetails={goDetails}/>
<View style={{marginHorizontal: 10}}/> <View style={{marginHorizontal: 10}}/>
<RecipeElement
number="03"
title="Vichyssoise"
textList={ingredientListV2}
description="Cold soup of vegetables. Difficult recipe. Not advised to beginners. 1h or more."
duration="1h and a half"
navigateDetails={goDetails}/>
<View style={{marginHorizontal: 10}}/>
</ScrollView> </ScrollView>
<View style={{marginBottom: "20%"}}/> <View style={{marginBottom: "20%"}}/>
</LinearGradient> </LinearGradient>

Loading…
Cancel
Save