Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Feature/spike/global page #6

Merged
merged 9 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 37 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"react-native": "^0.73.5",
"react-native-logs": "^5.1.0",
"react-native-safe-area-context": "^4.9.0",
"react-native-screens": "^3.29.0"
"react-native-screens": "^3.29.0",
"react-native-vector-icons": "^10.0.3"
},
"devDependencies": {
"@babel/core": "^7.23.9",
Expand All @@ -27,6 +28,7 @@
"@react-native/metro-config": "0.74.1",
"@react-native/typescript-config": "0.74.1",
"@types/react": "^18.2.60",
"@types/react-native-vector-icons": "^6.4.18",
"@types/react-test-renderer": "^18.0.7",
"babel-jest": "^29.7.0",
"eslint": "^8.57.0",
Expand Down
71 changes: 59 additions & 12 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,68 @@
import React from 'react';
import {SafeAreaView, StyleSheet, Text} from 'react-native';
import { NavigationContainer } from '@react-navigation/native';

Check failure

Code scanning / ESLint

Replace ·NavigationContainer· with NavigationContainer Error

Replace ·NavigationContainer· with NavigationContainer
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';

Check failure

Code scanning / ESLint

Replace ·createBottomTabNavigator· with createBottomTabNavigator Error

Replace ·createBottomTabNavigator· with createBottomTabNavigator
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';

// import {NavigationContainer} from '@react-navigation/native';
const Tab = createBottomTabNavigator();

const LastScanScreen = () => null;
const PlateScreen = () => null;
const QRScanScreen = () => null;
const SearchScreen = () => null;
const AccountScreen = () => null;
Thomlam marked this conversation as resolved.
Show resolved Hide resolved

const App = () => {
return (
<SafeAreaView style={styles.screen}>
<Text>App</Text>
</SafeAreaView>
<NavigationContainer>
<Tab.Navigator>
<Tab.Screen
name="Veggies"
component={LastScanScreen}
options={{
tabBarIcon: ({ color, size }) => (

Check failure

Code scanning / ESLint

Replace ·color,·size· with color,·size Error

Replace ·color,·size· with color,·size
<Icon name="carrot" color={color} size={size} />
),
}}
/>
<Tab.Screen
name="Plate"
component={PlateScreen}
options={{
tabBarIcon: ({ color, size }) => (

Check failure

Code scanning / ESLint

Replace ·color,·size· with color,·size Error

Replace ·color,·size· with color,·size
<Icon name="food" color={color} size={size} />
),
}}
/>
<Tab.Screen
name="QRScan"
component={QRScanScreen}
options={{
tabBarIcon: ({ color, size }) => (

Check failure

Code scanning / ESLint

Replace ·color,·size· with color,·size Error

Replace ·color,·size· with color,·size
<Icon name="qrcode-scan" color={color} size={size} />
),
}}
/>
<Tab.Screen
name="Search"
component={SearchScreen}
options={{
tabBarIcon: ({ color, size }) => (

Check failure

Code scanning / ESLint

Replace ·color,·size· with color,·size Error

Replace ·color,·size· with color,·size
<Icon name="magnify" color={color} size={size} />
),
}}
/>
<Tab.Screen
name="Account"
component={AccountScreen}
options={{
tabBarIcon: ({ color, size }) => (

Check failure

Code scanning / ESLint

Replace ·color,·size· with color,·size Error

Replace ·color,·size· with color,·size
<Icon name="account-circle" color={color} size={size} />
),
}}
/>
</Tab.Navigator>
</NavigationContainer>
);
};

const styles = StyleSheet.create({
screen: {
flex: 1,
backgroundColor: 'white',
},
});

export default App;
39 changes: 39 additions & 0 deletions src/MockApiComponent.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import React from 'react';
import { SafeAreaView, StyleSheet, ScrollView } from 'react-native';

Check failure

Code scanning / ESLint

Replace ·SafeAreaView,·StyleSheet,·ScrollView· with SafeAreaView,·StyleSheet,·ScrollView Error

Replace ·SafeAreaView,·StyleSheet,·ScrollView· with SafeAreaView,·StyleSheet,·ScrollView
import NutritionInfo from './NutritionInfo';

Check failure

Code scanning / ESLint

Delete · Error

Delete ·

const fakeApiData = {
product_name: "Ourson Chocolat",

Check failure

Code scanning / ESLint

Replace "Ourson·Chocolat" with 'Ourson·Chocolat' Error

Replace "Ourson·Chocolat" with 'Ourson·Chocolat'
ingredients_text: "Cacao, sucre, lait",

Check failure

Code scanning / ESLint

Replace "Cacao,·sucre,·lait" with 'Cacao,·sucre,·lait' Error

Replace "Cacao,·sucre,·lait" with 'Cacao,·sucre,·lait'
nutriments: {
carbohydrates: 54,
proteins: 7,
fat: 30,
sugars: 100,
salt: 0.2,
},
ecoscore_score: "75",

Check failure

Code scanning / ESLint

Replace "75" with '75' Error

Replace "75" with '75'
nutriscore_grade: "B",

Check failure

Code scanning / ESLint

Replace "B" with 'B' Error

Replace "B" with 'B'
};
Loule95450 marked this conversation as resolved.
Show resolved Hide resolved

const App = () => {
return (
<SafeAreaView style={styles.screen}>
<ScrollView contentContainerStyle={styles.content}>
<NutritionInfo data={fakeApiData} />
</ScrollView>
</SafeAreaView>
);
};

const styles = StyleSheet.create({
screen: {
flex: 1,
backgroundColor: 'white',
},
content: {
padding: 20,
},
});

export default App;
48 changes: 48 additions & 0 deletions src/NutritionInfo.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import React from 'react';
import { View, Text, StyleSheet } from 'react-native';

Check failure

Code scanning / ESLint

Replace ·View,·Text,·StyleSheet· with View,·Text,·StyleSheet Error

Replace ·View,·Text,·StyleSheet· with View,·Text,·StyleSheet

const NutritionInfo = ({ data}) => {

Check failure

Code scanning / ESLint

Delete · Error

Delete ·
const { product_name, ingredients_text, nutriments, ecoscore_score, nutriscore_grade } = data;

Check failure

Code scanning / ESLint

Replace ·product_name,·ingredients_text,·nutriments,·ecoscore_score,·nutriscore_grade with ⏎····product_name,⏎····ingredients_text,⏎····nutriments,⏎····ecoscore_score,⏎····nutriscore_grade,⏎· Error

Replace ·product\_name,·ingredients\_text,·nutriments,·ecoscore\_score,·nutriscore\_grade with ⏎····product\_name,⏎····ingredients\_text,⏎····nutriments,⏎····ecoscore\_score,⏎····nutriscore\_grade,⏎·

return (
<View style={styles.container}>
<Text style={styles.title}>{product_name}</Text>
<Text style={styles.subtitle}>Ingrédients: {ingredients_text}</Text>
<View style={styles.section}>
<Text style={styles.sectionTitle}>Informations Nutritionnelles:</Text>
<Text>Carbohydrates: {nutriments.carbohydrates}g</Text>
<Text>Protéines: {nutriments.proteins}g</Text>
<Text>Graisses: {nutriments.fat}g</Text>
<Text>Sucres: {nutriments.sugars}g</Text>
<Text>Sel: {nutriments.salt}g</Text>
</View>
<View style={styles.section}>
<Text style={styles.sectionTitle}>Scores:</Text>
<Text>Eco-Score: {ecoscore_score}</Text>
<Text>Nutri-Score: {nutriscore_grade}</Text>
</View>
</View>
);
};

const styles = StyleSheet.create({
container: {
padding: 20,
},
title: {
fontSize: 18,
fontWeight: 'bold',
},
subtitle: {
fontSize: 14,
marginVertical: 10,
},
section: {
marginVertical: 10,
},
sectionTitle: {
fontWeight: 'bold',
},
});

export default NutritionInfo;
Loading
Loading