瀏覽代碼

Fixed ios issues

vbea 3 年之前
父節點
當前提交
a9efcdb8df

+ 2 - 2
Strides-APP/android/app/version.properties

@@ -1,2 +1,2 @@
-#Mon May 15 12:51:09 CST 2023
-VERSION_CODE=224
+#Thu May 18 15:20:34 CST 2023
+VERSION_CODE=225

+ 29 - 8
Strides-APP/app/components/Dialog.js

@@ -61,7 +61,7 @@ const showResultDialog = (message, ok, back) => {
 const showProgressDialog = (message='Loading...') => {
   //message = message ?? 'Waiting...';
   ModalPortal.showLoading((
-    isIOS ? <IOSProgress message={message}/>
+    isIOS ? message//<IOSProgress message={message}/>
           : <AndroidProgress message={message}/>
   ));
 }
@@ -369,13 +369,16 @@ const andStyles = StyleSheet.create({
   progressView: {
     alignItems: 'center',
     flexDirection: 'row'
+  },
+  endView: {
+    paddingTop: 16
   }
 });
 
 export default Dialog = {
-  styles: andStyles,
   BUTTON_OK: BUTTON_OK,
   BUTTON_CANCEL: BUTTON_CANCEL,
+  isShowing: ModalPortal.isShowing,
   showDialog: showDialog,
   dismissAll: dismissAll,
   dismissDialog: dismissDialog,
@@ -389,20 +392,38 @@ export default Dialog = {
     propagateSwipe: true,
     useNativeDriver: true,
     hideModalContentWhileAnimating: true
-  }
+  },
+  styles: andStyles,
+  IOSProgress: IOSProgress
 }
 
 //Toast显示位置
 const toastPosition = isIOS ? 0 : -70;
 
