Метод делегата Pulley с SWRevealViewController не вызывается - PullRequest
0 голосов
/ 26 февраля 2019

Я использую библиотеку SWReveal https://github.com/John-Lluch/SWRevealViewController для создания приложения бокового меню.в моем главном контроллере вида у меня есть вид карты, а в виде карты я реализовал нижний лист https://github.com/52inc/Pulley/, который работает нормально.Затем я продолжил устанавливать свой контроллер вид спереди как PulleyPrimaryContentControllerDelegate У меня есть faButton, который находится у основания mapView, эта fabButton должна быть перенастроена и перемещена вверх, когда настроен нижний лист, но я не могу этого сделать,Я пытался решить эту проблему в течение нескольких дней, но пока не ответил.ниже приведен мой код, любое добавление будет сделано по запросу

class BottomSheetVC: PulleyViewController {

    weak var infoVc: InfoVC!
    weak var estimateVc: EstimateVC!
    weak var serviceUnavailableVc: ServiceUnavailableVC!
    weak var onTripVc: OnTripVC!

    weak private var currentViewController: UIViewController? {
        didSet {
            if let onTripVc = oldValue as? OnTripVC {
                // Reset the view if it was showing the cancellation reason view.
                // This ensures the cancellation view is not the initial view next time
                // this bottom sheet is shown.
                onTripVc.setSecondViewVisible(false)
            }
            if let currentViewController = currentViewController {
                setDrawerContentViewController(controller: currentViewController, animated: false)
                setNeedsSupportedDrawerPositionsUpdate()
            }
        }
    }

    var mode = BottomSheetMode.info {
        didSet {
            switch mode {
            case .info: currentViewController = infoVc
            case .estimate: currentViewController = estimateVc
            case .serviceUnavailable: currentViewController = serviceUnavailableVc
            case .onTrip: currentViewController = onTripVc
            }
        }
    }
}

SheetContent.swift

...
class ServiceUnavailableVC: BaseBottomSheetVC {
    override var mode: BottomSheetMode {
        return .serviceUnavailable
    }
}

class BaseBottomSheetVC: UIViewController, PulleyDrawerViewControllerDelegate {
    var mode: BottomSheetMode {
        return .onTrip
    }

    func collapsedDrawerHeight(bottomSafeArea: CGFloat) -> CGFloat {
        return mode.collapsedDrawerHeight
    }

    func partialRevealDrawerHeight(bottomSafeArea: CGFloat) -> CGFloat {
        return mode.partialRevealDrawerHeight
    }

    func supportedDrawerPositions() -> [PulleyPosition] {
        return mode.supportedDrawerPositions
    }
}


// MARK: - PulleyPrimaryContentControllerDelegate
extension HomeVC: PulleyPrimaryContentControllerDelegate {
    func drawerPositionDidChange(drawer: PulleyViewController, bottomSafeArea: CGFloat) {
        guard let drawer = drawer as? BottomSheetVC else { return }
        switch drawer.drawerPosition {
        case .closed:
            if drawer.mode == .estimate {
                self.toggleButton.image = Icon.arrowBack
            }
        case .collapsed:
            if drawer.mode == .estimate {
                self.toggleButton.image = Icon.close
            }
        default: break
        }
    }

    func makeUIAdjustmentsForFullscreen(progress: CGFloat, bottomSafeArea: CGFloat) {

    }

    func drawerChangedDistanceFromBottom(drawer: PulleyViewController, distance: CGFloat,
                                         bottomSafeArea: CGFloat) {

        print("DRAWER DISPLAY")
        guard let drawer = drawer as? BottomSheetVC else { return }
        print("DRAWER DISPLAY \(drawer.currentDisplayMode)")
        let distance = distance - bottomSafeArea
        if drawer.mode == .estimate || drawer.mode == .onTrip {
            mapView.padding = UIEdgeInsets(top: 20, left: 0, bottom: distance, right: 20)
        }
        else if drawer.mode == .info {
            // This fixes a bug where the bottom padding added to the map when the promo bottom
            // sheet is visible causes the map pin to be off the center of the map. To fix this,
            // add padding to the top and bottom of the map.
            mapView.padding = UIEdgeInsets(top: distance, left: 0, bottom: distance, right: 20)
        }
        else {
            mapView.padding = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
        }
        fabBottomConstraint.constant = distance + 16
    }
}

Как мне запустить Bottom Viewcontroller

let storyboard = R.storyboard.baseSB()

            let swVC = storyboard.instantiateViewController(withIdentifier: SWRevealViewController.className) as! SWRevealViewController

            swVC.loadView()

            let homeVC = swVC.frontViewController as! HomeVC

            homeVC.mode = AppMode.go
            let bottomSheetVC = BottomSheetVC(contentViewController: swVC, drawerViewController: UIViewController())
            bottomSheetVC.drawerCornerRadius = 0
            bottomSheetVC.initialDrawerPosition = .closed
            bottomSheetVC.shadowRadius = 0
            bottomSheetVC.shadowOpacity = 0

            homeVC.bottomDrawer = bottomSheetVC
            bottomSheetVC.modalTransitionStyle = .crossDissolve

            self?.present(bottomSheetVC, animated: true, completion: nil)
...