ilink-world/App.js

461 lines
18 KiB
JavaScript
Raw Normal View History

2019-06-16 13:09:54 +00:00
/**
* Sample React Native App
* https://github.com/facebook/react-native
*
* @format
* @flow
*/
2020-03-20 18:28:22 +00:00
import React, { Component } from 'react';
2020-08-11 09:42:31 +00:00
import { ActionSheetProvider, connectActionSheet } from '@expo/react-native-action-sheet'
import { Platform, StyleSheet, Text, View, YellowBox, AsyncStorage } from 'react-native';
2020-04-17 22:03:04 +00:00
import { createSwitchNavigator, createStackNavigator, createDrawerNavigator, createAppContainer, createBottomTabNavigator, HeaderBackButton } from 'react-navigation';
2020-08-11 09:42:31 +00:00
import OneSignal from 'react-native-onesignal';
import _ from 'lodash';
2019-06-16 13:09:54 +00:00
import Connect from "./screens/login/Connect";
import SplashScreen from "./screens/splashscreen/SplashScreen";
import HelpMenu from "./screens/help/HelpMenu";
import Help from "./screens/help/Help";
import ForgottenPassword from "./screens/login/ForgottenPassword";
import TypeChoiser from "./screens/login/TypeChoiser";
import CreateUserStep2 from "./screens/login/createUserStep2";
import createAccount from "./screens/login/createAccount";
import UpdateInformations from "./screens/account/UpdateInformations";
import UserAccount from "./screens/account/UserAccount";
import ActivateAccount from "./screens/login/ActivateAccount";
import Notifications from "./screens/notifications/Notifications";
import About from "./screens/configurations/About";
import Configurations from "./screens/configurations/Configurations";
import History from './screens/history-request/History'
import OptionsMenu from "./screens/optionMenu/OptionsMenu";
import Home from "./screens/home/Home";
import HistoryItemDetails from "./screens/history-request/HistoryItemDetails";
import SuperViseurGroupeHome from "./screens/groupes/SuperViseurGroupeHome";
import HistoryRequester from "./screens/history-request/HistoryRequester";
import AddNetwork from "./screens/account/AddNetwork";
import MyHistory from "./screens/history-request/MyHistory";
import Icon from "react-native-vector-icons/FontAwesome5";
import { Appbar } from 'react-native-paper';
import IconWithBadge from "./screens/IconWithBadge"
import I18n from "react-native-i18n";
import Filter from './screens/home/Filter';
import { createMaterialBottomTabNavigator } from 'react-navigation-material-bottom-tabs';
2020-04-17 22:03:04 +00:00
import WalletDetail from './screens/wallet/WalletDetail';
import WalletSelect from './screens/wallet/WalletSelect';
import { PersistGate } from 'redux-persist/integration/react';
import { store, persistor } from './redux/store';
2020-08-11 09:42:31 +00:00
import { Provider, connect } from 'react-redux';
2020-04-24 15:11:08 +00:00
import WalletDepot from './screens/wallet/WalletDepot';
import WalletRetrait from './screens/wallet/WalletRetrait';
2020-05-30 21:58:22 +00:00
import CreateIdentification from './screens/identification/createIdentification';
import WalletDetailUser from './screens/wallet/WalletDetailUser';
2020-06-02 09:05:50 +00:00
import WalletOptionSelect from './screens/wallet/WalletOptionSelect';
2020-06-10 03:10:45 +00:00
import ValidateIdentification from './screens/identification/validateIdentification';
2020-06-16 09:25:46 +00:00
import CreateIdentificationUser from './screens/identification/CreateIdentificationUser';
2020-06-18 05:38:10 +00:00
import OperateurOptionSelect from './screens/wallet/OperateurOptionSelect';
import PaiementFacture from './screens/wallet/PaiementFacture';
2020-06-23 08:55:19 +00:00
import EnvoieWalletToWalletUser from './screens/wallet/user/EnvoieWalletToWalletUser';
2020-06-23 10:28:52 +00:00
import EnvoieWalletToCashUser from './screens/wallet/user/EnvoieWalletToCash';
2020-07-02 14:35:00 +00:00
import LinkCard from './screens/wallet/user/LinkCard';
import EnvoieWalletToCardUser from './screens/wallet/user/EnvoieWalletToCardUser';
import EnvoieWalletToBankUser from './screens/wallet/user/EnvoieWalletToBankUser';
import RetraitWalletVersCashUser from './screens/wallet/user/RetraitWalletVersCashUser';
import RetraitCarteVersCashUser from './screens/wallet/user/RetraitCarteVersCashUser';
import RetraitCarteVersWalletUser from './screens/wallet/user/RetraitCarteVersWalletUser';
2020-07-04 17:38:39 +00:00
import RetraitEnCashAgent from './screens/wallet/agent/RetraitEnCashAgent';
import RetraitCarteVersCashAgent from './screens/wallet/agent/RetraitCarteVersCashAgent';
import EnvoieCashVersWalletAgent from './screens/wallet/agent/EnvoieCashVersWalletAgent';
import EnvoieCashVersAutreWalletAgent from './screens/wallet/agent/EnvoieCashVersAutreWalletAgent';
2020-07-08 19:01:56 +00:00
import EnvoieCashVersCarteAgent from './screens/wallet/agent/EnvoieCashVersCarteAgent';
import EnvoiCashVersCashAgent from './screens/wallet/agent/EnvoiCashVersCashAgent';
2020-08-11 09:42:31 +00:00
import ModifyIdentificationUser from './screens/identification/ModifyIdentificationUser';
import CreateGroupNanoCredit from './screens/nano-credit/CreateGroupNanoCredit';
import { bindActionCreators } from 'redux';
import DemandValidationGroup from './screens/nano-credit/DemandGroupNanoCredit';
2020-08-13 07:23:23 +00:00
import DemandGroupNanoCreditDetail from './screens/nano-credit/DemandGroupNanoCreditDetail';
2020-04-18 19:59:05 +00:00
2019-06-16 13:09:54 +00:00
const instructions = Platform.select({
2020-03-20 18:28:22 +00:00
ios: 'Press Cmd+R to reload,\n' + 'Cmd+D or shake for dev menu',
android:
'Double tap R on your keyboard to reload,\n' +
'Shake or press menu button for dev menu',
2019-06-16 13:09:54 +00:00
});
2020-03-20 18:28:22 +00:00
const theme = require("./utils/theme")
const AuthStack = createStackNavigator({
login: Connect,
helpMenu: HelpMenu,
help: Help,
forgottenpass: ForgottenPassword,
typeaccountcreate: TypeChoiser,
simpleusercreate: createAccount,
step2: CreateUserStep2,
activateaccout: ActivateAccount
}, {
headerMode: 'none'
})
const AppStack = createDrawerNavigator({
sta: createStackNavigator({
home: Home,
/* filtre:Filter,
network:Networks,*/
useraccount: {
screen: UserAccount,
navigationOptions: {
},
},
2020-05-30 21:58:22 +00:00
walletSelect: WalletSelect,
2020-06-16 09:25:46 +00:00
createIdentificationUser: CreateIdentificationUser,
2020-08-11 09:42:31 +00:00
modifyIdentificationUser: ModifyIdentificationUser,
2020-03-20 18:28:22 +00:00
notificationview: Notifications,
configuration: Configurations,
2020-05-30 21:58:22 +00:00
about: About,
2020-06-02 09:05:50 +00:00
walletDetailUser: WalletDetailUser,
2020-06-17 14:09:27 +00:00
walletOptionSelect: WalletOptionSelect,
2020-06-18 05:38:10 +00:00
operateurOptionSelect: OperateurOptionSelect,
operateurOptionSelect: OperateurOptionSelect,
2020-06-23 08:55:19 +00:00
paiementFacture: PaiementFacture,
2020-06-23 10:28:52 +00:00
envoieWalletToWalletUser: EnvoieWalletToWalletUser,
2020-07-02 14:35:00 +00:00
envoieWalletToCashUser: EnvoieWalletToCashUser,
envoieWalletToCardUser: EnvoieWalletToCardUser,
envoieWalletToBankUser: EnvoieWalletToBankUser,
retraitWalletVersCashUser: RetraitWalletVersCashUser,
retraitCarteVersCashUser: RetraitCarteVersCashUser,
retraitCarteVersWalletUser: RetraitCarteVersWalletUser,
2020-08-11 09:42:31 +00:00
linkCard: LinkCard,
createGroupNanoCredit: CreateGroupNanoCredit,
groupNanoCredit: {
screen: createBottomTabNavigator({
demandeValidationGroupe: DemandValidationGroup,
OthersDemand: MyHistory
}, {
headerMode: "none",
header: null,
headerTitle: null,
title: I18n.t('MANAGE_GROUP'),
tabBarOptions: {
labelStyle: {
fontSize: 13,
},
}
}),
navigationOptions: ({ navigation }) => ({
header: null,
headerMode: 'none',
headerTitle: null,
activeColor: '#f0edf6',
inactiveColor: '#3e2465',
barStyle: { backgroundColor: '#694fad' },
drawerLabel: I18n.t('MANAGE_GROUP'),
drawerIcon: ({ tintColor }) => (
<Icon
name={'account-multiple'}
size={24}
/>)
}),
},
2020-08-13 07:23:23 +00:00
demandeValidationGroupe: DemandGroupNanoCreditDetail
2020-03-20 18:28:22 +00:00
})
}, { contentComponent: OptionsMenu, headerMode: 'none', contentOptions: { activeTintColor: theme.accent } })
2020-04-11 22:33:59 +00:00
2020-03-20 18:28:22 +00:00
const AppAgentStack = createDrawerNavigator({
sta: createStackNavigator({
home: Home,
useraccount: UserAccount,
2020-04-24 15:11:08 +00:00
walletSelect: WalletSelect,
2020-05-30 21:58:22 +00:00
createIdentification: CreateIdentification,
2020-06-10 03:10:45 +00:00
validateIdentification: ValidateIdentification,
2020-03-20 18:28:22 +00:00
Historique:
{
screen: createBottomTabNavigator({ myDemand: MyHistory }, {
headerMode: "none",
header: null,
headerTitle: null,
headerTitle: I18n.t('CREDIT_MANAGE'),
tabBarOptions: {
labelStyle: {
fontSize: 13,
fontWeight: "bold"
},
}
}),
navigationOptions: ({ navigation }) => ({
header: null,
headerMode: 'none',
headerTitle: null,
activeColor: '#f0edf6',
inactiveColor: '#3e2465',
barStyle: { backgroundColor: '#694fad' },
2020-04-17 22:03:04 +00:00
headerLeft: (<HeaderBackButton />),
2020-03-20 18:28:22 +00:00
drawerLabel: I18n.t('CREDIT_MANAGE'),
drawerIcon: ({ tintColor }) => (
<Icon
name={'credit-card'}
size={24}
/>)
}),
},
historyItemDetails: HistoryItemDetails,
creditrequest: HistoryRequester,
addNetwork: AddNetwork,
updateinformation: UpdateInformations,
notificationview: Notifications,
configuration: Configurations,
2020-04-17 22:03:04 +00:00
about: About,
2020-04-24 15:11:08 +00:00
walletDetail: WalletDetail,
walletDepot: WalletDepot,
2020-06-02 09:05:50 +00:00
walletRetrait: WalletRetrait,
2020-06-17 14:09:27 +00:00
walletOptionSelect: WalletOptionSelect,
2020-06-18 05:38:10 +00:00
operateurOptionSelect: OperateurOptionSelect,
2020-07-04 17:38:39 +00:00
paiementFacture: PaiementFacture,
retraitEnCashAgent: RetraitEnCashAgent,
retraitCarteVersCashAgent: RetraitCarteVersCashAgent,
envoieCashVersWalletAgent: EnvoieCashVersWalletAgent,
2020-07-08 19:01:56 +00:00
envoieCashVersAutreWalletAgent: EnvoieCashVersAutreWalletAgent,
envoieCashVersCarteAgent: EnvoieCashVersCarteAgent,
envoiCashVersCashAgent: EnvoiCashVersCashAgent,
2020-08-11 09:42:31 +00:00
createGroupNanoCredit: CreateGroupNanoCredit
2020-03-20 18:28:22 +00:00
})
}, {
contentComponent: OptionsMenu,
backBehavior: "none",
lazy: false,
headerMode: 'none', contentOptions: { activeTintColor: theme.accent }
2020-08-11 09:42:31 +00:00
});
2020-03-20 18:28:22 +00:00
const AppAdministratorStack = createDrawerNavigator({
sta: createStackNavigator({
home: Home,
useraccount: UserAccount,
2020-04-24 15:11:08 +00:00
walletSelect: WalletSelect,
2020-03-20 18:28:22 +00:00
Historique: {
screen: createBottomTabNavigator({
myDemand: MyHistory, OthersDemand: MyHistory
}, {
headerMode: "none",
header: null,
headerTitle: null,
title: I18n.t('CREDIT_MANAGE'),
tabBarOptions: {
labelStyle: {
fontSize: 13,
},
}
}),
navigationOptions: ({ navigation }) => ({
header: null,
headerMode: 'none',
headerTitle: null,
activeColor: '#f0edf6',
inactiveColor: '#3e2465',
barStyle: { backgroundColor: '#694fad' },
drawerLabel: I18n.t('CREDIT_MANAGE'),
drawerIcon: ({ tintColor }) => (
<Icon
name={'credit-card'}
size={24}
/>)
}),
},
creditrequest: HistoryRequester,
historyItemDetails: HistoryItemDetails,
superviseurgroup: SuperViseurGroupeHome,
notificationview: Notifications,
configuration: Configurations,
2020-04-17 22:03:04 +00:00
about: About,
2020-04-24 15:11:08 +00:00
walletDetail: WalletDetail,
walletDepot: WalletDepot,
walletRetrait: WalletRetrait
2020-03-20 18:28:22 +00:00
})
},
{
contentComponent: OptionsMenu,
backBehavior: "none",
headerMode: 'none'
2020-08-11 09:42:31 +00:00
});
2020-03-20 18:28:22 +00:00
const AppSuperAdministrator = createDrawerNavigator({
sta: createStackNavigator({
home: Home,
useraccount: UserAccount,
2020-04-24 15:11:08 +00:00
walletSelect: WalletSelect,
2020-03-20 18:28:22 +00:00
Historique: {
screen: createBottomTabNavigator({ OthersDemand: MyHistory }, {
headerMode: "none",
header: null,
headerTitle: null,
title: I18n.t('CREDIT_MANAGE'),
tabBarOptions: {
labelStyle: {
fontSize: 13,
fontWeight: "bold"
},
}
}),
navigationOptions: ({ navigation }) => ({
title: I18n.t('CREDIT_MANAGE'),
headerMode: "none",
header: null,
headerTitle: null,
drawerIcon: ({ tintColor }) => (
<Icon
name={'credit-card'}
size={24}
/>)
}),
},
creditrequest: HistoryRequester,
historyItemDetails: HistoryItemDetails,
superviseurgroup: SuperViseurGroupeHome,
notificationview: Notifications,
configuration: Configurations,
2020-04-17 22:03:04 +00:00
about: About,
2020-04-24 15:11:08 +00:00
walletDetail: WalletDetail,
walletDepot: WalletDepot,
walletRetrait: WalletRetrait
2020-03-20 18:28:22 +00:00
})
}, {
contentComponent: OptionsMenu,
backBehavior: "none",
headerMode: 'none'
2020-08-11 09:42:31 +00:00
});
2020-03-20 18:28:22 +00:00
export const AppNavigator = createSwitchNavigator({
first: {
screen: SplashScreen
},
App: AppStack,
AgentApp: AppAgentStack,
adminApp: AppAdministratorStack,
supAdminApp: AppSuperAdministrator,
Auth: AuthStack
}, {
initialRouteName: 'first'
2019-06-16 13:09:54 +00:00
});
const AppContainer = createAppContainer(AppNavigator);
2020-04-17 22:03:04 +00:00
class App extends React.Component {
2020-04-18 19:59:05 +00:00
2020-08-11 09:42:31 +00:00
constructor(properties) {
super(properties);
//Remove this method to stop OneSignal Debugging
OneSignal.setLogLevel(6, 0);
// Replace 'YOUR_ONESIGNAL_APP_ID' with your OneSignal App ID.
OneSignal.init("e8e7251f-713d-4658-9510-86d877fa6a7c", { kOSSettingsKeyAutoPrompt: false, kOSSettingsKeyInAppLaunchURL: false, kOSSettingsKeyInFocusDisplayOption: 2 });
OneSignal.inFocusDisplaying(2); // Controls what should happen if a notification is received while the app is open. 2 means that the notification will go directly to the device's notification center.
// The promptForPushNotifications function code will show the iOS push notification prompt. We recommend removing the following code and instead using an In-App Message to prompt for notification permission (See step below)
OneSignal.promptForPushNotificationsWithUserResponse(myiOSPromptCallback);
OneSignal.addEventListener('received', this.onReceived);
OneSignal.addEventListener('opened', this.onOpened);
OneSignal.addEventListener('ids', this.onIds);
}
_getOneSignalIds = () => {
return new Promise(async (resolve, reject) => {
try {
const getElement = await AsyncStorage.getItem('@config:onesignalIds');
resolve(getElement);
} catch (error) {
reject(error);
}
});
}
_saveOneSignalIds = async (ids) => {
try {
await AsyncStorage.setItem('@config:onesignalIds', ids);
} catch (error) {
console.warn(error);
}
}
componentWillUnmount() {
OneSignal.removeEventListener('received', this.onReceived);
OneSignal.removeEventListener('opened', this.onOpened);
OneSignal.removeEventListener('ids', this.onIds);
}
onReceived(notification) {
console.log("Notification received: ", notification);
}
onOpened(openResult) {
2020-08-13 07:23:23 +00:00
let data = openResult.notification.payload.additionalData;
2020-08-11 09:42:31 +00:00
console.log('Message: ', openResult.notification.payload.body);
console.log('Data: ', openResult.notification.payload.additionalData);
console.log('isActive: ', openResult.notification.isAppInFocus);
console.log('openResult: ', openResult);
}
onIds = async (device) => {
console.log('Device info: ', device);
AsyncStorage.getAllKeys((err, keys) => {
AsyncStorage.multiGet(keys, (err, stores) => {
stores.map(async (result, i, store) => {
let key = store[i][0];
if (!_.isEqual(key, '@config:onesignalIds')) {
if (i === stores.length - 1) {
this._saveOneSignalIds(device.userId);
}
}
});
});
});
}
2020-04-17 22:03:04 +00:00
render() {
return (
<Provider store={store}>
2020-04-18 19:59:05 +00:00
<PersistGate persistor={persistor}>
2020-08-11 09:42:31 +00:00
<ActionSheetProvider>
<AppContainer />
</ActionSheetProvider>
2020-04-17 22:03:04 +00:00
</PersistGate>
</Provider>
);
}
}
2020-08-11 09:42:31 +00:00
function myiOSPromptCallback(permission) {
// do something with permission value
}
2020-04-17 22:03:04 +00:00
export default App;
2019-06-16 13:09:54 +00:00
const styles = StyleSheet.create({
2020-03-20 18:28:22 +00:00
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10,
},
instructions: {
textAlign: 'center',
color: '#333333',
marginBottom: 5,
},
2019-06-16 13:09:54 +00:00
});