Coder Social home page Coder Social logo

travelc / inputbaraccessoryview Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nathantannar4/inputbaraccessoryview

0.0 2.0 0.0 5.22 MB

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

License: MIT License

Swift 99.29% Ruby 0.44% Objective-C 0.27%

inputbaraccessoryview's Introduction

InputBarAccessoryView

CocoaPods CocoaPods Donate

Features

  • A growing UITextView with optional fixed height
  • Image paste support
  • RxSwift inspired reactive components that respond to given events
  • Top/Bottom/Left/Right UIStackViews that act as toolbars to place buttons
  • Drop in autocomplete for any given prefix
  • Autocomplete attributed text highlighting
  • Drop in attachment view for file/photo management
  • Drop in Slack style TypingIndicator
  • Plugin support for your own InputPlugins
  • iPhone X Support

Installation via CocoaPods

pod 'InputBarAccessoryView'

Installation via Carthage

github "nathantannar4/InputBarAccessoryView"

Requirements

iOS 9.0+ Swift 4 XCode 9.0+

Documentation

Getting Started

Jazzy Generated Docs

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

Demo

Screenshots

Featured In

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

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?

Changelog

  • 2.1.0 - AutocompleteManager table view datasource methods are now marked as open - AutocompleteManager changed to manage UITextViews rather than only InputTextViews - AutocompleteSession bug fixes - Example updated for asynchronous completion lookups with AutocompleteManager
  • 2.0.0 - API Stability - Bug Fixes - InputManager renamed to InputPlugin - Added shouldManageSendButtonEnabledState to InputBarAccessoryView
  • 1.5.4 - Bug Fixes
  • 1.5.3 - [WIP] TypingIndicator InputItem view added, see example - shouldForceTextViewMaxHeight property added
  • 1.5.2 - Better autocomplete detection
  • 1.5.1 - Optimize AutocompleteManager & AttachmentManager
  • 1.5.0 - Stability and bug fixes
  • 1.4.0 - iPhone X Fixes - IntrinsicContentSize caching to increase performance - Auto Manage maxTextViewHeight
  • 1.3.0 - iPhone X Fixes
  • 1.2.0 - Better XCode docs - InputItem is now a protocol that you can give to the InputBarAccessoryView - InputPlugin is now a protocol that you can conform to make a plugin - AutocompleteManager and AttactchmentManager are no longer members of InputBarAccessoryView by default. You will need to create them and assign them to the InputPlugin property of the InputBarAccessoryView
  • 1.1.2 - Fixed issue where adjusting the InputTextView's placeholder text alignment didn't work - Fixed iPhone X support where the home indicator overlapped the InputTextView
  • 1.1.1 - AutocompleteManager bug fixes and customization improvements
  • 1.1.0 - AttactchmentManager (Beta)
  • 1.0.0
    • A more refined AutocompleteManager
    • Auto-layout bug fixes

pre-release versions not documented

Find a bug? Open an issue!

Author

Nathan Tannar - https://nathantannar.me

License

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

inputbaraccessoryview's People

Contributors

nathantannar4 avatar cwalo avatar lordcodes avatar hemangshah 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.