Marino Faggiana 6 anni fa
parent
commit
50b86ad793

+ 0 - 4
Nextcloud.xcodeproj/project.pbxproj

@@ -145,7 +145,6 @@
 		F73B4F141F470D9100BBEE4B /* nsUTF8Prober.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F73B4EE71F470D9100BBEE4B /* nsUTF8Prober.cpp */; };
 		F73B4F151F470D9100BBEE4B /* symbols.cmake in Resources */ = {isa = PBXBuildFile; fileRef = F73B4EEA1F470D9100BBEE4B /* symbols.cmake */; };
 		F73B4F171F470D9100BBEE4B /* uchardet.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F73B4EEC1F470D9100BBEE4B /* uchardet.cpp */; };
-		F73B4F791E8D3BF800A97F07 /* CCMainTabBarController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F73B4F781E8D3BF800A97F07 /* CCMainTabBarController.swift */; };
 		F73CC0691E813DFF006E3047 /* BKPasscodeDummyViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = F73CC0591E813DFF006E3047 /* BKPasscodeDummyViewController.m */; };
 		F73CC06A1E813DFF006E3047 /* BKPasscodeDummyViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = F73CC0591E813DFF006E3047 /* BKPasscodeDummyViewController.m */; };
 		F73CC06C1E813DFF006E3047 /* BKPasscodeField.m in Sources */ = {isa = PBXBuildFile; fileRef = F73CC05B1E813DFF006E3047 /* BKPasscodeField.m */; };
@@ -800,7 +799,6 @@
 		F73B4EEA1F470D9100BBEE4B /* symbols.cmake */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = symbols.cmake; sourceTree = "<group>"; };
 		F73B4EEC1F470D9100BBEE4B /* uchardet.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = uchardet.cpp; sourceTree = "<group>"; };
 		F73B4EED1F470D9100BBEE4B /* uchardet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = uchardet.h; sourceTree = "<group>"; };
-		F73B4F781E8D3BF800A97F07 /* CCMainTabBarController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CCMainTabBarController.swift; sourceTree = "<group>"; };
 		F73CB5771ED46807005F2A5A /* NCBridgeSwift.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NCBridgeSwift.h; sourceTree = "<group>"; };
 		F73CC0581E813DFF006E3047 /* BKPasscodeDummyViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BKPasscodeDummyViewController.h; sourceTree = "<group>"; };
 		F73CC0591E813DFF006E3047 /* BKPasscodeDummyViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BKPasscodeDummyViewController.m; sourceTree = "<group>"; };
@@ -1773,7 +1771,6 @@
 				F70211F71BAC56E9003FC03E /* CCCellMainTransfer.h */,
 				F70211F81BAC56E9003FC03E /* CCCellMainTransfer.m */,
 				F70211F91BAC56E9003FC03E /* CCCellMainTransfer.xib */,
-				F73B4F781E8D3BF800A97F07 /* CCMainTabBarController.swift */,
 				F70211FA1BAC56E9003FC03E /* CCMain.h */,
 				F70211FB1BAC56E9003FC03E /* CCMain.m */,
 				F7226EDB1EE4089300EBECB1 /* Main.storyboard */,
@@ -3729,7 +3726,6 @@
 				F762CB0D1EACB66200B38484 /* NSArray+XLFormAdditions.m in Sources */,
 				F7F801031D98205A007537BC /* CCCertificate.m in Sources */,
 				F77B0E4F1D118A16002130FE /* CCManageAutoUpload.m in Sources */,
-				F73B4F791E8D3BF800A97F07 /* CCMainTabBarController.swift in Sources */,
 				F7FCFFE01D707B83000E6E29 /* CCPeekPop.m in Sources */,
 				F7BAADC81ED5A87C00B7EAD4 /* NCDatabase.swift in Sources */,
 				F77B0E541D118A16002130FE /* CCMove.m in Sources */,

+ 0 - 103
iOSClient/Main/CCMainTabBarController.swift

