소스 검색

clear code

marinofaggiana 4 년 전
부모
커밋
e1f1f9352c
1개의 변경된 파일48개의 추가작업 그리고 48개의 파일을 삭제
  1. 48 48
      iOSClient/Utility/NCPopupViewController.swift

+ 48 - 48
iOSClient/Utility/NCPopupViewController.swift

@@ -71,7 +71,7 @@ public class NCPopupViewController: UIViewController {
     
     private var containerView = UIView()
     
-    // MARK: -
+    // MARK: - Life Cycle
     
     // NOTE: Don't use this init method
     required public init?(coder aDecoder: NSCoder) {
@@ -127,53 +127,6 @@ public class NCPopupViewController: UIViewController {
         NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillHide(_:)), name: UIResponder.keyboardWillHideNotification, object: nil);
     }
     
-    // MARK: -
-    
-    @objc internal func keyboardWillShow(_ notification : Notification?) {
-                
-        var keyboardSize = CGSize.zero
-        
-        if let info = notification?.userInfo {
-
-            let frameEndUserInfoKey = UIResponder.keyboardFrameEndUserInfoKey
-                    
-            //  Getting UIKeyboardSize.
-            if let keyboardFrame = info[frameEndUserInfoKey] as? CGRect {
-                        
-                let screenSize = UIScreen.main.bounds
-                        
-                //Calculating actual keyboard displayed size, keyboard frame may be different when hardware keyboard is attached (Bug ID: #469) (Bug ID: #381)
-                let intersectRect = keyboardFrame.intersection(screenSize)
-                        
-                if intersectRect.isNull {
-                    keyboardSize = CGSize(width: screenSize.size.width, height: 0)
-                } else {
-                    keyboardSize = intersectRect.size
-                }
-                
-                if keyboardPosizionEnabled {
-                                           
-                    let popupDiff = screenSize.height - ((screenSize.height - (popupHeight ?? 0)) / 2)
-                    let keyboardDiff = screenSize.height - keyboardSize.height
-                    let diff = popupDiff - keyboardDiff
-                    
-                    if centerYConstraint != nil && diff > 0 {
-                        centerYConstraint?.constant = -(diff + 10)
-                    }
-                }
-            }
-        }
-    }
-    
-    @objc func keyboardWillHide(_ notification: Notification) {
-        
-        if keyboardPosizionEnabled {
-            if centerYConstraint != nil {
-                centerYConstraint?.constant = 0
-            }
-        }
-    }
-    
     // MARK: - Setup
 
     private func addDismissGesture() {
@@ -252,6 +205,53 @@ public class NCPopupViewController: UIViewController {
             self.delegate?.popupViewControllerDidDismissByTapGesture(self)
         }
     }
+    
+    // MARK: - Keyboard notification
+    
+    @objc internal func keyboardWillShow(_ notification : Notification?) {
+                
+        var keyboardSize = CGSize.zero
+        
+        if let info = notification?.userInfo {
+
+            let frameEndUserInfoKey = UIResponder.keyboardFrameEndUserInfoKey
+                    
+            //  Getting UIKeyboardSize.
+            if let keyboardFrame = info[frameEndUserInfoKey] as? CGRect {
+                        
+                let screenSize = UIScreen.main.bounds
+                        
+                //Calculating actual keyboard displayed size, keyboard frame may be different when hardware keyboard is attached (Bug ID: #469) (Bug ID: #381)
+                let intersectRect = keyboardFrame.intersection(screenSize)
+                        
+                if intersectRect.isNull {
+                    keyboardSize = CGSize(width: screenSize.size.width, height: 0)
+                } else {
+                    keyboardSize = intersectRect.size
+                }
+                
+                if keyboardPosizionEnabled {
+                                           
+                    let popupDiff = screenSize.height - ((screenSize.height - (popupHeight ?? 0)) / 2)
+                    let keyboardDiff = screenSize.height - keyboardSize.height
+                    let diff = popupDiff - keyboardDiff
+                    
+                    if centerYConstraint != nil && diff > 0 {
+                        centerYConstraint?.constant = -(diff + 10)
+                    }
+                }
+            }
+        }
+    }
+    
+    @objc func keyboardWillHide(_ notification: Notification) {
+        
+        if keyboardPosizionEnabled {
+            if centerYConstraint != nil {
+                centerYConstraint?.constant = 0
+            }
+        }
+    }
 }
 
 // MARK: - UIGestureRecognizerDelegate