Skip to content
A customizable bottom half modal used in merpay
Swift Ruby Objective-C
Branch: master
Clone or download
masamichiueta Merge pull request #1 from mercari/uiviewcontroller-extension
Add UIViewController extension to present BottomHalfModal
Latest commit 669c54e Oct 9, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github Initial commit Oct 4, 2019
BottomHalfModal Add UIViewController extension and separete files Oct 9, 2019
BottomHalfModalDemo.xcodeproj Add UIViewController extension and separete files Oct 9, 2019
Demo Fix demo to use extension Oct 9, 2019
Screenshots Initial commit Oct 4, 2019
.gitignore
BottomHalfModal.podspec Fix podspec Oct 4, 2019
CONTRIBUTING.md Initial commit Oct 4, 2019
LICENSE Initial commit Oct 4, 2019
README.md Update README Oct 9, 2019

README.md

BottomHalfModal Platform iOS11+ License: MIT

BottomHalfModal is a customizable half modal UI used in merpay.

BottomHaflModal

Installation

Carthage

github "mercari/BottomHalfModal"

CocoaPods

pod "BottomHalfModal"

Usage

BottomHalfModal can present any type of UIVIewController as content. The presented view controller needs to confirm to SheetContentHeightModifiable and define sheetContentHeightToModify that is the height of the half modal. Then call adjustFrameToSheetContentHeightIfNeeded() in viewDidAppear.

import BottomHalfModal

class XXXXViewController: SheetContentHeightModifiable {
    var sheetContentHeightToModify: CGFloat = 320
    
    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)
        adjustFrameToSheetContentHeightIfNeeded()
    }
}

Then, call presentBottomHalfModal(_ viewControllerToPresent: UIViewController, animated: Bool, completion: (() -> Void)?) to show the content.

    let vc = XXXXViewController()
    presentBottomHalfModal(vc, animated: true, completion: nil)

If you want to use UINavigationController in BottomHalfModal, use BottomHalfModalNavigationController. It handles content height update while push and pop navigations.

    let vc = XXXXViewController()
    let nav = BottomHalfNavigationController(rootViewController: vc)
    presentBottomHalfModal(nav, animated: true, completion: nil)

If you support multiple device orientation, please call adjustFrameToSheetContentHeightIfNeeded() in viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) too.

override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
    super.viewWillTransition(to: size, with: coordinator)
    adjustFrameToSheetContentHeightIfNeeded(with: coordinator)
}

Demo

Basic
Basic
TableView
TableView
Navigation
Navigation
StickyButton
StickyButton
Input
Input

Contribution

Please read the CLA carefully before submitting your contribution to Mercari. Under any circumstances, by submitting your contribution, you are deemed to accept and agree to be bound by the terms and conditions of the CLA.

https://www.mercari.com/cla/

License

Copyright 2019 Mercari, Inc.

Licensed under the MIT License.

You can’t perform that action at this time.