• This repository has been archived on 01/Aug/2019
  • Stars
    star
    2,422
  • Rank 18,996 (Top 0.4 %)
  • Language
    Swift
  • License
    Other
  • Created over 8 years ago
  • Updated over 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A fast, lightweight messenger component built on AsyncDisplaykit and written in Swift

./NMessenger

License MIT

NMessenger is a fast, lightweight messenger component built on AsyncDisplaykit and written in Swift. Developers can inherently achieve 60FPS scrolling and smooth transitions with rich content components.

NMessenger

Features

Built-in support for:

Version Information

  • 1.0.0

Requirements

  • iOS 8.2+

Installation for Cocoapods

# For latest release in cocoapods - 1.0.80 (Swift 3, ASDK 2.X)
pod 'NMessenger'

# For ASDK 1.9
pod 'NMessenger', '1.0.79'

# For Swift 2.3 support
pod 'NMessenger', '1.0.76'

Notes

For iOS 10 Support

Add NSPhotoLibraryUsageDescription and NSCameraUsageDescription to your App Info.plist to specify the reason for accessing photo library and camera. See Cocoa Keys for more details.

Landscape Mode

  • Landscape mode is not currently supported. While it may be supported in a future release, we have disabled device rotation for NMessengerViewController to prevent issues.

Getting Started

NMessengerViewController

NMessenger comes with a prebuilt NMessengerViewController that has a few supported features.

  • Posting messages
  • Input bar with a custom placeholder
  • Camera and photo library access
  • Typing indicator support

Posting Messages

Send a text message.

func sendText(text: String, isIncomingMessage:Bool) -> GeneralMessengerCell

Text Message

---

Send a message with an image.

func sendImage(image: UIImage, isIncomingMessage:Bool) -> GeneralMessengerCell

Send a message with a network image. (Uses AsyncDisplayKit with PINCache to lazyload and cache network images)

func sendNetworkImage(imageURL: String, isIncomingMessage:Bool) -> GeneralMessengerCell

Image Message

---

A message with a collection view can be created directly from an array of views or nodes. Note: Nodes take advantage of ASDK's async rendering capabilities and will make this component scroll more smoothly.

func sendCollectionViewWithViews(views: [UIView], numberOfRows:CGFloat, isIncomingMessage:Bool) -> GeneralMessengerCell
func sendCollectionViewWithNodes(nodes: [ASDisplayNode], numberOfRows:CGFloat, isIncomingMessage:Bool) -> GeneralMessengerCell

One line CollectionView

One line CollectionView

Multi line CollectionView

Multi line CollectionView

---

Send a message with a custom view or node. Note: Nodes take advantage of ASDK's async rendering capabilities and will make this component scroll more smoothly.

func sendCustomView(view: UIView, isIncomingMessage:Bool) -> GeneralMessengerCell
func sendCustomNode(node: ASDisplayNode, isIncomingMessage:Bool) -> GeneralMessengerCell

Custom Message

These functions are meant to be overridden for network calls and other controller logic.

Typing Indicators

Typing indicators signify that incoming messages are being typed. This will be the last message in the messenger by default.

/** Adds an incoming typing indicator to the messenger */
func showTypingIndicator(avatar: ASDisplayNode) -> GeneralMessengerCell

/** Removes a typing indicator from the messenger */
func removeTypingIndicator(indicator: GeneralMessengerCell)

Typing Indicator

Custom InputBar

To use a custom input bar, you must subclass InputBarView. InputBarView conforms to InputBarViewProtocol:

@objc public protocol InputBarViewProtocol
{
    /* Superview of textInputView - can hold send button and/or attachment button*/
    var textInputAreaView: UIView! {get set}
    /* UITextView where the user will input the text*/
    var textInputView: UITextView! {get set}
    //NMessengerViewController where to input is sent to
    var controller:NMessengerViewController! {get set}
}

Both textInputAreaView and textInputView must be created in order for NMessengerViewController to have the correct behavior. controller is set by the initializer in InputBarView base class.

In order to use your custom InputBar, override func getInputBar()->InputBarView in NMessengerViewController.

NMessenger

NMessenger can be added to any view.

self.messengerView = NMessenger(frame: CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height))
messengerView.delegate = self
self.view.addSubview(self.messengerView)

