Giter Club home page Giter Club logo

bottomsheet's Introduction

Bottom Sheet

Bottom Sheet component is designed to handle any content, including a scrolling one.

  • ✅ use any content size, and it will adapt
  • ✅ use scrollable content: UICollectionView, UITableView or UIScrollView
  • ✅ dismiss interactively by swipe-down or just tapping on an empty space
  • ✅ build flows inside using BottomSheetNavigationController
    • ✅ supports all system transitions: push and (interactive) pop
    • ✅ transition animated between different content sizes
  • ✅ Customize appearance:
    • pull bar visibility
    • corner radius
    • shadow background color

How it looks like

Adapts to content size Interactive dismissal
adapt-to-content-size interactive-dismissal

NavigationController inside Bottom Sheet

Push and pop transitions Interactive pop transition
system-push-pop interactive-pop

Installation

Swift Package Manager

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

dependencies: [
    .package(url: "https://github.com/joomcode/BottomSheet", from: "2.0.0")
]

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ bundle install

To integrate BottomSheet into your Xcode project using CocoaPods, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
use_frameworks!

target '<Your Target Name>' do
    pod 'BottomSheet', :git => 'https://github.com/joomcode/BottomSheet'
end

Getting started

This repo contains demo, which can be a great start for understanding Bottom Sheet usage, but here are simple steps to follow:

  1. Create UIViewController to present and set content's size by preferredContentSize property
  2. (optional) Conform to ScrollableBottomSheetPresentedController if your view controller is list-based
  3. Present by using presentBottomSheet(viewController:configuration:)

If you want to build flows, use BottomSheetNavigationController

presentBottomSheetInsideNavigationController(
    viewController: viewControllerToPresent,
    configuration: .default
)

You can customize appearance passing configuration parameter

presentBottomSheet(
    viewController: viewControllerToPresent,
    configuration: BottomSheetConfiguration(
        cornerRadius: 10,
        pullBarConfiguration: .visible(.init(height: 20)),
        shadowConfiguration: .init(backgroundColor: UIColor.black.withAlphaComponent(0.6))
    ),
    canBeDismissed: {
        // return `true` or `false` based on your business logic
        true
    },
    dismissCompletion: {
        // handle dismiss completion if user closed bottom sheet by a gesture
    }
)

Resources

Read the article on Medium for betting understanding of how it works under the hood

bottomsheet's People

Contributors

carbonimax avatar mikhailmaslo avatar pboulch avatar rusik avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.