Skip to content

Commit

Permalink
add connexion with back end
Browse files Browse the repository at this point in the history
  • Loading branch information
asmaElouali committed Jul 18, 2024
1 parent 2563918 commit bfd8c7f
Show file tree
Hide file tree
Showing 20 changed files with 576 additions and 59 deletions.
50 changes: 45 additions & 5 deletions App.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { Component, useEffect, useState } from "react";
import React, { Component, useCallback, useContext, useEffect, useState } from "react";
import { View, Text, StyleSheet, Image, TouchableOpacity, Alert } from "react-native";
import { global_styles } from './src/style/globalstyle';
//import DinningTable from "./screens/DinningTable";
Expand All @@ -25,6 +25,9 @@ import HeaderBar from "./src/components/HeaderBar";
import Scanner from "./src/screens/Scanner";


import { ThemeContext } from './src/context/AuthContext';
import * as Keychain from 'react-native-keychain';


/*const Stack = createNativeStackNavigator();
export default class App extends Component {
Expand Down Expand Up @@ -55,10 +58,47 @@ export default class App extends Component {
}
}*/
/*const App = () => {
// console.log("Globale data", MenuData[0].subcategories[0].items);
return (
<Scanner/>
);
const authContext = useContext(ThemeContext);
const [status, setStatus] = useState('loading');
const loadJWT = useCallback(async () => {
try {
const value = await Keychain.getGenericPassword();
if (value) {
const jwt = JSON.parse(value.password);
authContext?.setAuthState({
accessToken: jwt.accessToken || null,
refreshToken: jwt.refreshToken || null,
authenticated: jwt.accessToken !== null,
});
setStatus('success');
// Continue with your code using jwt
} else {
// Handle the case where no password was found
console.error("No password found");
// You can also set a default value for jwt or handle this scenario as needed
}
} catch (error) {
setStatus('error');
console.log('Keychain Error: ${error.message}');
authContext?.setAuthState({
accessToken: null,
refreshToken: null,
authenticated: false,
});
}
}, []);
useEffect(() => {
loadJWT();
}, [loadJWT]);
if (authContext?.authState?.authenticated == false) {
return <SignInScreen />
} else {
return <Passcode />
}
};
export default App;*/
Expand Down
3 changes: 2 additions & 1 deletion android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:allowBackup="false"
android:theme="@style/AppTheme">
android:theme="@style/AppTheme"
android:usesCleartextTraffic="true">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
Expand Down
Binary file added android/app/src/main/assets/fonts/Feather.ttf
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions android/link-assets-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@
"path": "src/assets/fonts/app_icons.ttf",
"sha1": "18e5fe2f93c853bbb495975f04df56438d595de5"
},
{
"path": "src/assets/fonts/Feather.ttf",
"sha1": "e6604258b1ced5efd51360875d782fca65381d47"
},
{
"path": "src/assets/fonts/FontAwesome.ttf",
"sha1": "13b1eab65a983c7a73bc7997c479d66943f7c6cb"
},
{
"path": "src/assets/fonts/Ionicons.ttf",
"sha1": "86e07c3d974eb09099e6e5a9b3b8310303cf0feb"
Expand Down Expand Up @@ -32,6 +40,14 @@
{
"path": "src/assets/images/salade/saladfile.png",
"sha1": "f701b92eb6f2c55a4a7a4d296a69dd15ebc654db"
},
{
"path": "src/assets/images/scanner/flashlight_on.png",
"sha1": "1c1910e713779d91d36498fc11aba6bebee61381"
},
{
"path": "src/assets/images/scanner/torch_off.png",
"sha1": "95f15e4cebbde6166f091f3d5c3a7a1710e63b07"
}
]
}
14 changes: 13 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,17 @@
import {AppRegistry} from 'react-native';
import App from './App';
import {name as appName} from './app.json';
import { AuthProvider } from './src/context/AuthContext';
import {AxiosProvider} from './src/context/AxiosProvider';
import React from 'react';

