Browse Source

transition bug fix

Signed-off-by: abhishek2513 <abhishek.dogra25130@gmail.com>
abhishek2513 1 year ago
parent
commit
ee75cb279d
1 changed files with 8 additions and 6 deletions
  1. 8 6
      iOSClient/Main/Collection Common/NCCollectionViewCommon.swift

+ 8 - 6
iOSClient/Main/Collection Common/NCCollectionViewCommon.swift

@@ -66,7 +66,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
     private var pushed: Bool = false
 
     private var tipView: EasyTipView?
-
+    private var isTransitioning: Bool = false
     // DECLARE
     internal var layoutKey = ""
     internal var titleCurrentFolder = ""
@@ -733,9 +733,12 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
     func accountRequestAddAccount() {
         appDelegate.openLogin(viewController: self, selector: NCGlobal.shared.introLogin, openLoginWeb: false)
     }
-
+    
     func tapButtonSwitch(_ sender: Any) {
-
+        
+        guard isTransitioning == false else { return }
+        isTransitioning = true
+        
         if layoutForView?.layout == NCGlobal.shared.layoutGrid {
 
             // list layout
@@ -749,8 +752,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
 
             self.collectionView.reloadData()
             self.collectionView.collectionViewLayout.invalidateLayout()
-            self.collectionView.setCollectionViewLayout(self.listLayout, animated: true)
-
+            self.collectionView.setCollectionViewLayout(self.listLayout, animated: true) {_ in self.isTransitioning = false }
         } else {
 
             // grid layout
@@ -768,7 +770,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
 
             self.collectionView.reloadData()
             self.collectionView.collectionViewLayout.invalidateLayout()
-            self.collectionView.setCollectionViewLayout(self.gridLayout, animated: true)
+            self.collectionView.setCollectionViewLayout(self.gridLayout, animated: true) {_ in self.isTransitioning = false }
         }
     }