Swiftpack.co -  havebeenfitz/anchoredbottomsheet as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
havebeenfitz/anchoredbottomsheet
iOS Maps-like bottom sheet with anchor points and reusable view
.package(url: "https://github.com/havebeenfitz/anchoredbottomsheet.git", from: "1.3.5")

Untitled_Artwork 4

Platform CI Status Version SPM Carthage License

⚠️ Breaking changes in 1.0.0. BottomSheetViewConfiguration now expects UImage? as close icon instead of bool flag

SnapKit is no longer a dependency since 1.2.0

🎉 .byContent anchor mode is available since 1.3.0. BottomSheetView can now resize itself to match the subviews content height as long as it's smaller than screen height

About

Demo

This is iOS Maps like anchored bottom sheet with configurable anchors and reusable BottomSheetView, that can be used inside provided modal controller or without it.

BottomSheetView supports all kinds of UIView's including UIScrollView and it's ancestors as a container view.

BottomSheetViewController is intended to be used as a modal presented controller.

To configure BottomSheetView you should use BottomSheetViewConfiguration struct like this:

let config = BottomSheetViewConfiguration(
    contentView: UIView(),
    parentViewController: self,
    defaultPosition: .middle(),
    positions: [.top(), .middle(), .bottom()],
    isSlidingToAppear: false,
    isPullIndicatorNeeded: true,
    closeButtonIcon: UIImage(named: "closeIcon"),
    isDismissAllowed: false,
    cornerRadius: 16
)

Supported anchors:

  1. Top
  2. Middle
  3. Bottom
  4. Fixed
  5. By content

Each anchor has associated value, which will override default height for this anchor. By content mode is not yet implemented, feel free to open a pull request.

Once configuration is done, you should create BottomSheetView like this:

let bottomSheetView = BottomSheetView(configuration: configuration)

If you want to use this view for some complex UI cases, BottomSheetView will handle the pan gesture and will notify BottomSheetViewDelegate in heightDidChange(to height: CGFloat) method

If you want to implement general pop-up behaviour, you should use BottomSheetViewController. Create and present it like so:

let bottomSheetViewController = BottomSheetViewController(bottomSheetView: bottomSheetView)
        
bottomSheetViewController.delegate = self
bottomSheetViewController.present(from: self)

Installation

Cocoapods

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

pod 'AnchoredBottomSheet', '~> 1.3.5'

Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.

You can install Carthage with Homebrew using the following command:

$ brew update
$ brew install carthage

To integrate AnchoredBottomSheet into your Xcode project using Carthage, specify it in your Cartfile:

github "havebeenfitz/anchoredbottomsheet" "1.3.5"

Run carthage update to build the framework and drag the built SnapKit.framework into your Xcode project.

Swift Package Manager

Swift Package Manager is a tool for managing the distribution of Swift code. It’s integrated with the Swift build system to automate the process of downloading, compiling, and linking dependencies.

Xcode 11+ is required to build AnchoredBottomSheet using Swift Package Manager.

To integrate AnchoredBottomSheet into your Xcode project using Swift Package Manager, add it to the dependencies value of your Package.swift:

dependencies: [
    .package(
        url: "https://github.com/havebeenfitz/anchoredbottomsheet.git",
        .upToNextMajor(from: "1.3.5")
    )
]

Manually

If you prefer not to use either of the aforementioned dependency managers, you can integrate AnchoredBottomSheet into your project manually.


Requirements

Xcode 12+, iOS deployment target ≥ 10

Author

havebeenfitz, max.kraev@gmail.com

License

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

GitHub

link
Stars: 8
Last commit: 6 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

Update project for Xcode 12.5
6 weeks ago

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