A Google like action sheet for iOS written in Swift.

Overview

MaterialActionSheetController

Lightweight and totally customizable. Create and present it the way you do with UIAlertController.

Version License Platform

Screenshots

  • Demo

| Default light theme | Dark theme | Custom header | |---|---|---|---|---| | | | |

Features

  • Using closures to configure actions
  • Action with optional icon and accessory view
  • Handling touch on accessory view
  • Separate long action list in sections
  • Using closures to callback when controller is about to dismiss
  • 2 built-in themes: light & dark
  • Customizable header
  • Swift 3 compliant

Todos

  • Present on iPad as a pop-up
  • Documenting

Requirements

  • iOS 8.0+
  • Xcode 8
  • Swift 3

Installation

CocoaPods

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

pod 'MaterialActionSheetController'

Manually

Add MaterialActionSheetController.swift to your project

Usage

// Import MaterialActionSheetController if you're using CocoaPods
import MaterialActionSheetController
// Create an action
let lightBulbAction = MaterialAction(
        icon: UIImage(named: "lightbulb"),
        title: "Action with UISwitch as an accessory view", handler: { [unowned self] (accessoryView) in
            self.doSomething()
        }, 
        accessoryView: UISwitch(), 
        dismissOnAccessoryTouch: true, 
        accessoryHandler: { [unowned self] (accessoryView) in
            if let lightBulbSwitch = accessoryView as? UISwitch {
                if accessoryView.on {
                    print("Light is ON!")
                } else {
                    print("Light is OFF!")
                }
            }
            self.doSomeOtherThing()
    })
// Then create your MaterialActionSheetController
// parameter sections is a variadic which take a flexible list of section
let materialActionSheetController = MaterialActionSheetController(
        title: "A nice title",
        message: "A friendly message",
        actionSections: [aCoolAction, anotherCoolAction], [cancelAction])
// Or create 
let materialActionSheetController = MaterialActionSheetController()
materialActionSheetController.title = "A nice title"
materialActionSheetController.message = "A friendly message"
materialActionSheetController.actionSections.append([aCoolAction, anotherCoolAction])
materialActionSheetController.actionSections.append([cancelAction])
// Customize theme
materialActionSheetController.theme = MaterialActionSheetTheme.dark()

// Custom header view
let imageView = UIImageView(image: UIImage(named: "myimage"))
imageView.bounds = CGRect(origin: CGPoint.zero, size: CGSize(width: 300, height: 100))
materialActionSheetController.customHeaderView = imageView

// Handler on "will dismiss" and "did dismiss" event
materialActionSheetController.willDismiss = { [unowned self] in
    print("I will dismiss.")
    self.doSomething()
}

// Finally present it
materialActionSheetController.didDismiss = { [unowned self] in
    print("I did dismiss.")
    self.doSomething()
}

presentViewController(materialActionSheetController, animated: true, completion: nil)

See code in demo for more detailed examples.

Contribute

Feel free to make PR, contributions are warmly welcome and appreciated.

License

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

You might also like...
Multiplatform (iOS, macOS) SwiftUI bottom sheet drawer. Expandable bottomsheet. Slide out bottom menu
Multiplatform (iOS, macOS) SwiftUI bottom sheet drawer. Expandable bottomsheet. Slide out bottom menu

Multiplatform (iOS, macOS) SwiftUI bottom sheet drawer Features It does not re-render the background content while manipulating with the sheet iOS and

BottomSheetDemo - Bottom sheet modal view controller with swift
BottomSheetDemo - Bottom sheet modal view controller with swift

当我们想弹出一个预览视图,bottom sheet modal view controller 非常实用。在 iOS 中,长按拖拽手势可以让 controlle

DGBottomSheet - The lightest swift bottom sheet library
DGBottomSheet - The lightest swift bottom sheet library

DGBottomSheet Requirements Installation Usage DGBottomSheet The lightest swift b

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