With NMessenger, there is no need to manage a data source. Simply add a message and forget about it.

Changing and updating a message relies on a reference. These references can be passed through a delegate method or stored locally in a class.

self.delegate.deleteMessageBtnClick(self)
.
.
.
func deleteMessageBtnClick(message: GeneralMessageCell) {
  self.messengerView.removeMessage(message, .None)
}

Message Bubbles

NMessenger comes with a few prebuilt bubble types. bubble can also easily be subclassed to create a new bubble component.

SimpleBubble

Simple Bubble

DefaultBubble

Default Bubble

StackedBubble

Stacked Bubble

ImageBubble - Can be used with any 9 Patch Image

Image Bubble

By setting hasLayerMask = true, bubbles will mask their content. This is relevant for images and other rich content components.

Bubble Configuration

In order to configure custom bubbles for the messenger, you must create a new class that implements BubbleConfigurationProtocol.

/** Configures a bubble for a ContentNode. Implement this to create your own bubble configuration */
protocol BubbleConfigurationProtocol {
    var isMasked: Bool {get set}
    
    /** Create and return a UI color representing an incoming message */
    func getIncomingColor() -> UIColor
    
    /** Create and return a UI color representing an outgoing message */
    func getOutgoingColor() -> UIColor
    
    /** Create and return a bubble for the ContentNode */
    func getBubble() -> Bubble
    
    /** Create and return a bubble that is used by the Message group for Message nodes after the first. This is typically used to "stack" messages */
    func getSecondaryBubble() -> Bubble
}

This protocol is meant to provide a new instance of the bubble class for primary (messageNode) and secondary (messageGroup) bubble types. By changing var sharedBubbleConfiguration: BubbleConfigurationProtocol in NMessengerViewController, you can set the configuration for all newly added messages.

Content Nodes and Custom Components

Content Nodes

A Content Node holds message content in a MessageNode (everything inside of the bubble).

Content Node

Subclassing ContentNode gives you the ability to define your own content. This is particularly useful for creating rich content components that are not in our stock message kit. Alternatively, you can initialize a 'CustomContentNode' with your own view or node.

Content Nodes can also be given a BubbleConfigurationProtocol to customize their bubble.

GeneralMessengerCell

GeneralMessengerCell can be subclassed to make any type of component. All messenger cells extend this object.

Timestamps

Timestamps can be easily added with the MessageSentIndicator class.

let messageTimestamp = MessageSentIndicator()
messageTimestamp.messageSentText = "NOW"

//NMessengerViewController
self.addMessageToMessenger(messageTimestamp)

//NMessenger
messengerView.addMessage(messageTimestamp, scrollsToMessage: false)

Avatars

Custom avatars can be set with an AsyncDisplayKit ASImageNode.

let nAvatar = ASImageNode()
nAvatar.image = UIImage(named: "nAvatar")
.
.
.
messageNode.avatarNode = nAvatar

Head Prefetching

Many messengers prefetch at the head. This is not trivial with a UITableView or AysncDisplayKit features. NMessenger supports head prefetching out of the box.

To use the head prefetch feature, set var doesBatchFetch: Bool = true on NMessenger. NMessengerDelegate will also need to be implemented and set by your controller.

@objc protocol NMessengerDelegate {
    /**
     Triggered when a load batch content should be called. This method is called on a background thread.
     Make sure to add prefetched content with *endBatchFetchWithMessages(messages: [GeneralMessengerCell])**/
    optional func batchFetchContent()
    /** Returns a newly created loading Indicator that should be used at the top of the messenger */
    optional func batchFetchLoadingIndicator()->GeneralMessengerCell
}

All batch fetch network calls should be done in batchFetchContent. Make sure to add your message cells with endBatchFetchWithMessages(messages: [GeneralMessengerCell]) to end the batch fetch. Calling this function will remove the loading indicator and batch fetch lock.

Message Groups

Message Groups can be used to stack messages and animate avatars. Like MessageNode, MessageGroup extends GeneralMessageCell. The difference, however is that MessageGroup holds a table of MessageNodes rather than a ContentNode.

