Giter Site home page Giter Site logo

cocoabar's Introduction

CocoaBar

Build Status


A flexible and simple to use SnackBar view for iOS.

Installation

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

pod 'CocoaBar'

Swift 2.1 support is available in version 0.1.7 or below:

pod 'CocoaBar', '~> 0.1.0'

And run pod install.

Usage

CocoaBar can be attached to a view or window.

public init(window: UIWindow?)
public init(view: UIView?)

The CocoaBar can then be shown or hidden using the showAnimated or hideAnimated functions. There are numerous convenience functions available for showing the CocoaBar to allow for easy customisation. They provide the following:

  • Duration - either a Double or DisplayDuration; which provides a preset time period to display the bar for.
  • Layout - provide a custom CocoaBarLayout layout to display.
  • Style - use one of the predefined layouts for display.

When a CocoaBar is attached to the keyWindow, it is made available as the keyCocoaBar. showAnimated and hideAnimated class functions are then available on CocoaBar for the keyCocoaBar.

Customisation

Custom layouts can be displayed in a CocoaBar with the use of a CocoaBarLayout subclass.

CocoaBarLayout will automatically attempt to inflate a nib associated with the layout (using the same class name), and use AutoLayout to calculate the required dimensions. init(nibName, height) is also available to manually specify the nib to use and set an explicit height. Refer to the example project to see usage of a custom layout.

The following properties are available to customise on a CocoaBarLayout:

  • backgroundStyle - customise the appearance of the layout background.
  • displayStyle - customise the display appearance of the layout.
  • keylineColor - the colour of the 1pt keyline at the top of the layout.
  • dismissButton - attach to a button that serves purely for dismissal of the CocoaBar.
  • actionButton - attach to a button that serves as an action button for the layout. Interaction will result in the cocoaBar(cocoaBar: actionButtonPressed actionButton:) being called for the CocoaBarDelegate.

Requirements

Supports iOS 8 and above.

cocoabar's People

Contributors

jrg-developer avatar msaps avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

cocoabar's Issues

doShowAnimated and doHideAnimated delegate call order

Hi Merrick,

This isn't as much an issue as feedback.

I have changed the callback order I expected from the didShowAnimated / didHideAnimated delegates in relation to the completion callbacks.

The call order of the completion handler and the didShowAnimated/didHideAnimated handler will be called in reverse order depending on the state of the animated flag.

So I changed your code, to call

willShowAnimated / willHideAnimated (This is ok)
completion (Line 431 / 492 of CocoaBar.swift)
didShowAnimate / didHideAnimated (This could be called before completion, depending on the animated flag passed in)

I raised this issue for the sake of symmetry and perhaps expected call order from client code.

Cheers,
Samson

Swift 3 CocoaPod

I see a commit on September 9th with message "use conversion tool," so it looks like you've started the process of converting to Swift 3.

However, the Example project still prompts to convert this, so it looks like there's a bit to be done still.

Do you have plans for Swift 3 release, in particular new CocoaPod version?

If you're too bogged down, will you accept/review PR for such? I'm happy to help here as I'm going to be needing it soon and would prefer to get changes into upstream if possible. ๐Ÿ˜„

Custom layout in Cocoabar

I can able to create a custom layout..But I need to change text labels in custom layout. Im not able to do that since custom layout are in CocoaLayout.I tried changing label text says unwrapping nil value

Allow to adjust/increase of the dismiss timer

In case of multiple calls for snackbar, the default behavior is for the bars to stack up. We do not like that behavior and it works better for our use case if we only have the snackbar reflect the last action. Everything works except one small thing. The problem is if say we have 2 actions with an interval of 1 seconds and say the snackbar disappears after 2 seconds, when we update the snackbar after the second action the timer does not get "updated" and the snackbar disappears after 1 second after the second action as opposed to 2 seconds as it should be.

Can you please whether tell me how I can use the library in such a use case or perhaps you can update the library and expose a method to "reset" the timer (basically prolonging its display) in some way.

Thanks.

Show CocoaBar at top

It would be great if you could choose whether to pin the bar a t the bottom or the top!

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.