Simple UIAlertController builder class in Swift.

Overview

Kamagari

Language CocoaPods Carthage compatible License Issues

Simple UIAlertController builder class in Swift.

Features

  • AlertBuilder class to simply build UIAlertController by using method chaining
  • UIAlertController extension methods to simply present UIAlertController on screen

Usage

The following sample codes shows how to use Kamagari in order to present UIAlertController.

// ActionSheet Sample
    if UIDevice.current.userInterfaceIdiom != .pad {
            // Sample to show on iPad
            AlertBuilder(title: "Question", message: "Are you sure where Kamagari is?", preferredStyle: .actionSheet)
                .addAction(title: "NO", style: .cancel) { _ in }
                .addAction(title: "YES", style: .default) { _ in }
                .build()
                .kam_show(animated: true)
    } else {
            /*
             Sample to show on iPad
             With setPopoverPresentationProperties(), specify the properties of UIPopoverPresentationController.
             */
            AlertBuilder(title: "Question", message: "Are you sure where Kamagari is?", preferredStyle: .actionSheet)
                .addAction(title: "YES", style: .default) { _ in }
                .addAction(title: "Not Sure", style: .default) { _ in }
                .setPopoverPresentationProperties(sourceView: view, sourceRect: CGRect(x: 0, y: 0, width: 100, height: 100) ,                                barButtonItem: nil, permittedArrowDirections: .any)
                .build()
                .kam_show(animated: true)
  }

Requirements

  • iOS 8.0+
  • Swift 4.0
  • Xcode 9.0

Installation

  • Install with CocoaPods
pod 'Kamagari'
  • Copy in all the files into your project
  • Use git submodule

Release Notes

See https://github.com/tasanobu/Kamagari/releases

License

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

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

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

PMAlertController is a great and customizable alert that can substitute UIAlertController
PMAlertController is a great and customizable alert that can substitute UIAlertController

PMAlertController is a small library that allows you to substitute Apple's uncustomizable UIAlertController, with a beautiful and totally customizable

Advanced usage of UIAlertController and pickers based on it: Telegram, Contacts, Location, PhotoLibrary, Country, Phone Code, Currency, Date...
Advanced usage of UIAlertController and pickers based on it: Telegram, Contacts, Location, PhotoLibrary, Country, Phone Code, Currency, Date...

Alerts & Pickers Advanced usage of native UIAlertController with TextField, TextView, DatePicker, PickerView, TableView, CollectionView and MapView. F

This is an iOS control for selecting a date using UIDatePicker in an UIAlertController like manner
This is an iOS control for selecting a date using UIDatePicker in an UIAlertController like manner

RMDateSelectionViewController This framework allows you to select a date by presenting an action sheet. In addition, it allows you to add actions arro

This is an iOS control for presenting any UIView in an UIAlertController like manner
This is an iOS control for presenting any UIView in an UIAlertController like manner

RMActionController This framework allows you to present just any view as an action sheet. In addition, it allows you to add actions around the present

This is an iOS control for selecting something using UIPickerView in an UIAlertController like manner
This is an iOS control for selecting something using UIPickerView in an UIAlertController like manner

RMPickerViewController This framework allows you to pick something with a picker presented as an action sheet. In addition, it allows you to add actio

Customizable replacement for UIAlertController

ActionSheet Customizable replacement for UIAlertController. Requirements Installation Swift Package Manager The Swift Package Manager is a tool for au

UIAlertController with continuity.

CuckooAlert Allow multiple use of presentViewController to UIAlertController. You may be disappointed from this. Do you imagine that cuckoo spit out s

Use UIAlertController like a boss.
Use UIAlertController like a boss.

Description Requirements Installation CocoaPods Carthage Usage License Description CatAlertController is a high level manager object that with chainin