================
| MessageGroup | -> ===============    ===============
================    | MessageNode | -> | ContentNode | (Primary Bubble)
                    ---------------    ===============
                    | MessageNode | -> | ContentNode | (Secondary Bubble)
                    ---------------    ===============
                    | MessageNode | -> | ContentNode | (Secondary Bubble)
                    ---------------    ===============
                    | MessageNode | -> | ContentNode | (Secondary Bubble)
                    ===============    ===============

Additionally, MessageGroup determines the bubble type of the MessageNode's content based on the position in the table. The first message's content will have a primary bubble, the rest will have a secondary bubble. Typically, the avatar will be disabled on any MessagesNode in the group, but kept for the MessageGroup.

Message Group

Adding, Removing, and Updating

Message Groups include a few slick animations for Adding, Removing, and Updating MessageNodes in the group. These can be called directly from MessageGroup or Added and Removed from NMessenger. Note: These are not surfaced in the NMessengerViewController yet

It is recommended that they are removed from NMessenger because of the possibility that the MessageNode removed was the last message in the group. If this happens, the MessageGroup will remain after the MessageGroup was removed. NMessenger makes sure that in this case the MessageGroup is removed from the messenger.

Adding

To add a MessageNode.

messageGroup.addMessageToGroup(message: GeneralMessengerCell, completion: (()->Void)?)

Message Group Add Animation

Removing

To remove a MessageNode.

messageGroup.removeMessageFromGroup(message: GeneralMessengerCell, completion: (()->Void)?)

Message Group Remove Animation

Updating

To update an existing MessageNode with a new MessageNode.

messageGroup.replaceMessage(message: GeneralMessengerCell, withMessage newMessage: GeneralMessengerCell, completion: (()->Void)?)

Message Group Update Animation

Authors

  • Aaron Tainter
  • David Schechter

More Repositories

1

nice-modal-react

A modal state manager for React.
TypeScript
2,063
star
2

akutan

A distributed knowledge graph store
Go
1,654
star
3

tsv-utils

eBay's TSV Utilities: Command line tools for large, tabular data files. Filtering, statistics, sampling, joins and more.
D
1,419
star
4

bayesian-belief-networks

Pythonic Bayesian Belief Network Package, supporting creation of and exact inference on Bayesian Belief Networks specified as pure python functions.
Python
1,122
star
5

NuRaft

C++ implementation of Raft core logic as a replication library
C++
1,010
star
6

restcommander

Fast Parallel Async HTTP client as a Service to monitor and manage 10,000 web servers. (Java+Akka)
Java
899
star
7

parallec

Fast Parallel Async HTTP/SSH/TCP/UDP/Ping Client Java Library. Aggregate 100,000 APIs & send anywhere in 20 lines of code. Ping/HTTP Calls 8000 servers in 12 seconds. (Akka) www.parallec.io
Java
810
star
8

HeadGazeLib

A library to empower iOS app control through head gaze without a finger touch
Swift
754
star
9

Sequence-Semantic-Embedding

Tools and recipes to train deep learning models and build services for NLP tasks such as text classification, semantic search ranking and recall fetching, cross-lingual information retrieval, and question answering etc.
Python
460
star
10

modanet

ModaNet: A large-scale street fashion dataset with polygon annotations
336
star
11

flutter_glove_box

Various eBay tools for Flutter development
Dart
319
star
12

Neutrino

Neutrino is a software load balancer(SLB)
Scala
306
star
13

KPRN

Reasoning Over Knowledge Graph Paths for Recommendation
Lua
280
star
14

UAF

UAF - Universal Authentication Framework
Java
276
star
15

griffin

Model driven data quality service
JavaScript
240
star
16

cors-filter

CORS (Cross Origin Resource Sharing) is a mechanism supported by W3C to enable cross origin requests in web-browsers. CORS requires support from both browser and server to work. This is a Java servlet filter implementation of server-side CORS for web containers such as Apache Tomcat.
Java
231
star
17

Jungle

An embedded key-value store library specialized for building state machine and log store
C++
224
star
18

sbom-scorecard

Generate a score for your sbom to understand if it will actually be useful.
Go
221
star
19

ebayui-core

Collection of Marko widgets; considered to be the core building blocks for all eBay components, pages & apps
TypeScript
217
star
20

