Skip to content

Commit

Permalink
Merge branch 'master-qa' of https://github.com/sap-labs-france/ev-mobile
Browse files Browse the repository at this point in the history
 into charging_stations_radius

# Conflicts:
#	src/screens/charging-stations/list/ChargingStations.tsx
  • Loading branch information
AlixH committed Dec 3, 2021
2 parents c9c67ef + 6c68ed4 commit 765ac04
Show file tree
Hide file tree
Showing 28 changed files with 148 additions and 191 deletions.
1 change: 1 addition & 0 deletions android/app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<color name="primary">#0a6ed1</color>
<color name="modalBackground">#262626</color>
<color name="status_bar_color">#00376C</color>
<color name="modalBackground">#262626</color>
<color name="navigationBarBackground">#E7E7E7</color>
<color name="white">#FFF</color>
</resources>
99 changes: 58 additions & 41 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { StatusBar } from 'react-native';
import { RootSiblingParent } from 'react-native-root-siblings';
import { scale } from 'react-native-size-matters';

import computeStyleSheet from './AppStyles';
import DeepLinkingManager from './deeplinking/DeepLinkingManager';
import I18nManager from './I18n/I18nManager';
import LocationManager from './location/LocationManager';
Expand Down Expand Up @@ -171,7 +170,9 @@ function createChargingStationDetailsTabsNavigator(props: BaseProps) {
inactiveColor={commonColor.topTabBarActiveTextColor}
barStyle={barStyle}
labeled
backBehavior="none">
shifting={true}
backBehavior="history"
>
<ChargingStationDetailsTabs.Screen
name="ChargingStationActions"
component={ChargingStationActions}
Expand Down Expand Up @@ -213,7 +214,9 @@ function createChargingStationConnectorDetailsTabsNavigator(props: BaseProps) {
inactiveColor={commonColor.topTabBarActiveTextColor}
barStyle={barStyle}
labeled
shifting={true}>
shifting={true}
backBehavior="history"
>
<ChargingStationConnectorDetailsTabs.Screen
name="ChargingStationConnectorDetails"
component={ChargingStationConnectorDetails}
Expand Down Expand Up @@ -247,7 +250,8 @@ function createTransactionDetailsTabsNavigator(props: BaseProps) {
inactiveColor={commonColor.topTabBarTextColor}
barStyle={barStyle}
labeled
backBehavior="history">
backBehavior="history"
>
<TransactionDetailsTabs.Screen
name="TransactionDetails"
component={TransactionDetails}
Expand All @@ -263,7 +267,7 @@ function createTransactionDetailsTabsNavigator(props: BaseProps) {
initialParams={props?.route?.params?.params}
options={{
title: I18n.t('details.graph'),
tabBarIcon: (iconProps) => createTabBarIcon(iconProps, 'AntDesign', 'linechart')
tabBarIcon: (iconProps) => createTabBarIcon(iconProps, 'MaterialCommunityIcons', 'chart-line')
}}
/>
</TransactionDetailsTabs.Navigator>
Expand All @@ -273,11 +277,31 @@ function createTransactionDetailsTabsNavigator(props: BaseProps) {
function createSitesNavigator(props: BaseProps) {
return (
<SitesStack.Navigator initialRouteName="Sites" screenOptions={{ headerShown: false }}>
<SitesStack.Screen name="Sites" component={Sites} initialParams={props?.route?.params?.params} />
<SitesStack.Screen name="SiteAreas" component={SiteAreas} initialParams={props?.route?.params?.params} />
<SitesStack.Screen name="ChargingStations" component={ChargingStations} initialParams={props?.route?.params?.params} />
<SitesStack.Screen
name="ChargingStationDetailsTabs"
name="Sites"
component={Sites}
initialParams={props?.route?.params?.params}
/>
<SitesStack.Screen
name="SiteAreas"
component={SiteAreas}
initialParams={props?.route?.params?.params}
/>
<SitesStack.Screen
name="ChargingStations"
component={ChargingStations}
initialParams={props?.route?.params?.params}
/>
<SitesStack.Screen
name="AddCar" component={AddCar}
initialParams={props?.route?.params?.params}
/>
<SitesStack.Screen
name="AddPaymentMethod"
component={StripePaymentMethodCreationForm}
initialParams={props?.route?.params?.params}
/>
<SitesStack.Screen name="ChargingStationDetailsTabs"
component={createChargingStationDetailsTabsNavigator}
initialParams={props?.route?.params?.params}
/>
Expand All @@ -291,15 +315,23 @@ function createSitesNavigator(props: BaseProps) {
component={createTransactionDetailsTabsNavigator}
initialParams={props?.route?.params?.params}
/>
<SitesStack.Screen name="ReportError" component={ReportError} initialParams={props?.route?.params?.params} />
<SitesStack.Screen
name="ReportError"
component={ReportError}
initialParams={props?.route?.params?.params}
/>
</SitesStack.Navigator>
);
}

function createChargingStationsNavigator(props: BaseProps) {
return (
<ChargingStationsStack.Navigator initialRouteName="ChargingStations" screenOptions={{ headerShown: false, gestureEnabled: false }}>
<ChargingStationsStack.Screen name="ChargingStations" component={ChargingStations} initialParams={props?.route?.params?.params} />
<ChargingStationsStack.Screen
name="ChargingStations"
component={ChargingStations}
initialParams={props?.route?.params?.params}
/>
<ChargingStationsStack.Screen
name="ChargingStationDetailsTabs"
component={createChargingStationDetailsTabsNavigator}
Expand All @@ -316,13 +348,17 @@ function createChargingStationsNavigator(props: BaseProps) {
component={StripePaymentMethodCreationForm}
initialParams={props?.route?.params?.params}
/>
<AppDrawer.Screen name="QRCodeScanner" component={ChargingStationQrCode} initialParams={props?.route?.params?.params} />
<ChargingStationsStack.Screen name="QRCodeScanner" component={ChargingStationQrCode} initialParams={props?.route?.params?.params} />
<ChargingStationsStack.Screen
name="TransactionDetailsTabs"
component={createTransactionDetailsTabsNavigator}
initialParams={props?.route?.params?.params}
/>
<ChargingStationsStack.Screen name="ReportError" component={ReportError} initialParams={props?.route?.params?.params} />
<ChargingStationsStack.Screen
name="ReportError"
component={ReportError}
initialParams={props?.route?.params?.params}
/>
</ChargingStationsStack.Navigator>
);
}
Expand Down Expand Up @@ -352,11 +388,6 @@ function createTransactionInProgressNavigator(props: BaseProps) {
component={TransactionsInProgress}
initialParams={props?.route?.params?.params}
/>
<TransactionInProgressStack.Screen
name="ChargingStationDetailsTabs"
component={createChargingStationDetailsTabsNavigator}
initialParams={props?.route?.params?.params}
/>
<TransactionInProgressStack.Screen
name="ChargingStationConnectorDetailsTabs"
component={createChargingStationConnectorDetailsTabsNavigator}
Expand Down Expand Up @@ -402,7 +433,11 @@ function createInvoicesNavigator(props: BaseProps) {
function createPaymentMethodsNavigator(props: BaseProps) {
return (
<PaymentMethodsStack.Navigator initialRouteName="PaymentMethods" screenOptions={{ headerShown: false }}>
<PaymentMethodsStack.Screen name="PaymentMethods" component={PaymentMethods} initialParams={props?.route?.params?.params} />
<PaymentMethodsStack.Screen
name="PaymentMethods"
component={PaymentMethods}
initialParams={props?.route?.params?.params}
/>
<PaymentMethodsStack.Screen
name="StripePaymentMethodCreationForm"
component={StripePaymentMethodCreationForm}
Expand All @@ -413,7 +448,6 @@ function createPaymentMethodsNavigator(props: BaseProps) {
}

function createAppDrawerNavigator(props: BaseProps) {
const appStyles = computeStyleSheet();
return (
<AppDrawer.Navigator
initialRouteName="ChargingStationsNavigator"
Expand All @@ -427,34 +461,18 @@ function createAppDrawerNavigator(props: BaseProps) {
backBehavior={'history'}
drawerPosition="left"
drawerContent={(drawerProps) => <Sidebar {...drawerProps} />}>
<AppDrawer.Screen
name="ChargingStationsNavigator"
component={createChargingStationsNavigator}
initialParams={props?.route?.params?.params}
/>
<AppDrawer.Screen name="ChargingStationsNavigator" component={createChargingStationsNavigator} initialParams={props?.route?.params?.params}/>
<AppDrawer.Screen name="QRCodeScanner" component={ChargingStationQrCode} initialParams={props?.route?.params?.params} />
<AppDrawer.Screen name="SitesNavigator" component={createSitesNavigator} initialParams={props?.route?.params?.params} />
<AppDrawer.Screen name="StatisticsNavigator" component={createStatsNavigator} initialParams={props?.route?.params?.params} />
<AppDrawer.Screen name="ReportErrorNavigator" component={createReportErrorNavigator} initialParams={props?.route?.params?.params} />
<AppDrawer.Screen
name="TransactionHistoryNavigator"
component={createTransactionHistoryNavigator}
initialParams={props?.route?.params?.params}
/>
<AppDrawer.Screen
name="TransactionInProgressNavigator"
component={createTransactionInProgressNavigator}
initialParams={props?.route?.params?.params}
/>
<AppDrawer.Screen name="TransactionHistoryNavigator" component={createTransactionHistoryNavigator} initialParams={props?.route?.params?.params}/>
<AppDrawer.Screen name="TransactionInProgressNavigator" component={createTransactionInProgressNavigator} initialParams={props?.route?.params?.params}/>
<AppDrawer.Screen name="UsersNavigator" component={createUsersNavigator} initialParams={props?.route?.params?.params} />
<AppDrawer.Screen name="TagsNavigator" component={createTagsNavigator} initialParams={props?.route?.params?.params} />
<AppDrawer.Screen name="CarsNavigator" component={createCarsNavigator} initialParams={props?.route?.params?.params} />
<AppDrawer.Screen name="InvoicesNavigator" component={createInvoicesNavigator} initialParams={props?.route?.params?.params} />
<AppDrawer.Screen
name="PaymentMethodsNavigator"
component={createPaymentMethodsNavigator}
initialParams={props?.route?.params?.params}
/>
<AppDrawer.Screen name="PaymentMethodsNavigator" component={createPaymentMethodsNavigator} initialParams={props?.route?.params?.params}/>
</AppDrawer.Navigator>
);
}
Expand Down Expand Up @@ -559,7 +577,6 @@ export default class App extends React.Component<Props, State> {

public render() {
const { showAppUpdateDialog } = this.state;
const commonColors = Utils.getCurrentCommonColor();
return (
this.state.isNavigationStateLoaded && (
<RootSiblingParent>
Expand Down
3 changes: 3 additions & 0 deletions src/components/modal/ModalSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ export default class ModalSelect<T extends ListItem> extends React.Component<Pro
swipeDirection={'down'}
animationInTiming={1000}
onSwipeComplete={() => this.setState({ isVisible: false })}
// Modal component registers the given method for hardwareBackPress event and unregisters it when the modal inner content unmounts.
// Inner component list also unsubscribe on unmount, allowing the last subscriber to choose back implementation.
// Here the last subscriber is the parent component
onBackButtonPress={() => this.setState({ isVisible: false })}
onBackdropPress={() => this.setState({ isVisible: false })}
hideModalContentWhileAnimating={true}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Text, View } from 'native-base';
import React from 'react';

import I18nManager from '../../../I18n/I18nManager';
import BaseScreen from '../../../screens/base-screen/BaseScreen';
import BaseProps from '../../../types/BaseProps';
import Transaction from '../../../types/Transaction';
import Utils from '../../../utils/Utils';
Expand All @@ -16,7 +15,7 @@ export interface Props extends BaseProps {
}

interface State {}
export default class TransactionHeaderComponent extends BaseScreen<Props, State> {
export default class TransactionHeaderComponent extends React.Component<Props, State> {
public state: State;
public props: Props;

Expand Down
7 changes: 3 additions & 4 deletions src/provider/CentralServerProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ export default class CentralServerProvider {
let tenantLogo = this.tenantLogosCache.get(tenant.subdomain);
if (!tenantLogo) {
// Call backend
const result = await this.axiosInstance.get(`${this.buildCentralRestServerServiceUtilURL(tenant)}/${ServerAction.TENANT_LOGO}`, {
const result = await this.axiosInstance.get(this.buildUtilRestEndpointUrl(ServerRoute.REST_TENANT_LOGO), {
headers: this.buildHeaders(),
responseType: 'arraybuffer',
params: {
Expand Down Expand Up @@ -542,7 +542,7 @@ export default class CentralServerProvider {
// Build Sorting
this.buildSorting(sorting, params);
// Call
const result = await this.axiosInstance.get(`${this.buildCentralRestServerServiceSecuredURL()}/${ServerAction.SITES}`, {
const result = await this.axiosInstance.get(this.buildRestEndpointUrl(ServerRoute.REST_SITES), {
headers: this.buildSecuredHeaders(),
params
});
Expand Down Expand Up @@ -878,11 +878,10 @@ export default class CentralServerProvider {
let foundSiteImage = this.siteImagesCache.get(id);
if (!foundSiteImage) {
// Call backend
const result = await this.axiosInstance.get(`${this.buildCentralRestServerServiceUtilURL(this.tenant)}/${ServerAction.SITE_IMAGE}`, {
const result = await this.axiosInstance.get(this.buildUtilRestEndpointUrl(ServerRoute.REST_SITE_IMAGE, { id }), {
headers: this.buildHeaders(),
responseType: 'arraybuffer',
params: {
ID: id,
TenantID: this.decodedToken?.tenantID
}
});
Expand Down
8 changes: 1 addition & 7 deletions src/screens/auth/AuthHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { Image, ImageStyle } from 'react-native';
import DeviceInfo from 'react-native-device-info';

import BaseProps from '../../types/BaseProps';
import BaseScreen from '../base-screen/BaseScreen';
import computeStyleSheet from './AuthStyles';

export interface Props extends BaseProps {
Expand All @@ -15,15 +14,10 @@ export interface Props extends BaseProps {

interface State {}

export default class AuthHeader extends BaseScreen<Props, State> {
export default class AuthHeader extends React.Component<Props, State>{
public state: State;
public props: Props;

// eslint-disable-next-line no-useless-constructor
public constructor(props: Props) {
super(props);
}

public setState = (
state: State | ((prevState: Readonly<State>, props: Readonly<Props>) => State | Pick<State, never>) | Pick<State, never>,
callback?: () => void
Expand Down
7 changes: 0 additions & 7 deletions src/screens/auth/eula/Eula.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,6 @@ export default class Eula extends BaseScreen<Props, State> {
}
};

public onBack = () => {
// Back mobile button: Force navigation
this.props.navigation.navigate('Login');
// Do not bubble up
return true;
};

public render() {
const style = computeStyleSheet();
const { eulaTextHtml, loading } = this.state;
Expand Down
30 changes: 2 additions & 28 deletions src/screens/auth/login/Login.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
import I18n from 'i18n-js';
import { Button, CheckBox, Form, Icon, Item, Spinner, Text, View } from 'native-base';
import React from 'react';
import {
BackHandler,
Keyboard,
KeyboardAvoidingView,
NativeEventSubscription,
ScrollView,
TextInput,
TouchableOpacity
} from 'react-native';

import { BackHandler, Keyboard, KeyboardAvoidingView, ScrollView, TextInput, TouchableOpacity } from 'react-native';
import DialogModal from '../../../components/modal/DialogModal';
import ExitAppDialog from '../../../components/modal/exit-app/ExitAppDialog';
import computeModalCommonStyle from '../../../components/modal/ModalCommonStyle';
Expand Down Expand Up @@ -53,7 +44,6 @@ export default class Login extends BaseScreen<Props, State> {
public props: Props;
private tenants: TenantConnection[] = [];
private passwordInput: TextInput;
private backHandler: NativeEventSubscription;
private formValidationDef = {
tenantSubDomain: {
presence: {
Expand Down Expand Up @@ -114,8 +104,6 @@ export default class Login extends BaseScreen<Props, State> {

public async componentDidMount() {
await super.componentDidMount();
// Bind the back button to the onBack method (Android)
this.backHandler = BackHandler.addEventListener('hardwareBackPress', this.onBack.bind(this));
let email = (this.state.email = '');
let password = (this.state.password = '');
let tenant: TenantConnection;
Expand Down Expand Up @@ -174,10 +162,8 @@ export default class Login extends BaseScreen<Props, State> {

public async componentDidFocus() {
super.componentDidFocus();
// Bind the back button to the onBack method (Android)
this.backHandler = BackHandler.addEventListener('hardwareBackPress', this.onBack.bind(this));
const tenantSubDomain = Utils.getParamFromNavigation(this.props.route, 'tenantSubDomain', this.state.tenantSubDomain);
// Check if current Tenant selection is still valid (handle delete tenant usee case)
// Check if current Tenant selection is still valid (handle delete tenant use case)
if (tenantSubDomain) {
// Get the current Tenant
const tenant = await this.centralServerProvider.getTenant(tenantSubDomain.toString());
Expand All @@ -202,18 +188,6 @@ export default class Login extends BaseScreen<Props, State> {
}
}

public componentWillUnmount() {
super.componentWillUnmount();
// Unbind the back button and reset its default behavior (Android)
this.backHandler.remove();
}

public componentDidBlur() {
super.componentDidBlur();
// Unbind the back button and reset its default behavior (Android)
this.backHandler.remove();
}

public async checkAutoLogin(tenant: TenantConnection, email: string, password: string) {
// Check if user can be logged
if (
Expand Down
Loading

0 comments on commit 765ac04

Please sign in to comment.