Browse Source

Animation Tab Bar Controller

Marino Faggiana 8 years ago
parent
commit
d8c43953d3

+ 4 - 0
Nextcloud.xcodeproj/project.pbxproj

@@ -125,6 +125,7 @@
 		F732B3371E8045A1002B7D75 /* SwiftWebVC.strings in Resources */ = {isa = PBXBuildFile; fileRef = F732B3351E8045A1002B7D75 /* SwiftWebVC.strings */; };
 		F732BA061D76CE1500E9878B /* CCNetworking.m in Sources */ = {isa = PBXBuildFile; fileRef = F732BA041D76CE1500E9878B /* CCNetworking.m */; };
 		F732BA0B1D76DBA500E9878B /* CCNetworking.m in Sources */ = {isa = PBXBuildFile; fileRef = F732BA041D76CE1500E9878B /* CCNetworking.m */; };
+		F73B4F791E8D3BF800A97F07 /* CCMainTabBarController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F73B4F781E8D3BF800A97F07 /* CCMainTabBarController.swift */; };
 		F73C002F1E55D7DF00EEEFA7 /* CCManageCryptoCloudSecurity.m in Sources */ = {isa = PBXBuildFile; fileRef = F73C002E1E55D7DF00EEEFA7 /* CCManageCryptoCloudSecurity.m */; };
 		F73C41501E82E51F000137C0 /* TableExternalSites+CoreDataClass.m in Sources */ = {isa = PBXBuildFile; fileRef = F73C414D1E82E51F000137C0 /* TableExternalSites+CoreDataClass.m */; };
 		F73C41511E82E51F000137C0 /* TableExternalSites+CoreDataClass.m in Sources */ = {isa = PBXBuildFile; fileRef = F73C414D1E82E51F000137C0 /* TableExternalSites+CoreDataClass.m */; };
@@ -1127,6 +1128,7 @@
 		F73814291E65A52D0011A45E /* fr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fr; path = fr.lproj/InfoPlist.strings; sourceTree = "<group>"; };
 		F738142A1E65A52D0011A45E /* fr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fr; path = fr.lproj/Intro.strings; sourceTree = "<group>"; };
 		F738142B1E65A52D0011A45E /* fr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fr; path = fr.lproj/Error.strings; sourceTree = "<group>"; };
+		F73B4F781E8D3BF800A97F07 /* CCMainTabBarController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CCMainTabBarController.swift; sourceTree = "<group>"; };
 		F73C002D1E55D7DF00EEEFA7 /* CCManageCryptoCloudSecurity.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCManageCryptoCloudSecurity.h; sourceTree = "<group>"; };
 		F73C002E1E55D7DF00EEEFA7 /* CCManageCryptoCloudSecurity.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CCManageCryptoCloudSecurity.m; sourceTree = "<group>"; };
 		F73C414C1E82E51F000137C0 /* TableExternalSites+CoreDataClass.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "TableExternalSites+CoreDataClass.h"; sourceTree = "<group>"; };
@@ -1755,6 +1757,7 @@
 				F70211FA1BAC56E9003FC03E /* CCMain.h */,
 				F70211FB1BAC56E9003FC03E /* CCMain.m */,
 				F7D0E65E1BC5042E008D989A /* CCDetail.h */,
+				F73B4F781E8D3BF800A97F07 /* CCMainTabBarController.swift */,
 				F7D0E65F1BC5042E008D989A /* CCDetail.m */,
 				F787E5581BC503ED00AFBFE1 /* Main.storyboard */,
 				F78F6FAE1CC8CCB700F4EA25 /* CCSection.h */,
@@ -4187,6 +4190,7 @@
 				F77B0E4F1D118A16002130FE /* CCManageCameraUpload.m in Sources */,
 				F77B0E511D118A16002130FE /* UIImage+Filtering.m in Sources */,
 				F73CCDEB1DC13776007E38D8 /* XLFormSegmentedCell.m in Sources */,
