Browse Source

fix

Signed-off-by: marinofaggiana <ios@nextcloud.com>
marinofaggiana 3 years ago
parent
commit
a16a72a1e1

+ 3 - 0
iOSClient/Extensions/UIImage+Extensions.swift

@@ -205,6 +205,9 @@ extension UIImage {
         return UIImage(cgImage: downsampledImage)
         return UIImage(cgImage: downsampledImage)
     }
     }
     
     
+    // Source:
+    // https://stackoverflow.com/questions/27092354/rotating-uiimage-in-swift/47402811#47402811
+    
     func rotate(radians: Float) -> UIImage? {
     func rotate(radians: Float) -> UIImage? {
         var newSize = CGRect(origin: CGPoint.zero, size: self.size).applying(CGAffineTransform(rotationAngle: CGFloat(radians))).size
         var newSize = CGRect(origin: CGPoint.zero, size: self.size).applying(CGAffineTransform(rotationAngle: CGFloat(radians))).size
         // Trim off the extremely small float value to prevent core graphics from rounding it up
         // Trim off the extremely small float value to prevent core graphics from rounding it up

+ 2 - 2
iOSClient/Main/Create cloud/NCCreateFormUploadScanDocument.swift

@@ -762,8 +762,8 @@ class NCCreateScanDocument: NSObject, VNDocumentCameraViewControllerDelegate {
         }
         }
 
 
         controller.dismiss(animated: true) {
         controller.dismiss(animated: true) {
-            if self.viewController is NCScan {
-                (self.viewController as! NCScan).loadImage()
+            if let viewController = self.viewController as? NCScan {
+                viewController.loadImage()
             } else {
             } else {
                 let storyboard = UIStoryboard(name: "NCScan", bundle: nil)
                 let storyboard = UIStoryboard(name: "NCScan", bundle: nil)
                 let controller = storyboard.instantiateInitialViewController()!
                 let controller = storyboard.instantiateInitialViewController()!

+ 1 - 1
iOSClient/ScanDocument/NCScan+CollectionView.swift

@@ -69,7 +69,7 @@ extension NCScan: UICollectionViewDataSource {
 
 
             let cell = (collectionView.dequeueReusableCell(withReuseIdentifier: "cell2", for: indexPath) as? NCScanCell)!
             let cell = (collectionView.dequeueReusableCell(withReuseIdentifier: "cell2", for: indexPath) as? NCScanCell)!
             cell.delegate = self
             cell.delegate = self
-            cell.imageIndex = indexPath.row
+            cell.index = indexPath.row
 
 
             var image = imagesDestination[indexPath.row]
             var image = imagesDestination[indexPath.row]
 
 

+ 3 - 0
iOSClient/ScanDocument/NCScan.swift

@@ -228,6 +228,9 @@ class NCScan: UIViewController, NCScanCellCellDelegate {
         return image
         return image
     }
     }
 
 
+    // destinationIndexPath: indexpath of the collection view where the user drops the element
+    // collectionView: collectionView in which reordering needs to be done.
+
     func reorderItems(coordinator: UICollectionViewDropCoordinator, destinationIndexPath: IndexPath, collectionView: UICollectionView) {
     func reorderItems(coordinator: UICollectionViewDropCoordinator, destinationIndexPath: IndexPath, collectionView: UICollectionView) {
 
 
         let items = coordinator.items
         let items = coordinator.items

+ 1 - 10
iOSClient/ScanDocument/NCScanCell.swift

@@ -31,16 +31,7 @@ class NCScanCell: UICollectionViewCell {
     @IBOutlet weak var rotate: UIButton!
     @IBOutlet weak var rotate: UIButton!
 
 
     weak var delegate: NCScanCellCellDelegate?
     weak var delegate: NCScanCellCellDelegate?
-    private var index = 0
-
-    var imageIndex: Int {
-        get {
-            return index
-        }
-        set {
-            index = newValue
-        }
-    }
+    var index = 0
 
 
     @IBAction func touchUpInsideDelete(_ sender: Any) {
     @IBAction func touchUpInsideDelete(_ sender: Any) {
         delegate?.delete(with: index, sender: sender)
         delegate?.delete(with: index, sender: sender)