+const getStringMessage = (msg) => {
+  if (typeof msg == 'object') {
+    if (msg.err) {
+      return "" + msg.err;
+    } else if (msg.msg) {
+      return "" + msg.msg;
+    } else if (msg.message) {
+      return "" + msg.message;
+    } else {
+      return JSON.stringify(msg);
+    }
+  } else {
+    return "" + msg;
+  }
+}
+
 export const InitSomething = () => {
   global.dialogId = undefined;
-  global.EndView = () => <View style={ui.end}/>
+  global.EndView = () => <View style={andStyles.endView}/>
 
   global.toastShort = (msg) => {
+    if (typeof msg !== 'string')
+      msg = getStringMessage(msg);
     if (utils.isNotEmpty(msg)) {
-      if (typeof msg !== 'string')
-        msg = '' + msg;
       Toast.show(msg, {
         duration: Toast.durations.SHORT,
         position: toastPosition,
@@ -423,9 +444,9 @@ export const InitSomething = () => {
   }
 
   global.toastLong = (msg) => {
+    if (typeof msg !== 'string')
+      msg = getStringMessage(msg);
     if (utils.isNotEmpty(msg)) {
-      if (typeof msg !== 'string')
-        msg = '' + msg;
       Toast.show(msg, {
         duration: Toast.durations.LONG,
         position: toastPosition,

+ 57 - 16
Strides-APP/app/components/ModalPortal.js

@@ -3,7 +3,9 @@
  * @邠心vbe on 2022/02/28
  */
 import React, { Component } from 'react';
+import { StyleSheet, View } from 'react-native';
 import Modal from 'react-native-modal';
+import Dialog from './Dialog';
 
 let modal
 export default class ModalPortal extends Component {
@@ -12,11 +14,13 @@ export default class ModalPortal extends Component {
     this.state = {
       showDialog: false,
       showLoading: false,
+      showIOSLoading: false,
       children: <></>,
-      loadChildren: <></>
+      loadChildren: <></>,
+      loadMessage: "Loading...",
     };
     modal = this;
-    this.afterHide = undefined;
+    this.isHide = true;
   }
 
   static show(children) {
@@ -39,11 +43,23 @@ export default class ModalPortal extends Component {
     modal.dismissAll();
   }
 
+  static isShowing() {
+    return modal.isShowing();
+  }
+
   show(children) {
     if (isIOS) {
+      if (!this.isHide) {
+        setTimeout(() => {
+          this.show(children);
+        }, 500);
+        return;
+      }
       this.setState({
         showDialog: true,
         children: children,
+      }, () => {
+        this.onModalShow();
       })
     } else {
       this.setState({
@@ -55,12 +71,11 @@ export default class ModalPortal extends Component {
 
   showLoading(children) {
     if (isIOS) {
+      //console.log("showIOSLoading", children)
       this.setState({
-        showDialog: true,
-        //showLoading: true,
-        children: children,
-        //loadChildren: children
-      });
+        loadMessage: children,
+        showIOSLoading: true
+      })
     } else {
       this.setState({
         showLoading: true,
@@ -78,7 +93,7 @@ export default class ModalPortal extends Component {
   dismissLoading() {
     if (isIOS) {
       this.setState({
-        showDialog: false
+        showIOSLoading: false
       })
     } else {
       this.setState({
@@ -90,10 +105,16 @@ export default class ModalPortal extends Component {
   dismissAll() {
     this.setState({
       showDialog: false,
-      showLoading: false
+      showLoading: false,
+      showIOSLoading: false
     })
   }
 
+  isShowing() {
+    //console.log("[ModalPortal] isShowing", this.state.showDialog);
+    return this.state.showDialog;
+  }
+
   onBackPress() {
     if (this.state.showLoading) {
       this.dismissLoading();
@@ -102,13 +123,14 @@ export default class ModalPortal extends Component {
     }
   }
 
+  onModalShow() {
+    console.log('onModalShow', this.isHide);
+    this.isHide = false;
+  }
+
   onModalHide() {
-    console.log('onModalHide', this.afterHide);
-    if (this.afterHide) {
-      console.log('onModalHide');
-      this.afterHide();
-      this.afterHide = undefined;
-    }
+    console.log('onModalHide', this.isHide);
+    this.isHide = true;
   }
 
   render() {
@@ -122,7 +144,7 @@ export default class ModalPortal extends Component {
           animationOut={"fadeOut"}
           useNativeDriver={true}
           onBackButtonPress={() => this.onBackPress()}
-          //onModalHide={() => this.onModalHide()}
+          onModalHide={() => this.onModalHide()}
         >
           {this.state.children}
         </Modal>
@@ -139,7 +161,26 @@ export default class ModalPortal extends Component {
         >
           {this.state.loadChildren}
         </Modal>
+        { this.state.showIOSLoading &&
+          <View style={styles.iosLoadingView}>
+            <Dialog.IOSProgress message={this.state.loadMessage}/>
+          </View>
+        }
       </>
     );
   }
 }
+
+const styles = StyleSheet.create({
+  iosLoadingView: {
+    top: 0,
+    left: 0,
+    right: 0,
+    bottom: 0,
+    zIndex: 500,
+    alignItems: 'center',
+    position: 'absolute',
+    justifyContent: 'center',
+    backgroundColor: 'rgba(0,0,0,.7)'
+  }
+})

+ 56 - 39
Strides-APP/app/pages/chargeV2/Charging.js

@@ -285,56 +285,73 @@ export const DashboardView = ({isCharging=false, connectorInfo={}}) => {
 
 export const EnterStationDialog = ({visible, stationId, onConfirm, onClose}) => {
   var [inputStationId, setInput] = useState('')
+  var [iosKillDialog, killDialog] = useState(true)
 
   const enterStatioinId= () => {
     //console.log(inputStationId);
     if (inputStationId) {
-      QRResult.applyInputStation(inputStationId, stationId, (success, err) => {
-        setInput('')
-        if (success) {
-          if (onConfirm) onConfirm()
-        } else if (err) {
-          toastShort(err)
-        }
-        if (onClose) onClose()
-      });
+      if (isIOS && iosKillDialog) {
+        onClose();
+        killDialog(false);
+      } else {
+        QRResult.applyInputStation(inputStationId, stationId, (success, err) => {
+          setInput('')
+          if (success) {
+            if (onConfirm) onConfirm()
+          } else if (err) {
+            toastShort(err)
+          }
+          if (onClose) onClose()
+        });
+      }
     } else {
       toastShort('Please input Station ID')
     }
   }
 
+  useEffect(() => {
+    if (!visible && !iosKillDialog) {
+      killDialog(true);
+      setTimeout(() => {
+        enterStatioinId();
+      }, 100);
+    }
+  }, [iosKillDialog])
+
   return (
-    <Modal
-      isVisible={visible}
-      {...ModalProps}
-      onBackdropPress={() => onClose}
-      onBackButtonPress={() => onClose}>
-      <View style={styles.stationDialog}>
-        <Text style={styles.stationInputTitle}>Enter Station ID</Text>
-        <TextInput
-          style={styles.stationInput}
-          defaultValue={inputStationId}
-          placeholder='e.g: LEMOC0002-1'
-          placeholderTextColor={textPlacehoder}
-          onChangeText={text => setInput(text)}
-        />
-        <View style={styles.dialogButtons}>
-          <Button
-            textSize={17}
-            style={styles.buttonCancel}
-            viewStyle={ViewHeight(42)}
-            text='Close'
-            textColor={textCancel}
-            onClick={onClose}/>
-          <Button
-            textSize={17}
-            style={styles.buttonOK}
-            viewStyle={ViewHeight(42)}
-            text='Confirm'
-            onClick={() => enterStatioinId()}/>
+    iosKillDialog
+    ? <Modal
+        isVisible={visible}
+        {...ModalProps}
+        onBackdropPress={() => onClose}
+        onBackButtonPress={() => onClose}>
+        <View style={styles.stationDialog}>
+          <Text style={styles.stationInputTitle}>Enter Station ID</Text>
+          <TextInput
+            style={styles.stationInput}
+            defaultValue={inputStationId}
+            placeholder='e.g: LEMOC0002-1'
+            placeholderTextColor={textPlacehoder}
+            onChangeText={text => setInput(text)}
+          />
+          <View style={styles.dialogButtons}>
+            <Button
+              textSize={17}
+              style={styles.buttonCancel}
+              viewStyle={ViewHeight(42)}
+              text='Close'
+              textColor={textCancel}
+              onClick={onClose}/>
+            <Button
+              textSize={17}
+              style={styles.buttonOK}
+              viewStyle={ViewHeight(42)}
+              text='Confirm'
+              onClick={() => enterStatioinId()}/>
+          </View>
         </View>
-      </View>
-    </Modal>
+      </Modal>
+    : <></>
   )
 }