• Stars
    star
    219
  • Rank 174,957 (Top 4 %)
  • Language
    Swift
  • License
    MIT License
  • Created almost 2 years ago
  • Updated 11 months ago

Reviews

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

Repository Details

⌨️ Add tools above your keyboard with iOS-like keyboard buttons.

KeyboardToolbar

👀 Overview

Use KeyboardToolbar to add tools as an input accessory view to a UITextField, UITextView, or any other view conforming to UITextInput.

KeyboardToolbar creates buttons with an iOS-like appearance and behavior.

📖 Documentation

The public interface is documented in the Swift files and can be found in KeyboardToolbar/Sources/KeyboardToolbar. You can also read the documention on Swift Package Index.

Lastly, you can also build the documentation yourself by opening the Swift package in Xcode and selecting Product > Build Documentation in the menu bar.

📦 Adding the Package

KeyboardToolbar is distributed using the Swift Package Manager. Install it in a project by adding it as a dependency in your Package.swift manifest or through “Package Dependencies” in project settings.

let package = Package(
    dependencies: [
        .package(url: "[email protected]:simonbs/KeyboardToolbar.git", from: "0.1.0")
    ]
)

🚀 Getting Started

The best way to understand how KeyboardToolbar is integrated into your project is by having a look at the Example project in this repository.

At a high level there are two steps required to setting up the keyboard toolbar.

  1. Create an instance of KeyboardToolbarView and assign it to inputAccessoryView on a UITextField, UITextView, or any other view that conforms to the UITextInput protocol.
  2. Assign an array of KeyboardToolGroup items to the groups property on your instance of KeyboardToolbarView.

The below code snippet shows how the two steps can be performed.

/// Create our instance of KeyboardToolbarView and pass it to an instance of UITextView.
let keyboardToolbarView = KeyboardToolbarView()
textView.inputAccessoryView = keyboardToolbarView
// Setup our tool groups.
let canUndo = textView.undoManager?.canUndo ?? false
let canRedo = textView.undoManager?.canRedo ?? false
keyboardToolbarView.groups = [
    // Tools for undoing and redoing text in the text view.
    KeyboardToolGroup(items: [
        KeyboardToolGroupItem(style: .secondary, representativeTool: BlockKeyboardTool(symbolName: "arrow.uturn.backward") { [weak self] in
            self?.textView.undoManager?.undo()
            self?.setupKeyboardTools()
        }, isEnabled: canUndo),
        KeyboardToolGroupItem(style: .secondary, representativeTool: BlockKeyboardTool(symbolName: "arrow.uturn.forward") { [weak self] in
            self?.textView.undoManager?.redo()
            self?.setupKeyboardTools()
        }, isEnabled: canRedo)
    ]),
    // Tools for inserting characters into our text view.
    KeyboardToolGroup(items: [
        KeyboardToolGroupItem(representativeTool: InsertTextKeyboardTool(text: "(", textView: textView), tools: [
            InsertTextKeyboardTool(text: "(", textView: textView),
            InsertTextKeyboardTool(text: "{", textView: textView),
            InsertTextKeyboardTool(text: "[", textView: textView),
            InsertTextKeyboardTool(text: "]", textView: textView),
            InsertTextKeyboardTool(text: "}", textView: textView),
            InsertTextKeyboardTool(text: ")", textView: textView)
        ]),
        KeyboardToolGroupItem(representativeTool: InsertTextKeyboardTool(text: ".", textView: textView), tools: [
            InsertTextKeyboardTool(text: ".", textView: textView),
            InsertTextKeyboardTool(text: ",", textView: textView),
            InsertTextKeyboardTool(text: ";", textView: textView),
            InsertTextKeyboardTool(text: "!", textView: textView),
            InsertTextKeyboardTool(text: "&", textView: textView),
            InsertTextKeyboardTool(text: "|", textView: textView)
        ]),
        KeyboardToolGroupItem(representativeTool: InsertTextKeyboardTool(text: "=", textView: textView), tools: [
            InsertTextKeyboardTool(text: "=", textView: textView),
            InsertTextKeyboardTool(text: "+", textView: textView),
            InsertTextKeyboardTool(text: "-", textView: textView),
            InsertTextKeyboardTool(text: "/", textView: textView),
            InsertTextKeyboardTool(text: "*", textView: textView),
            InsertTextKeyboardTool(text: "<", textView: textView),
            InsertTextKeyboardTool(text: ">", textView: textView)
        ]),
        KeyboardToolGroupItem(representativeTool: InsertTextKeyboardTool(text: "#", textView: textView), tools: [
            InsertTextKeyboardTool(text: "#", textView: textView),
            InsertTextKeyboardTool(text: "\"", textView: textView),
            InsertTextKeyboardTool(text: "'", textView: textView),
            InsertTextKeyboardTool(text: "$", textView: textView),
            InsertTextKeyboardTool(text: "\\", textView: textView),
            InsertTextKeyboardTool(text: "@", textView: textView),
            InsertTextKeyboardTool(text: "%", textView: textView),
            InsertTextKeyboardTool(text: "~", textView: textView)
        ])
    ]),
    KeyboardToolGroup(items: [
        // Tool to present the find navigator.
        KeyboardToolGroupItem(style: .secondary, representativeTool: BlockKeyboardTool(symbolName: "magnifyingglass") { [weak self] in
            self?.textView.findInteraction?.presentFindNavigator(showingReplace: false)
        }),
        // Tool to dismiss the keyboard.
        KeyboardToolGroupItem(style: .secondary, representativeTool: BlockKeyboardTool(symbolName: "keyboard.chevron.compact.down") { [weak self] in
            self?.textView.resignFirstResponder()
        })
    ])
]