jsonpipe

A lightweight AJAX client for chunked JSON responses
JavaScript
204
star
21

ebay-font

A small utility to efficiently load custom web fonts
JavaScript
175
star
22

skin

Pure CSS framework designed & developed by eBay for a branded, e-commerce marketplace.
JavaScript
171
star
23

accelerator

The Accelerator is a tool for fast and reproducible processing of large amounts of data.
Python
150
star
24

firebase-remote-config-monitor

Monitors firebase remote config values, posting changes to slack
JavaScript
139
star
25

maxDNN

High Efficiency Convolution Kernel for Maxwell GPU Architecture
C++
132
star
26

go-ovn

A Go library for OVN Northbound/Southbound DB access using native OVSDB protocol
Go
108
star
27

Gringofts

Gringofts makes it easy to build a replicated, fault-tolerant, high throughput and distributed event-sourced system.
C++
102
star
28

parallec-samples

Single file examples and ready-to-use servers show how to use parallec.io library. Examples to aggregate APIs and publish to Elastic Search and Kafka, and many more. www.parallec.io
Java
92
star
29

userscript-proxy

HTTP proxy to inject scripts and stylesheets into existing sites.
JavaScript
87
star
30

xcelite

Java
81
star
31

RANSynCoders

Jupyter Notebook
81
star
32

mindpatterns

HTML Accessibility Pattern Examples
HTML
79
star
33

ebay-oauth-python-client

Python OAuth SDK: Get OAuth tokens for eBay public APIs
Python
78
star
34

figma-include-accessibility-annotations

Include is a tool built to make annotating for accessibility (a11y) easier—easier for designers to spec and easier for developers to understand what is required.
JavaScript
77
star
35

embedded-druid

Java
75
star
36

ebay-oauth-nodejs-client

🔑 Generate an OAuth token that can be used to call the eBay Developer REST APIs.
JavaScript
66
star
37

Design-Grid-Overlay

A Chrome extension to overlay a design grid on your web page; configurable to fit many design scenarios.
JavaScript
65
star
38

json-comparison

Powerful JSON comparison tool for identifying all the changes within JSON files
Java
63
star
39

xFraud

Jupyter Notebook
63
star
40

bascomtask

Lightweight parallel Java tasks
Java
62
star
41

DASTProxy

Java
58
star
42

ebay-oauth-csharp-client

eBay OAuth C# Client Library
C#
57
star
43

jsonex

Java Object Serializer and Deserializer to JSON Format. Focuses on configuration friendliness, arbitrary object serialization and compact JSON format
Java
56
star
44

nvidiagpubeat

nvidiagpubeat is an elastic beat that uses NVIDIA System Management Interface (nvidia-smi) to monitor NVIDIA GPU devices and can ingest metrics into Elastic search cluster, with support for both 6.x and 7.x versions of beats. nvidia-smi is a command line utility, based on top of the NVIDIA Management Library (NVML), intended to aid in the management and monitoring of NVIDIA GPU devices.
Go
54
star
45

ebay-oauth-java-client

eBay OAuth APIs client for Java
Java
50
star
46

nice-dag

nice-dag is a lightweight javascript library, which is used to present a DAG diagram.
TypeScript
50
star
47

AutoOpt

Automatic and Simultaneous Adjustment of Learning Rate and Momentum for Stochastic Gradient Descent
Python
45
star
48

SparkChamber

An event tracking framework for iOS
Swift
45
star
49

Winder

Winder is a simple state machine based on Quartz Scheduler. It helps to write multiple steps tasks on Quartz Scheduler. Winder derived from a state machine which is widly used in eBay Cloud. eBay Platform As A Service(PaaS) uses it to deploy software to hundreds of thousands virtual machines.
Java
45
star
50

GZinga

Java
43
star
51

YiDB

Java
43
star
52

block-aggregator

C++
41
star
53

collectbeat

Beats with discovery capabilities for environments like Kubernetes
Go
41
star
54

bsonpatch

A BSON implementation of RFC 6902 to compute the difference between two BSON documents
Java
39
star
55

Jenkins-Pipeline-Utils

Global Jenkins Pipeline Library with common utilities.
Groovy
39
star
56

cassandra-river

