marinofaggiana преди 5 години
родител
ревизия
c57c834ad3

+ 16 - 16
Nextcloud.xcodeproj/project.pbxproj

@@ -441,10 +441,10 @@
 		F78F74342163757000C2ADAD /* NCTrash.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F78F74332163757000C2ADAD /* NCTrash.storyboard */; };
 		F78F74362163781100C2ADAD /* NCTrash.swift in Sources */ = {isa = PBXBuildFile; fileRef = F78F74352163781100C2ADAD /* NCTrash.swift */; };
 		F790110E21415BF600D7B136 /* NCViewerRichdocument.swift in Sources */ = {isa = PBXBuildFile; fileRef = F790110D21415BF600D7B136 /* NCViewerRichdocument.swift */; };
-		F79018B6240962C7007C9B6D /* DismissAnimationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F79018B2240962C7007C9B6D /* DismissAnimationController.swift */; };
-		F79018B7240962C7007C9B6D /* MediaContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F79018B3240962C7007C9B6D /* MediaContentView.swift */; };
-		F79018B8240962C7007C9B6D /* MediaBrowserViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F79018B4240962C7007C9B6D /* MediaBrowserViewController.swift */; };
-		F79018B9240962C7007C9B6D /* ContentTransformers.swift in Sources */ = {isa = PBXBuildFile; fileRef = F79018B5240962C7007C9B6D /* ContentTransformers.swift */; };
+		F79018B6240962C7007C9B6D /* NCViewerImageDismissAnimationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F79018B2240962C7007C9B6D /* NCViewerImageDismissAnimationController.swift */; };
+		F79018B7240962C7007C9B6D /* NCViewerImageContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F79018B3240962C7007C9B6D /* NCViewerImageContentView.swift */; };
+		F79018B8240962C7007C9B6D /* NCViewerImageViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F79018B4240962C7007C9B6D /* NCViewerImageViewController.swift */; };
+		F79018B9240962C7007C9B6D /* NCViewerImageContentTransformers.swift in Sources */ = {isa = PBXBuildFile; fileRef = F79018B5240962C7007C9B6D /* NCViewerImageContentTransformers.swift */; };
 		F79630EE215527D40015EEA5 /* NCViewerMedia.swift in Sources */ = {isa = PBXBuildFile; fileRef = F79630ED215527D40015EEA5 /* NCViewerMedia.swift */; };
 		F79728D422F96F2E003CACA7 /* NCShareLinkFolderMenuView.xib in Resources */ = {isa = PBXBuildFile; fileRef = F79728D322F96F2D003CACA7 /* NCShareLinkFolderMenuView.xib */; };
 		F79728D622F9A0B1003CACA7 /* NCShareUserFolderMenuView.xib in Resources */ = {isa = PBXBuildFile; fileRef = F79728D522F9A0B0003CACA7 /* NCShareUserFolderMenuView.xib */; };