More Repositories

1

Runestone

📝 Performant plain text editor for iOS with syntax highlighting, line numbers, invisible characters and much more.
Swift
2,301
star
2

SBSAnimoji

🐵 Animoji app using Apples AvatarKit
Objective-C
985
star
3

BSKeyboardControls

Put controls above the keyboard on your iPhone or iPad app.
Objective-C
528
star
4

dependency-graph

🕸️ dependency-graph is a command-line tool that can visualize the dependencies of packages.
Swift
164
star
5

SBSCustomAnimoji

🐶 Custom Animoji using Apples AvatarKit
Objective-C
106
star
6

xctemplates

⚙️ Opinionated Xcode templates
Shell
94
star
7

darkdocs

Safari extension that adds support for dark mode in Apple’s developer documentation.
CSS
73
star
8

InfiniteCanvas

🖌 Infinite canvas using PencilKit
Swift
65
star
9

alfred-youtube-workflow

A workflow for Alfred 2.0 which lets the user search for YouTube videos and have them returned to Alfred.
Python
54
star
10

alfred-tweetbot-workflow

Control Tweetbot from Alfred 2.0
Python
44
star
11

Prettier

✨ Wrapper for the Prettier code formatter written in Swift
Swift
44
star
12

thingsapp

Node module for creating todos in Things.app
JavaScript
38
star
13

BSPanViewController

A take on the sliding controllers which can optionally move the status bar along with the main view.
Objective-C
36
star
14

Temperatus

A Mac application which shows the current temperature using a Thermodo device
Objective-C
35
star
15

TreeSitterLanguages

Languages for Tree-sitter wrapped in Swift packages
C
33
star
16

alfred-safari-tabs-workflow

Manage tabs in Safari
Python
22
star
17

ios-widget-sizes

The sizes of widgets for select iPhones and iPads.
19
star
18

alfred-movies-workflow

Lookup movies on IMDb and OMDb
Python
17
star
19

homebridge-roomba

Roomba plugin for Homebridge
JavaScript
15
star
20

AppleFeedback

💬 Sample projects submitted to Apple Feedback
Swift
15
star
21

appiconset-creator

Creates .appiconset directories for iOS projects
JavaScript
15
star
22

homebridge-samsungtv

Samsung TV plugin for homebridge.
JavaScript
14
star
23

alfred-cloudapp-workflow

CloudApp workflow for Alfred 2.0 which allows for managing uploads.
Python
14
star
24

