Browse Source

new view share

marinofaggiana 5 năm trước cách đây
mục cha
commit
bf0cf3f2eb

+ 9 - 0
iOSClient/Settings/Acknowledgements.rtf

@@ -316,4 +316,13 @@ The MIT License (MIT)\
 \
 Copyright (c) Wenchao Ding\
 ____________________________________________\
+\
+
+\f1\b DropDown
+\f0\b0 \
+\
+The MIT License (MIT)\
+\
+Copyright (c) Kevin Hirsch\
+____________________________________________\
 }

+ 28 - 2
iOSClient/Share/NCShare.swift

@@ -22,8 +22,8 @@
 //
 
 import Foundation
-import UIKit
 import Parchment
+import DropDown
 
 class NCShare: UIViewController, UIGestureRecognizerDelegate, NCShareLinkCellDelegate, NCShareUserCellDelegate, NCShareNetworkingDelegate {
     
@@ -172,7 +172,28 @@ class NCShare: UIViewController, UIGestureRecognizerDelegate, NCShareLinkCellDel
         
         guard let items = items else { return }
         
-        NCShareCommon.sharedInstance.openDropDownUser(view: self.searchField, width: 0, height: 0, items: items)
+        let appearance = DropDown.appearance()
+        let dropDown = DropDown()
+        
+        if #available(iOS 11.0, *) {
+            appearance.setupMaskedCorners([.layerMaxXMaxYCorner, .layerMinXMaxYCorner])
+        }
+        
+        dropDown.dataSource = items.map {$0.name}
+        dropDown.anchorView = searchField
+        dropDown.bottomOffset = CGPoint(x: 0, y: searchField.bounds.height)
+        
+        dropDown.cellNib = UINib(nibName: "NCShareUserDropDownCell", bundle: nil)
+        dropDown.customCellConfiguration = { (index: Index, item: String, cell: DropDownCell) -> Void in
+            guard let cell = cell as? NCShareUserDropDownCell else { return }
+            //cell.displayName.text = item
+        }
+        
+        dropDown.selectionAction = { [weak self] (index, item) in
+            
+        }
+        
+        dropDown.show()
     }
 }
 
@@ -308,3 +329,8 @@ protocol NCShareUserCellDelegate {
     func switchCanEdit(with tableShare: tableShare?, switch: Bool, sender: Any)
     func tapMenu(with tableShare: tableShare?, sender: Any)
 }
+
+class NCShareUserDropDownCell: DropDownCell {
+    
+    @IBOutlet weak var logoImageView: UIImageView!
+}

+ 0 - 27
iOSClient/Share/NCShareCommon.swift

@@ -22,7 +22,6 @@
 
 import Foundation
 import FSCalendar
-import DropDown
 
 class NCShareCommon: NSObject {
     @objc static let sharedInstance: NCShareCommon = {
@@ -148,27 +147,6 @@ class NCShareCommon: NSObject {
         return(calendarView: calendar, viewWindow: viewWindow)
     }
     
-    func openDropDownUser(view: UITextField, width: CGFloat, height: CGFloat, items: [OCShareUser]) {
-        
-        let appearance = DropDown.appearance()
-        let dropDown = DropDown()
-        
-        if #available(iOS 11.0, *) {
-            appearance.setupMaskedCorners([.layerMaxXMaxYCorner, .layerMinXMaxYCorner])
-        }
-        
-        dropDown.dataSource = items.map {$0.name}
-        dropDown.anchorView = view
-        
-        dropDown.cellNib = UINib(nibName: "NCShareUserDropDownCell", bundle: nil)
-        dropDown.customCellConfiguration = { (index: Index, item: String, cell: DropDownCell) -> Void in
-            guard let cell = cell as? NCShareUserDropDownCell else { return }
-            //cell.displayName.text = item
-        }
-
-        dropDown.show()
-    }
-    
     func copyLink(tableShare: tableShare?, viewController: UIViewController) {
         
         let appDelegate = UIApplication.shared.delegate as! AppDelegate
@@ -192,8 +170,3 @@ class NCShareCommon: NSObject {
         }
     }
 }
-
-class NCShareUserDropDownCell: DropDownCell {
-    
-    @IBOutlet weak var logoImageView: UIImageView!    
-}