Skip to content
Snippets Groups Projects

Fix scrolling of drawers

1 file
+ 12
5
Compare changes
  • Side-by-side
  • Inline
import UIKit
import UIKit
 
import ScrollViewController
/// Opens up `Drawer` on a given parent view controller
/// Opens up `Drawer` on a given parent view controller
public struct PresentDrawer: Action {
public struct PresentDrawer: Action {
@@ -35,7 +36,7 @@ public struct PresentDrawer: Action {
@@ -35,7 +36,7 @@ public struct PresentDrawer: Action {
/// Performs `PresentDrawer` action
/// Performs `PresentDrawer` action
public struct PresentDrawerNavigator: TypedNavigator {
public struct PresentDrawerNavigator: TypedNavigator {
/// Custom transitioning delegate
/// Custom transitioning delegate
let transitioningDelegate = BottomTransitioningDelegate()
let transitioningDelegate = FullscreenTransitioningDelegate()
/// View controller which should be opened up
/// View controller which should be opened up
var viewController: ([Any]) -> UIViewController
var viewController: ([Any]) -> UIViewController
@@ -47,13 +48,19 @@ public struct PresentDrawerNavigator: TypedNavigator {
@@ -47,13 +48,19 @@ public struct PresentDrawerNavigator: TypedNavigator {
}
}
public func perform(_ action: PresentDrawer, completion: @escaping () -> Void) {
public func perform(_ action: PresentDrawer, completion: @escaping () -> Void) {
transitioningDelegate.isDismissableOnBackgroundTouch = action.isDismissable
let scrollViewController = ScrollViewController()
let controller = viewController(action.items)
let controller = viewController(action.items)
controller.transitioningDelegate = transitioningDelegate
scrollViewController.addChild(controller)
controller.modalPresentationStyle = .overFullScreen
scrollViewController.contentView = controller.view
 
scrollViewController.wrapperView.handlesTouchesOutsideContent = !action.isDismissable
 
scrollViewController.wrapperView.alignContentToBottom = true
 
scrollViewController.scrollView.bounces = false
 
controller.didMove(toParent: scrollViewController)
 
scrollViewController.transitioningDelegate = transitioningDelegate
 
scrollViewController.modalPresentationStyle = .overFullScreen
action.parent.present(
action.parent.present(
controller,
scrollViewController,
animated: action.animated,
animated: action.animated,
completion: completion
completion: completion
)
)
Loading