Swiftpack.co -  OfTheWolf/UBottomSheet as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
OfTheWolf/UBottomSheet
iPhone Maps App bottom sheet - A Protocol Oriented Approach
.package(url: "https://github.com/OfTheWolf/UBottomSheet.git", from: "1.0.9")

Next Level

Language Version Platform License

Features
πŸ“ Apple Maps bottom sheet behaviour
βš“ Supports panning with UIScrollView and UIView
πŸŒ’ Allows adding dimmable background view
πŸ“± Set sheet content as UIViewController or UINavigationController
πŸ“– Navigation inside sheet with UINavigationController
🌈 Add one or more sheet stop positions
🎯 Change sheet position programmatically
πŸŒ€ Present as many sheet as you want
πŸš€ Move multiple sheets simultaneously or seperately
🏹 Rubber banding
πŸ‘‹ Dismiss at bottom

Demos

Apple Maps & Childs Navigation In Sheet Pull To Dismiss Multiple Sheet Positions
Tag Tag Tag Tag

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Bottom sheet child view controllers must conform to the Draggable protocol.

class MapsDemoBottomSheetController: UIViewController, Draggable{
    @IBOutlet weak var tableView: UITableView!
      
    override func viewDidLoad() {
        super.viewDidLoad()
        if #available(iOS 11.0, *) {
            tableView.contentInsetAdjustmentBehavior = .never
        } else {
            automaticallyAdjustsScrollViewInsets = false
        }
        tableView.delegate = self
        tableView.dataSource = self
    }
    
    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        
        //adds pan gesture recognizer to draggableView()
        sheetCoordinator?.startTracking(item: self) 
    }

//  MARK: Draggable protocol implementations

    var sheetCoordinator: UBottomSheetCoordinator? 

    func draggableView() -> UIScrollView? {
        return tableView
    }
}

Create a UBottomSheetCoordinator from the main view controller. Use the UBottomSheetCoordinator to add and configure the sheet.


// parentViewController: main view controller that presents the bottom sheet
// call this within viewWillLayoutSubViews to make sure view frame has measured correctly. see example projects. 
let sheetCoordinator = UBottomSheetCoordinator(parent: parentViewController)

let vc = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "MapsDemoBottomSheetController") as! MapsDemoBottomSheetController

vc.sheetCoordinator = sheetCoordinator

sheetCoordinator.addSheet(vc, to: parentViewController)

Requirements

ios9.0+, Xcode10+

Installation

UBottomSheet is available through CocoaPods and Swift Package Manager.

CocoaPods

Add the following line to your Podfile:

pod 'UBottomSheet'

SPM

Add this url in XCode > File > Swift Packages > Add Package Dependency:

https://github.com/OfTheWolf/UBottomSheet

See Also

TwitterProfile Nested scroll view behaviour of Twitter Profile screen.

Author

uğur, uguboz@gmail.com

License

UBottomSheet is available under the MIT license. See the LICENSE file for more info.

GitHub

link
Stars: 310
Last commit: 4 weeks ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Release Notes

31 weeks ago

#34 and #50 fixed

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API