📑 Actionsheet with navigation features such as the Flipboard App

Overview

Logo

Swift 4.0+ iOS 9.0 Version Carthage Compatible Platform License


📑 SHEET helps you easily create a wide variety of action sheets with navigation features used in the Flipboard App


Example

Installation

CocoaPods

pod 'Sheet', '~> 0.6.0'

Carthage

github "ParkGwangBeom/Sheet" ~> 0.6.0

Manually

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

Usage

Implementing the contents of a Sheet is similar to implementing an existing UICollectionViewController. Simply make your view controller subclass of SheetContentsViewController.

import Sheet

class ViewController: SheetContentsViewController {

   /// Sheet visible contents height. If contentSize height is less than visibleContentsHeight, contentSize height is applied.
    override var visibleContentsHeight: CGFloat {
        return 600
    }
    
    /// Give CollectionView a chance to regulate Supplementray Element
    override func registCollectionElement() {
        let nib = UINib(nibName: "TitleHeaderView", bundle: nil)
        collectionView?.register(nib, forSupplementaryViewOfKind: SheetLayoutElement.header.kind, withReuseIdentifier: SheetLayoutElement.header.id)
    }

    /// Provide an opportunity to set default settings for collectionview custom layout
    override func setupSheetLayout(_ layout: SheetContentsLayout) {
        layout.settings.itemSize = { indexPath in
            let height: CGFloat = indexPath.section == 0 ? 30 : 60
            return CGSize(width: UIScreen.main.bounds.width, height: height)
        }
        layout.sectionInset = UIEdgeInsets(top: 0, left: 0, bottom: 15, right: 0)
        layout.settings.headerSize = CGSize(width: UIScreen.main.bounds.width, height: 60)
        layout.settings.isHeaderStretchy = true
    }
    
   override func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
        return 10
    }
    
    override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath)
         ...
        return cell
    }
    
    override func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
         ...
    }
   
     ...
}

You can use the custom action sheet transition using the default api provided by UIKit such as present, push, pop.

🔥 However, do not use the dismiss of the NavigationController, but use the close (duration: completion :) function.

// present
let contentsViewController = ViewController()
let sheetNavigation = SheetNavigationController(rootViewController: contentsViewController)
present(sheetNavigation, animated: true, completion: nil)

// push
let nextContentsViewController = NextContentsViewController()
navigationController?.pushViewController(nextContentsViewController, animated: true)

// pop
navigationController?.popViewController(animated: true)

See the Example project for more details.

Layout

Sheet basically has Navigation structure. All children should inherit from SheetContentsViewController. SheetContentsViewController inherits UICollectionViewController by default, and its layout is like the following image.

layout

Please refer to Example Code for detailed setting of image layout.

Advanced

Easily customizable by SheetContents.

Options

Property Type Default Value
defaultToolBarBackgroundColor UIColor .black
sheetToolBarHeight CGFloat 50
isSheetToolBarHidden Bool false
cornerRadius CGFloat 0
defaultVisibleContentHeight CGFloat 240
dimmingViewBackgroundColor UIColor .black.withAlphaComponent(0.3)
sheetBackgroundColor UIColor .white
presentTransitionType SheetPresentTransitionType .scale

Layout Settings

Property Type
headerSize CGSize?
footerSize CGSize?
itemSize ((IndexPath) -> CGSize)?
sectionHeaderSize ((IndexPath) -> CGSize)?
sectionFooterSize ((IndexPath) -> CGSize)?

SheetContentsViewController

Property Type
sheetToolBar UIView
Method Explanation
func registCollectionElement() Give CollectionView a chance to regulate Supplementray Element
func setupSheetLayout() Provide an opportunity to set default settings for collectionview custom layout
func reload() Help reload CollectionView and adjust the height of the content.
func close(completion: (() -> Void)? = nil) Sheet Dismiss

Custom ToolBar

The built-in toolbar consists of a single button.

Default ToolBar

Setting up a Custom ToolBar is very simple.

sheetToolBar = CustomToolBar()

Author

License

Sheet is released under the MIT license. See LICENSE for details.

You might also like...
A crisp in-app notification/message banner built in Swift.
A crisp in-app notification/message banner built in Swift.

RMessage Screenshots Intro Welcome to RMessage! RMessage is a simple notification library written in Swift to help you display notification on the scr

Simple Swift in-app notifications
Simple Swift in-app notifications

LNRSimpleNotifications TSMessages is an amazingly powerful in-app notifications library but requires a lot of setup. LNRSimpleNotifications is a simpl

In-app notification in Swift, with customizable buttons and input text field.
In-app notification in Swift, with customizable buttons and input text field.

Notie Undistracted in-app notification in Swift, with added buttons and input box. Installation CocoaPods To integrate Notie into your Xcode project u