@@ -1141,10 +1141,10 @@
 		F78F74352163781100C2ADAD /* NCTrash.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCTrash.swift; sourceTree = "<group>"; };
 		F790110D21415BF600D7B136 /* NCViewerRichdocument.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCViewerRichdocument.swift; sourceTree = "<group>"; };
 		F79018A424092EF4007C9B6D /* ATGMediaBrowser.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ATGMediaBrowser.framework; path = Carthage/Build/iOS/ATGMediaBrowser.framework; sourceTree = "<group>"; };
-		F79018B2240962C7007C9B6D /* DismissAnimationController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DismissAnimationController.swift; sourceTree = "<group>"; };
-		F79018B3240962C7007C9B6D /* MediaContentView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MediaContentView.swift; sourceTree = "<group>"; };
-		F79018B4240962C7007C9B6D /* MediaBrowserViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MediaBrowserViewController.swift; sourceTree = "<group>"; };
-		F79018B5240962C7007C9B6D /* ContentTransformers.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ContentTransformers.swift; sourceTree = "<group>"; };
+		F79018B2240962C7007C9B6D /* NCViewerImageDismissAnimationController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NCViewerImageDismissAnimationController.swift; sourceTree = "<group>"; };
+		F79018B3240962C7007C9B6D /* NCViewerImageContentView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NCViewerImageContentView.swift; sourceTree = "<group>"; };
+		F79018B4240962C7007C9B6D /* NCViewerImageViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NCViewerImageViewController.swift; sourceTree = "<group>"; };
+		F79018B5240962C7007C9B6D /* NCViewerImageContentTransformers.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NCViewerImageContentTransformers.swift; sourceTree = "<group>"; };
 		F7956FC91B4886E60085DEA3 /* CCUploadFromOtherUpp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCUploadFromOtherUpp.h; sourceTree = "<group>"; };
 		F7956FCA1B4886E60085DEA3 /* CCUploadFromOtherUpp.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CCUploadFromOtherUpp.m; sourceTree = "<group>"; };
 		F7956FCB1B4886E60085DEA3 /* CCUploadFromOtherUpp.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = CCUploadFromOtherUpp.storyboard; sourceTree = "<group>"; };
@@ -2179,11 +2179,11 @@
 		F79018B1240962C7007C9B6D /* NCViewerImage */ = {
 			isa = PBXGroup;
 			children = (
-				F79018B2240962C7007C9B6D /* DismissAnimationController.swift */,
-				F79018B3240962C7007C9B6D /* MediaContentView.swift */,
+				F79018B2240962C7007C9B6D /* NCViewerImageDismissAnimationController.swift */,
+				F79018B3240962C7007C9B6D /* NCViewerImageContentView.swift */,
 				F7381439240FE48D00404AC7 /* NCViewerImageCommon.swift */,
-				F79018B4240962C7007C9B6D /* MediaBrowserViewController.swift */,
-				F79018B5240962C7007C9B6D /* ContentTransformers.swift */,
+				F79018B4240962C7007C9B6D /* NCViewerImageViewController.swift */,
+				F79018B5240962C7007C9B6D /* NCViewerImageContentTransformers.swift */,
 			);
 			path = NCViewerImage;
 			sourceTree = "<group>";
@@ -3404,7 +3404,7 @@
 				F77B0E041D118A16002130FE /* UIImage+animatedGIF.m in Sources */,
 				37ECC83B23D0C7410082EFA2 /* NCMenuAction.swift in Sources */,
 				F73B4EFE1F470D9100BBEE4B /* LangHungarianModel.cpp in Sources */,
-				F79018B8240962C7007C9B6D /* MediaBrowserViewController.swift in Sources */,
+				F79018B8240962C7007C9B6D /* NCViewerImageViewController.swift in Sources */,
 				F769454022E9F077000A798A /* NCSharePaging.swift in Sources */,
 				F760F79921F21F61006B1A73 /* CropViewController.swift in Sources */,
 				F70022EC1EC4C9100080073F /* OCXMLSharedParser.m in Sources */,
@@ -3418,7 +3418,7 @@
 				F73F537F1E929C8500F8678D /* CCMore.swift in Sources */,
 				F73B4EF71F470D9100BBEE4B /* LangBulgarianModel.cpp in Sources */,
 				F7F54D0C1E5B14C800E19C62 /* MWTapDetectingView.m in Sources */,
-				F79018B7240962C7007C9B6D /* MediaContentView.swift in Sources */,
+				F79018B7240962C7007C9B6D /* NCViewerImageContentView.swift in Sources */,
 				F7FB1D3E215E191D00D669EA /* NCViewerDocumentWeb.swift in Sources */,
 				F78E7065219F096B006F23E4 /* NCAvatar.swift in Sources */,
 				F7DFB7F0219C5B8000680748 /* NCCreateFormUploadAssets.swift in Sources */,
@@ -3587,7 +3587,7 @@
 				F70022D41EC4C9100080073F /* NSDate+ISO8601.m in Sources */,
 				F762CB151EACB66200B38484 /* XLFormRowNavigationAccessoryView.m in Sources */,
 				F762CB0A1EACB66200B38484 /* XLFormDescriptor.m in Sources */,
-				F79018B6240962C7007C9B6D /* DismissAnimationController.swift in Sources */,
+				F79018B6240962C7007C9B6D /* NCViewerImageDismissAnimationController.swift in Sources */,
 				F7020FCE2233D7F700B7297D /* NCCreateFormUploadVoiceNote.swift in Sources */,
 				F7F4B1D823C74B3E00D82A6E /* NCRichWorkspace.swift in Sources */,
 				F726EEEC1FED1C820030B9C8 /* NCEndToEndInitialize.swift in Sources */,
@@ -3604,7 +3604,7 @@
 				F707C26521A2DC5200F6181E /* NCStoreReview.swift in Sources */,
 				F73B4EFF1F470D9100BBEE4B /* LangRussianModel.cpp in Sources */,
 				F7BAADCB1ED5A87C00B7EAD4 /* NCManageDatabase.swift in Sources */,
-				F79018B9240962C7007C9B6D /* ContentTransformers.swift in Sources */,
+				F79018B9240962C7007C9B6D /* NCViewerImageContentTransformers.swift in Sources */,
 				F7A321551E9E2A070069AD1B /* CCFavorites.m in Sources */,
 				F704FA5C232A343F00BBA952 /* IMImagemeterViewer.swift in Sources */,
 				F73B4F031F470D9100BBEE4B /* LangVietnameseModel.cpp in Sources */,

+ 7 - 7
iOSClient/Main/NCDetailViewController.swift

@@ -37,7 +37,7 @@ class NCDetailViewController: UIViewController {
     @objc var offlineFilterImage: Bool = false
 
     private let appDelegate = UIApplication.shared.delegate as! AppDelegate
-    private var mediaBrowser: MediaBrowserViewController?
+    private var mediaBrowser: NCViewerImageViewController?
     private var metadatas = [tableMetadata]()
     private var mediaBrowserIndexStart = 0
         
@@ -378,7 +378,7 @@ class NCDetailViewController: UIViewController {
 
 //MARK: - MediaBrowser - Delegate/DataSource
 
-extension NCDetailViewController: MediaBrowserViewControllerDelegate, MediaBrowserViewControllerDataSource {
+extension NCDetailViewController: NCViewerImageViewControllerDelegate, NCViewerImageViewControllerDataSource {
     
     func viewImage() {
         
@@ -393,7 +393,7 @@ extension NCDetailViewController: MediaBrowserViewControllerDelegate, MediaBrows
             }
             self.metadatas = metadatas
             
-            mediaBrowser = MediaBrowserViewController(index: mediaBrowserIndexStart, dataSource: self, delegate: self)
+            mediaBrowser = NCViewerImageViewController(index: mediaBrowserIndexStart, dataSource: self, delegate: self)
             if mediaBrowser != nil {
                            
                 self.backgroundView.image = nil
@@ -418,11 +418,11 @@ extension NCDetailViewController: MediaBrowserViewControllerDelegate, MediaBrows
         }
     }
     
-    func numberOfItems(in mediaBrowser: MediaBrowserViewController) -> Int {
+    func numberOfItems(in mediaBrowser: NCViewerImageViewController) -> Int {
         return metadatas.count
     }
 
-    func mediaBrowser(_ mediaBrowser: MediaBrowserViewController, imageAt index: Int, completion: @escaping MediaBrowserViewControllerDataSource.CompletionBlock) {
+    func mediaBrowser(_ mediaBrowser: NCViewerImageViewController, imageAt index: Int, completion: @escaping NCViewerImageViewControllerDataSource.CompletionBlock) {
         
         if index >= metadatas.count { return }
         let metadata = metadatas[index]
@@ -474,7 +474,7 @@ extension NCDetailViewController: MediaBrowserViewControllerDelegate, MediaBrows
         }
     }
     
-    func mediaBrowser(_ mediaBrowser: MediaBrowserViewController, didChangeFocusTo index: Int, view: MediaContentView) {
+    func mediaBrowser(_ mediaBrowser: NCViewerImageViewController, didChangeFocusTo index: Int, view: NCViewerImageContentView) {
         
         if index >= metadatas.count { return }
         let metadata = metadatas[index]
@@ -488,7 +488,7 @@ extension NCDetailViewController: MediaBrowserViewControllerDelegate, MediaBrows
         }
     }
     
-    func mediaBrowserTap(_ mediaBrowser: MediaBrowserViewController) {
+    func mediaBrowserTap(_ mediaBrowser: NCViewerImageViewController) {
         guard let navigationController = self.navigationController else { return }
         
         if navigationController.isNavigationBarHidden {

+ 17 - 2
iOSClient/Viewer/NCViewerImage/NCViewerImageCommon.swift

@@ -5,6 +5,21 @@
 //  Created by Marino Faggiana on 04/03/2020.
 //  Copyright © 2020 Marino Faggiana. All rights reserved.
 //
+//  Author Marino Faggiana <marino.faggiana@nextcloud.com>
+//
+//  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
 
@@ -63,11 +78,11 @@ class NCViewerImageCommon: NSObject {
         return image
     }
     
-    func imageChangeSizeView(mediaBrowser: MediaBrowserViewController?, size: CGSize, metadata: tableMetadata?) {
+    func imageChangeSizeView(mediaBrowser: NCViewerImageViewController?, size: CGSize, metadata: tableMetadata?) {
         guard let mediaBrowser = mediaBrowser else { return }
         
         var image: UIImage?
-        var contentViewSaved : MediaContentView?
+        var contentViewSaved : NCViewerImageContentView?
         for contentView in mediaBrowser.contentViews {
             if contentView.position == 0 && contentView.isLoading == false {
                 image = contentView.image

+ 34 - 33
iOSClient/Viewer/NCViewerImage/ContentTransformers.swift → iOSClient/Viewer/NCViewerImage/NCViewerImageContentTransformers.swift

@@ -1,24 +1,25 @@
 //
 //  ContentTransformers.swift
-//  ATGMediaBrowser
+//  Nextcloud
 //
-//  Created by Suraj Thomas K on 7/17/18.
-//  Copyright © 2018 Al Tayer Group LLC.
+//  Created by Suraj Thomas K on 7/17/18 Copyright © 2018 Al Tayer Group LLC..
+//  Modify for Nextcloud by Marino Faggiana on 04/03/2020.
+//  Copyright © 2019 Marino Faggiana. All rights reserved.
 //
-//  Permission is hereby granted, free of charge, to any person obtaining a copy of this software
-//  and associated documentation files (the "Software"), to deal in the Software without
-//  restriction, including without limitation the rights to use, copy, modify, merge, publish,
-//  distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
-//  Software is furnished to do so, subject to the following conditions:
+//  Author Marino Faggiana <marino.faggiana@nextcloud.com>
 //
-//  The above copyright notice and this permission notice shall be included in all copies or
-//  substantial portions of the Software.
+//  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.
 //
-//  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
-//  BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-//  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
-//  DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//  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/>.
 //
 
 /**
@@ -41,12 +42,12 @@
 
     Be mindful of the drawing order, when designing new transitions.
  */
-public typealias ContentTransformer = (_ contentView: UIView, _ position: CGFloat) -> Void
+public typealias NCViewerImageContentTransformer = (_ contentView: UIView, _ position: CGFloat) -> Void
 
 // MARK: - Default Transitions
 
 /// An enumeration to hold default content transformers
-public enum DefaultContentTransformers {
+public enum NCViewerImageDefaultContentTransformers {
 
     /**
      Horizontal move-in-out content transformer.
@@ -54,9 +55,9 @@ public enum DefaultContentTransformers {
      - Requires:
          * GestureDirection: Horizontal
     */
-    public static let horizontalMoveInOut: ContentTransformer = { contentView, position in
+    public static let horizontalMoveInOut: NCViewerImageContentTransformer = { contentView, position in
 
-        let widthIncludingGap = contentView.bounds.size.width + MediaContentView.interItemSpacing
+        let widthIncludingGap = contentView.bounds.size.width + NCViewerImageContentView.interItemSpacing
         contentView.transform = CGAffineTransform(translationX: widthIncludingGap * position, y: 0.0)
     }
 
@@ -66,9 +67,9 @@ public enum DefaultContentTransformers {
      - Requires:
         * GestureDirection: Vertical
      */
-    public static let verticalMoveInOut: ContentTransformer = { contentView, position in
+    public static let verticalMoveInOut: NCViewerImageContentTransformer = { contentView, position in
 
-        let heightIncludingGap = contentView.bounds.size.height + MediaContentView.interItemSpacing
+        let heightIncludingGap = contentView.bounds.size.height + NCViewerImageContentView.interItemSpacing
         contentView.transform = CGAffineTransform(translationX: 0.0, y: heightIncludingGap * position)
     }
 
@@ -79,7 +80,7 @@ public enum DefaultContentTransformers {
         * GestureDirection: Horizontal
         * DrawOrder: PreviousToNext
      */
-    public static let horizontalSlideOut: ContentTransformer = { contentView, position in
+    public static let horizontalSlideOut: NCViewerImageContentTransformer = { contentView, position in
 
         var scale: CGFloat = 1.0
         if position < -0.5 {
@@ -89,7 +90,7 @@ public enum DefaultContentTransformers {
         }
         var transform = CGAffineTransform(scaleX: scale, y: scale)
 
-        let widthIncludingGap = contentView.bounds.size.width + MediaContentView.interItemSpacing
+        let widthIncludingGap = contentView.bounds.size.width + NCViewerImageContentView.interItemSpacing
         let x = position >= 0.0 ? widthIncludingGap * position : 0.0
         transform = transform.translatedBy(x: x, y: 0.0)
 
@@ -106,7 +107,7 @@ public enum DefaultContentTransformers {
          * GestureDirection: Vertical
          * DrawOrder: PreviousToNext
      */
-    public static let verticalSlideOut: ContentTransformer = { contentView, position in
+    public static let verticalSlideOut: NCViewerImageContentTransformer = { contentView, position in
 
         var scale: CGFloat = 1.0
         if position < -0.5 {
@@ -116,7 +117,7 @@ public enum DefaultContentTransformers {
         }
         var transform = CGAffineTransform(scaleX: scale, y: scale)
 
-        let heightIncludingGap = contentView.bounds.size.height + MediaContentView.interItemSpacing
+        let heightIncludingGap = contentView.bounds.size.height + NCViewerImageContentView.interItemSpacing
         let y = position >= 0.0 ? heightIncludingGap * position : 0.0
         transform = transform.translatedBy(x: 0.0, y: y)
 
@@ -133,7 +134,7 @@ public enum DefaultContentTransformers {
          * GestureDirection: Horizontal
          * DrawOrder: NextToPrevious
      */
-    public static let horizontalSlideIn: ContentTransformer = { contentView, position in
+    public static let horizontalSlideIn: NCViewerImageContentTransformer = { contentView, position in
 
         var scale: CGFloat = 1.0
         if position > 0.5 {
@@ -143,7 +144,7 @@ public enum DefaultContentTransformers {
         }
         var transform = CGAffineTransform(scaleX: scale, y: scale)
 
-        let widthIncludingGap = contentView.bounds.size.width + MediaContentView.interItemSpacing
+        let widthIncludingGap = contentView.bounds.size.width + NCViewerImageContentView.interItemSpacing
         let x = position > 0.0 ? 0.0 : widthIncludingGap * position
         transform = transform.translatedBy(x: x, y: 0.0)
 
@@ -160,7 +161,7 @@ public enum DefaultContentTransformers {
          * GestureDirection: Vertical
          * DrawOrder: NextToPrevious
      */
-    public static let verticalSlideIn: ContentTransformer = { contentView, position in
+    public static let verticalSlideIn: NCViewerImageContentTransformer = { contentView, position in
 
         var scale: CGFloat = 1.0
         if position > 0.5 {
@@ -170,7 +171,7 @@ public enum DefaultContentTransformers {
         }
         var transform = CGAffineTransform(scaleX: scale, y: scale)
 
-        let heightIncludingGap = contentView.bounds.size.height + MediaContentView.interItemSpacing
+        let heightIncludingGap = contentView.bounds.size.height + NCViewerImageContentView.interItemSpacing
         let y = position > 0.0 ? 0.0 : heightIncludingGap * position
         transform = transform.translatedBy(x: 0.0, y: y)
 
@@ -186,7 +187,7 @@ public enum DefaultContentTransformers {
      - Requires:
      * GestureDirection: Horizontal
      */
-    public static let horizontalZoomInOut: ContentTransformer = { contentView, position in
+    public static let horizontalZoomInOut: NCViewerImageContentTransformer = { contentView, position in
 
         let minScale: CGFloat = 0.5
         // Scale factor is used to reduce the scale animation speed.
@@ -195,7 +196,7 @@ public enum DefaultContentTransformers {
 
         // Actual gap will be scaleFactor * 0.5 times of contentView.bounds.size.width.
         let actualGap = contentView.bounds.size.width * scaleFactor * 0.5
-        let gapCorrector = MediaContentView.interItemSpacing - actualGap
+        let gapCorrector = NCViewerImageContentView.interItemSpacing - actualGap
 
         let widthIncludingGap = contentView.bounds.size.width + gapCorrector
         let translation = (widthIncludingGap * position)/scale
@@ -212,7 +213,7 @@ public enum DefaultContentTransformers {
      - Requires:
      * GestureDirection: Vertical
      */
-    public static let verticalZoomInOut: ContentTransformer = { contentView, position in
+    public static let verticalZoomInOut: NCViewerImageContentTransformer = { contentView, position in
 
         let minScale: CGFloat = 0.5
         // Scale factor is used to reduce the scale animation speed.
@@ -221,7 +222,7 @@ public enum DefaultContentTransformers {
 
         // Actual gap will be scaleFactor * 0.5 times of contentView.bounds.size.height.
         let actualGap = contentView.bounds.size.height * scaleFactor * 0.5
-        let gapCorrector = MediaContentView.interItemSpacing - actualGap
+        let gapCorrector = NCViewerImageContentView.interItemSpacing - actualGap
 
         let heightIncludingGap = contentView.bounds.size.height + gapCorrector
         let translation = (heightIncludingGap * position)/scale

+ 22 - 26
iOSClient/Viewer/NCViewerImage/MediaContentView.swift → iOSClient/Viewer/NCViewerImage/NCViewerImageContentView.swift

@@ -1,24 +1,25 @@
 //
-//  MediaContentView.swift
-//  ATGMediaBrowser
+//  NCViewerImageContentView.swift
+//  Nextcloud
 //
-//  Created by Suraj Thomas K on 7/10/18.
-//  Copyright © 2018 Al Tayer Group LLC.
+//  Created by Suraj Thomas K on 7/10/18 Copyright © 2018 Al Tayer Group LLC..
+//  Modify for Nextcloud by Marino Faggiana on 04/03/2020.
+//  Copyright © 2019 Marino Faggiana. All rights reserved.
 //
-//  Permission is hereby granted, free of charge, to any person obtaining a copy of this software
-//  and associated documentation files (the "Software"), to deal in the Software without
-//  restriction, including without limitation the rights to use, copy, modify, merge, publish,
-//  distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
-//  Software is furnished to do so, subject to the following conditions:
+//  Author Marino Faggiana <marino.faggiana@nextcloud.com>
 //
-//  The above copyright notice and this permission notice shall be included in all copies or
-//  substantial portions of the Software.
+//  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.
 //
-//  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
-//  BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-//  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
-//  DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//  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/>.
 //
 
 /// Holds the value of minimumZoomScale and maximumZoomScale of the image.
@@ -42,11 +43,6 @@ public struct ZoomScale {
         maximum: 1.0
     )
 
-    /**
-     Initializer.
-     - parameter minimum: The minimum zoom level.
-     - parameter maximum: The maximum zoom level.
-     */
     public init(minimum: CGFloat, maximum: CGFloat) {
 
         minimumZoomScale = minimum
@@ -54,7 +50,7 @@ public struct ZoomScale {
     }
 }
 
-public class MediaContentView: UIScrollView {
+public class NCViewerImageContentView: UIScrollView {
 
     // MARK: - Exposed variables
     internal static var interItemSpacing: CGFloat = 0.0
@@ -63,7 +59,7 @@ public class MediaContentView: UIScrollView {
             resetZoom()
         }
     }
-    internal static var contentTransformer: ContentTransformer = DefaultContentTransformers.horizontalMoveInOut
+    internal static var contentTransformer: NCViewerImageContentTransformer = NCViewerImageDefaultContentTransformers.horizontalMoveInOut
 
     internal var position: CGFloat {
         didSet {
@@ -150,7 +146,7 @@ public class MediaContentView: UIScrollView {
 
 // MARK: - View Composition and Events
 
-extension MediaContentView {
+extension NCViewerImageContentView {
 
     private func initializeViewComponents() {
 
@@ -214,7 +210,7 @@ extension MediaContentView {
 
     internal func updateTransform() {
 
-        MediaContentView.contentTransformer(self, position)
+        NCViewerImageContentView.contentTransformer(self, position)
     }
 
     internal func handleChangeInViewSize(to size: CGSize) {
@@ -274,7 +270,7 @@ extension MediaContentView {
 
 // MARK: - UIScrollViewDelegate
 
-extension MediaContentView: UIScrollViewDelegate {
+extension NCViewerImageContentView: UIScrollViewDelegate {
 
     public func viewForZooming(in scrollView: UIScrollView) -> UIView? {
 

+ 22 - 21
iOSClient/Viewer/NCViewerImage/DismissAnimationController.swift → iOSClient/Viewer/NCViewerImage/NCViewerImageDismissAnimationController.swift

@@ -1,27 +1,28 @@
 //
-//  DismissAnimationController.swift
-//  ATGMediaBrowser
+//  NCViewerImageDismissAnimationController.swift
+//  Nextcloud
 //
-//  Created by Suraj Thomas K on 7/19/18.
-//  Copyright © 2018 Al Tayer Group LLC.
+//  Created by Suraj Thomas K on 7/19/18 Copyright © 2018 Al Tayer Group LLC..
+//  Modify for Nextcloud by Marino Faggiana on 04/03/2020.
+//  Copyright © 2019 Marino Faggiana. All rights reserved.
 //
-//  Permission is hereby granted, free of charge, to any person obtaining a copy of this software
-//  and associated documentation files (the "Software"), to deal in the Software without
-//  restriction, including without limitation the rights to use, copy, modify, merge, publish,
-//  distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
-//  Software is furnished to do so, subject to the following conditions:
+//  Author Marino Faggiana <marino.faggiana@nextcloud.com>
 //
-//  The above copyright notice and this permission notice shall be included in all copies or
-//  substantial portions of the Software.
+//  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.
 //
-//  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
-//  BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-//  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
-//  DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//  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/>.
 //
 
-internal class DismissAnimationController: NSObject {
+internal class NCViewerImageDismissAnimationController: NSObject {
 
     private enum Constants {
 
@@ -34,8 +35,8 @@ internal class DismissAnimationController: NSObject {
     }
 
     internal var image: UIImage?
-    internal let gestureDirection: MediaBrowserViewController.GestureDirection
-    internal weak var viewController: MediaBrowserViewController?
+    internal let gestureDirection: NCViewerImageViewController.GestureDirection
+    internal weak var viewController: NCViewerImageViewController?
     internal var interactionInProgress = false
 
     private lazy var imageView = UIImageView()
@@ -50,8 +51,8 @@ internal class DismissAnimationController: NSObject {
 
     init(
         image: UIImage? = nil,
-        gestureDirection: MediaBrowserViewController.GestureDirection,
-        viewController: MediaBrowserViewController
+        gestureDirection: NCViewerImageViewController.GestureDirection,
+        viewController: NCViewerImageViewController
         ) {
 
         self.image = image

+ 50 - 51
iOSClient/Viewer/NCViewerImage/MediaBrowserViewController.swift → iOSClient/Viewer/NCViewerImage/NCViewerImageViewController.swift

@@ -1,29 +1,28 @@
 //
-//  MediaBrowserViewController.swift
-//  ATGMediaBrowser
+//  NCViewerImageViewController.swift
+//  Nextcloud
 //
-//  Created by Suraj Thomas K on 7/10/18.
-//  Copyright © 2018 Al Tayer Group LLC.
+//  Created by Suraj Thomas K on 7/10/18 Copyright © 2018 Al Tayer Group LLC..
+//  Modify for Nextcloud by Marino Faggiana on 04/03/2020.
+//  Copyright © 2019 Marino Faggiana. All rights reserved.
 //
-//  Permission is hereby granted, free of charge, to any person obtaining a copy of this software
-//  and associated documentation files (the "Software"), to deal in the Software without
-//  restriction, including without limitation the rights to use, copy, modify, merge, publish,
-//  distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
-//  Software is furnished to do so, subject to the following conditions:
+//  Author Marino Faggiana <marino.faggiana@nextcloud.com>
 //
-//  The above copyright notice and this permission notice shall be included in all copies or
-//  substantial portions of the Software.
+//  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.
 //
-//  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
-//  BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-//  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
-//  DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//  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/>.
 //
 
-// MARK: - MediaBrowserViewControllerDataSource protocol
-/// Protocol to supply media browser contents.
-public protocol MediaBrowserViewControllerDataSource: class {
+public protocol NCViewerImageViewControllerDataSource: class {
 
     /**
      Completion block for passing requested media image with details.
@@ -43,7 +42,7 @@ public protocol MediaBrowserViewControllerDataSource: class {
      - parameter mediaBrowser: Reference to media browser object.
      - returns: An integer with number of items to be shown in media browser.
      */
-    func numberOfItems(in mediaBrowser: MediaBrowserViewController) -> Int
+    func numberOfItems(in mediaBrowser: NCViewerImageViewController) -> Int
 
     /**
      Method to supply image for specific index.
@@ -51,7 +50,7 @@ public protocol MediaBrowserViewControllerDataSource: class {
      - parameter index: Index of the requested media.
      - parameter completion: Completion block to be executed on fetching the media image.
      */
-    func mediaBrowser(_ mediaBrowser: MediaBrowserViewController, imageAt index: Int, completion: @escaping CompletionBlock)
+    func mediaBrowser(_ mediaBrowser: NCViewerImageViewController, imageAt index: Int, completion: @escaping CompletionBlock)
 
     /**
      This method is used to get the target frame into which the browser will perform the dismiss transition.
@@ -60,17 +59,17 @@ public protocol MediaBrowserViewControllerDataSource: class {
      - note:
         If this method is not implemented, the media browser will perform slide up/down transition on dismissal.
     */
-    func targetFrameForDismissal(_ mediaBrowser: MediaBrowserViewController) -> CGRect?
+    func targetFrameForDismissal(_ mediaBrowser: NCViewerImageViewController) -> CGRect?
 }
 
-extension MediaBrowserViewControllerDataSource {
+extension NCViewerImageViewControllerDataSource {
 
-    public func targetFrameForDismissal(_ mediaBrowser: MediaBrowserViewController) -> CGRect? { return nil }
+    public func targetFrameForDismissal(_ mediaBrowser: NCViewerImageViewController) -> CGRect? { return nil }
 }
 
-// MARK: - MediaBrowserViewControllerDelegate protocol
+// MARK: - NCViewerImageViewControllerDelegate protocol
 
-public protocol MediaBrowserViewControllerDelegate: class {
+public protocol NCViewerImageViewControllerDelegate: class {
 
     /**
      Method invoked on scrolling to next/previous media items.
@@ -79,19 +78,19 @@ public protocol MediaBrowserViewControllerDelegate: class {
      - note:
         This method will not be called on first load, and will be called only on swiping left and right.
      */
-    func mediaBrowser(_ mediaBrowser: MediaBrowserViewController, didChangeFocusTo index: Int, view: MediaContentView)
+    func mediaBrowser(_ mediaBrowser: NCViewerImageViewController, didChangeFocusTo index: Int, view: NCViewerImageContentView)
     
-    func mediaBrowserTap(_ mediaBrowser: MediaBrowserViewController)
+    func mediaBrowserTap(_ mediaBrowser: NCViewerImageViewController)
 
     func mediaBrowserDismiss()
 }
 
-extension MediaBrowserViewControllerDelegate {
+extension NCViewerImageViewControllerDelegate {
 
-    public func mediaBrowser(_ mediaBrowser: MediaBrowserViewController, didChangeFocusTo index: Int, view: MediaContentView) {}
+    public func mediaBrowser(_ mediaBrowser: NCViewerImageViewController, didChangeFocusTo index: Int, view: NCViewerImageContentView) {}
 }
 
-public class MediaBrowserViewController: UIViewController {
+public class NCViewerImageViewController: UIViewController {
 
     // MARK: - Exposed Enumerations
 
@@ -149,17 +148,17 @@ public class MediaBrowserViewController: UIViewController {
     // MARK: - Exposed variables
 
     /// Data-source object to supply media browser contents.
-    public weak var dataSource: MediaBrowserViewControllerDataSource?
+    public weak var dataSource: NCViewerImageViewControllerDataSource?
     /// Delegate object to get callbacks on media browser events.
-    public weak var delegate: MediaBrowserViewControllerDelegate?
+    public weak var delegate: NCViewerImageViewControllerDelegate?
 
     /// Gesture direction. Default is `horizontal`.
     public var gestureDirection: GestureDirection = .horizontal
     /// Content transformer closure. Default is `horizontalMoveInOut`.
-    public var contentTransformer: ContentTransformer = DefaultContentTransformers.horizontalMoveInOut {
+    public var contentTransformer: NCViewerImageContentTransformer = NCViewerImageDefaultContentTransformers.horizontalMoveInOut {
         didSet {
 
-            MediaContentView.contentTransformer = contentTransformer
+            NCViewerImageContentView.contentTransformer = contentTransformer
             contentViews.forEach({ $0.updateTransform() })
         }
     }
@@ -176,7 +175,7 @@ public class MediaBrowserViewController: UIViewController {
     /// Gap between consecutive media items. Default is `50.0`.
     public var gapBetweenMediaViews: CGFloat = Constants.gapBetweenContents {
         didSet {
-            MediaContentView.interItemSpacing = gapBetweenMediaViews
+            NCViewerImageContentView.interItemSpacing = gapBetweenMediaViews
             contentViews.forEach({ $0.updateTransform() })
         }
     }
@@ -215,7 +214,7 @@ public class MediaBrowserViewController: UIViewController {
         }
     }
 
-    public var contentViews: [MediaContentView] = []
+    public var contentViews: [NCViewerImageContentView] = []
 
     lazy private var tapGestureRecognizer: UITapGestureRecognizer = { [unowned self] in
         let gesture = UITapGestureRecognizer()
@@ -258,7 +257,7 @@ public class MediaBrowserViewController: UIViewController {
 
     private var numMediaItems = 0
 
-    private lazy var dismissController = DismissAnimationController(
+    private lazy var dismissController = NCViewerImageDismissAnimationController(
         gestureDirection: gestureDirection,
         viewController: self
     )
@@ -280,8 +279,8 @@ public class MediaBrowserViewController: UIViewController {
 
     public init(
         index: Int = 0,
-        dataSource: MediaBrowserViewControllerDataSource,
-        delegate: MediaBrowserViewControllerDelegate? = nil
+        dataSource: NCViewerImageViewControllerDataSource,
+        delegate: NCViewerImageViewControllerDelegate? = nil
         ) {
 
         self.index = index
@@ -316,7 +315,7 @@ public class MediaBrowserViewController: UIViewController {
 
 // MARK: - View Lifecycle and Events
 
-extension MediaBrowserViewController {
+extension NCViewerImageViewController {
 
     override public var prefersStatusBarHidden: Bool {
 
@@ -370,14 +369,14 @@ extension MediaBrowserViewController {
             mediaContainerView.bottomAnchor.constraint(equalTo: view.bottomAnchor)
         ])
 
-        MediaContentView.interItemSpacing = gapBetweenMediaViews
-        MediaContentView.contentTransformer = contentTransformer
+        NCViewerImageContentView.interItemSpacing = gapBetweenMediaViews
+        NCViewerImageContentView.contentTransformer = contentTransformer
 
         contentViews.forEach({ $0.removeFromSuperview() })
         contentViews.removeAll()
 
         for i in -1...1 {
-            let mediaView = MediaContentView(
+            let mediaView = NCViewerImageContentView(
                 index: i + index,
                 position: CGFloat(i),
                 frame: view.bounds
@@ -405,7 +404,7 @@ extension MediaBrowserViewController {
 
 // MARK: - Gesture Recognizers
 
-extension MediaBrowserViewController {
+extension NCViewerImageViewController {
 
     @objc private func panGestureEvent(_ recognizer: UIPanGestureRecognizer) {
 
@@ -498,7 +497,7 @@ extension MediaBrowserViewController {
 
 // MARK: - Updating View Positions
 
-extension MediaBrowserViewController {
+extension NCViewerImageViewController {
 
     @objc private func update(_ timeInterval: TimeInterval) {
 
@@ -635,7 +634,7 @@ extension MediaBrowserViewController {
         return normalizedTranslation
     }
 
-    private func updateContents(of contentView: MediaContentView) {
+    private func updateContents(of contentView: NCViewerImageContentView) {
 
         contentView.image = nil
         let convertedIndex = sanitizeIndex(contentView.index)
@@ -674,7 +673,7 @@ extension MediaBrowserViewController {
         return mediaView(at: 1)?.image
     }
 
-    private func mediaView(at index: Int) -> MediaContentView? {
+    private func mediaView(at index: Int) -> NCViewerImageContentView? {
 
         guard index < contentViews.count else {
 
@@ -687,7 +686,7 @@ extension MediaBrowserViewController {
 
 // MARK: - UIGestureRecognizerDelegate
 
-extension MediaBrowserViewController: UIGestureRecognizerDelegate {
+extension NCViewerImageViewController: UIGestureRecognizerDelegate {
 
     public func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
 
@@ -719,7 +718,7 @@ extension MediaBrowserViewController: UIGestureRecognizerDelegate {
         ) -> Bool {
 
         if gestureRecognizer is UIPanGestureRecognizer,
-            let scrollView = otherGestureRecognizer.view as? MediaContentView {
+            let scrollView = otherGestureRecognizer.view as? NCViewerImageContentView {
             return scrollView.zoomScale == 1.0
         }
         return false
@@ -731,7 +730,7 @@ extension MediaBrowserViewController: UIGestureRecognizerDelegate {
         ) -> Bool {
 
         if gestureRecognizer is UITapGestureRecognizer {
-            return otherGestureRecognizer.view is MediaContentView
+            return otherGestureRecognizer.view is NCViewerImageContentView
         }
         return false
     }