+				F73B4F791E8D3BF800A97F07 /* CCMainTabBarController.swift in Sources */,
 				F7FCFFE01D707B83000E6E29 /* CCPeekPop.m in Sources */,
 				F7F06E911DBFACC600099AE9 /* NSIndexSet+CTAssetsPickerController.m in Sources */,
 				F77B0E541D118A16002130FE /* CCMove.m in Sources */,

+ 71 - 0
iOSClient/Main/CCMainTabBarController.swift

@@ -0,0 +1,71 @@
+//
+//  CCMainTabBarController.swift
+//  Nextcloud
+//
+//  Created by Marino Faggiana on 30/03/17.
+//  Copyright © 2017 TWS. All rights reserved.
+//
+
+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!
+        let fromView = tabBarController.selectedViewController!.view
+        let toView = viewController.view
+        
+        if (fromView == toView) {
+            return false
+        }
+        
+        let fromIndex = tabViewControllers.index(of: tabBarController.selectedViewController!)
+        let toIndex = tabViewControllers.index(of: viewController)
+        
+        let offScreenRight = CGAffineTransform(translationX: (toView?.frame.width)!, y: 0)
+        let offScreenLeft = CGAffineTransform(translationX: -(toView?.frame.width)!, y: 0)
+        
+        // start the toView to the right of the screen
+        
+        if (toIndex! < fromIndex!) {
+            toView?.transform = offScreenLeft
+            fromView?.transform = offScreenRight
+        } else {
+            toView?.transform = offScreenRight
+            fromView?.transform = offScreenLeft
+        }
+        
+        fromView?.tag = 124
+        toView?.addSubview(fromView!)
+        
+        self.view.isUserInteractionEnabled = false
+        UIView.animate(withDuration: 0.5, delay: 0.0, usingSpringWithDamping: 1, initialSpringVelocity: 0, options: UIViewAnimationOptions.curveEaseOut, animations: {
+            
+            toView?.transform = CGAffineTransform.identity
+            
+        }, completion: { finished in
+            
+            let subViews = toView?.subviews
+            for subview in subViews!{
+                if (subview.tag == 124) {
+                    subview.removeFromSuperview()
+                }
+            }
+            tabBarController.selectedIndex = toIndex!
+            self.view.isUserInteractionEnabled = true
+            
+        })
+        
+        return true
+    }
+}
+

+ 4 - 4
iOSClient/Main/Main.storyboard

@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11762" systemVersion="16D32" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="4IE-mo-rkp">
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11762" systemVersion="16E195" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="4IE-mo-rkp">
     <device id="retina4_7" orientation="portrait">
         <adaptation id="fullscreen"/>
     </device>
@@ -345,10 +345,10 @@
             </objects>
             <point key="canvasLocation" x="9778" y="3019"/>
         </scene>
-        <!--Tab Bar Controller-->
+        <!--Main Tab Bar Controller-->
         <scene sceneID="gY3-Ur-rTC">
             <objects>
-                <tabBarController automaticallyAdjustsScrollViewInsets="NO" id="FkP-Lh-8zt" sceneMemberID="viewController">
+                <tabBarController automaticallyAdjustsScrollViewInsets="NO" id="FkP-Lh-8zt" customClass="CCMainTabBarController" customModule="Nextcloud" customModuleProvider="target" sceneMemberID="viewController">
                     <toolbarItems/>
                     <navigationItem key="navigationItem" id="ozb-fg-0GE">
                         <barButtonItem key="backBarButtonItem" title="Back" id="oUu-2v-gUF"/>
@@ -646,7 +646,7 @@
         <image name="cryptocloud_sfondo_iPad" width="256" height="187"/>
         <image name="fileNextcloud" width="25" height="25"/>
         <image name="tabBarFavorite" width="25" height="25"/>
-        <image name="tabBarPhotos" width="25" height="25"/>
+        <image name="tabBarPhotos" width="25" height="21"/>
         <image name="tabBarSettings" width="25" height="25"/>
     </resources>
     <inferredMetricsTieBreakers>