Snow globe framework is delightful / slightly cheese easter egg for christmas season. Turns your awesome app into a snow globe, when user shake the device.
Snow globe framework is delightful / slightly cheese easter egg for christmas season. Turns your awesome app into a snow globe, when user shake the device.

SnowGlobe.framework SnowGlobe.framework its easy to use, open source iOS framework written in swift. It allows you to ad delightful / cheesy Christmas

CoffeeToast - A swift package to easily add Toast notifications to your app

CoffeeToast A simple Swift package to add Toast Notifications to your app. Insta

Simple app to help understanding the spoken text in islamic prayers.
Simple app to help understanding the spoken text in islamic prayers.

About • Community Forum • App Store • Donation • Contributing • License About You regularly pray your prayers in Arabic, but do not really understand

Swift Package mimicking UIKit's ActionSheet with added features
Swift Package mimicking UIKit's ActionSheet with added features

ActionSheetController A Swift package that mimics the UIAlertController Actionsheet with added features. ActionSheetController gives you the ability t

Phimp.me - Photo Image Editor and Sharing App. Phimp.me is a Photo App for iOS that aims to replace proprietary photo applications. It offers features such as taking photos, adding filters, editing images and uploading them to social networks. FlexibleImage is implemented with the hope that anyone could easily develop an app that provides features such as Camera Filter and Theme.
FlexibleImage is implemented with the hope that anyone could easily develop an app that provides features such as Camera Filter and Theme.

FlexibleImage is implemented with the hope that anyone could easily develop an app that provides features such as Camera Filter and Theme. When you wr

An application on the iPad for people who cook. It comes with features such as smart recipes, recipe management and ingredient inventory tracking.

ChopChop ChopChop is an application on the iPad for people who cook. It comes with features such as smart recipes, recipe management and ingredient in

Quickly reproduce the dropdown UIPickerView / ActionSheet functionality on iOS.
Quickly reproduce the dropdown UIPickerView / ActionSheet functionality on iOS.

ActionSheetPicker-3.0 Important update Now I fixed most of the things and merge PR' (thanks to ). I did much work to support this library from iOS 5.

Menu controller with expandable item groups, custom position and appearance animation written with Swift. Similar to ActionSheet style of UIAlertController.
Menu controller with expandable item groups, custom position and appearance animation written with Swift. Similar to ActionSheet style of UIAlertController.

Easy to implement controller with expanding menu items. Design is very similar to iOS native ActionSheet presentation style of a UIAlertController. As

Simple Alert View written in Swift, which can be used as a UIAlertController. (AlertController/AlertView/ActionSheet)
Simple Alert View written in Swift, which can be used as a UIAlertController. (AlertController/AlertView/ActionSheet)

DOAlertController Simple Alert View written in Swift, which can be used as a UIAlertController replacement. It supports from iOS7! It is simple and ea

Customizable simple Alert and simple ActionSheet for Swift
Customizable simple Alert and simple ActionSheet for Swift

SimpleAlert It is simple and easily customizable alert. Can be used as UIAlertController. Appetize's Demo Requirements Swift 5.0 iOS 9.0 or later How

A custom SwiftUI modifier to present an ActionSheet or a Popover menu
A custom SwiftUI modifier to present an ActionSheet or a Popover menu

ActionOver A custom SwiftUI modifier to present an Action Sheet on iPhone and a Popover on iPad and Mac. iPhone Preview iPad Preview Mac Preview Featu

A drop-in universal library helps you to manage the navigation bar styles and makes transition animations smooth between different navigation bar styles
A drop-in universal library helps you to manage the navigation bar styles and makes transition animations smooth between different navigation bar styles

A drop-in universal library helps you to manage the navigation bar styles and makes transition animations smooth between different navigation bar styles while pushing or popping a view controller for all orientations. And you don't need to write any line of code for it, it all happens automatically.

Navigation toolbar is a Swift slide-modeled UI navigation controller.
Navigation toolbar is a Swift slide-modeled UI navigation controller.

Navigation toolbar is a Swift slide-modeled UI navigation controller. We specialize in the designing and coding of custom UI for Mo

An alternative SwiftUI NavigationView implementing classic stack-based navigation giving also some more control on animations and programmatic navigation.
An alternative SwiftUI NavigationView implementing classic stack-based navigation giving also some more control on animations and programmatic navigation.

swiftui-navigation-stack An alternative SwiftUI NavigationView implementing classic stack-based navigation giving also some more control on animations

The elegant yet functional dropdown menu, written in Swift, appears underneath the navigation bar to display a list of defined items when a user clicks on the navigation title.
The elegant yet functional dropdown menu, written in Swift, appears underneath the navigation bar to display a list of defined items when a user clicks on the navigation title.

