Code Monkey home page Code Monkey logo

whisper's Introduction

Whisper

CircleCI License Platform

Description 🍃

Break the silence of your UI, whispering, shouting or whistling at it. Whisper is a component that will make the task of displaying messages and in-app notifications simple. It has three different views inside.

Whispers

Whisper

Display a short message at the bottom of the navigation bar—this can be anything, from a "Great Job!" to an error message. It can have images or even a loader.

Shouts

In-App

Let users know that something happened inside the app with this beautiful customizable in-app notification.

Whistles

Whistle

This is the smallest of all, a beautiful discretion in your UI.

Bonus

All sounds are fully customizable, as are colors and fonts.

Shouts have an optional action that will be called if the user taps on it, and you'll even get a message when the Shout is gone. Finally, if you want to set how long the Shout should be displayed, you have a duration property.

In Whisper, there is no need to think about scroll view insets anymore—this will be handled automatically. As an added bonus, when transitioning from one view controller to another, the next controller's offset will be adjusted as you'd expect. It just works!

Usage

The usage of the component is so simple, you just create a message in the case of Whisper, an announcement in the case of a Shout, or a Murmur in the case of a Whistle. Because there may be a conflict with show from UIViewController, you need to explicitly use the Whisper namespace to call show.

For a Whisper:
let message = Message(title: "Enter your message here.", backgroundColor: .red)

// Show and hide a message after delay
Whisper.show(whisper: message, to: navigationController, action: .show)

// Present a permanent message
Whisper.show(whisper: message, to: navigationController, action: .present)

// Hide a message
Whisper.hide(whisperFrom: navigationController)
For a Shout:
let announcement = Announcement(title: "Your title", subtitle: "Your subtitle", image: UIImage(named: "avatar"))
Whisper.show(shout: announcement, to: navigationController, completion: {
  print("The shout was silent.")
})
For a Whistle:
let murmur = Murmur(title: "This is a small whistle...")

// Show and hide a message after delay
Whisper.show(whistle: murmur, action: .show(0.5))

// Present a permanent status bar message
Whisper.show(whistle: murmur, action: .present)

// Hide a message
Whisper.hide(whistleAfter: 3)

If you want to use Whisper with Objective-C, you can find information about it here.

Installation

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

pod 'Whisper'

Whisper is also available through Carthage. To install just write into your Cartfile:

github "hyperoslo/Whisper"

Roadmap

In the future the idea is to keep improving and add some features:

  • Improve the offset detection and animation.
  • Add more UI related components into Whisper.
  • More customization points and more sizes for each whisper.
  • Custom actions inside Whispers and Shouts.
  • We are open to new and awesome ideas, contribute if you like! :)

Author

Hyper made this with ❤️

Contribute

We would love for you to contribute to Whisper, check the CONTRIBUTING file for more info.

License

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

whisper's People

Contributors

3lvis avatar acadet avatar arthur-here avatar bevbomb avatar chrisamanse avatar cmilr avatar davidlamys avatar duemunk avatar ferdens avatar gilserrap avatar jesster2k10 avatar jgiola avatar jgorset avatar jinjic avatar jondwillis avatar minuscorp avatar n1mda avatar nachosoto avatar onmyway133 avatar plu avatar ramongilabert avatar sammy-sc avatar shrugs avatar sumitee2 avatar tiepvuvan avatar tkohout avatar vadymmarkov avatar valic avatar wowlocal avatar zenangst 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  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  avatar  avatar

Watchers

 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  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

whisper's Issues

Request: Change access levels to make it easier to subclass

As it is, it's very difficult to subclass Whisper due to so many of the properties being set to public private(set)

For instance, I would try to change the height by setting ShoutView.Dimensions.height = 85 before calling Shout(announcement: to:), but that function calls shout.craft(), which immediately resets Dimensions.Height. So a solution would be to subclass ShoutView and override craft(), but I can't override a few of the statements in there because the setters are inaccessible.

Whistle permanent?

Is possible to use a Whistle like a permanent message?
Is possible to hide it programmatically?

Problem with TableView Insets