Comments
  • Crash on iPad when presenting as UIAlertControllerStyleActionSheet

    Crash on iPad when presenting as UIAlertControllerStyleActionSheet

    Crash Log

    2015-07-17 12:28:09.187 Sample[75631:2123973] *** Terminating app due to uncaught exception 'NSGenericException', reason: 'Your application has presented a UIAlertController (<UIAlertController: 0x7fbcbd09b2e0>) of style UIAlertControllerStyleActionSheet. The modalPresentationStyle of a UIAlertController with this style is UIModalPresentationPopover. You must provide location information for this popover through the alert controller's popoverPresentationController. You must provide either a sourceView and sourceRect or a barButtonItem.  If this information is not known when you present the alert controller, you may provide it in the UIPopoverPresentationControllerDelegate method -prepareForPopoverPresentation.'
    *** First throw call stack:
    (
        0   CoreFoundation                      0x0000000107e98c65 __exceptionPreprocess + 165
        1   libobjc.A.dylib                     0x0000000109a03bb7 objc_exception_throw + 45
        2   UIKit                               0x0000000108e4b03a -[UIPopoverPresentationController presentationTransitionWillBegin] + 2650
        3   UIKit                               0x0000000108846d39 __71-[UIPresentationController _initViewHierarchyForPresentationSuperview:]_block_invoke + 1305
        4   UIKit                               0x0000000108845380 __56-[UIPresentationController runTransitionForCurrentState]_block_invoke + 189
        5   UIKit                               0x000000010875b5ec _applyBlockToCFArrayCopiedToStack + 314
        6   UIKit                               0x000000010875b466 _afterCACommitHandler + 533
        7   CoreFoundation                      0x0000000107dcbca7 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
        8   CoreFoundation                      0x0000000107dcbc00 __CFRunLoopDoObservers + 368
        9   CoreFoundation                      0x0000000107dc1a33 __CFRunLoopRun + 1123
        10  CoreFoundation                      0x0000000107dc1366 CFRunLoopRunSpecific + 470
        11  GraphicsServices                    0x000000010be9ea3e GSEventRunModal + 161
        12  UIKit                               0x00000001087378c0 UIApplicationMain + 1282
        13  Sample                              0x0000000107c88ef7 main + 135
        14  libdyld.dylib                       0x000000010a16b145 start + 1
    )
    libc++abi.dylib: terminating with uncaught exception of type NSException
    
    opened by tasanobu 1
  • How to dismiss the alert in the handler

    How to dismiss the alert in the handler

    let alert = AlertBuilder(title: "", message: R.string.please_enable_location, preferredStyle: .alert)
                    .addAction(title: "Cancel", style: .cancel) { _ in }
                    .addAction(title: "Settings", style: .default) { _ in
                        UIApplication.shared.openURL(URL(string: "App-Prefs:root=Privacy&path=LOCATION")!)
                        alert.dismiss(animated: true, completion: nil) // compiler error
                    }
                    .build()
                    alert.kam_show(animated: true)
    
    opened by chanonly123 0
Releases(1.1.0)
  • 1.1.0(Sep 24, 2016)

  • 1.0.1(Mar 28, 2016)

  • 1.0.0(Sep 10, 2015)

  • 0.9.0(Sep 10, 2015)

    • Add a method to AlertController in order to configure properties of UIAlertController.popoverPresentationController

      The following sample is to show an action sheet by specifying the properties of UIPopoverPresentationController with the newly added method AlertBuilder.setPopoverPresentationProperties()

      AlertBuilder(title: "Question", message: "Are you sure where Kamagari is?", preferredStyle: .ActionSheet)
      .addAction(title: "YES", style: .Default) { _ in }
      .addAction(title: "Not Sure", style: .Default) { _ in }
      .setPopoverPresentationProperties(sourceView: view, sourceRect: CGRectMake(0, 0, 100, 100), barButtonItem: nil, permittedArrowDirections: .Any)
      .build()
      .kam_show(animated: true)
      
    Source code(tar.gz)
    Source code(zip)
  • 0.8.0(Sep 10, 2015)

Owner
Kazunobu Tasaka
Kazunobu Tasaka
A simple, customizable popup dialog for iOS written in Swift. Replaces UIAlertController alert style.

Introduction Popup Dialog is a simple, customizable popup dialog written in Swift. Features Easy to use API with hardly any boilerplate code Convenien

Orderella Ltd. 3.8k Dec 20, 2022
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
A simple custom popup dialog view for iOS written in Swift. Replaces UIAlertController alert style.

A simple custom popup dialog view for iOS written in Swift. Replaces UIAlertController alert style.

donggyu 5 Jan 26, 2022
💬 A tiny extension for UIAlertController that makes working with it very simple. Only 150 lines of code.

AlertController ?? A tiny extension for UIAlertController that makes working with it very simple. Only 150 lines of code. Alert let alert = UIAlertCon

Mezhevikin Alexey 9 Nov 2, 2022
Simple and elegant way to handle UIAlertController.

SwiftyAlert SwiftAlert is simple and elegant way to handle UIAlertController. Feature Handle action with async/await Method chain Support UITextField

Jaesung Jung 2 Oct 30, 2022
Easy Swift UIAlertController

EZAlertController Easy Swift UIAlertController One line setup for all UIAlertControllers Button action with closures instead of selectors Easily custo

Kan Yilmaz 366 Sep 14, 2022
Swifty, modern UIAlertController wrapper.

Alertift Alertift.alert(title: "Alertift", message: "Alertift is swifty, modern, and awesome UIAlertController wrapper.") .action(.default("❤️"))

Suguru Kishimoto 287 Jan 7, 2023
Advanced usage of UIAlertController and pickers based on it: Telegram, Contacts, Location, PhotoLibrary, Country, Phone Code, Currency, Date...

Alerts & Pickers Advanced usage of native UIAlertController with TextField, TextView, DatePicker, PickerView, TableView, CollectionView and MapView. F

RV 5.5k Dec 22, 2022
An easier constructor for UIAlertController. Present an alert from anywhere.

ALRT An easier constructor for UIAlertController. Present an alert from anywhere like this. ALRT.create(.alert, title: "Alert?").addOK().addCancel().s

Masahiro Watanabe 97 Nov 11, 2022
PMAlertController is a great and customizable alert that can substitute UIAlertController

PMAlertController is a small library that allows you to substitute Apple's uncustomizable UIAlertController, with a beautiful and totally customizable

Paolo Musolino 2.5k Jan 3, 2023