Latest 1.1.0
Homepage https://github.com/TangentW/ChatMenu
License MIT
Platforms ios 9.0
Frameworks UIKit
Authors

ChatMenu

ChatMenu
Carthage compatible
CocoaPods

ChatMenu

Requirements

  • iOS 9.0 or higher
  • Swift 4.0

Demo

Run the Sample project in Xcode to see ChatMenu in action.

Installation

Carthage

github "TangentW/ChatMenu"

Cocoapods

pod "ChatMenu"

Usage

ChatMenu is very simple to use, All you need just call a function:

/// Show a menu on a particular chat bubble view, with an action sheet
/// attached to it.
///
/// - Parameters:
///   - bubbleView: Chat bubble view.
///   - direction: The direction in which the bubble view is located.
///   - actions: Actions of the action sheet in menu.
///   - items: Items to show on the bubble view, such as emoji.
///   - dismissCallback: Called when menu will dismiss.
///   - completedDismissCallback: Called when menu did dismiss.
static func show(on bubbleView: UIView,
                     direction: Direction,
                     actions: [Action],
                     items: [BubbleItem],
                     dismissCallback: (() -> ())? = nil,
                     completedDismissCallback: (() -> ())? = nil)

Example usage

// Items
let emojis = "😀👍👎❤️🎉".characters.map { String($0) }
let items = emojis.map { emoji in
    ChatMenu.BubbleItem(title: emoji, image: nil, action: { 
        print("did Selected" + emoji)
    })
}

// Actions
let cameraAction = ChatMenu.Action(title: "Camera", tintColor: .green) {
    print("Open Camera")
}
let albumAction = ChatMenu.Action(title: "Album", tintColor: .orange) {
    print("Open Album")
}
let cancelAction = ChatMenu.Action(style: .cancel, title: "Cancel", tintColor: .red) { 
    print("Cancel")
}
let actions = [cameraAction, albumAction, cancelAction]

// Show
ChatMenu.show(on: bubbleView,
              direction: .left,
              actions: actions,
              items: items,
              dismissCallback: { print("ChatMenu will dismiss") },
              completedDismissCallback: { print("ChatMenu did dismiss") })

License

The MIT License (MIT)

Latest podspec

{
    "name": "ChatMenu",
    "version": "1.1.0",
    "summary": "A menu display on chat bubble view just like iMessage.",
    "homepage": "https://github.com/TangentW/ChatMenu",
    "license": "MIT",
    "authors": {
        "Tangent": "[email protected]"
    },
    "platforms": {
        "ios": "9.0"
    },
    "source": {
        "git": "https://github.com/TangentW/ChatMenu.git",
        "tag": "1.1.0"
    },
    "source_files": "ChatMenu/ChatMenu/*.swift",
    "resources": "ChatMenu/ChatMenu/*.xcassets",
    "frameworks": "UIKit",
    "pushed_with_swift_version": "4.0"
}

Pin It on Pinterest

Share This