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 7 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
71 changes: 71 additions & 0 deletions package-lock.json

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

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"android": "react-native run-android",
"ios": "react-native run-ios",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"start": "react-native start",
"test": "jest"
},
Expand All @@ -20,6 +21,7 @@
"react-native-logs": "^5.1.0",
"react-native-safe-area-context": "^4.9.0",
"react-native-screens": "^3.29.0",
"react-native-vector-icons": "^10.0.3",
"react-native-vision-camera": "^3.9.0",
"react-redux": "^9.1.0"
},
Expand All @@ -32,6 +34,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: 52 additions & 19 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
import React, {useEffect} from 'react';
import {NavigationContainer} from '@react-navigation/native';
import {SafeAreaView, StyleSheet, Text} from 'react-native';
import {Provider} from 'react-redux';

// import {NavigationContainer} from '@react-navigation/native';
// import TabNavigator from './components/navigators/TabNavigator.tsx';
import {createBottomTabNavigator} from '@react-navigation/bottom-tabs';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
import {useCameraPermission} from 'react-native-vision-camera';
import {Provider} from 'react-redux';

Check failure

Code scanning / ESLint

disallow unused variables Error

'Provider' is defined but never used.

Check failure

Code scanning / ESLint

Disallow unused variables Error

'Provider' is defined but never used.
import store from './service/redux/store.ts';

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 = () => {
const {hasPermission, requestPermission} = useCameraPermission();
const renderIcon = (name) => ({color, size}) => <Icon name={name} color={color} size={size} />;
Fixed Show fixed Hide fixed
Fixed Show fixed Hide fixed
Fixed Show fixed Hide fixed
Fixed Show fixed Hide fixed

useEffect(() => {
if (!hasPermission) {
Expand All @@ -17,22 +26,46 @@
}, [hasPermission, requestPermission]);

return (
<SafeAreaView style={styles.screen}>
<Provider store={store}>
<Text>App</Text>
{/*<NavigationContainer>*/}
{/* <TabNavigator />*/}
{/*</NavigationContainer>*/}
</Provider>
</SafeAreaView>
<NavigationContainer>
<Tab.Navigator>
<Tab.Screen
name="Veggies"
component={LastScanScreen}
options={{
tabBarIcon: this.renderIcon("carrot"),
Fixed Show fixed Hide fixed
}}
/>
<Tab.Screen
name="Plate"
component={PlateScreen}
options={{
tabBarIcon: this.renderIcon("food"),
Fixed Show fixed Hide fixed
}}
/>
<Tab.Screen
name="QRScan"
component={QRScanScreen}
options={{
tabBarIcon: this.renderIcon("qrcode-scan"),
Fixed Show fixed Hide fixed
}}
/>
<Tab.Screen
name="Search"
component={SearchScreen}
options={{
tabBarIcon: this.renderIcon("magnify"),
Fixed Show fixed Hide fixed
}}
/>
<Tab.Screen
name="Account"
component={AccountScreen}
options={{
tabBarIcon: this.renderIcon("account-circle"),
Fixed Show fixed Hide fixed
}}
/>
</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';
import NutritionInfo from './NutritionInfo';

const fakeApiData = {
product_name: 'Ourson Chocolat',
ingredients_text: 'Cacao, sucre, lait',
nutriments: {
carbohydrates: 54,
proteins: 7,
fat: 30,
sugars: 100,
salt: 0.2,
},
ecoscore_score: '75',
nutriscore_grade: 'B',
};

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;
54 changes: 54 additions & 0 deletions src/NutritionInfo.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import React from 'react';
import {View, Text, StyleSheet} from 'react-native';

const NutritionInfo = ({data}) => {
const {
product_name,
ingredients_text,
nutriments,
ecoscore_score,
nutriscore_grade,
} = data;

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