Răsfoiți Sursa

Enhancement

vbea 2 ani în urmă
părinte
comite
26fcfabe06

+ 1 - 1
Strides-APP/app.json

@@ -13,7 +13,7 @@
     "nationally": false,
     "notifications": true,
     "support": {
-      "phone": "006564775355",
+      "phone": "+6564775355",
       "whatsapp": "https://wa.me/6597285916"
     }
   },

+ 3 - 2
Strides-APP/app/components/Dialog.js

@@ -34,12 +34,13 @@ const showDialog = (props) => {
     ok: props.ok || $t('nav.ok'),
     cancel: props.cancel || $t('nav.cancel'),
     showCancel: props.showCancel != undefined ? props.showCancel : true,
-    callback: props.callback
+    callback: props.callback,
+    onBackPress: props.onBackPress
   }
   ModalPortal.show((
     isIOS ? <IOSDialog {...param}/>
           : <AndroidDialog {...param}/>
-  ));
+  ), param?.onBackPress);
 }
 
 /**

+ 10 - 3
Strides-APP/app/components/ModalPortal.js

@@ -20,10 +20,11 @@ export default class ModalPortal extends Component {
     };
     modal = this;
     this.isHide = true;
+    this.onBack = undefined;
   }
 
-  static show(children) {
-    return modal.show(children);
+  static show(children, onBack) {
+    return modal.show(children, onBack);
   }
 
   static showLoading(children) {
@@ -46,7 +47,7 @@ export default class ModalPortal extends Component {
     return modal.isShowing();
   }
 
-  show(children) {
+  show(children, onBack=undefined) {
     if (isIOS) {
       if (!this.isHide) {
         setTimeout(() => {
@@ -65,6 +66,7 @@ export default class ModalPortal extends Component {
         showDialog: true,
         children: children
       })
+      this.onBack = onBack;
     }
   }
 
@@ -87,6 +89,7 @@ export default class ModalPortal extends Component {
     this.setState({
       showDialog: false
     })
+    this.onBack = undefined;
   }
 
   dismissLoading() {
@@ -115,6 +118,10 @@ export default class ModalPortal extends Component {
   }
 
   onBackPress() {
+    if (this.onBack) {
+      this.onBack();
+      return;
+    }
     if (this.state.showLoading) {
       this.dismissLoading();
     } else if (this.state.showDialog) {

+ 2 - 1
Strides-APP/app/i18n/locales/en.js

@@ -157,7 +157,8 @@ export default {
     searchHint: "Search using site name or service provider",
     statusPrivate: "Private Site",
     updateNow: "UPDATE NOW",
-    versionUpdate: "Version Update"
+    versionUpdate: "Version Update",
+    backAgainTips: "Press the back button again to exit the program"
   },
   drawer: {
     sign: "Sign In",

+ 2 - 1
Strides-APP/app/i18n/locales/zh-TW.js

@@ -157,7 +157,8 @@ export default {
     searchHint: "使用站點名稱或服務提供商搜尋",
     statusPrivate: "私有站點",
     updateNow: "現在更新",
-    versionUpdate: "發現新版本"
+    versionUpdate: "發現新版本",
+    backAgainTips: "再次點擊返回鍵退出程式"
   },
   drawer: {
     sign: "請登⼊",

+ 2 - 1
Strides-APP/app/i18n/locales/zh.js

@@ -157,7 +157,8 @@ export default {
     searchHint: "使用站点名称或服务提供商搜索",
     statusPrivate: "私有站点",
     updateNow: "现在更新",
-    versionUpdate: "发现新版本"
+    versionUpdate: "发现新版本",
+    backAgainTips: "再按一次返回键退出程序"
   },
   drawer: {
     sign: "请登录",

+ 21 - 4
Strides-APP/app/pages/home/Home.js

@@ -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);
           }
         }
       }