BottomSheetPresentable - admiral-team/admiralui-ios GitHub Wiki

Class

Interface presentation view controller that will be presented using the PanModal transition.


Declaration

public protocol BottomSheetPresentable: AnyObject

Overview

Interface serves for presenting view controller by PanModal transition. This view of controller is bottom sheet view. Bottom sheets are surfaces containing supplementary content that are anchored to the bottom of the screen. For example, you can see work bottom sheet in Apple maps.

Live example

Configure a Bottom Sheet

For configuration PanModal transition in your controller need that your UIViewController comply with the protocol BottomSheetPresentable. After need implement property panScrollable, you need show our object which inhered UIViewScroll.

class BottomSheetExampleViewController: UIViewController, BottomSheetPresentable {
    
    var panScrollable: UIScrollView? {
        tableView
    }

}

Adjusting Heights

Height values of the panModal can be adjusted by overriding shortFormHeight or longFormHeight.

var shortFormHeight: PanModalHeight {
    return .contentHeight(300)
}

var longFormHeight: PanModalHeight {
    return .maxHeightWithTopInset(40)
}

Updates at Runtime

Values are stored during presentation, so when adjusting at runtime you should call panModalSetNeedsLayoutUpdate()

func viewDidLoad() {
    hasLoaded = true

    panModalSetNeedsLayoutUpdate()
    panModalTransition(to: .shortForm)
}

var shortFormHeight: PanModalHeight {
    if hasLoaded {
        return .contentHeight(200)
    }
    return .maxHeight
}

Contribution

You can help us to find bugs or ask us to add features.

  • To start issue please use ready-made templates.
  • To make changes to the repository, you need to create a fork of the project, make changes to the code and create a pull request in our project. You can read more about this in the Github documentation.