Marino Faggiana 6 жил өмнө
parent
commit
3975e8d43c

+ 27 - 27
Nextcloud.xcodeproj/project.pbxproj

@@ -2077,41 +2077,41 @@
 		F760F75621F21F61006B1A73 /* PhotoEditor */ = {
 			isa = PBXGroup;
 			children = (
-				F760F75721F21F61006B1A73 /* icomoon.ttf */,
-				F760F75821F21F61006B1A73 /* StickersViewController.xib */,
-				F760F75921F21F61006B1A73 /* ColorsCollectionViewDelegate.swift */,
-				F760F75A21F21F61006B1A73 /* PhotoEditor+Keyboard.swift */,
-				F760F75B21F21F61006B1A73 /* PhotoEditor+Controls.swift */,
-				F760F75C21F21F61006B1A73 /* PhotoEditorViewController.xib */,
-				F760F75D21F21F61006B1A73 /* PhotoEditor+StickersViewController.swift */,
-				F760F75E21F21F61006B1A73 /* PhotoEditor+UITextView.swift */,
-				F760F75F21F21F61006B1A73 /* UIImageView+Alpha.swift */,
+				F760F77821F21F61006B1A73 /* ColorCollectionViewCell.swift */,
 				F760F76021F21F61006B1A73 /* ColorCollectionViewCell.xib */,
+				F760F75921F21F61006B1A73 /* ColorsCollectionViewDelegate.swift */,
+				F760F77A21F21F61006B1A73 /* CropRectView.swift */,
+				F760F77021F21F61006B1A73 /* CropView.swift */,
+				F760F77621F21F61006B1A73 /* CropViewController.swift */,
+				F760F76E21F21F61006B1A73 /* EmojiCollectionViewCell.swift */,
 				F760F76121F21F61006B1A73 /* EmojiCollectionViewCell.xib */,
+				F760F76F21F21F61006B1A73 /* EmojisCollectionViewDelegate.swift */,
+				F760F77921F21F61006B1A73 /* GradientView.swift */,
+				F760F75721F21F61006B1A73 /* icomoon.ttf */,
 				F760F76221F21F61006B1A73 /* LaunchScreen.storyboard */,
-				F760F76421F21F61006B1A73 /* PhotoEditor+Font.swift */,
+				F760F76D21F21F61006B1A73 /* PhotoCropEditorBorder.png */,
 				F760F76521F21F61006B1A73 /* PhotoCropEditorBorder@2x.png */,
-				F760F76621F21F61006B1A73 /* UIView+Image.swift */,
-				F760F76721F21F61006B1A73 /* UIImage+Size.swift */,
-				F760F76821F21F61006B1A73 /* UIImage+Crop.swift */,
-				F760F76921F21F61006B1A73 /* StickersViewController.swift */,
-				F760F76A21F21F61006B1A73 /* Protocols.swift */,
-				F760F76B21F21F61006B1A73 /* PhotoEditor+Drawing.swift */,
 				F760F76C21F21F61006B1A73 /* PhotoCropEditorBorder@3x.png */,
-				F760F76D21F21F61006B1A73 /* PhotoCropEditorBorder.png */,
-				F760F76E21F21F61006B1A73 /* EmojiCollectionViewCell.swift */,
-				F760F76F21F21F61006B1A73 /* EmojisCollectionViewDelegate.swift */,
-				F760F77021F21F61006B1A73 /* CropView.swift */,
-				F760F77121F21F61006B1A73 /* ResizeControl.swift */,
+				F760F75B21F21F61006B1A73 /* PhotoEditor+Controls.swift */,
+				F760F77721F21F61006B1A73 /* PhotoEditor+Crop.swift */,
+				F760F76B21F21F61006B1A73 /* PhotoEditor+Drawing.swift */,
+				F760F76421F21F61006B1A73 /* PhotoEditor+Font.swift */,
 				F760F77221F21F61006B1A73 /* PhotoEditor+Gestures.swift */,
+				F760F75A21F21F61006B1A73 /* PhotoEditor+Keyboard.swift */,
+				F760F75D21F21F61006B1A73 /* PhotoEditor+StickersViewController.swift */,
+				F760F75E21F21F61006B1A73 /* PhotoEditor+UITextView.swift */,
 				F760F77321F21F61006B1A73 /* PhotoEditorViewController.swift */,
-				F760F77421F21F61006B1A73 /* StickerCollectionViewCell.xib */,
+				F760F75C21F21F61006B1A73 /* PhotoEditorViewController.xib */,
+				F760F76A21F21F61006B1A73 /* Protocols.swift */,
+				F760F77121F21F61006B1A73 /* ResizeControl.swift */,
 				F760F77521F21F61006B1A73 /* StickerCollectionViewCell.swift */,
-				F760F77621F21F61006B1A73 /* CropViewController.swift */,
-				F760F77721F21F61006B1A73 /* PhotoEditor+Crop.swift */,
-				F760F77821F21F61006B1A73 /* ColorCollectionViewCell.swift */,
-				F760F77921F21F61006B1A73 /* GradientView.swift */,
-				F760F77A21F21F61006B1A73 /* CropRectView.swift */,
+				F760F77421F21F61006B1A73 /* StickerCollectionViewCell.xib */,
+				F760F76921F21F61006B1A73 /* StickersViewController.swift */,
+				F760F75821F21F61006B1A73 /* StickersViewController.xib */,
+				F760F76821F21F61006B1A73 /* UIImage+Crop.swift */,
+				F760F76721F21F61006B1A73 /* UIImage+Size.swift */,
+				F760F75F21F21F61006B1A73 /* UIImageView+Alpha.swift */,
+				F760F76621F21F61006B1A73 /* UIView+Image.swift */,
 			);
 			path = PhotoEditor;
 			sourceTree = "<group>";

+ 21 - 6
iOSClient/Main/Create cloud/NCCreateFormUploadAssets.swift

@@ -30,11 +30,11 @@ import Foundation
 
 class NCCreateFormUploadAssets: XLFormViewController, NCSelectDelegate, PhotoEditorDelegate {
     
-    var serverUrl : String = ""
-    var titleServerUrl : String?
-    var assets: NSMutableArray = []
-    var cryptated : Bool = false
-    var session : String = ""
+    var serverUrl: String = ""
+    var titleServerUrl: String?
+    var assets = NSMutableArray()
+    var cryptated: Bool = false
+    var session: String = ""
     weak var delegate: createFormUploadAssetsDelegate?
     
     let appDelegate = UIApplication.shared.delegate as! AppDelegate
@@ -406,6 +406,9 @@ class NCCreateFormUploadAssets: XLFormViewController, NCSelectDelegate, PhotoEdi
             let photoEditor = PhotoEditorViewController(nibName:"PhotoEditorViewController",bundle: Bundle(for: PhotoEditorViewController.self))
 
             photoEditor.image = image
+            photoEditor.photoEditorDelegate = self
+            photoEditor.hiddenControls = [.save, .share, .sticker]
+            
             self.present(photoEditor, animated: true, completion: nil)
         })
     }
@@ -413,7 +416,19 @@ class NCCreateFormUploadAssets: XLFormViewController, NCSelectDelegate, PhotoEdi
     // MARK: - Photo Editor Delegate
 
     func doneEditing(image: UIImage) {
-        //imageView.image = image
+        UIImageWriteToSavedPhotosAlbum(image, self, #selector(imageSaved(_:didFinishSavingWithError:contextInfo:)), nil)
+    }
+    
+    @objc func imageSaved(_ image: UIImage, didFinishSavingWithError error: Error?, contextInfo: UnsafeRawPointer) {
+        
+        let fetchOptions = PHFetchOptions()
+        fetchOptions.sortDescriptors = [NSSortDescriptor(key: "creationDate", ascending: false)]
+        let fetchResult = PHAsset.fetchAssets(with: PHAssetMediaType.image, options: fetchOptions)
+        if let asset = fetchResult.firstObject {
+            self.assets = NSMutableArray(array: [asset])
+        }
+
+        print("done")
     }
     
     func canceledEditing() {