Browse Source

Merge pull request #1118 from Infomaniak/newdrawer-fix

Newdrawer fix + grabber + no margins
Marino Faggiana 5 years ago
parent
commit
0df0569a49

+ 19 - 7
iOSClient/Main/Menu/NCMainMenuTableViewController.swift

@@ -75,7 +75,7 @@ class NCMainMenuTableViewController: UITableViewController {
 extension NCMainMenuTableViewController: FloatingPanelControllerDelegate {
 
     func floatingPanel(_ vc: FloatingPanelController, layoutFor newCollection: UITraitCollection) -> FloatingPanelLayout? {
-        return NCMainMenuFloatingPanelLayout(height: min(self.actions.count * 60, Int(self.view.frame.height) - 48))
+        return NCMainMenuFloatingPanelLayout(height: self.actions.count * 60, vertical: newCollection.verticalSizeClass == .compact)
     }
 
     func floatingPanel(_ vc: FloatingPanelController, behaviorFor newCollection: UITraitCollection) -> FloatingPanelBehavior? {
@@ -87,26 +87,38 @@ extension NCMainMenuTableViewController: FloatingPanelControllerDelegate {
 class NCMainMenuFloatingPanelLayout: FloatingPanelLayout {
 
     let height: CGFloat
+    let isVertical: Bool
 
-    init(height: Int) {
+    init(height: Int, vertical: Bool) {
         self.height = CGFloat(height)
+        self.isVertical = vertical
     }
 
     var initialPosition: FloatingPanelPosition {
-        return .tip
+        return isVertical ? .full : .half
     }
 
     var supportedPositions: Set<FloatingPanelPosition> {
-        return [.tip]
+        return isVertical ? [.full] : [.half]
     }
 
     func insetFor(position: FloatingPanelPosition) -> CGFloat? {
-        switch position {
-        case .tip: return height
-        default: return nil
+        if (isVertical && position == .full) {
+            return max(48, UIScreen.main.bounds.size.height - height)
+        } else if (!isVertical && position == .half) {
+            return min(height, UIScreen.main.bounds.size.height - 48)
+        } else {
+            return nil
         }
     }
 
+    public func prepareLayout(surfaceView: UIView, in view: UIView) -> [NSLayoutConstraint] {
+        return [
+            surfaceView.leftAnchor.constraint(equalTo: view.leftAnchor, constant: 0),
+            surfaceView.rightAnchor.constraint(equalTo: view.rightAnchor, constant: 0),
+        ]
+    }
+
     func backdropAlphaFor(position: FloatingPanelPosition) -> CGFloat {
         return 0.2
     }

+ 0 - 1
iOSClient/Main/Menu/NCMenuPanelController.swift

@@ -32,7 +32,6 @@ class NCMenuPanelController: FloatingPanelController {
     override func viewDidLoad() {
         super.viewDidLoad()
 
-        self.surfaceView.grabberHandle.isHidden = true
         self.isRemovalInteractionEnabled = true
         if #available(iOS 11, *) {
             self.surfaceView.cornerRadius = 16