Git Product home page Git Product logo

dropdownalert's Introduction

DropdownAlert

Version License Platform

A clean, customizable Swift alternative to RKDropdownAlert.

Overview

RKDropdownAlert is great. It's simple and easy to use. The developer is a great guy. But...there are some problems.

First, it's written in Objective-C and any Swift developer will tell you the same thing:

ew

Second, it's not responsive. To be truly responsive, any view library should be written using AutoLayout.

Finally, there's a huge caveat:

WAIT! Don't use pods if you want to customize or use the quick and easy [RKDropdownAlert show]

Developers have come to expect the convenience of Cocoapods and if you can't both customize the dropdown and download it from Cocoapods, what's the point?

That's where DropdownAlert comes in. Weighing in at just under 300 lines, DropdownAlert is sleek, fully customizable, responsive, Swift 2.3 compatible, and powered by Facebook's pop animation library, allowing for awesome custom animations.

Usage

DropdownAlert comes with 3 animation types, Basic, Spring, and Custom:

/**
Animation types the dropdown can be presented with.

- Basic:  Basic, simple animation.
- Spring: Spring animation.
- Custom: Custom animation.
*/
public enum AnimationType {
    case Basic(timingFunction: CAMediaTimingFunction)
    case Spring(bounce: CGFloat, speed: CGFloat)
    case Custom(POPPropertyAnimation)
}

Simply call like so:

DropdownAlert.showWithAnimation(.Basic(timingFunction: CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseIn)), title: "Login Failed", message: "Incorrect username/password", duration: 2)

animation-demo

You can stack as many animations as you want:

stacked-animations

Customization

Unlike RKDropdownAlert, DropdownAlert is fully customizable in conjunction with Cocoapods. The following class level properties are customizable:

class var defaultBackgroundColor: UIColor
class var defaultTextColor: UIColor 
class var defaultTitle: String
class var defaultMessage: String
class var defaultAnimationDuration: Double
class var defaultDuration: Double
class var defaultHeight: CGFloat
class var defaultTitleFont: UIFont
class var defaultMessageFont: UIFont
class var defaultFontSize: CGFloat

And because DropdownAlert internally uses Autolayout, the size of the alert will be always be greater than or equal to the default height + content overflow size, meaning your message can be as long as you want!

To customize a particular attribute:

DropdownAlert.defaultHeight = 110
DropdownAlert.defaultBackgroundColor = UIColor.blueColor()

Support

Feel free to open an issue or issue a PR! Check out the contribution guide for more info.

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Installation

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

pod "DropdownAlert"

Author

Brendan Conron, [email protected].

Twitter

License

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

dropdownalert's People

Contributors

thebarndog avatar

Watchers

James Cloos avatar José Lucas Souza das Chagas 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.