GithubHelp home page GithubHelp logo

xnth97 / accessorykit Goto Github PK

View Code? Open in Web Editor NEW
14.0 3.0 1.0 813 KB

A customizable, expandable, and easy-to-use InputAccessoryView component for iOS.

Home Page: https://cocoapods.org/pods/AccessoryKit

License: MIT License

Ruby 2.84% Swift 97.16%
ios ui swift accessoryview inputaccessoryview ipados

accessorykit's Introduction

AccessoryKit

A customizable, expandable, and easy-to-use input accessory view component for iOS.

Version License Platform

Features

AccessoryKit aims to provide a customizable, expandable and easy-to-use input accessory view. This component is developed for and is currently used in my app MDNotes.

The main features are:

  • Responsively uses UITextInputAssistantItem on iPad and UITextInputView on iPhone.
  • Scrollable input accessory view with blurry background and customizable buttons.
  • Grouping buttons into a visually related button group.
  • Supports Auto Layout and Safe Area.
  • Supports dark mode.
  • Provides built-in pre-defined buttons with SF Symbol.
  • Supports presenting UIMenu on input accessory view.
  • Control state of identified buttons independently.

Usage

Requirements

  • iOS 14.0+
  • Swift 5.7+

Installation

Swift Package Manager

AccessoryKit is available as a Swift Package. Add this repo to your project through Xcode GUI or Package.swift.

dependencies: [
    .package(url: "https://github.com/xnth97/AccessoryKit.git", .upToNextMajor(from: "2.0.0"))
]

CocoaPods

To install AccessoryKit, simply add the following line to your Podfile:

pod 'AccessoryKit'

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

API

// Create view model array of key button groups
let keyButtonGroups: [KeyboardAccessoryButtonGroup] = [
    // Group is just an array of `KeyboardAccessoryButton`. Group elements will be visually 
    // grouped and close to each other.
    [
        // Create button with built-in type and tap handler block that will be placed on 
        // the leading side of keyboard on iPad
        KeyboardAccessoryButton(type: .undo, position: .leading) { [weak self] in
            self?.undo()
        },
        // Create button with UIImage that will be collapsed in an overflow menu on iPad
        KeyboardAccessoryButton(image: UIImage(named: "img"), position: .overflow),
    ],
    [
        // Create button with title
        KeyboardAccessoryButton(title: "Button"),
        // Create button with UIMenu
        KeyboardAccessoryButton(type: .link, menu: createInsertMenu()),
    ],
]

// Initialize and retain `KeyboardAccessoryManager`
self.accessoryManager = KeyboardAccessoryView(
    keyButtonGroups: keyButtonGroups,
    showDismissKeyboardKey: true,
    delegate: self)

// Configures the `UITextView` with `KeyboardAccessoryManager`
self.accessoryManager.configure(textView: textView)

License

AccessoryKit is available under the MIT license. See the LICENSE file for more info.

accessorykit's People

Contributors

xnth97 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

mohsinalimat

accessorykit's Issues

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.