Cassandra river for Elastic search.
Java
38
star
57

nice-form-react

A meta based form builder for React.
TypeScript
35
star
58

arc

adaptive resources and components
JavaScript
35
star
59

regressr

A command line regression testing framework for testing HTTP services
Scala
34
star
60

ebashlib

A bash script battery which gathers several generic helper scripts for other repositories.
Shell
30
star
61

modshot

Takes screenshot of UI modules and compare with baselines using PhantomCSS
JavaScript
29
star
62

FeedSDK-Python

eBay Python Feed SDK - SDK for downloading large gzipped (tsv) item feed files and applying filters for curation
Python
29
star
63

ebayui-core-react

eBayUI React components
TypeScript
28
star
64

visual-html

Visual regression testing without the flakiness.
TypeScript
28
star
65

accessibility-ruleset-runner

eBay Accessibility Ruleset Runner automates 20% of WCAG 2.0 AA recommendations, saving time on manual testing.
JavaScript
27
star
66

crossdomain-xhr

JavaScript
27
star
67

oink

REST based interface for PIG execution
Java
27
star
68

bonsai

open source version of the Bonsai library
Scala
26
star
69

geosense

Self-contained jar to lookup timezone by lat+lon
Java
25
star
70

browser-telemetry

A Telemetry module for collecting errors, logs, metrics, uncaught exceptions etc on browser side.
JavaScript
25
star
71

oja

Lightweight Dependency Injection Framework for Node.JS Apps - Structure your application business logic
JavaScript
25
star
72

SketchSVG

Have icons in a Sketch file but don't want to manually extract and compress them as SVGs? Let our SketchSVG tool do it!
JavaScript
25
star
73

CustomRippleView

The Custom Ripple View library provides Android developers an easy way to customize and implement a Ripple Effect view.
Kotlin
24
star
74

FGrav

Dynamic Flame Graph Visualizations from raw data in your browser
JavaScript
24
star
75

nodash

Lightweight replacement for subset of Lodash
JavaScript
24
star
76

FeedSDK

Java SDK for downloading large gzipped (tsv) item feed files and applying filters for curation
Java
24
star
77

HomeStore

Storage Engine for block and key/value stores.
C++
22
star
78

kube-credentials-plugin

A Jenkins plugin to store credentials in kubernetes
Java
21
star
79

releaser

A declarative API that syncs specs from git to kubernetes
Go
20
star
80

airflow-rest-api-plugin

A plugin of Apache Airflow that exposes REST endpoints for custom REST APIs.
Python
20
star
81

mtdtool

The Manual Test Demultiplexer is a desktop app (Mac and Windows) that provides an interface for driving manual testing on multiple physical devices.
Java
20
star
82

graph-analytics-plugin

Gradle Project Graph Analysis and Reporting Plugin
Kotlin
19
star
83

EBNObservable

A block-based Key-Value Observing (KVO) implementation with observable collections.
Objective-C
19
star
84

skin-react

Skin components built with React (Typescript)
TypeScript
18
star
85

accelerator-project_skeleton

Python
18
star
86

taxonomy-sdk

An SDK designed to bring transparency to the rapid evolution of our aspects metadata for our partners.
Java
18
star
87

ebay-oauth-android-client

eBay OAuth Android Client library
Kotlin
17
star
88

wextracto

Python
17
star
89

myriad

Java
17
star
90

event-notification-nodejs-sdk

NodeJS SDK designed to simplify processing of eBay notifications.
JavaScript
17
star
91

TDD-Albums

A Hands-On Tutorial for iPhone Developers Learning TDD
17
star
92

lightning

Lightning is a Java based, super fast, multi-mode, asynchronous, and distributed URL execution engine from eBay
HTML
17
star
93

fluid

Fluid Web Components
JavaScript
16
star
94

ostara

Java
16
star
95

RTran

Road to Continous Upgrade
Scala
15
star
96

NautilusTelemetry

An iOS implementation of OpenTelemetry
Swift
15
star
97

hadoop-tsdb-connector

Java
15
star
98

Pine

Pine: Machine Learning Prediction As A Service
Scala
15
star
99

Flink-SQL-Extension

TypeScript
15
star
100

eslint-config-ebay

JavaScript
14
star