marinofaggiana hace 5 años
padre
commit
cfe7c74659
Se han modificado 4 ficheros con 245 adiciones y 5 borrados
  1. 1 1
      Cartfile
  2. 20 4
      iOSClient/Main/CCMain.m
  3. 45 0
      iOSClient/Share/NCShare.storyboard
  4. 179 0
      iOSClient/Share/NCShare.swift

+ 1 - 1
Cartfile

@@ -1,4 +1,4 @@
-github "tilltue/TLPhotoPicker" == 1.9.2
+github "tilltue/TLPhotoPicker" == 1.9.3
 github "kishikawakatsumi/UICKeyChainStore" == 2.1.2
 github "danielsaidi/Sheeeeeeeeet" == 1.2.2
 github "MortimerGoro/MGSwipeTableCell" == 1.6.8

+ 20 - 4
iOSClient/Main/CCMain.m

@@ -1879,19 +1879,35 @@
 
 - (void)openShareWithMetadata:(tableMetadata *)metadata
 {
+#ifdef DEBUG
+
+    UINavigationController *shareNavigationController = [[UIStoryboard storyboardWithName:@"NCShare" bundle:nil] instantiateInitialViewController];
+    NCShare *shareViewController = (NCShare *)shareNavigationController.topViewController;
+    
+    shareViewController.metadata = metadata;
+    shareViewController.shareLink = [appDelegate.sharesLink objectForKey:metadata.fileID];
+    shareViewController.shareUserAndGroup = [appDelegate.sharesUserAndGroup objectForKey:metadata.fileID];;
+    
+    [shareNavigationController setModalPresentationStyle:UIModalPresentationFormSheet];
+    [self presentViewController:shareNavigationController animated:YES completion:nil];
+    
+#else
+
     // Apriamo la view
     CCShareOC *shareOC = [[UIStoryboard storyboardWithName:@"CCShare" bundle:nil] instantiateViewControllerWithIdentifier:@"CCShareOC"];
-        
+    
     shareOC.delegate = self;
-        
+    
     shareOC.metadata = metadata;
     shareOC.serverUrl = metadata.serverUrl;
-        
+    
     shareOC.shareLink = [appDelegate.sharesLink objectForKey:metadata.fileID];
     shareOC.shareUserAndGroup = [appDelegate.sharesUserAndGroup objectForKey:metadata.fileID];
-        
+    
     [shareOC setModalPresentationStyle:UIModalPresentationFormSheet];
     [self presentViewController:shareOC animated:YES completion:nil];
+    
+#endif
 }
 
 - (void)readShareServer

+ 45 - 0
iOSClient/Share/NCShare.storyboard

@@ -44,5 +44,50 @@
             </objects>
             <point key="canvasLocation" x="334.78260869565219" y="-167.41071428571428"/>
         </scene>
+        <!--View Controller-->
+        <scene sceneID="tNH-9u-08n">
+            <objects>
+                <viewController storyboardIdentifier="activity" id="Q5S-G4-EEF" sceneMemberID="viewController">
+                    <view key="view" contentMode="scaleToFill" id="7uF-QZ-62w">
+                        <rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
+                        <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+                        <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
+                        <viewLayoutGuide key="safeArea" id="USS-2P-JRO"/>
+                    </view>
+                </viewController>
+                <placeholder placeholderIdentifier="IBFirstResponder" id="NcC-LH-u4T" userLabel="First Responder" sceneMemberID="firstResponder"/>
+            </objects>
+            <point key="canvasLocation" x="335" y="528"/>
+        </scene>
+        <!--View Controller-->
+        <scene sceneID="R3f-Og-D1Y">
+            <objects>
+                <viewController storyboardIdentifier="comments" id="GMr-2Y-4vs" sceneMemberID="viewController">
+                    <view key="view" contentMode="scaleToFill" id="5MM-pX-rNX">
+                        <rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
+                        <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+                        <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
+                        <viewLayoutGuide key="safeArea" id="j3W-IW-lzW"/>
+                    </view>
+                </viewController>
+                <placeholder placeholderIdentifier="IBFirstResponder" id="l4G-HZ-s1x" userLabel="First Responder" sceneMemberID="firstResponder"/>
+            </objects>
+            <point key="canvasLocation" x="1032" y="528"/>
+        </scene>
+        <!--View Controller-->
+        <scene sceneID="Iqh-6B-MEV">
+            <objects>
+                <viewController storyboardIdentifier="sharing" id="bgO-Rz-2M1" sceneMemberID="viewController">
+                    <view key="view" contentMode="scaleToFill" id="aV2-U6-JTf">
+                        <rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
+                        <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+                        <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
+                        <viewLayoutGuide key="safeArea" id="eAi-wv-a4Y"/>
+                    </view>
+                </viewController>
+                <placeholder placeholderIdentifier="IBFirstResponder" id="4Te-U6-4XT" userLabel="First Responder" sceneMemberID="firstResponder"/>
+            </objects>
+            <point key="canvasLocation" x="1720" y="528"/>
+        </scene>
     </scenes>
 </document>

