|
|
@@ -3,7 +3,7 @@
|
|
|
* @邠心vbe on 2021/08/13
|
|
|
*/
|
|
|
import React, { Component } from 'react';
|
|
|
-import { View, StyleSheet, BackHandler, Linking } from 'react-native';
|
|
|
+import { View, StyleSheet, BackHandler, Linking, AppState } from 'react-native';
|
|
|
import app from '../../../app.json'
|
|
|
import { i18nUtil } from '../../i18n';
|
|
|
import apiBase from '../../api/apiBase';
|
|
|
@@ -41,6 +41,8 @@ export default class HomePage extends Component {
|
|
|
parkingFee: 'ALL',
|
|
|
connectorType: ''
|
|
|
};
|
|
|
+ this.stateListener;
|
|
|
+ this.forceUpdateDialog = undefined;
|
|
|
}
|
|
|
|
|
|
componentDidMount() {
|
|
|
@@ -87,6 +89,11 @@ export default class HomePage extends Component {
|
|
|
}
|
|
|
}
|
|
|
});*/
|
|
|
+ this.stateListener = AppState.addEventListener("change", state => {
|
|
|
+ if (state == 'active' && this.forceUpdateDialog) {
|
|
|
+ this.showUpdateDialog(this.forceUpdateDialog);
|
|
|
+ }
|
|
|
+ });
|
|
|
BackHandler.addEventListener('hardwareBackPress', this.toExit)
|
|
|
this.isHide = false;
|
|
|
this.checkUpdateVersion();
|
|
|
@@ -98,6 +105,9 @@ export default class HomePage extends Component {
|
|
|
this.unsubscribe();
|
|
|
}*/
|
|
|
this.backSeconds = 0;
|
|
|
+ if (this.stateListener) {
|
|
|
+ this.stateListener.remove();
|
|
|
+ }
|
|
|
BackHandler.removeEventListener("hardwareBackPress", this.toExit)
|
|
|
}
|
|
|
|
|
|
@@ -118,7 +128,7 @@ export default class HomePage extends Component {
|
|
|
if (time - this.backSeconds < 2000) {
|
|
|
BackHandler.exitApp();
|
|
|
} else {
|
|
|
- toastShort("Press the back button again to exit the program");
|
|
|
+ toastShort($t("home.backAgainTips"));
|
|
|
this.backSeconds = time;
|
|
|
//e.preventDefault();
|
|
|
}
|
|
|
@@ -142,7 +152,7 @@ export default class HomePage extends Component {
|
|
|
if (desc) {
|
|
|
const upLog = i18nUtil.analyzeLocaleData(desc);
|
|
|
if (typeof upLog == "string") {
|
|
|
- this.showUpdateDialog({
|
|
|
+ const prps = {
|
|
|
title: $t("home.versionUpdate"),
|
|
|
message: $t("home.newVersionName") + res.data.versionName + "\n\n" + upLog,
|
|
|
showCancel: !(res.data.force),
|
|
|
@@ -157,7 +167,14 @@ export default class HomePage extends Component {
|
|
|
Linking.openURL(uri);
|
|
|
}
|
|
|
}
|
|
|
- })
|
|
|
+ }
|
|
|
+ if (res.data.force) {
|
|
|
+ prps.onBackPress = () => {
|
|
|
+
|
|
|
+ }
|
|
|
+ this.forceUpdateDialog = prps;
|
|
|
+ }
|
|
|
+ this.showUpdateDialog(prps);
|
|
|
}
|
|
|
}
|
|
|
}
|