Giter Club home page Giter Club logo

asyncmessagesviewcontroller's Introduction

AsyncMessagesViewController

A smooth, responsive and flexible messages UI library for iOS apps. Built on top of the awesome Texture (formerly AsyncDisplayKit) framework, it takes full advantage of asynchronous layout and rendering to deliver a "butter smooth" scrolling experience.

Screenshot1    Screenshot2

Dependencies

Requirements

  • iOS 9 and later.
  • Swift 4.
  • ARC.

Installation

From CocoaPods:

pod 'AsyncMessagesViewController'  

Without CocoaPods

Copy the Source\ directory to your project and install all dependencies.

How to use

  • Example project
    • Run pod install.
    • Open AsyncMessagesViewController.xcworkspace.
    • Enjoy the simple ViewController.swift class.
  • Model
    • Your message model object should conform to MessageData protocol.
  • View
    • MessageCellNode is your friend. Most of the time you don't want to subclass it.
    • There are 2 basic built-in bubble nodes implemented for you: MessageTextBubbleNode for text based messages and MessageNetworkImageBubbleNode for remote image based messages.
    • Need a custom bubble node? Here you go.
  • Controller
    • Your view controller should subclass AsyncMessagesViewController. As you may see, it's a very simple view controller (and should be). Most of the magic is in the data source.
    • What data source, you may ask. Any data source that conform to AsyncMessagesCollectionViewDataSource protocol.
    • There is a default implemention: DefaultAsyncMessagesCollectionViewDataSource. This class keeps a sorted list of messages, but doesn't allow you to change them directly. Instead, you must alter messages using given methods in its protocol and let it handle the heavy work. It can (supposedly) smartly determine which cells need to be inserted, deleted and reloaded. Why? because:
      • Calling reloadData is very expensive on ASCollectionView (and ASTableView).
      • Most of the time, inserting/deleting a cell causing UI changes in other cells as well. DefaultAsyncMessagesCollectionViewDataSource can detect those changes automatically.
    • MessageCellNodeMetadata provides runtime-computed information about a message and how its data should be presented in a MessageCellNode. Metadata of a message is often computed based on the relationship with other messages. For example, message's sender name should be displayed if it is an incoming message and is the first one in a set of consecutive messages sent by a same user. Or message's date should be shown if it is the first message sent within a 15 minutes window. This kind of UI logic is encapsulated in MessageCellNodeMetadataFactory and computed at runtime. Of course you can implement your own logic.

Customizations

  • Custom bubble node:
    • Please read this guide on subclassing ASDisplayNode.
    • Implement a factory that conforms to MessageBubbleNodeFactory protocol.
    • Inject your factory to DefaultAsyncMessagesCollectionViewDataSource via its initializer.
    • Inject the data source to AsyncMessagesViewController (also via its initializer).
  • Custom bubble image's colors:
    • Initiate a MessageBubbleImageProvider with whatever colors you want.
    • Inject it to your data source.
    • Inject the data source to your view controller.
  • Custom bubble images:
    • Implementing your own MessageBubbleImageProvider.
    • Inject it to your data source.
    • Inject the data source to your view controller.
  • Custom logic for computing cell metadata:
    • Subclass MessageCellNodeMetadataFactory and override any neccessary method.
    • Inject it to your data source.
    • Inject the data source to your view controller.
  • Custom format for message date:
    • Subclass MessageTimestampFormatter and override attributedTimestamp(NSDate).
    • Inject it to your data source.
    • Inject the data source to your view controller.
  • Any customization related to the input toolbar:
  • Other customizations:
    • File an issue and I will be more than happy to help :)

Contributing

All feedbacks, questions and pull requests are very welcome. See here for details.

Credits

Created by Huy Nguyen, an Android developer :)

License

AsyncMessagesViewController is released under an MIT License. See here for details.

Copyright © 2015 Huy Nguyen.

asyncmessagesviewcontroller's People

Contributors

nguyenhuy avatar qtdzz avatar fredericjacobs avatar

Watchers

James Cloos 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.