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 8 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
18 changes: 16 additions & 2 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1113,10 +1113,16 @@ PODS:
- React-jsi (= 0.73.5)
- React-logger (= 0.73.5)
- React-perflogger (= 0.73.5)
- RNCAsyncStorage (1.22.2):
- React-Core
- RNScreens (3.29.0):
- glog
- RCT-Folly (= 2022.05.16.00)
- React-Core
- RNVectorIcons (10.0.3):
- glog
- RCT-Folly (= 2022.05.16.00)
- React-Core
- SocketRocket (0.6.1)
- VisionCamera (3.9.0):
- React
Expand Down Expand Up @@ -1198,7 +1204,9 @@ DEPENDENCIES:
- React-runtimescheduler (from `../node_modules/react-native/ReactCommon/react/renderer/runtimescheduler`)
- React-utils (from `../node_modules/react-native/ReactCommon/react/utils`)
- ReactCommon/turbomodule/core (from `../node_modules/react-native/ReactCommon`)
- "RNCAsyncStorage (from `../node_modules/@react-native-async-storage/async-storage`)"
- RNScreens (from `../node_modules/react-native-screens`)
- RNVectorIcons (from `../node_modules/react-native-vector-icons`)
- VisionCamera (from `../node_modules/react-native-vision-camera`)
- Yoga (from `../node_modules/react-native/ReactCommon/yoga`)

Expand Down Expand Up @@ -1316,8 +1324,12 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native/ReactCommon/react/utils"
ReactCommon:
:path: "../node_modules/react-native/ReactCommon"
RNCAsyncStorage:
:path: "../node_modules/@react-native-async-storage/async-storage"
RNScreens:
:path: "../node_modules/react-native-screens"
RNVectorIcons:
:path: "../node_modules/react-native-vector-icons"
VisionCamera:
:path: "../node_modules/react-native-vision-camera"
Yoga:
Expand Down Expand Up @@ -1384,11 +1396,13 @@ SPEC CHECKSUMS:
React-runtimescheduler: 814b644a5f456c7df1fba7bcd9914707152527c6
React-utils: 987a4526a2fc0acdfaf87888adfe0bf9d0452066
ReactCommon: 2947b0bffd82ea0e58ca7928881152d4c6dae9af
RNCAsyncStorage: 014a78b2cc8cc107c9e92ee428dc0c1ac3223416
RNScreens: 17e2f657f1b09a71ec3c821368a04acbb7ebcb46
RNVectorIcons: 73ab573085f65a572d3b6233e68996d4707fd505
SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17
VisionCamera: 7a5c87805b13adaaa557132b44879ed1e1e39786
Yoga: a716eea57d0d3430219c0a5a233e1e93ee931eb7
Yoga: 9e6a04eacbd94f97d94577017e9f23b3ab41cf6c

PODFILE CHECKSUM: 0324d2f1bead3c67e34ad5270355479295c48a2e

COCOAPODS: 1.15.0
COCOAPODS: 1.15.2
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
74 changes: 55 additions & 19 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,26 @@
import React, {useEffect} from 'react';
import {NavigationContainer} from '@react-navigation/native';
import {SafeAreaView, StyleSheet, Text} from 'react-native';

Check failure

Code scanning / ESLint

disallow unused variables Error

'SafeAreaView' is defined but never used.

Check failure

Code scanning / ESLint

Disallow unused variables Error

'SafeAreaView' is defined but never used.

Check failure

Code scanning / ESLint

disallow unused variables Error

'StyleSheet' is defined but never used.

Check failure

Code scanning / ESLint

Disallow unused variables Error

'StyleSheet' is defined but never used.

Check failure

Code scanning / ESLint

disallow unused variables Error

'Text' is defined but never used.

Check failure

Code scanning / ESLint

Disallow unused variables Error

'Text' is defined but never used.
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';

Check failure

Code scanning / ESLint

disallow unused variables Error

'store' is defined but never used.

Check failure

Code scanning / ESLint

Disallow unused variables Error

'store' is defined but never used.

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 =

Check failure

Code scanning / ESLint

disallow unused variables Error

'renderIcon' is assigned a value but never used.

Check failure

Code scanning / ESLint

Disallow unused variables Error

'renderIcon' is assigned a value but never used.
name =>
({color, size}) =>
<Icon name={name} color={color} size={size} />;
Dismissed Show dismissed Hide dismissed

useEffect(() => {
if (!hasPermission) {
Expand All @@ -17,22 +29,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'),
}}
/>
<Tab.Screen
name="Plate"
component={PlateScreen}
options={{
tabBarIcon: this.renderIcon('food'),
}}
/>
<Tab.Screen
name="QRScan"
component={QRScanScreen}
options={{
tabBarIcon: this.renderIcon('qrcode-scan'),
}}
/>
<Tab.Screen
name="Search"
component={SearchScreen}
options={{
tabBarIcon: this.renderIcon('magnify'),
}}
/>
<Tab.Screen
name="Account"
component={AccountScreen}
options={{
tabBarIcon: this.renderIcon('account-circle'),
}}
/>
</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