GithubHelp home page GithubHelp logo

shayanzadeh / tsmessages Goto Github PK

View Code? Open in Web Editor NEW

This project forked from krausefx/tsmessages

0.0 2.0 0.0 928 KB

Easy to use and customizable messages/notifications for iOS à la Tweetbot

License: BSD 2-Clause "Simplified" License

Objective-C 98.79% Ruby 1.21%

tsmessages's Introduction

TSMessages

This framework provides an easy to use class to display message views (à la Tweetbot).

The message moves from the top of the screen underneath the navigation bar and stays there for a few seconds, depending on the length of the displayed text. To dismiss a message before the time runs out, the user can swipe it to the top or just tap it.

There are 4 different types already set up for you: Success, Error, Warning, Message (take a look at the screenshots).

It is very easy to add new message types with a different design. Add the new type to the message type enum, add the needed design properties to the configuration file and set the name of the theme (used in the config file and images) in TSMessagesView.m inside the switch case.

Take a look at the Example project to see how to use this library. You have to open the workspace, not the project file, since the Example project uses cocoapods.

Follow the developer on Twitter: KrauseFx (Felix Krause)

Installation

From CocoaPods

Add pod 'TSMessages' to your Podfile.

Manually

Drag the whole folder into your project and remove the example project. This library requires ARC.

Drag HexColors{.h/.m} from Submodules/HexColors/Classes into your project.

To display messages use the following code:

    [TSMessage displayMessageWithTitle:title
                              subtitle:subtitle
                                  type:TSMessageTypeError];

    // Add a button to the message
    TSMessageView *view = [TSMessage messageWithTitle:@"New version available"
                                             subtitle:@"Please update our app"
                                                 type:TSMessageTypeDefault];

    [view setButtonWithTitle:NSLocalizedString(@"Update", nil) callback:^(TSMessageView *messageView) {
        [messageView dismiss];

        [TSMessage displayMessageWithTitle:NSLocalizedString(@"Thanks for updating", nil)
                                  subtitle:nil
                                      type:TSMessageTypeSuccess];
    }];

    [view displayOrEnqueue];

    // Use a custom design file
    [TSMessage addCustomDesignFromFileWithName:@"AlternativeDesign.json"];

The following properties can be set:

  • viewController: The view controller to show the message in. This might be the navigation controller.
  • title: The title of the message view
  • subtitle: The text that is displayed underneath the title (optional)
  • image: A custom icon image that is used instead of the default one (optional)
  • type: The message type (Message, Warning, Error, Success)
  • duration: The duration the message should be displayed (optional)
  • callback: The block that should be executed, when the user dismissed the message by swiping it away (optional)
  • userDismissEnabled: Define whether or not the message can be dismissed by the user by tapping and swipping (on by default)

Except the title and the message type, all of the listed values are optional

You don't need to do anything with TSMessageView, except you want to modify the behavior or the types of the message itself.

If you don't want a detailed description (the text underneath the title) you don't need to set one. The message will automatically resize itself properly.

iOS 7 Error iOS 7 Message

This project requires ARC.

If you have ideas how to improve this library please let me know or send a pull request.

Changes

0.9.4

  • Added new initializer (Sorry about that, it was necessary)
  • Added easy way to customize the design with an additional design file
  • Added iOS 7 support

0.9.3

  • Added new customization options for buttons (font size, custom background image, separate font and shadow color)
  • Added method to dismiss the currently active message
  • Added option to show a message until it is dismissed by the user
  • Added option to disable dismissing message by the user
  • Added method to check whether a message is currently being displayed
  • Fixed auto rotation when message is displayed on the bottom

0.9.2

  • Added option to show message on the bottom of the screen
  • Added option to show a button inside the message

TODOs

  • Fix/improve blur effect
  • Potentially support UIKit Dynamics

tsmessages's People

Contributors

adlai-holler avatar al-little avatar dennisreimann avatar dwarfland avatar fawkeswei avatar grichards-trulia avatar hannesoid avatar interstateone avatar jcarbaugh avatar jercik avatar koraktor avatar krausefx avatar mbaranowski avatar mrs- avatar muesliq avatar myell0w avatar onato avatar rileytestut avatar runmad avatar segiddins avatar shayanzadeh avatar srekke avatar toco avatar wangyandongnx avatar zhiyi7 avatar

Watchers

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