Swiftpack.co - Package - finn-no/BottomSheet

CircleCI Carthage compatible CocoaPods compatible Swift Package Manager compatible

BottomSheet is an implementation of custom modal presentation style for thumb-friendly interactive views anchored to the bottom of the screen.

  • [x] Custom UIViewControllerTransitioningDelegate for dismissable modal bottom sheets
  • [x] BottomSheetView for displaying complementary content as a standard bottom sheet view
  • [x] Expanding bottom sheets with multiple states to transition between
  • [x] Support for automatic view height based on Auto Layout constraints
  • [x] Beatiful spring animation

Demo

Installation

BottomSheet is available through Carthage. Append this line to your Cartfile:

github "finn-no/BottomSheet"

BottomSheet is also available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'FINNBottomSheet'

To integrate using Apple's Swift package manager, add the following as a dependency to your Package.swift:

.package(url: "https://github.com/finn-no/BottomSheet.git", .upToNextMajor(from: "1.0.0"))

Usage

View controller -based presentation:

let transitioningDelegate = BottomSheetTransitioningDelegate(
    targetHeights: [.bottomSheetAutomatic, UIScreen.main.bounds.size.height - 200],
    startTargetIndex: 0
)
let viewController = UIViewController()
viewController.transitioningDelegate = transitioningDelegate
viewController.modalPresentationStyle = .custom

present(viewController, animated: true)

View -based presentation:

let contentView = UIView()
contentView.backgroundColor = .red

let bottomSheetView = BottomSheetView(
    contentView: contentView,
    targetHeights: [100, 500]
)

// Can be presented in any UIView subclass
bottomSheetView.present(in: viewController.view, targetIndex: 0) 

Github

link
Stars: 10
Help us keep the lights on

Dependencies

Used By

Total: 0

Releases

2.3.0 - Dec 4, 2019

Support navigation controllers #13

2.2.0 - Dec 2, 2019

#9 Fix present without animation #10 Dismiss presented view controller when tapping dimmed background #11 Add initial velocity to spring animation #12 Make sure interactive presentation works properly

2.1.0 - Nov 27, 2019

Animate to currentTargetOffset in reset method #8

2.0.1 - Nov 26, 2019

Add rubber band effect to the bottom target #7

2.0.0 - Nov 26, 2019

  • Improve threshold and offset calculations #5
  • Replace translationState function with array of models #6