+ 179 - 0
iOSClient/Share/NCShare.swift

@@ -25,11 +25,190 @@ import Foundation
 import Parchment
 
 class NCShare: UIViewController {
+    
+    private let pagingViewController = NCShareHeaderViewController()
+    
+    @objc var metadata: tableMetadata?
+    @objc var shareLink: String = ""
+    @objc var shareUserAndGroup: String = ""
+
     override func viewDidLoad() {
         super.viewDidLoad()
         
         let storyboard = UIStoryboard(name: "NCShare", bundle: nil)
+        
+        let activityViewController = storyboard.instantiateViewController(withIdentifier: "activity")
+        let commentsViewController = storyboard.instantiateViewController(withIdentifier: "comments")
+        let sharingViewController = storyboard.instantiateViewController(withIdentifier: "sharing")
+    
+        let pagingViewController = FixedPagingViewController(viewControllers: [
+            activityViewController,
+            commentsViewController,
+            sharingViewController
+        ])
+        
+        addChild(pagingViewController)
+        view.addSubview(pagingViewController.view)
+        pagingViewController.didMove(toParent: self)
+        
+        pagingViewController.selectedTextColor = .black
+        pagingViewController.indicatorColor = .black
+        pagingViewController.indicatorOptions = .visible(
+            height: 1,
+            zIndex: Int.max,
+            spacing: .zero,
+            insets: .zero
+        )
+        
+        // Contrain the paging view to all edges.
+        pagingViewController.view.translatesAutoresizingMaskIntoConstraints = false
+        NSLayoutConstraint.activate([
+            pagingViewController.view.topAnchor.constraint(equalTo: view.topAnchor),
+            pagingViewController.view.bottomAnchor.constraint(equalTo: view.bottomAnchor),
+            pagingViewController.view.leadingAnchor.constraint(equalTo: view.leadingAnchor),
+            pagingViewController.view.trailingAnchor.constraint(equalTo: view.trailingAnchor),
+        ])
+        
+        var image = CCGraphics.changeThemingColorImage(UIImage(named: "exit")!, width: 40, height: 40, color: UIColor.gray)
+        image = image?.withRenderingMode(.alwaysOriginal)
+        self.navigationItem.rightBarButtonItem = UIBarButtonItem(image: image, style:.plain, target: self, action: #selector(exitTapped))
+        
+        let iconFileExists = FileManager.default.fileExists(atPath: CCUtility.getDirectoryProviderStorageIconFileID(metadata?.fileID, fileNameView: metadata?.fileNameView))
+        
+        
+        
+        /*
+        if iconFileExists {
+        
+            cell.file.image = UIImage.init(contentsOfFile: CCUtility.getDirectoryProviderStorageIconFileID(metadata.fileID, fileNameView: metadata.fileNameView))
+        } else {
+            if metadata.iconName.count > 0 {
+                cell.file.image = UIImage.init(named: metadata.iconName)
+            } else {
+                cell.file.image = UIImage.init(named: "file")
+            }
+        }
+        */
+        
+        // Set our data source and delegate.
+        pagingViewController.dataSource = self
+        pagingViewController.delegate = self
+    }
+    
+    @objc func exitTapped() {
+        self.dismiss(animated: true, completion: nil)
+    }
+}
+
+extension NCShare: PagingViewControllerDataSource {
+    
+    func pagingViewController<T>(_ pagingViewController: PagingViewController<T>, viewControllerForIndex index: Int) -> UIViewController {
+        let viewController = TableViewController()
+        
+        // Inset the table view with the height of the menu height.
+        let height = pagingViewController.options.menuHeight + CustomPagingView.HeaderHeight
+        let insets = UIEdgeInsets(top: height, left: 0, bottom: 0, right: 0)
+        viewController.tableView.contentInset = insets
+        viewController.tableView.scrollIndicatorInsets = insets
+        viewController.tableView.delegate = self
+        
+        return viewController
+    }
+    
+    func pagingViewController<T>(_ pagingViewController: PagingViewController<T>, pagingItemForIndex index: Int) -> T {
+        return PagingIndexItem(index: index, title: "View \(index)") as! T
+    }
+    
+    func numberOfViewControllers<T>(in: PagingViewController<T>) -> Int{
+        return 3
+    }
+    
+}
 
+extension NCShare: PagingViewControllerDelegate {
+    
+    func pagingViewController<T>(_ pagingViewController: PagingViewController<T>, didScrollToItem pagingItem: T, startingViewController: UIViewController?, destinationViewController: UIViewController, transitionSuccessful: Bool) {
+        guard let startingViewController = startingViewController as? TableViewController else { return }
+        guard let destinationViewController = destinationViewController as? TableViewController else { return }
+        
+        // Set the delegate on the currently selected view so that we can
+        // listen to the scroll view delegate.
+        if transitionSuccessful {
+            startingViewController.tableView.delegate = nil
+            destinationViewController.tableView.delegate = self
+        }
+    }
+    
+    func pagingViewController<T>(_ pagingViewController: PagingViewController<T>, willScrollToItem pagingItem: T, startingViewController: UIViewController, destinationViewController: UIViewController) {
+        guard let destinationViewController = destinationViewController as? TableViewController else { return }
+        
+        // Update the content offset based on the height of the header view.
+        if let pagingView = pagingViewController.view as? CustomPagingView {
+            if let headerHeight = pagingView.headerHeightConstraint?.constant {
+                let offset = headerHeight + pagingViewController.options.menuHeight
+                destinationViewController.tableView.contentOffset = CGPoint(x: 0, y: -offset)
+            }
+        }
     }
+    
+}
 
+class NCShareHeaderViewController: PagingViewController<PagingIndexItem> {
+    
+    public var image: UIImage?
+    func setx() {
+    
+    }
+    
+    override func loadView() {
+        view = NCShareHeader(
+            options: options,
+            collectionView: collectionView,
+            pageView: pageViewController.view
+        )
+    }
+}
+
+class NCShareHeader: PagingView {
+    
+    static let HeaderHeight: CGFloat = 200
+    var image: UIImage?
+    
+    var headerHeightConstraint: NSLayoutConstraint?
+    
+    private lazy var headerView: UIImageView = {
+        let view = UIImageView(image: UIImage(named: "file"))
+        view.contentMode = .scaleAspectFill
+        view.clipsToBounds = true
+        return view
+    }()
+    
+    override func setupConstraints() {
+        addSubview(headerView)
+        
+        pageView.translatesAutoresizingMaskIntoConstraints = false
+        collectionView.translatesAutoresizingMaskIntoConstraints = false
+        headerView.translatesAutoresizingMaskIntoConstraints = false
+        
+        headerHeightConstraint = headerView.heightAnchor.constraint(
+            equalToConstant: NCShareHeader.HeaderHeight
+        )
+        headerHeightConstraint?.isActive = true
+        
+        NSLayoutConstraint.activate([
+            collectionView.leadingAnchor.constraint(equalTo: leadingAnchor),
+            collectionView.trailingAnchor.constraint(equalTo: trailingAnchor),
+            collectionView.heightAnchor.constraint(equalToConstant: options.menuHeight),
+            collectionView.topAnchor.constraint(equalTo: headerView.bottomAnchor),
+            
+            headerView.topAnchor.constraint(equalTo: topAnchor),
+            headerView.leadingAnchor.constraint(equalTo: leadingAnchor),
+            headerView.trailingAnchor.constraint(equalTo: trailingAnchor),
+            
+            pageView.leadingAnchor.constraint(equalTo: leadingAnchor),
+            pageView.trailingAnchor.constraint(equalTo: trailingAnchor),
+            pageView.bottomAnchor.constraint(equalTo: bottomAnchor),
+            pageView.topAnchor.constraint(equalTo: topAnchor)
+        ])
+    }
 }