Hi!
I have two TableViewControllers as you can see in the video I've attached here.
In the 2nd one I show a permanent Whisper notification (the only thing I've changed is the WhisperView height to 38). When the user press back, on viewWillDisappear() I invoke Silent(navigationController!) and the insets for the first TableViewControllers breaks. It returns top = -38 instead of top = 0.0, as my navigationBar is opaque, not transparent.
The second time I do it, as you can see in the video, the insets becomes worst, because this time it returns top = -76, so 38 x 2. And it goes on and on.
I have tried to solve this but couldn't exactly found the right line to modified in the pod.
Hope you can help me!
Thank you very much!
Pablo
movie

Announce from anywhere

Hi,
I'm trying to show a shout but I'm getting this error:

fatal error: The controller must contain a navigation bar: file .../Pods/Whisper/Source/ShoutFactory.swift, line 154

My use case is that I want to show when a new push notification arrives anywhere the user is but I have some ViewController that don't have a navigation bar.

Edit
Maybe just change this line? I don't know why it must be a navigationcontroller

 public func shout(to controller: UIViewController) {
     //--Remove
    //guard let controller = controller.navigationController else { fatalError("The controller must contain a navigation bar") } 

    let width = UIScreen.mainScreen().bounds.width
    controller.view.addSubview(self)

    frame = CGRect(x: 0, y: 0, width: width, height: 0)
    backgroundView.frame = CGRect(x: 0, y: 0, width: width, height: 0)

    UIView.animateWithDuration(0.35, animations: {
      self.frame.size.height = Dimensions.height
      self.backgroundView.frame.size.height = self.frame.height
    })
  }

Whisper usage examples don't work

let message = Message(title: "Added to favorites")
Whisper(message, to: self, action: .Show)

"Cannot call value of non-function type 'module'" on the second line

Question: Tabbar controller?

How can i use Whisper from a tabbarcontroller without a navigationcontroller? I am new to ios, if I cant do it in a tabbarcontroller what should i do in my storyboard to make it work?

Whistle restart application without crashing

Hi,
If I try to call a Murmur my application restart to the Initial View Controller.

var murmur = Murmur(title: "Can you retry please?")
Whistle(murmur) //Restart if this is not commented

Same behavior with iPhone or simulator. Only tested with latest SDK iOS 9.2.0.
Any idea?

Feature: Ability to change text colour

I've seen that you recently added the ability to change the background colour (which is really useful), however we want to change our background to a light green, but without being able to change the text colour it is really unreadable.

To be able to pass a text colour in addition to the background colour would be great!

Can't get Shout to work in Swift 3

Hi there,

I am really struggling with implementing the Shout in my app, and I have tried to follow the instructions regarding code, as well as trying several other methods in an attempt to make it work.

Here is two attempts I've tried:

        let anno = Announcement(title: "My title", subtitle: "My subtitle", image: UIImage(named: ""), duration: 3.0) { 

            show(shout: anno, to: ViewController)

        }

And:

        let anno = Announcement(title: "My title", subtitle: "My subtitle", image: UIImage(named: ""), duration: 3.0, action: nil)

        show(shout: anno, to: ViewController)

I have also tried to switch between using 'ViewController' and 'self' with no luck. Any ideas on how I would implement this correctly?

Thanks in advance!

🛠 Bug: terminating application

You create new UIWindow in WhistleFactory() on 20nd line.

It cause the application crash on didFinishLaunchingWithOptions methods because of followings in my opinion.

http://stackoverflow.com/a/33958144/3022613

2016-05-11 04:32:22.166 Smart Citizen[742:145841] *** Assertion failure in -[UIApplication _runWithMainScene:transitionContext:completion:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit/UIKit-3512.60.7/UIApplication.m:3401
2016-05-11 04:32:22.168 Smart Citizen[742:145841] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Application windows are expected to have a root view controller at the end of application launch'
*** First throw call stack:
(0x1834f2e38 0x182b57f80 0x1834f2d08 0x183e78124 0x1888e6ad0 0x1888e3674 0x184e937ac 0x184e93618 0x184e939c8 0x1834a9124 0x1834a8bb8 0x1834a68b8 0x1833d0d10 0x1886ab834 0x1886a5f70 0x1000ae594 0x182f6e8b8)
libc++abi.dylib: terminating with uncaught exception of type NSException

Can you provide any solution for this? Why do you need to create new UIWindow?

BTW: Without Whisper pod everything works well, same AppDelegate.swift file.

If you want to investigate problem I can share my project folder.

Message size is incorrect

First of all — thanks for such nice lib! :)

I've found 2 issues:

  1. If application is in split-screen-mode (so app window size != mainScreen size) — we have wrongly sized Message
  2. If Message is used in any kind of non-fulscreen popover/presentation controller — we have same issue

Here is an: example

I think, proper solution will be to just get width of navigationBar, what do you think?

P.S. Will try to create a PR with this change during the weekend

Whistle override status bar style .lightContent

When using Whistle in an app that currently is showing a status bar with .lightContent and not the .default black, Whistle changes the status bar to the black one.

I haven't found a work around yet, but it's probably due to the fact that Whistle uses an extra UIWindow.

Whistle's content is cropped

From what I have seen so far, the height of any whistle/murmur is fixed and not dynamic. Then, if its content is too long, it is simply cropped/hidden.

Can we update this?

Also, would it be possible to add a parameter for inner margins? I can help if needed.

'show' is getting confused with UIViewController show in swift3 branch

The latest beta XCode is having issues with the show method. There is a show method on UIViewController that it keeps getting confused with. Not sure why it can't differentiate between the two but it can't.

A better way of defining these methods might be the following:

public func showAnnouncement(_ announcement: Announcement, to: UIViewController, completion: (() -> Void)? = nil)

public func showMurmur(_ murmur: Murmur, action: WhistleAction = .show(1.5))

public func showMessage(_ message: Message, to: UINavigationController, action: WhisperAction = .Show)

Then you can leave the first label off when calling:

showAnnouncement(announcementVar, to: self)
showMurmur(murmurVar, .show(2.0))
showMessage(messageVar, to: self.navigationController, .Show(2.0))

Feature: Ability to define timeout

We use the Whisper to display a notification to the user upon an event. It works great, however, we would like the whisper to display longer so that the user has more time to read it.

The ability to pass a timeout value when creating the whisper would be great!

Swift 3 Branch

Are you planning on publishing a Swift 3 branch? It looks like there are a couple of PRs to that effect.
Thanks.

Status Bar

Hey, I'm trying to use the murmur version of Whisper. However, the status bar is becoming hidden, how to prevent this?

Feature: Handle a queue of notifications

Right now if you trigger two Shouts, only the last one will be displayed. The second one should wait until the first one has been removed, so no notification is hidden.

This could be done with an array of notifications, and a callback everytime a notification is terminated: if the array is not empty then we display the next one.

Not sure if this feature is part of your roadmap, but I thought i would be a nice to have

testBasicSetup failed

commit: 160a367c
testBasicSetup() fails because of the last assert XCTAssertEqual(app.buttons.count, 6)

Feature request / warning: Notification banners on bottom of screen

This seems like a great library, thanks for the hard work! I built a custom, similar component to this a while ago but will definitely be using this more full-featured gem moving forward.

My request is to have the option to display these bars on the bottom of the screen, on top or above any potential tabbar.

My warning is: I heard through the grapevine that Twitter uses the bottom-notification style because Apple thought the top-style-popdowns looked too similar (confusing the users) to the native notification banners. Maybe this could be noted in the readme?

Shout duration?

Hello,
is it possible to set the duration of a Shout?
Even better, make it permanent and dismissable tapping on it?

Thanks,

P

Namespace and global function conflict

Hi,

I have a name conflict with my model class "Message".
Tried to use Whisper's struct "Message" like Whisper.Message but it conflicts with global function
Whisper(message: Message, to: UINavigationController, action: WhisperAction = .Show)

Best regards and thanks for the lib :)

Support Buttons

In the current implementation Whisper has no intention to use buttons in the whisper. Is it possible to add buttons with different callbacks to manage this?

Build fails on Xcode 7.3 beta 2

just a heads up, Whisper fails compilation on Xcode 7.3 beta 2.

ExampleApp/Pods/Whisper/Source/WhisperFactory.swift:289:72: error: value of type 'Index' (aka 'Int') has no member 'value'
        performControllerMove(navigationController.viewControllers[Int(index.value) - 1])

Action on Notification tap

Hi,

This library is awesome but I need one feature in it which I think is essential for any notification.
I need to implement action when user taps on shout announcement.
I did not find it anywhere. If it is already implemented, please mention and close this issue.

Thanks!

modifyInset issue

I use Whisper in my navigationController with a tableviewController ,but I use a pull to refresh to my tableViewController. when the Whisper shows ,the tableView Inset changed,which makes my tableview inset changed.I changed the Config.swift property modifyInset to False ,that is fine.so I'm weird if is possible to public this property

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.