AppRegistry.registerComponent(appName, () => App);
const Root = ()=>{
return(
<AuthProvider>
<AxiosProvider>
<App />
</AxiosProvider>
</AuthProvider>
)
}
AppRegistry.registerComponent(appName, () => Root);
16 changes: 16 additions & 0 deletions ios/link-assets-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@
"path": "src/assets/fonts/app_icons.ttf",
"sha1": "18e5fe2f93c853bbb495975f04df56438d595de5"
},
{
"path": "src/assets/fonts/Feather.ttf",
"sha1": "e6604258b1ced5efd51360875d782fca65381d47"
},
{
"path": "src/assets/fonts/FontAwesome.ttf",
"sha1": "13b1eab65a983c7a73bc7997c479d66943f7c6cb"
},
{
"path": "src/assets/fonts/Ionicons.ttf",
"sha1": "86e07c3d974eb09099e6e5a9b3b8310303cf0feb"
Expand Down Expand Up @@ -32,6 +40,14 @@
{
"path": "src/assets/images/salade/saladfile.png",
"sha1": "f701b92eb6f2c55a4a7a4d296a69dd15ebc654db"
},
{
"path": "src/assets/images/scanner/flashlight_on.png",
"sha1": "1c1910e713779d91d36498fc11aba6bebee61381"
},
{
"path": "src/assets/images/scanner/torch_off.png",
"sha1": "95f15e4cebbde6166f091f3d5c3a7a1710e63b07"
}
]
}
16 changes: 16 additions & 0 deletions ios/restaurantproject.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
7A9F82F761824C999D299AA5 /* amazonpay.png in Resources */ = {isa = PBXBuildFile; fileRef = 354CFF0B11474E77BCCC81C8 /* amazonpay.png */; };
920137035CAC48788E48A894 /* applepay.png in Resources */ = {isa = PBXBuildFile; fileRef = 8EF52289722944CFAFE34170 /* applepay.png */; };
32B1E09698F04FAE87B675CD /* gpay.png in Resources */ = {isa = PBXBuildFile; fileRef = E34C3B635C7246D5B0E9255D /* gpay.png */; };
92E816C24DCA424CA079D0FE /* Feather.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 8D27D1608E354E69BF942D1E /* Feather.ttf */; };
0634B443108249618195A46F /* FontAwesome.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 02F151B2A3D44B2E9841CA50 /* FontAwesome.ttf */; };
4471B80721DC47408F060408 /* flashlight_on.png in Resources */ = {isa = PBXBuildFile; fileRef = 72B31B791CD34279A0A9277F /* flashlight_on.png */; };
6786218173944E22B7C9CF86 /* torch_off.png in Resources */ = {isa = PBXBuildFile; fileRef = B074E8AD34D841CE8EE4C13E /* torch_off.png */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -61,6 +65,10 @@
354CFF0B11474E77BCCC81C8 /* amazonpay.png */ = {isa = PBXFileReference; name = "amazonpay.png"; path = "../src/assets/images/paymentMode/amazonpay.png"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = unknown; explicitFileType = undefined; includeInIndex = 0; };
8EF52289722944CFAFE34170 /* applepay.png */ = {isa = PBXFileReference; name = "applepay.png"; path = "../src/assets/images/paymentMode/applepay.png"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = unknown; explicitFileType = undefined; includeInIndex = 0; };
E34C3B635C7246D5B0E9255D /* gpay.png */ = {isa = PBXFileReference; name = "gpay.png"; path = "../src/assets/images/paymentMode/gpay.png"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = unknown; explicitFileType = undefined; includeInIndex = 0; };
8D27D1608E354E69BF942D1E /* Feather.ttf */ = {isa = PBXFileReference; name = "Feather.ttf"; path = "../src/assets/fonts/Feather.ttf"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = unknown; explicitFileType = undefined; includeInIndex = 0; };
02F151B2A3D44B2E9841CA50 /* FontAwesome.ttf */ = {isa = PBXFileReference; name = "FontAwesome.ttf"; path = "../src/assets/fonts/FontAwesome.ttf"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = unknown; explicitFileType = undefined; includeInIndex = 0; };
72B31B791CD34279A0A9277F /* flashlight_on.png */ = {isa = PBXFileReference; name = "flashlight_on.png"; path = "../src/assets/images/scanner/flashlight_on.png"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = unknown; explicitFileType = undefined; includeInIndex = 0; };
B074E8AD34D841CE8EE4C13E /* torch_off.png */ = {isa = PBXFileReference; name = "torch_off.png"; path = "../src/assets/images/scanner/torch_off.png"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = unknown; explicitFileType = undefined; includeInIndex = 0; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -178,6 +186,10 @@
354CFF0B11474E77BCCC81C8 /* amazonpay.png */,
8EF52289722944CFAFE34170 /* applepay.png */,
E34C3B635C7246D5B0E9255D /* gpay.png */,
8D27D1608E354E69BF942D1E /* Feather.ttf */,
02F151B2A3D44B2E9841CA50 /* FontAwesome.ttf */,
72B31B791CD34279A0A9277F /* flashlight_on.png */,
B074E8AD34D841CE8EE4C13E /* torch_off.png */,
);
name = Resources;
sourceTree = "<group>";
Expand Down Expand Up @@ -286,6 +298,10 @@
7A9F82F761824C999D299AA5 /* amazonpay.png in Resources */,
920137035CAC48788E48A894 /* applepay.png in Resources */,
32B1E09698F04FAE87B675CD /* gpay.png in Resources */,
92E816C24DCA424CA079D0FE /* Feather.ttf in Resources */,
0634B443108249618195A46F /* FontAwesome.ttf in Resources */,
4471B80721DC47408F060408 /* flashlight_on.png in Resources */,
6786218173944E22B7C9CF86 /* torch_off.png in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
2 changes: 2 additions & 0 deletions ios/restaurantproject/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@
<array>
<string>app_icons.ttf</string>
<string>Ionicons.ttf</string>
<string>Feather.ttf</string>
<string>FontAwesome.ttf</string>
</array>
</dict>
</plist>
Loading

0 comments on commit bfd8c7f

Please sign in to comment.