@@ -1,103 +0,0 @@
-//
-//  CCMainTabBarController.swift
-//  Nextcloud iOS
-//
-//  Created by Marino Faggiana on 30/03/17.
-//  Copyright © 2017 TWS. All rights reserved.
-//
-//  Author Marino Faggiana <m.faggiana@twsweb.it>
-//
-//  This program is free software: you can redistribute it and/or modify
-//  it under the terms of the GNU General Public License as published by
-//  the Free Software Foundation, either version 3 of the License, or
-//  (at your option) any later version.
-//
-//  This program is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-//  GNU General Public License for more details.
-//
-//  You should have received a copy of the GNU General Public License
-//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
-//
-
-import Foundation
-
-class CCMainTabBarController : UITabBarController, UITabBarControllerDelegate {
-    
-    override func viewDidLoad() {
-        
-        super.viewDidLoad()
-        delegate = self
-    }
-    
-    //Delegate methods
-    func tabBarController(_ tabBarController: UITabBarController, shouldSelect viewController: UIViewController) -> Bool {
-        
-        let tabViewControllers = tabBarController.viewControllers!
-        guard let toIndex = tabViewControllers.index(of: viewController) else {
-            
-            if let vc = viewController as? UINavigationController {
-                vc.popToRootViewController(animated: true);
-            }
-            
-            return false
-        }
-        
-        animateToTab(toIndex: toIndex)
-        
-        return true
-    }
-    
-    func animateToTab(toIndex: Int) {
-        
-        let tabViewControllers = viewControllers!
-        let fromView = selectedViewController!.view!
-        let toView = tabViewControllers[toIndex].view!
-        let fromIndex = tabViewControllers.index(of: selectedViewController!)
-        
-        guard fromIndex != toIndex else {return}
-        
-        // Add the toView to the tab bar view
-        fromView.superview?.addSubview(toView)
-        fromView.superview?.backgroundColor = UIColor.white
-        
-        // Position toView off screen (to the left/right of fromView)
-        let screenWidth = UIScreen.main.bounds.size.width;
-        let scrollRight = toIndex > fromIndex!;
-        let offset = (scrollRight ? screenWidth : -screenWidth)
-        toView.center = CGPoint(x: (fromView.center.x) + offset, y: (toView.center.y))
-        
-        // Disable interaction during animation
-        view.isUserInteractionEnabled = false
-        
-        UIView.animate(withDuration: 0.3, delay: 0.0, usingSpringWithDamping: 1, initialSpringVelocity: 0, options: UIViewAnimationOptions.curveEaseOut, animations: {
-            
-            // Slide the views by -offset
-            fromView.center = CGPoint(x: fromView.center.x - offset, y: fromView.center.y);
-            toView.center   = CGPoint(x: toView.center.x - offset, y: toView.center.y);
-            
-        }, completion: { finished in
-            
-            // Remove the old view from the tabbar view.
-            fromView.removeFromSuperview()
-            self.selectedIndex = toIndex
-            self.view.isUserInteractionEnabled = true
-        })
-    }
-}
-
-//
-// https://stackoverflow.com/questions/44822558/ios-11-uitabbar-uitabbaritem-positioning-issue/46348796#46348796
-//
-extension UITabBar {
-    // Workaround for iOS 11's new UITabBar behavior where on iPad, the UITabBar inside
-    // the Master view controller shows the UITabBarItem icon next to the text
-    override open var traitCollection: UITraitCollection {
-        if UIDevice.current.userInterfaceIdiom == .pad {
-            return UITraitCollection(horizontalSizeClass: .compact)
-        }
-        return super.traitCollection
-    }
-}
-

+ 80 - 0
iOSClient/Main/NCMainCommon.swift

@@ -568,6 +568,86 @@ class NCMainCommon: NSObject {
             })
         }
     }
+}
+    
+//MARK: -
     
+class CCMainTabBarController : UITabBarController, UITabBarControllerDelegate {
+        
+    override func viewDidLoad() {
+            
+        super.viewDidLoad()
+        delegate = self
+    }
+        
+    //Delegate methods
+    func tabBarController(_ tabBarController: UITabBarController, shouldSelect viewController: UIViewController) -> Bool {
+            
+        let tabViewControllers = tabBarController.viewControllers!
+        guard let toIndex = tabViewControllers.index(of: viewController) else {
+                
+            if let vc = viewController as? UINavigationController {
+                vc.popToRootViewController(animated: true);
+            }
+                
+            return false
+        }
+            
+        animateToTab(toIndex: toIndex)
+            
+        return true
+    }
+        
+    func animateToTab(toIndex: Int) {
+            
+        let tabViewControllers = viewControllers!
+        let fromView = selectedViewController!.view!
+        let toView = tabViewControllers[toIndex].view!
+        let fromIndex = tabViewControllers.index(of: selectedViewController!)
+            
+        guard fromIndex != toIndex else {return}
+            
+        // Add the toView to the tab bar view
+        fromView.superview?.addSubview(toView)
+        fromView.superview?.backgroundColor = UIColor.white
+            
+        // Position toView off screen (to the left/right of fromView)
+        let screenWidth = UIScreen.main.bounds.size.width;
+        let scrollRight = toIndex > fromIndex!;
+        let offset = (scrollRight ? screenWidth : -screenWidth)
+        toView.center = CGPoint(x: (fromView.center.x) + offset, y: (toView.center.y))
+            
+        // Disable interaction during animation
+        view.isUserInteractionEnabled = false
+            
+        UIView.animate(withDuration: 0.3, delay: 0.0, usingSpringWithDamping: 1, initialSpringVelocity: 0, options: UIViewAnimationOptions.curveEaseOut, animations: {
+                
+            // Slide the views by -offset
+            fromView.center = CGPoint(x: fromView.center.x - offset, y: fromView.center.y);
+            toView.center   = CGPoint(x: toView.center.x - offset, y: toView.center.y);
+                
+        }, completion: { finished in
+                
+            // Remove the old view from the tabbar view.
+            fromView.removeFromSuperview()
+            self.selectedIndex = toIndex
+            self.view.isUserInteractionEnabled = true
+        })
+    }
+}
+
+//
+// https://stackoverflow.com/questions/44822558/ios-11-uitabbar-uitabbaritem-positioning-issue/46348796#46348796
+//
+extension UITabBar {
+    // Workaround for iOS 11's new UITabBar behavior where on iPad, the UITabBar inside
+    // the Master view controller shows the UITabBarItem icon next to the text
+    override open var traitCollection: UITraitCollection {
+        if UIDevice.current.userInterfaceIdiom == .pad {
+            return UITraitCollection(horizontalSizeClass: .compact)
+        }
+        return super.traitCollection
+    }
 }
 
+