Browse Source

new share view

marinofaggiana 5 năm trước cách đây
mục cha
commit
65a50bd8aa
1 tập tin đã thay đổi với 19 bổ sung2 xóa
  1. 19 2
      iOSClient/Share/NCShare.swift

+ 19 - 2
iOSClient/Share/NCShare.swift

@@ -228,7 +228,7 @@ class NCShareComments: UIViewController {
 
 // MARK: - Share
 
-class NCShare: UIViewController, UIGestureRecognizerDelegate, NCShareLinkCellDelegate {
+class NCShare: UIViewController, UIGestureRecognizerDelegate, NCShareLinkCellDelegate, NCShareNetworkingDelegate {
     
     var metadata: tableMetadata?
     private let appDelegate = UIApplication.shared.delegate as! AppDelegate
@@ -268,6 +268,9 @@ class NCShare: UIViewController, UIGestureRecognizerDelegate, NCShareLinkCellDel
         NotificationCenter.default.addObserver(self, selector: #selector(self.reloadData), name: NSNotification.Name(rawValue: "reloadDataNCShare"), object: nil)
         
         reloadData()
+        
+        let networking = NCShareNetworking.init(account: metadata!.account, activeUrl: appDelegate.activeUrl, view: nil, delegate: self)
+        networking.readShare()
     }
     
     override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
@@ -284,7 +287,8 @@ class NCShare: UIViewController, UIGestureRecognizerDelegate, NCShareLinkCellDel
         if shares.firstShareLink != nil {
             tapMenu(with: shares.firstShareLink!, sender: sender)
         } else {
-            tapMenu(with: nil, sender: sender)
+            let networking = NCShareNetworking.init(account: metadata!.account, activeUrl: appDelegate.activeUrl, view: self.view, delegate: self)
+            networking.share(metadata: metadata!, password: "", permission: 1, hideDownload: false)
         }
     }
     
@@ -307,6 +311,19 @@ class NCShare: UIViewController, UIGestureRecognizerDelegate, NCShareLinkCellDel
         }
         tableView.reloadData()
     }
+    
+    // NCShareNetworkingDelegate
+    func readShareCompleted(errorCode: Int) {
+        NotificationCenter.default.post(name: NSNotification.Name(rawValue: "reloadDataNCShare"), object: nil, userInfo: nil)
+    }
+    
+    func shareCompleted(errorCode: Int) {
+        NotificationCenter.default.post(name: NSNotification.Name(rawValue: "reloadDataNCShare"), object: nil, userInfo: nil)
+    }
+    
+    func unShareCompleted() { }
+    
+    func updateShareWithError(idRemoteShared: Int) { }
 }
 
 extension NCShare: UITableViewDelegate {