forked from vergnet/application-amicale
Merge branch 'bare' of https://git.etud.insa-toulouse.fr/vergnet/application-amicale into bare
This commit is contained in:
commit
e1014a173e
22 changed files with 78 additions and 144 deletions
5
App.js
5
App.js
|
@ -60,7 +60,6 @@ export default class App extends React.Component<Props, State> {
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
LocaleManager.initTranslations();
|
LocaleManager.initTranslations();
|
||||||
// SplashScreen.preventAutoHide();
|
|
||||||
this.navigatorRef = React.createRef();
|
this.navigatorRef = React.createRef();
|
||||||
this.defaultHomeRoute = null;
|
this.defaultHomeRoute = null;
|
||||||
this.defaultHomeData = {};
|
this.defaultHomeData = {};
|
||||||
|
@ -71,8 +70,7 @@ export default class App extends React.Component<Props, State> {
|
||||||
this.loadAssetsAsync().then(() => {
|
this.loadAssetsAsync().then(() => {
|
||||||
this.onLoadFinished();
|
this.onLoadFinished();
|
||||||
});
|
});
|
||||||
// console.log(Linking.makeUrl('path/into/app', { hello: 'world', goodbye: 'now' }))
|
console.log("USING HERMES:" + global.HermesInternal !== null);
|
||||||
console.log(global.HermesInternal !== null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -176,6 +174,7 @@ export default class App extends React.Component<Props, State> {
|
||||||
showUpdate: this.storageManager.preferences.updateNumber.current !== Update.number.toString(),
|
showUpdate: this.storageManager.preferences.updateNumber.current !== Update.number.toString(),
|
||||||
showAprilFools: AprilFoolsManager.getInstance().isAprilFoolsEnabled() && this.storageManager.preferences.showAprilFoolsStart.current === '1',
|
showAprilFools: AprilFoolsManager.getInstance().isAprilFoolsEnabled() && this.storageManager.preferences.showAprilFoolsStart.current === '1',
|
||||||
});
|
});
|
||||||
|
console.log('hiding splash');
|
||||||
SplashScreen.hide();
|
SplashScreen.hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
7
__mocks__/react-native-keychain/index.js
vendored
Normal file
7
__mocks__/react-native-keychain/index.js
vendored
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
const keychainMock = {
|
||||||
|
SECURITY_LEVEL_ANY: "MOCK_SECURITY_LEVEL_ANY",
|
||||||
|
SECURITY_LEVEL_SECURE_SOFTWARE: "MOCK_SECURITY_LEVEL_SECURE_SOFTWARE",
|
||||||
|
SECURITY_LEVEL_SECURE_HARDWARE: "MOCK_SECURITY_LEVEL_SECURE_HARDWARE",
|
||||||
|
}
|
||||||
|
|
||||||
|
export default keychainMock;
|
|
@ -1,7 +1,8 @@
|
||||||
|
jest.mock('react-native-keychain');
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import ConnectionManager from "../../src/managers/ConnectionManager";
|
import ConnectionManager from "../../src/managers/ConnectionManager";
|
||||||
import {ERROR_TYPE} from "../../src/utils/WebData";
|
import {ERROR_TYPE} from "../../src/utils/WebData";
|
||||||
import * as SecureStore from 'expo-secure-store';
|
|
||||||
|
|
||||||
let fetch = require('isomorphic-fetch'); // fetch is not implemented in nodeJS but in react-native
|
let fetch = require('isomorphic-fetch'); // fetch is not implemented in nodeJS but in react-native
|
||||||
|
|
||||||
|
@ -25,45 +26,6 @@ test('isLoggedIn no', () => {
|
||||||
return expect(c.isLoggedIn()).toBe(false);
|
return expect(c.isLoggedIn()).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('recoverLogin error crypto', () => {
|
|
||||||
jest.spyOn(SecureStore, 'getItemAsync').mockImplementationOnce(() => {
|
|
||||||
return Promise.reject();
|
|
||||||
});
|
|
||||||
return expect(c.recoverLogin()).rejects.toBe(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('recoverLogin success crypto', () => {
|
|
||||||
jest.spyOn(SecureStore, 'getItemAsync').mockImplementationOnce(() => {
|
|
||||||
return Promise.resolve('token1');
|
|
||||||
});
|
|
||||||
return expect(c.recoverLogin()).resolves.toBe('token1');
|
|
||||||
});
|
|
||||||
|
|
||||||
test('saveLogin success', () => {
|
|
||||||
jest.spyOn(SecureStore, 'setItemAsync').mockImplementationOnce(() => {
|
|
||||||
return Promise.resolve();
|
|
||||||
});
|
|
||||||
return expect(c.saveLogin('email', 'token2')).resolves.toBeTruthy();
|
|
||||||
});
|
|
||||||
|
|
||||||
test('saveLogin error', () => {
|
|
||||||
jest.spyOn(SecureStore, 'setItemAsync').mockImplementationOnce(() => {
|
|
||||||
return Promise.reject();
|
|
||||||
});
|
|
||||||
return expect(c.saveLogin('email', 'token3')).rejects.toBeFalsy();
|
|
||||||
});
|
|
||||||
|
|
||||||
test('recoverLogin error crypto with saved token', () => {
|
|
||||||
jest.spyOn(SecureStore, 'getItemAsync').mockImplementationOnce(() => {
|
|
||||||
return Promise.reject();
|
|
||||||
});
|
|
||||||
return expect(c.recoverLogin()).resolves.toBe('token2');
|
|
||||||
});
|
|
||||||
|
|
||||||
test('recoverLogin success saved', () => {
|
|
||||||
return expect(c.recoverLogin()).resolves.toBe('token2');
|
|
||||||
});
|
|
||||||
|
|
||||||
test("isConnectionResponseValid", () => {
|
test("isConnectionResponseValid", () => {
|
||||||
let json = {
|
let json = {
|
||||||
error: 0,
|
error: 0,
|
||||||
|
|
|
@ -1,24 +1,9 @@
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="fr.amicaleinsat.application">
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="fr.amicaleinsat.application">
|
||||||
<uses-permission android:name="android.permission.INTERNET"/>
|
<uses-permission android:name="android.permission.INTERNET"/>
|
||||||
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
|
|
||||||
<uses-permission android:name="android.permission.MANAGE_DOCUMENTS"/>
|
|
||||||
<uses-permission android:name="android.permission.READ_INTERNAL_STORAGE"/>
|
|
||||||
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
|
|
||||||
<uses-permission android:name="android.permission.USE_FINGERPRINT"/>
|
|
||||||
<uses-permission android:name="android.permission.VIBRATE"/>
|
|
||||||
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>
|
|
||||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
|
|
||||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
|
|
||||||
<uses-permission android:name="android.permission.CAMERA" />
|
<uses-permission android:name="android.permission.CAMERA" />
|
||||||
<uses-permission android:name="android.permission.READ_CONTACTS"/>
|
<uses-permission android:name="android.permission.VIBRATE"/>
|
||||||
<uses-permission android:name="android.permission.READ_CALENDAR"/>
|
<uses-permission android:name="android.permission.READ_INTERNAL_STORAGE"/>
|
||||||
<uses-permission android:name="android.permission.WRITE_CALENDAR"/>
|
|
||||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
|
|
||||||
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
|
|
||||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
|
||||||
<uses-permission android:name="android.permission.WRITE_SETTINGS"/>
|
|
||||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
|
|
||||||
<uses-permission android:name="android.permission.WAKE_LOCK"/>
|
|
||||||
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"/>
|
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"/>
|
||||||
<application android:name=".MainApplication" android:label="@string/app_name" android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round" android:allowBackup="false" android:theme="@style/AppTheme">
|
<application android:name=".MainApplication" android:label="@string/app_name" android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round" android:allowBackup="false" android:theme="@style/AppTheme">
|
||||||
<meta-data android:name="com.facebook.sdk.AutoInitEnabled" android:value="false"/>
|
<meta-data android:name="com.facebook.sdk.AutoInitEnabled" android:value="false"/>
|
||||||
|
|
|
@ -16,10 +16,8 @@ public class BasePackageList {
|
||||||
new expo.modules.imageloader.ImageLoaderPackage(),
|
new expo.modules.imageloader.ImageLoaderPackage(),
|
||||||
new expo.modules.keepawake.KeepAwakePackage(),
|
new expo.modules.keepawake.KeepAwakePackage(),
|
||||||
new expo.modules.lineargradient.LinearGradientPackage(),
|
new expo.modules.lineargradient.LinearGradientPackage(),
|
||||||
new expo.modules.localization.LocalizationPackage(),
|
|
||||||
new expo.modules.location.LocationPackage(),
|
new expo.modules.location.LocationPackage(),
|
||||||
new expo.modules.permissions.PermissionsPackage(),
|
new expo.modules.permissions.PermissionsPackage(),
|
||||||
new expo.modules.securestore.SecureStorePackage(),
|
|
||||||
new expo.modules.sqlite.SQLitePackage(),
|
new expo.modules.sqlite.SQLitePackage(),
|
||||||
new expo.modules.webbrowser.WebBrowserPackage()
|
new expo.modules.webbrowser.WebBrowserPackage()
|
||||||
);
|
);
|
||||||
|
|
|
@ -16,5 +16,3 @@ echo "Installing dependencies..."
|
||||||
npm install
|
npm install
|
||||||
echo -e "Done\n"
|
echo -e "Done\n"
|
||||||
|
|
||||||
echo "Starting expo with clear cache..."
|
|
||||||
expo r -c
|
|
||||||
|
|
|
@ -52,28 +52,8 @@
|
||||||
</dict>
|
</dict>
|
||||||
</dict>
|
</dict>
|
||||||
</dict>
|
</dict>
|
||||||
<key>NSCalendarsUsageDescription</key>
|
|
||||||
<string>Allow Campus to access your calendar</string>
|
|
||||||
<key>NSCameraUsageDescription</key>
|
<key>NSCameraUsageDescription</key>
|
||||||
<string>Allow Campus to use the camera</string>
|
<string>Allow Campus to use the camera</string>
|
||||||
<key>NSContactsUsageDescription</key>
|
|
||||||
<string>Allow Campus experiences to access your contacts</string>
|
|
||||||
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
|
|
||||||
<string>Allow Campus to use your location</string>
|
|
||||||
<key>NSLocationAlwaysUsageDescription</key>
|
|
||||||
<string>Allow Campus to use your location</string>
|
|
||||||
<key>NSLocationWhenInUseUsageDescription</key>
|
|
||||||
<string>Allow Campus to use your location</string>
|
|
||||||
<key>NSMicrophoneUsageDescription</key>
|
|
||||||
<string>Allow Campus to access your microphone</string>
|
|
||||||
<key>NSMotionUsageDescription</key>
|
|
||||||
<string>Allow Campus to access your device's accelerometer</string>
|
|
||||||
<key>NSPhotoLibraryAddUsageDescription</key>
|
|
||||||
<string>Give Campus periences permission to save photos</string>
|
|
||||||
<key>NSPhotoLibraryUsageDescription</key>
|
|
||||||
<string>Give Campus periences permission to access your photos</string>
|
|
||||||
<key>NSRemindersUsageDescription</key>
|
|
||||||
<string>Allow Campus to access your reminders</string>
|
|
||||||
<key>UILaunchStoryboardName</key>
|
<key>UILaunchStoryboardName</key>
|
||||||
<string>LaunchScreen</string>
|
<string>LaunchScreen</string>
|
||||||
<key>UIRequiredDeviceCapabilities</key>
|
<key>UIRequiredDeviceCapabilities</key>
|
||||||
|
|
|
@ -44,4 +44,10 @@ target 'Campus' do
|
||||||
# react-native-cli autolinking
|
# react-native-cli autolinking
|
||||||
use_native_modules!
|
use_native_modules!
|
||||||
|
|
||||||
|
# Permissions
|
||||||
|
permissions_path = '../node_modules/react-native-permissions/ios'
|
||||||
|
|
||||||
|
pod 'Permission-Notifications', :path => "#{permissions_path}/Notifications.podspec"
|
||||||
|
pod 'Permission-Camera', :path => "#{permissions_path}/Camera.podspec"
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -27,10 +27,6 @@
|
||||||
"expo": "^37.0.0",
|
"expo": "^37.0.0",
|
||||||
"expo-barcode-scanner": "~8.1.0",
|
"expo-barcode-scanner": "~8.1.0",
|
||||||
"expo-camera": "latest",
|
"expo-camera": "latest",
|
||||||
"expo-linear-gradient": "~8.1.0",
|
|
||||||
"expo-localization": "~8.1.0",
|
|
||||||
"expo-permissions": "~8.1.0",
|
|
||||||
"expo-secure-store": "~8.1.0",
|
|
||||||
"i18n-js": "^3.3.0",
|
"i18n-js": "^3.3.0",
|
||||||
"react": "~16.9.0",
|
"react": "~16.9.0",
|
||||||
"react-dom": "16.9.0",
|
"react-dom": "16.9.0",
|
||||||
|
@ -43,8 +39,12 @@
|
||||||
"react-native-collapsible": "^1.5.2",
|
"react-native-collapsible": "^1.5.2",
|
||||||
"react-native-gesture-handler": "~1.6.0",
|
"react-native-gesture-handler": "~1.6.0",
|
||||||
"react-native-image-modal": "^1.0.6",
|
"react-native-image-modal": "^1.0.6",
|
||||||
|
"react-native-keychain": "^6.0.0",
|
||||||
|
"react-native-linear-gradient": "^2.5.6",
|
||||||
|
"react-native-localize": "^1.4.0",
|
||||||
"react-native-modalize": "^1.3.6",
|
"react-native-modalize": "^1.3.6",
|
||||||
"react-native-paper": "^3.8.0",
|
"react-native-paper": "^3.8.0",
|
||||||
|
"react-native-permissions": "^2.1.3",
|
||||||
"react-native-reanimated": "~1.7.0",
|
"react-native-reanimated": "~1.7.0",
|
||||||
"react-native-render-html": "^4.1.2",
|
"react-native-render-html": "^4.1.2",
|
||||||
"react-native-safe-area-context": "0.7.3",
|
"react-native-safe-area-context": "0.7.3",
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import {Text, withTheme} from 'react-native-paper';
|
import {Text, withTheme} from 'react-native-paper';
|
||||||
import HTML from "react-native-render-html";
|
import HTML from "react-native-render-html";
|
||||||
import {Linking} from "expo";
|
import {Linking} from "react-native";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
theme: Object,
|
theme: Object,
|
||||||
|
@ -18,7 +18,6 @@ class CustomHTML extends React.Component<Props> {
|
||||||
};
|
};
|
||||||
|
|
||||||
getBasicText = (htmlAttribs, children, convertedCSSStyles, passProps) => {
|
getBasicText = (htmlAttribs, children, convertedCSSStyles, passProps) => {
|
||||||
// console.log(convertedCSSStyles);
|
|
||||||
return <Text {...passProps}>{children}</Text>;
|
return <Text {...passProps}>{children}</Text>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
// @flow
|
// @flow
|
||||||
|
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import {LinearGradient} from "expo-linear-gradient";
|
|
||||||
import {Image, Platform, StatusBar, StyleSheet, View} from "react-native";
|
import {Image, Platform, StatusBar, StyleSheet, View} from "react-native";
|
||||||
import {MaterialCommunityIcons} from "@expo/vector-icons";
|
import {MaterialCommunityIcons} from "@expo/vector-icons";
|
||||||
import {Text} from "react-native-paper";
|
import {Text} from "react-native-paper";
|
||||||
|
@ -9,6 +8,7 @@ import i18n from 'i18n-js';
|
||||||
import AppIntroSlider from "react-native-app-intro-slider";
|
import AppIntroSlider from "react-native-app-intro-slider";
|
||||||
import Update from "../../constants/Update";
|
import Update from "../../constants/Update";
|
||||||
import ThemeManager from "../../managers/ThemeManager";
|
import ThemeManager from "../../managers/ThemeManager";
|
||||||
|
import LinearGradient from 'react-native-linear-gradient';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
onDone: Function,
|
onDone: Function,
|
||||||
|
@ -40,49 +40,49 @@ export default class CustomIntroSlider extends React.Component<Props> {
|
||||||
title: i18n.t('intro.slide1.title'),
|
title: i18n.t('intro.slide1.title'),
|
||||||
text: i18n.t('intro.slide1.text'),
|
text: i18n.t('intro.slide1.text'),
|
||||||
image: require('../../../assets/splash.png'),
|
image: require('../../../assets/splash.png'),
|
||||||
colors: ['#e01928', '#be1522'],
|
colors: ['#dc2634', '#be1522'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: '2',
|
key: '2',
|
||||||
title: i18n.t('intro.slide2.title'),
|
title: i18n.t('intro.slide2.title'),
|
||||||
text: i18n.t('intro.slide2.text'),
|
text: i18n.t('intro.slide2.text'),
|
||||||
icon: 'calendar-range',
|
icon: 'calendar-range',
|
||||||
colors: ['#d99e09', '#c28d08'],
|
colors: ['#d99e09', '#9e7205'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: '3',
|
key: '3',
|
||||||
title: i18n.t('intro.slide3.title'),
|
title: i18n.t('intro.slide3.title'),
|
||||||
text: i18n.t('intro.slide3.text'),
|
text: i18n.t('intro.slide3.text'),
|
||||||
icon: 'washing-machine',
|
icon: 'washing-machine',
|
||||||
colors: ['#1fa5ee', '#1c97da'],
|
colors: ['#1fa5ee', '#0976b1'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: '4',
|
key: '4',
|
||||||
title: i18n.t('intro.slide4.title'),
|
title: i18n.t('intro.slide4.title'),
|
||||||
text: i18n.t('intro.slide4.text'),
|
text: i18n.t('intro.slide4.text'),
|
||||||
icon: 'shopping',
|
icon: 'shopping',
|
||||||
colors: ['#ec5904', '#da5204'],
|
colors: ['#ec5904', '#b64300'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: '5',
|
key: '5',
|
||||||
title: i18n.t('intro.slide5.title'),
|
title: i18n.t('intro.slide5.title'),
|
||||||
text: i18n.t('intro.slide5.text'),
|
text: i18n.t('intro.slide5.text'),
|
||||||
icon: 'timetable',
|
icon: 'timetable',
|
||||||
colors: ['#7c33ec', '#732fda'],
|
colors: ['#7c33ec', '#5e11d1'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: '6',
|
key: '6',
|
||||||
title: i18n.t('intro.slide6.title'),
|
title: i18n.t('intro.slide6.title'),
|
||||||
text: i18n.t('intro.slide6.text'),
|
text: i18n.t('intro.slide6.text'),
|
||||||
icon: 'silverware-fork-knife',
|
icon: 'silverware-fork-knife',
|
||||||
colors: ['#ec1213', '#ff372f'],
|
colors: ['#ec1213', '#970902'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: '7',
|
key: '7',
|
||||||
title: i18n.t('intro.slide7.title'),
|
title: i18n.t('intro.slide7.title'),
|
||||||
text: i18n.t('intro.slide7.text'),
|
text: i18n.t('intro.slide7.text'),
|
||||||
icon: 'cogs',
|
icon: 'cogs',
|
||||||
colors: ['#37c13e', '#26852b'],
|
colors: ['#37c13e', '#1a5a1d'],
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
this.updateSlides = [
|
this.updateSlides = [
|
||||||
|
|
|
@ -7,9 +7,8 @@ import ErrorView from "./ErrorView";
|
||||||
import {ERROR_TYPE} from "../../utils/WebData";
|
import {ERROR_TYPE} from "../../utils/WebData";
|
||||||
import MaterialHeaderButtons, {Item} from '../Overrides/CustomHeaderButton';
|
import MaterialHeaderButtons, {Item} from '../Overrides/CustomHeaderButton';
|
||||||
import {HiddenItem} from "react-navigation-header-buttons";
|
import {HiddenItem} from "react-navigation-header-buttons";
|
||||||
import {Linking} from "expo";
|
|
||||||
import i18n from 'i18n-js';
|
import i18n from 'i18n-js';
|
||||||
import {Animated, BackHandler} from "react-native";
|
import {Animated, BackHandler, Linking} from "react-native";
|
||||||
import {withCollapsible} from "../../utils/withCollapsible";
|
import {withCollapsible} from "../../utils/withCollapsible";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// @flow
|
// @flow
|
||||||
|
|
||||||
import * as SecureStore from 'expo-secure-store';
|
import * as Keychain from 'react-native-keychain';
|
||||||
import {apiRequest, ERROR_TYPE, isResponseValid} from "../utils/WebData";
|
import {apiRequest, ERROR_TYPE, isResponseValid} from "../utils/WebData";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -14,7 +14,7 @@ import {apiRequest, ERROR_TYPE, isResponseValid} from "../utils/WebData";
|
||||||
* 500 : SERVER_ERROR -> pb coté serveur
|
* 500 : SERVER_ERROR -> pb coté serveur
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
const SERVER_NAME = "amicale-insat.fr";
|
||||||
const AUTH_PATH = "password";
|
const AUTH_PATH = "password";
|
||||||
|
|
||||||
export default class ConnectionManager {
|
export default class ConnectionManager {
|
||||||
|
@ -60,16 +60,16 @@ export default class ConnectionManager {
|
||||||
if (this.getToken() !== null)
|
if (this.getToken() !== null)
|
||||||
resolve(this.getToken());
|
resolve(this.getToken());
|
||||||
else {
|
else {
|
||||||
SecureStore.getItemAsync('token')
|
Keychain.getInternetCredentials(SERVER_NAME)
|
||||||
.then((token) => {
|
.then((data) => {
|
||||||
this.#token = token;
|
if (data) {
|
||||||
if (token !== null) {
|
this.#token = data.password;
|
||||||
this.onLoginStateChange(true);
|
this.onLoginStateChange(true);
|
||||||
resolve(token);
|
resolve(this.#token);
|
||||||
} else
|
} else
|
||||||
reject(false);
|
reject(false);
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(() => {
|
||||||
reject(false);
|
reject(false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -82,14 +82,14 @@ export default class ConnectionManager {
|
||||||
|
|
||||||
async saveLogin(email: string, token: string) {
|
async saveLogin(email: string, token: string) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
SecureStore.setItemAsync('token', token)
|
Keychain.setInternetCredentials(SERVER_NAME, 'token', token)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.#token = token;
|
this.#token = token;
|
||||||
this.#email = email;
|
this.#email = email;
|
||||||
this.onLoginStateChange(true);
|
this.onLoginStateChange(true);
|
||||||
resolve(true);
|
resolve(true);
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(() => {
|
||||||
reject(false);
|
reject(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -97,13 +97,13 @@ export default class ConnectionManager {
|
||||||
|
|
||||||
async disconnect() {
|
async disconnect() {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
SecureStore.deleteItemAsync('token')
|
Keychain.resetInternetCredentials(SERVER_NAME)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.#token = null;
|
this.#token = null;
|
||||||
this.onLoginStateChange(false);
|
this.onLoginStateChange(false);
|
||||||
resolve(true);
|
resolve(true);
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch(() => {
|
||||||
reject(false);
|
reject(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -143,7 +143,6 @@ export default class ConnectionManager {
|
||||||
async authenticatedRequest(path: string, params: Object) {
|
async authenticatedRequest(path: string, params: Object) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
if (this.getToken() !== null) {
|
if (this.getToken() !== null) {
|
||||||
// console.log(data);
|
|
||||||
let data = {
|
let data = {
|
||||||
token: this.getToken(),
|
token: this.getToken(),
|
||||||
...params
|
...params
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// @flow
|
// @flow
|
||||||
|
|
||||||
import i18n from 'i18n-js';
|
import i18n from 'i18n-js';
|
||||||
import * as Localization from 'expo-localization';
|
import * as RNLocalize from "react-native-localize";
|
||||||
|
|
||||||
import en from '../../translations/en';
|
import en from '../../translations/en';
|
||||||
import fr from '../../translations/fr';
|
import fr from '../../translations/fr';
|
||||||
|
@ -17,10 +17,10 @@ export default class LocaleManager {
|
||||||
static initTranslations() {
|
static initTranslations() {
|
||||||
i18n.fallbacks = true;
|
i18n.fallbacks = true;
|
||||||
i18n.translations = {fr, en};
|
i18n.translations = {fr, en};
|
||||||
i18n.locale = Localization.locale;
|
i18n.locale = RNLocalize.findBestAvailableLanguage(["en", "fr"]).languageTag;
|
||||||
}
|
}
|
||||||
|
|
||||||
static getCurrentLocale() {
|
static getCurrentLocale() {
|
||||||
return Localization.locale;
|
return RNLocalize.findBestAvailableLanguage(["en", "fr"]).languageTag;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
// @flow
|
// @flow
|
||||||
|
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import {Animated, FlatList, Image, View} from 'react-native';
|
import {Animated, FlatList, Image, Linking, View} from 'react-native';
|
||||||
import {Card, List, Text, withTheme} from 'react-native-paper';
|
import {Card, List, Text, withTheme} from 'react-native-paper';
|
||||||
import i18n from 'i18n-js';
|
import i18n from 'i18n-js';
|
||||||
import {Linking} from "expo";
|
|
||||||
import {Collapsible} from "react-navigation-collapsible";
|
import {Collapsible} from "react-navigation-collapsible";
|
||||||
import CustomTabBar from "../../components/Tabbar/CustomTabBar";
|
import CustomTabBar from "../../components/Tabbar/CustomTabBar";
|
||||||
import {withCollapsible} from "../../utils/withCollapsible";
|
import {withCollapsible} from "../../utils/withCollapsible";
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// @flow
|
// @flow
|
||||||
|
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import {ScrollView, View} from 'react-native';
|
import {Linking, ScrollView, View} from 'react-native';
|
||||||
import {Avatar, Button, Card, Chip, Paragraph, withTheme} from 'react-native-paper';
|
import {Avatar, Button, Card, Chip, Paragraph, withTheme} from 'react-native-paper';
|
||||||
import ImageModal from 'react-native-image-modal';
|
import ImageModal from 'react-native-image-modal';
|
||||||
import i18n from "i18n-js";
|
import i18n from "i18n-js";
|
||||||
|
@ -11,7 +11,6 @@ import CustomTabBar from "../../../components/Tabbar/CustomTabBar";
|
||||||
import type {category, club} from "./ClubListScreen";
|
import type {category, club} from "./ClubListScreen";
|
||||||
import type {CustomTheme} from "../../../managers/ThemeManager";
|
import type {CustomTheme} from "../../../managers/ThemeManager";
|
||||||
import {StackNavigationProp} from "@react-navigation/stack";
|
import {StackNavigationProp} from "@react-navigation/stack";
|
||||||
import {Linking} from "expo";
|
|
||||||
import {ERROR_TYPE} from "../../../utils/WebData";
|
import {ERROR_TYPE} from "../../../utils/WebData";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// @flow
|
// @flow
|
||||||
|
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import {Animated, KeyboardAvoidingView, StyleSheet, View} from "react-native";
|
import {Animated, KeyboardAvoidingView, Linking, StyleSheet, View} from "react-native";
|
||||||
import {Avatar, Button, Card, HelperText, Paragraph, TextInput, withTheme} from 'react-native-paper';
|
import {Avatar, Button, Card, HelperText, Paragraph, TextInput, withTheme} from 'react-native-paper';
|
||||||
import ConnectionManager from "../../managers/ConnectionManager";
|
import ConnectionManager from "../../managers/ConnectionManager";
|
||||||
import i18n from 'i18n-js';
|
import i18n from 'i18n-js';
|
||||||
|
@ -10,7 +10,6 @@ import {withCollapsible} from "../../utils/withCollapsible";
|
||||||
import {Collapsible} from "react-navigation-collapsible";
|
import {Collapsible} from "react-navigation-collapsible";
|
||||||
import CustomTabBar from "../../components/Tabbar/CustomTabBar";
|
import CustomTabBar from "../../components/Tabbar/CustomTabBar";
|
||||||
import type {CustomTheme} from "../../managers/ThemeManager";
|
import type {CustomTheme} from "../../managers/ThemeManager";
|
||||||
import {Linking} from "expo";
|
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
navigation: Object,
|
navigation: Object,
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
// @flow
|
// @flow
|
||||||
|
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import {ScrollView, View} from 'react-native';
|
import {Linking, ScrollView, View} from 'react-native';
|
||||||
import {Avatar, Card, Text, withTheme} from 'react-native-paper';
|
import {Avatar, Card, Text, withTheme} from 'react-native-paper';
|
||||||
import ImageModal from 'react-native-image-modal';
|
import ImageModal from 'react-native-image-modal';
|
||||||
import Autolink from "react-native-autolink";
|
import Autolink from "react-native-autolink";
|
||||||
import MaterialHeaderButtons, {Item} from "../../components/Overrides/CustomHeaderButton";
|
import MaterialHeaderButtons, {Item} from "../../components/Overrides/CustomHeaderButton";
|
||||||
import {Linking} from "expo";
|
|
||||||
import CustomTabBar from "../../components/Tabbar/CustomTabBar";
|
import CustomTabBar from "../../components/Tabbar/CustomTabBar";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
// @flow
|
// @flow
|
||||||
|
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import {StyleSheet, View} from "react-native";
|
import {Linking, StyleSheet, View} from "react-native";
|
||||||
import {Button, Text, withTheme} from 'react-native-paper';
|
import {Button, Text, withTheme} from 'react-native-paper';
|
||||||
import {BarCodeScanner} from "expo-barcode-scanner";
|
import {BarCodeScanner} from "expo-barcode-scanner";
|
||||||
import {Camera} from 'expo-camera';
|
import {Camera} from 'expo-camera';
|
||||||
import URLHandler from "../../utils/URLHandler";
|
import URLHandler from "../../utils/URLHandler";
|
||||||
import {Linking} from "expo";
|
|
||||||
import AlertDialog from "../../components/Dialogs/AlertDialog";
|
import AlertDialog from "../../components/Dialogs/AlertDialog";
|
||||||
import i18n from 'i18n-js';
|
import i18n from 'i18n-js';
|
||||||
import CustomTabBar from "../../components/Tabbar/CustomTabBar";
|
import CustomTabBar from "../../components/Tabbar/CustomTabBar";
|
||||||
|
|
|
@ -3,8 +3,7 @@
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import {Avatar, Button, Card, Paragraph, withTheme} from "react-native-paper";
|
import {Avatar, Button, Card, Paragraph, withTheme} from "react-native-paper";
|
||||||
import i18n from "i18n-js";
|
import i18n from "i18n-js";
|
||||||
import {ScrollView} from "react-native";
|
import {Linking, ScrollView} from "react-native";
|
||||||
import {Linking} from "expo";
|
|
||||||
import type {CustomTheme} from "../../managers/ThemeManager";
|
import type {CustomTheme} from "../../managers/ThemeManager";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
|
|
|
@ -228,7 +228,6 @@ class PlanningScreen extends React.Component<Props, State> {
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
// console.log("rendering PlanningScreen");
|
|
||||||
return (
|
return (
|
||||||
<CustomAgenda
|
<CustomAgenda
|
||||||
{...this.props}
|
{...this.props}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// @flow
|
// @flow
|
||||||
|
|
||||||
import * as Permissions from 'expo-permissions';
|
import {checkNotifications, requestNotifications, RESULTS} from 'react-native-permissions';
|
||||||
import {Notifications} from 'expo';
|
import {Notifications} from 'expo';
|
||||||
import AsyncStorageManager from "../managers/AsyncStorageManager";
|
import AsyncStorageManager from "../managers/AsyncStorageManager";
|
||||||
import LocaleManager from "../managers/LocaleManager";
|
import LocaleManager from "../managers/LocaleManager";
|
||||||
|
@ -14,13 +14,22 @@ const EXPO_TOKEN_SERVER = 'https://etud.insa-toulouse.fr/~amicale_app/expo_notif
|
||||||
* @returns {Promise}
|
* @returns {Promise}
|
||||||
*/
|
*/
|
||||||
export async function askPermissions() {
|
export async function askPermissions() {
|
||||||
const {status: existingStatus} = await Permissions.getAsync(Permissions.NOTIFICATIONS);
|
return new Promise(((resolve, reject) => {
|
||||||
let finalStatus = existingStatus;
|
checkNotifications().then(({status, settings}) => {
|
||||||
if (existingStatus !== 'granted') {
|
if (status === RESULTS.GRANTED)
|
||||||
const {status} = await Permissions.askAsync(Permissions.NOTIFICATIONS);
|
resolve();
|
||||||
finalStatus = status;
|
else if (status === RESULTS.BLOCKED)
|
||||||
}
|
reject()
|
||||||
return finalStatus === 'granted';
|
else {
|
||||||
|
requestNotifications().then(({status, settings}) => {
|
||||||
|
if (status === RESULTS.GRANTED)
|
||||||
|
resolve();
|
||||||
|
else
|
||||||
|
reject();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -33,12 +42,12 @@ export async function askPermissions() {
|
||||||
export async function initExpoToken() {
|
export async function initExpoToken() {
|
||||||
let token = AsyncStorageManager.getInstance().preferences.expoToken.current;
|
let token = AsyncStorageManager.getInstance().preferences.expoToken.current;
|
||||||
if (token === '') {
|
if (token === '') {
|
||||||
try {
|
askPermissions().then(() => {
|
||||||
await askPermissions();
|
Notifications.getExpoPushTokenAsync().then((token) => {
|
||||||
let expoToken = await Notifications.getExpoPushTokenAsync();
|
// Save token for instant use later on
|
||||||
// Save token for instant use later on
|
AsyncStorageManager.getInstance().savePref(AsyncStorageManager.getInstance().preferences.expoToken.key, token);
|
||||||
AsyncStorageManager.getInstance().savePref(AsyncStorageManager.getInstance().preferences.expoToken.key, expoToken);
|
});
|
||||||
} catch (e) {}
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue