GithubHelp home page GithubHelp logo

jjatie / inputbaraccessoryview Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nathantannar4/inputbaraccessoryview

0.0 1.0 0.0 5.78 MB

A simple and easily customizable InputAccessoryView for making powerful input bars with autocomplete and attachments

License: MIT License

Swift 99.34% Ruby 0.44% Objective-C 0.22%

inputbaraccessoryview's Introduction

Image

InputBarAccessoryView

Features

  • Autocomplete text with @mention, #hashtag or any other prefix
  • A self-sizing UITextView with an optional fixed height (can be replaced with any other view)
  • Image paste support
  • Autocomplete attributed text highlighting
  • Reactive components that respond to given events
  • Top/Bottom/Left/Right InputStackViews that act as toolbars to place buttons
  • RxSwift/RxCocoa Support with RxExtensions Cocoapod subspec
  • Drop in attachment view for file/photo management
  • Plugin support for your own InputPlugins
  • Compatible with all iPhones and iPads
  • RTL Support

Installation via CocoaPods

# Swift 5.0
pod 'InputBarAccessoryView'
# Swift 4.2
pod 'InputBarAccessoryView', '4.2.2'

Installation via Carthage

# Swift 5.0
github "nathantannar4/InputBarAccessoryView"
# Swift 4.2
github "nathantannar4/InputBarAccessoryView" "4.2.2"

Requirements

iOS 9.0+ Swift 5.0

The latest Swift 4.2 release is v4.2.2

Documentation

Getting Started

See the Example project to see how you can make the iMessage, Slack, Facebook and GitHawk input bars!

Example Usage

Featured In

Add your app to the list of apps using this library and make a pull request.

See Also

iMessage style TypingIndicator for chat apps

Latest Releases

  • 4.3.1
    • Add RxSwift/RxCocoa support through extensions and delegate proxies, requires Cocoapods installation of InputBarAccessoryView/RxExtensions
  • 4.3.0
    • Swift 5 support
  • 4.2.2
    • Fixed image paste orientation issue in InputTextView
  • 4.2.1
    • Fixed autocompletes of completions that contain spaces
    • Depricated isCaseSensitive in favor of a function asignment to pre-process autocompletions
  • 4.2.0
    • Added new API for overriding the main middle view, normally the InputTextView so it can be replaced with views such as a "Join" button", setMiddleContentView(_ view: UIView?, animated: Bool)
  • 4.1.2 - Add InputBarViewController which contains an InputBarAccessoryView as the inputAccessoryView by default with a convenient isInputBarHidden: Bool property to show/hide it
  • 4.1.1 - Add frameInsets: HorizontalEdgePadding property to InputBarAccessoryView to inset the view to be compatible with UISplitViewController or other custom containers where the view should not be the full width
  • 4.1.0 - Fix issue where setting long strings in viewDidLoad broke inital layout, Issue #41 - Add deleteCompletionByParts: Bool flag to AutocompleteManager to allow for partial deletions of autocompletes rather than just the entire substring. - Add InputBarSendButton to use as the sendButton in InputBarAccessoryView. This subclass of InputBarButtonItem has a UIActivityIndicatorView to show a spinner when making HTTP requests

Find a bug? Open an issue!

Layout

The layout of the InputBarAccessoryView is made of of 4 InputStackView's and an InputTextView. The padding of the subviews can be easily adjusted by changing the padding and textViewPadding properties. The constraints will automatically be updated.

It is important to note that each of the InputStackView 's to the left and right of the InputTextView are anchored by a width constraint. This way the InputTextView will always fill the space inbetween in addition to providing methods that can easily be called to hide all buttons to the right or left of the InputTextView by setting the width constraint constant to 0. The bottom and top stack views are not height constraint and rely on their intrinsicContentSize

func setLeftStackViewWidthConstant(to newValue: CGFloat, animated: Bool)

func setRightStackViewWidthConstant(to newValue: CGFloat, animated: Bool)

Reactive Hooks

Each InputBarButtonItem has properties that can hold actions that will be executed during various hooks such as the button being touched, the UITextView text changing and more! Thanks to these easy hooks with a few lines of code the items can be easily resized and animated similar to that of the Facebook messenger app.

// MARK: - Hooks
    
public typealias InputBarButtonItemAction = ((InputBarButtonItem) -> Void)    
    
private var onTouchUpInsideAction: InputBarButtonItemAction?
private var onKeyboardEditingBeginsAction: InputBarButtonItemAction?
private var onKeyboardEditingEndsAction: InputBarButtonItemAction?
private var onKeyboardSwipeGestureAction: ((InputBarButtonItem, UISwipeGestureRecognizer) -> Void)?
private var onTextViewDidChangeAction: ((InputBarButtonItem, InputTextView) -> Void)?
private var onSelectedAction: InputBarButtonItemAction?
private var onDeselectedAction: InputBarButtonItemAction?
private var onEnabledAction: InputBarButtonItemAction?
private var onDisabledAction: InputBarButtonItemAction?

Author

Nathan Tannar - https://nathantannar.me

License

Distributed under the MIT license. See LICENSE for more information.

inputbaraccessoryview's People

Contributors

cwalo avatar hemangshah avatar jameshays avatar lordcodes avatar nathantannar4 avatar

Watchers

 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.