Code Monkey home page Code Monkey logo

advancedactionsheet's Introduction

AdvancedActionSheet - iOS

A customizable, full-feature, lightweight iOS framework to be used instead of UIAlertController.

Cocoapods

AdvancedActionSheet is available through CocoaPods. Simply add the following to your Podfile:

use_frameworks!

target '<Your Target Name>' do
  pod 'AdvancedActionSheet'
end

How to use

  • Import it to your project:
import AdvancedActionSheet
  • Then create an instance of AdvancedActionSheet, add actions and present it:
let alert = AdvancedActionSheet()
alert.addAction(item: .normal(id: 0, title: "Action 1", completionHandler: { (_) in
    // User tapped on this action, do appropriate tasks
    alert.dismiss(animated: true)
}))
alert.addAction(item: .normal(id: 1, title: "Action 2", completionHandler: { (_) in
    // User tapped on this action, do appropriate tasks
    alert.dismiss(animated: true)
}))
alert.present(presenter: self, completion: nil)

  • add actions with image:
let alert = AdvancedActionSheet()
alert.addAction(item: .actionWithIcon(title: "Maps", titleColor: nil, image: UIImage(named: "maps") ?? UIImage(), completionHandler: { (_) in
    // User tapped on this action, do appropriate tasks
    alert.dismiss(animated: true)
}))
alert.addAction(item: .actionWithIcon(title: "Waze", titleColor: nil, image: UIImage(named: "waze") ?? UIImage(), completionHandler: { (_) in
    // User tapped on this action, do appropriate tasks
    alert.dismiss(animated: true)
}))
alert.addAction(item: .actionWithIcon(title: "Google Maps", titleColor: nil, image: UIImage(named: "google-maps") ?? UIImage(), completionHandler: { (_) in
    // User tapped on this action, do appropriate tasks
    alert.dismiss(animated: true)
}))
alert.present(presenter: self, completion: nil)

  • add selectable actions:
let alert = AdvancedActionSheet()
alert.addAction(item: .selectable(item: SelectableActionItem(id: 1, icon: nil, title: "USA", subtitle: "United States", defaultSelectionStatus: false, drawBottomLine: true)))
alert.addAction(item: .selectable(item: SelectableActionItem(id: 2, icon: nil, title: "UK", subtitle: "United Kingdom", defaultSelectionStatus: true, drawBottomLine: true)))
alert.addAction(item: .selectable(item: SelectableActionItem(id: 3, icon: nil, title: "Germany", subtitle: "๐Ÿ‡ฉ๐Ÿ‡ช", defaultSelectionStatus: true, drawBottomLine: true)))
alert.addAction(item: .selectable(item: SelectableActionItem(id: 4, icon: nil, title: "Utopia", subtitle: "๐Ÿคจ", defaultSelectionStatus: true, drawBottomLine: true)))
alert.addAction(item: .selectable(item: SelectableActionItem(id: 5, icon: nil, title: "Ant Title", subtitle: "Any description", defaultSelectionStatus: false, drawBottomLine: true)))
// - deactivatable: will deactivate action when no selectable is selected, and reactivate it as soon as one of them become selected
alert.addAction(item: .normal(id: 6, title: "Done", deactivatable: false, completionHandler: { (selectedIDs) in
    print(selectedIDs)
    alert.dismiss(animated: true)
}))
alert.present(presenter: self, completion: nil)

  • add gallery+camera action:
let alert = AdvancedActionSheet()
alert.addAction(item: .quickGalleryCollectionView(showCamera: true, completionHandler: { (assets, selectedActionIDs, sendAsFile) in
    // User tapped on send (as file or with compression) button
    // with selected assets &
    // selected selectable actions if there is any of them (in this example we have no selectable action while having gallery action)
    alert.dismiss(animated: true)
}, {
    // User tapped on camera, open camera as you wish (you can use UIImagePickerController)
    alert.dismiss(animated: true)
}))
alert.addAction(item: .normal(id: 0, title: "Contacts", deactivatable: false, completionHandler: { (selectedIDs) in
    // User tapped on this action, do appropriate tasks
    alert.dismiss(animated: true)
}))
alert.addAction(item: .normal(id: 1, title: "Location", deactivatable: false, completionHandler: { (selectedIDs) in
    // User tapped on this action, do appropriate tasks
    alert.dismiss(animated: true)
}))
alert.addAction(item: .normal(id: 2, title: "iCloud", deactivatable: false, completionHandler: { (selectedIDs) in
    // User tapped on this action, do appropriate tasks
    alert.dismiss(animated: true)
}))
alert.present(presenter: self, completion: nil)

Customize it:

You can customize theme (colors), fonts and even language (texts). It will fit in your application.

  • Config theme (colors):
// Just call this method
AdvancedActionSheetConfigs.configColors
  • Config fonts:
// Just call this method
AdvancedActionSheetConfigs.configFonts
  • Config language (texts):
// Just call this method
AdvancedActionSheetConfigs.configLanguage

advancedactionsheet's People

Contributors

alisamaiee avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

advancedactionsheet's Issues

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.