BuildABuddyKit

Learning material guiding the reader through documenting their project using Apple's DocC tool.
Swift
12
star
25

samsungtv

Node module for controlling a Samsung TV.
JavaScript
11
star
26

dotfiles

My dotfiles.
Python
10
star
27

Knob

Volume knob for Beoplay speakers
Swift
10
star
28

simonsays

Simon Says for your touch bar.
Swift
10
star
29

CharlesTVDB

A collection of classes for OS X and iOS which provides a block based interface for TheTVDB which is extremely easy to use.
Objective-C
10
star
30

synology-diskstation

Turn on and off a Synology DiskStation
JavaScript
10
star
31

Emcee

Shows the song currently playing in Spotify, Rdio or iTunes.
Swift
10
star
32

ImmersiveMoveAndRotate

Example project showing how an immersive scene on visionOS can contain a RealityView that presents a ModelEntity and how that entity can be dragged using DragGesture and rotated using RotateGesture.
Swift
9
star
33

ColoredTunes

Uses the artwork of the song currently playing in Spotify to change the color of your Philips Hue light bulbs.
Objective-C
6
star
34

BSSwipeTableViewCell

A very customizable table view cell which can be swiped left and right.
Objective-C
6
star
35

Charles

Charles helps you rename your video files and subtitles using data from TheTVDB.
Objective-C
6
star
36

install-op-cli

GitHub Action to install a specified version of the 1Password CLI.
HTML
5
star
37

spotify-controls-api

Simple API for controlling Spotify from other services.
JavaScript
5
star
38

SBSAnimojiRecording

🐨 Proof of concept showing how to overlay an Animoji on top of a camera feed using ARKit
Objective-C
5
star
39

jodelihood

Creates a map with posts from the Jodel community in your neighbourhood.
CSS
5
star
40

findemoji

Slå op i Fødevarestyrelsens kontrolrapporter og find en passende emoji
JavaScript
4
star
41

ThermoWallpaper

An OS X application which sets the desktop wallpaper to a Thermo thermometer showing the current temperature.
Objective-C
4
star
42

Cursor

Trigger an action when device is pointing at a known location.
Swift
3
star
43

alfred-rap-genius-workflow

Look up a song on Rap Genius from Alfred
3
star
44

Edinem

Editor for Charles session files built on Electron using React
JavaScript
2
star
45

dr-tv-player

OS X app for viewing DR TV live streams. Fast.
Swift
2
star
46

comedy-festival-api

Scrapes shows for the Comedy Festival
JavaScript
2
star
47

findemoji-ios

The Smileyordning is boring. The Emojiordning is more fun.
Swift
2
star
48

forspeciale

Forspeciale, Embedded and Distributed Systems, AAU 2015
TeX
2
star
49

alfred-lyricsfinder-workflow

A workflow for Alfred 2.0 which lets you quickly find lyrics for the song currently playing in Spotify.
Python
2
star
50

comedyfestival

Unofficial Comedy Festival app.
Swift
2
star
51

atju

iOS app for viewing pollen readings from DMI.
Swift
2
star
52

alfred-drtv-workflow

A workflow to browsing and downloading programs from DR TV.
Python
2
star
53

context-aware-home-automation

Context aware home automation based on the users position and motion gestures.
Java
1
star
54

roomba

Node module for controlling a Roomba vacuum cleaner.
JavaScript
1
star
55

speciale

Master's thesis at the Distributed and Embedded systems unit, Aalborg University, Denmark
TeX
1
star
56

BSConfig

Manage configurations in a property list.
Objective-C
1
star
57

docs.runestone.app

📖 Documentation for Runestone hosted on docs.runestone.app
HTML
1
star
58

pawawax

tvOS parallax on arbitrary views
Swift
1
star
59

WordbaseCheater

C++
1
star
60

atju-backend

Polls for pollen readings from DMI and stores them.
JavaScript
1
star
61

google-home-calendar-refresh

Copies calendar events into a primary Google calendar from iCal feeds thereby making it possible for a Google Home to read the calendar events.
JavaScript
1
star