|
|
@@ -4,19 +4,20 @@
|
|
|
*/
|
|
|
import React, { Component } from 'react';
|
|
|
import {createMaterialTopTabNavigator} from '@react-navigation/material-top-tabs';
|
|
|
-import { BackHandler, Pressable, StyleSheet } from 'react-native';
|
|
|
+import { View, BackHandler, Pressable, StyleSheet } from 'react-native';
|
|
|
import TabInfos from './TabInfos';
|
|
|
import TabCharge from './TabCharge';
|
|
|
import Reserve from './TabReserve';
|
|
|
import TabInfosV3 from '../chargeV3/TabInfos';
|
|
|
-import { QRResult } from '../charge/QRScan';
|
|
|
+import QRResult from '../charge/QRResult';
|
|
|
import apiStation from '../../api/apiStation';
|
|
|
import PagerUtil from './PagerUtil';
|
|
|
import utils from '../../utils/utils';
|
|
|
-import { Styles } from '../../components/Toolbar';
|
|
|
+import Toolbar, { Styles } from '../../components/Toolbar';
|
|
|
import { getFocusedRouteNameFromRoute } from '@react-navigation/core';
|
|
|
import app from '../../../app.json';
|
|
|
import HeaderTitle from '../../components/HeaderTitle';
|
|
|
+import { PageList } from '../Router';
|
|
|
|
|
|
export const PagerList = {
|
|
|
"tabInfo": "Info",
|
|
|
@@ -63,6 +64,7 @@ export default class ChargeAdapter extends Component {
|
|
|
this.action = "";
|
|
|
this.isHide = false;
|
|
|
this.titleName = "";
|
|
|
+ this.backHandler = undefined;
|
|
|
}
|
|
|
|
|
|
componentDidMount() {
|
|
|
@@ -91,7 +93,7 @@ export default class ChargeAdapter extends Component {
|
|
|
this.canShowLoginDialog();
|
|
|
});
|
|
|
}
|
|
|
- BackHandler.addEventListener('hardwareBackPress', this.backPage)
|
|
|
+ this.backHandler = BackHandler.addEventListener('hardwareBackPress', this.backPage)
|
|
|
PagerUtil.addOnRefresh(this);
|
|
|
PagerUtil.setSelectedVoucher({});
|
|
|
// setTimeout(() => {
|
|
|
@@ -116,13 +118,19 @@ export default class ChargeAdapter extends Component {
|
|
|
componentWillUnmount() {
|
|
|
QRResult.clearResult();
|
|
|
PagerUtil.onDestory();
|
|
|
- BackHandler.removeEventListener("hardwareBackPress", this.backPage)
|
|
|
+ if (this.backHandler) {
|
|
|
+ this.backHandler.remove();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
backPage = () => {
|
|
|
const params = this.props.route.params;
|
|
|
if (params.from && !this.isHide) {
|
|
|
- startPage(params.from);
|
|
|
+ if (params.from == PageList.home) {
|
|
|
+ startPage(params.from);
|
|
|
+ } else {
|
|
|
+ goBack2();
|
|
|
+ }
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
|
@@ -257,33 +265,52 @@ export default class ChargeAdapter extends Component {
|
|
|
render() {
|
|
|
const Tab = createMaterialTopTabNavigator();
|
|
|
return (
|
|
|
- <Tab.Navigator
|
|
|
- style={styles.container}
|
|
|
- screenOptions={{
|
|
|
- lazy: false,
|
|
|
- lazyPreloadDistance: 1,
|
|
|
- ...this.tabBarStyle
|
|
|
- }}
|
|
|
- backBehavior={() => this.backPage()}
|
|
|
- initialRouteName={PagerList.tabCharge}>
|
|
|
- { this.pageAdapter.map((item, index) =>
|
|
|
- <Tab.Screen
|
|
|
- key={index}
|
|
|
- name={item.name}
|
|
|
- component={item.component}
|
|
|
- options={{
|
|
|
- title: item.title,
|
|
|
- tabBarAllowFontScaling: false
|
|
|
- }}
|
|
|
- />
|
|
|
- )}
|
|
|
- </Tab.Navigator>
|
|
|
+ <View style={styles.container}>
|
|
|
+ <Toolbar
|
|
|
+ title={this.state.stationInfo?.name ?? "Charging Site"}
|
|
|
+ rightIcon={() => (
|
|
|
+ <Pressable
|
|
|
+ style={Styles.backIcon}
|
|
|
+ android_ripple={rippleLessIcon}
|
|
|
+ onPress={() => utils.directMaps(this.state.stationInfo.latitude, this.state.stationInfo.longitude, this.state.stationInfo.address)}>
|
|
|
+ <MaterialIcons
|
|
|
+ name='directions'
|
|
|
+ size={24}
|
|
|
+ color={pageTitleTint}
|
|
|
+ style={Styles.iconOpacity}
|
|
|
+ />
|
|
|
+ </Pressable>
|
|
|
+ )}
|
|
|
+ />
|
|
|
+ <Tab.Navigator
|
|
|
+ style={styles.container}
|
|
|
+ screenOptions={{
|
|
|
+ lazy: false,
|
|
|
+ lazyPreloadDistance: 1,
|
|
|
+ ...this.tabBarStyle
|
|
|
+ }}
|
|
|
+ backBehavior={() => this.backPage()}
|
|
|
+ initialRouteName={PagerList.tabCharge}>
|
|
|
+ { this.pageAdapter.map((item, index) =>
|
|
|
+ <Tab.Screen
|
|
|
+ key={index}
|
|
|
+ name={item.name}
|
|
|
+ component={item.component}
|
|
|
+ options={{
|
|
|
+ title: item.title,
|
|
|
+ tabBarAllowFontScaling: false
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ )}
|
|
|
+ </Tab.Navigator>
|
|
|
+ </View>
|
|
|
);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
const styles = StyleSheet.create({
|
|
|
container: {
|
|
|
+ flex: 1,
|
|
|
backgroundColor: colorLight
|
|
|
},
|
|
|
tabStyle: {
|