Present a sheet ViewController easily and control ViewController height with pangesture
Present a sheet ViewController easily and control ViewController height with pangesture

PanControllerHeight is designed to present a sheet ViewController easily and control ViewController height with pangesture.

SwiftUI Draggable Bottom Sheet

SwiftUI Draggable Bottom Sheet

Bottom Sheet component is widely used in Joom application

Bottom Sheet Bottom Sheet component is widely used in Joom application Installation Swift Package Manager Swift Package Manager is a tool for managing

A SwiftUI Partial Sheet fully customizable with dynamic height
A SwiftUI Partial Sheet fully customizable with dynamic height

A SwiftUI Partial Sheet fully customizable with dynamic height

Share-sheet-example - A sample project that reproduces an issue with Share Sheets

Hello, DTS! This project demonstrates the issue I'm having with the Share Sheet.

Comments
  • Sheet view is covered by a UITransitionView

    Sheet view is covered by a UITransitionView

    Hi, I'm using this great component in an app. I've had no problems in previous controllers, but now I've a issue: when presenting the sheet, it's all shown and all, but you can't touch anything on it or on the background, because there are two views that cover everything: a UITransitionView and a UIView.

    I'm presenting from a modal view, could this be the problem? When presenting in other parts of the app, these two views are behind the share sheet and everything works.

    Thanks for your time and effort 👍

    https://cloudup.com/cWgcCY6FoQi

    opened by klauslanza 1
Releases(1.1)
Owner
Thanh-Nhon NGUYEN
Mobile Developer
Thanh-Nhon NGUYEN
zekunyan 608 Dec 30, 2022
A Floating Action Button just like Google inbox for iOS

VCFloatingActionButton A Floating Action Button inspired from Google inbox for iOS. Using this in your project Import the VCFloatingActionButton to yo

Giridhar 298 May 16, 2022
Fully customizable and extensible action sheet controller written in Swift

XLActionController By XMARTLABS. XLActionController is an extensible library to quickly create any custom action sheet controller. Examples The action

xmartlabs 3.3k Dec 31, 2022
A Swift library to provide a bouncy action sheet

Hokusai is a Swift library that provides a bouncy action sheet. It will give the users a fancy experience without taking pains coding the cool animati

Yuta Akizuki 430 Nov 20, 2022
Action sheet allows including your custom views and buttons.

CustomizableActionSheet Action sheet allows including your custom views and buttons. Installation CocoaPods Edit your Podfile: pod 'CustomizableAction

Ryuta Kibe 191 Nov 26, 2021
An iOS library for SwiftUI to create draggable sheet experiences similar to iOS applications like Maps and Stocks.

An iOS library for SwiftUI to create draggable sheet experiences similar to iOS applications like Maps and Stocks.

Wouter 63 Jan 5, 2023
It is a highly configurable iOS library which allows easy styling with built in styles as well as extra header and footer views so that you can make extremely unique alerts and action sheets.

 CFAlertViewController CFAlertViewController is a library that helps you display and customise Alerts, Action Sheets, and Notifications on iPad and i

Crowdfire Inc. 1.1k Dec 18, 2022
ActionBee is a programmable pasteboard action trigger.

ActionBee ActionBee is a programmable pasteboard action trigger. Preview Video It can be used to clean your URL in text. To see code or import this mo

Derek Jones 2 Aug 24, 2022
Customizable Dynamic Bottom Sheet Library for iOS

DynamicBottomSheet Powerd by Witi Corp., Seoul, South Korea. Fully Customizable Dynamic Bottom Sheet Library for iOS. This library doesn't support sto

Witi Official 10 May 7, 2022
This is a small View modifier that adds detents for native .sheet representations that appeared in iOS 16

SheetDetentsModifier This is a small View modifier that adds detents for .sheet representations that appeared in iOS 16 It works starting with iOS 15

Alex Artemev 19 Oct 9, 2022