Introduction The elegant yet functional dropdown menu, written in Swift, appears underneath the navigation bar to display a list of defined items when

Comments
  • Bottomsheet close() not working

    Bottomsheet close() not working

    I appreciate developer for creating this useful library for iOS.

    It seems like there is no way to dismiss the sheet from the screen once it become active. I tried these methods below,

    close() sheetNavigationController?.close() navigationController?.popViewController(animated: true)

    none of them seems working, and the black color behind the sheet seems a bit weird. It suppose to be transparent i think.

    opened by webnizam 1
  • fix update topMargin for not full screen present

    fix update topMargin for not full screen present

    Issue

    sheetNavigationController의 modal presentStyle이 .fullScreen 혹은 .overFullScreen이 아닌 경우가 있을 수 있습니다. topMargin 계산 시에 screenHeight를 UIScreen.main.bounds.height로 일괄 적용하고 있어서 modal presentStyle이 full이 되지 않는 경우에는 topMargin이 더 크게 계산되는 경우가 있습니다.

    수정사항

    topMargin의 visibleHeight 계산시 minMargin 값을 셋팅하여 빼줍니다.

    opened by nobinson94 0
  • App Extension Compatibility Request

    App Extension Compatibility Request

    Hello,

    Would much work be required to enable this library to work in the context of an app extension?

    • For example in a Share Extension or Action Extension
    • https://developer.apple.com/app-extensions/

    I have tried to add this as a pod to my app's share extension target, but on running the share extension it crashed with a runtime issue. I believe it has something to do with the AppDelegate not being present in this context.

    Many Thanks,

    James

    opened by james-ff 0
  • Feature list

    Feature list

    [ ] cell, header view [ ] present, dismiss transition code [ ] add custom present animator [ ] add examples [ ] structured sheet tool bar [ ] change to layout delegate pattern [ ] modify the code so that it is possible to have the default viewcontrol as well as the SheetContentsViewController

    feature 
    opened by ParkGwangBeom 0
Releases(0.6.0)
Owner
ArLupin
...
ArLupin
Simple Alert View written in Swift, which can be used as a UIAlertController. (AlertController/AlertView/ActionSheet)

DOAlertController Simple Alert View written in Swift, which can be used as a UIAlertController replacement. It supports from iOS7! It is simple and ea

Daiki Okumura 406 Sep 5, 2022
Customizable simple Alert and simple ActionSheet for Swift

SimpleAlert It is simple and easily customizable alert. Can be used as UIAlertController. Appetize's Demo Requirements Swift 5.0 iOS 9.0 or later How

Kyohei Ito 397 Dec 6, 2022
(Experimental libraries) Controls interrupt handling, such as alert views, and is compatible with UIKit and Swift UI.

UIPresentCoordinator Controls interrupt handling, such as alert views, and is compatible with UIKit and Swift UI. This library manages items that are

Yuki Tamazawa 1 Jan 22, 2022
Package for creating, modifying, and managing subtitle files, such as SubRip (.srt).

SubtitleKit Package for creating, modifying, and managing subtitle files, such as SubRip (.srt). Supported formats Format File extension Is supported

GGorAA 2 Oct 28, 2022
BPStatusBarAlert is a library that allows you to easily make text-based alert that appear on the status bar and below navigation bar.

BPStatusBarAlert BPStatusBarAlert is a library that allows you to easily make text-based alert that appear on the status bar and below navigation bar.

Ben.Park 131 Aug 12, 2022
The easiest way to display highly customizable in app notification banners in iOS

Written in Swift 5 NotificationBanner is an extremely customizable and lightweight library that makes the task of displaying in app notification banne

Dalton Hinterscher 4.5k Jan 9, 2023
Dice roller, character sheet/ creator, and monster/item info app on the iphone12

DnD-LordDogMaw This file will be the start of a side project in the hopes of creating an iphone12 app for Dungeons and Dragons! This app will have 3 m

Paige Guajardo 2 Sep 17, 2021
Whisper is a component that will make the task of display messages and in-app notifications simple. It has three different views inside

Description ?? Break the silence of your UI, whispering, shouting or whistling at it. Whisper is a component that will make the task of displaying mes

HyperRedink 3.7k Dec 25, 2022
Animated alert library like Swarm app.

TKSwarmAlert Animation Tool for Alert like Swarm app. ScreenShot Installation CocoaPods You can use CocoaPods to install TKSwarmAlert by adding it to

Takuya Okamoto 581 Dec 2, 2022
Swift library to manage in app notification in swift language, like WhatsApp, Telegram, Frind, ecc.

InAppNotify - Manage in App notifications During develop of my app Frind, I needed to manage in app notifications like whatsapp or telegram, but i did

Luca Becchetti 438 Nov 20, 2022