Swiftpack.co -  thisIsTheFoxe/SimpleKeyboard as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
thisIsTheFoxe/SimpleKeyboard
A simple clone of the iOS system keyboard with SwiftUI
.package(url: "https://github.com/thisIsTheFoxe/SimpleKeyboard.git", from: "0.3")

SimpleKeyboard

Swift SwiftLint codecov Maintainability Rating

The idea of this package came from a keyboard-extension and the fact that - AFAIK - one can't open another keyboard within a keyboard-extension. So the goal was to have a ViewController, that simply displays the keyboard and changes a text variable.

Components

This project includes a SimpleKeyboard that takes a custom 2D-list of Strings which will be rendered as the keys. The SimpleStandardKeyboard provides a default implementation for some languages and a few more default settings.

Usage

Depending on the needs one can use the keyboards in a larger SwiftUI enviroment with a Text that will act as the TextField. Or one can choose to only display the keyboard with a the text input coming from a UIKit enviroment. To eventually get a UIViewController one has to use a UIHostingController. To manage the transition with all the Bindings, there is the KeyboardSettings: Observable.

Use SimpleKeyboard with UIKit

Here is an example implementation from one of my projects:

class MyViewController: UIViewController {
    @IBOutlet var textField: UITextField!
    
    //..........
    
    func presentKeyboard() {
        let keyboardSettings = KeyboardSettings(language: .english, textInput: self.textField)
        let keyboardVC = MyKeyboardMaker(settings: keyboardSettings).makeViewController()
        self.contentController.pushViewController(keyboardVC, animated: true)
    }
}

struct MyKeyboardMaker {
    
    @ObservedObject var settings: KeyboardSettings
    
    func makeViewController() -> UIHostingController<SimpleStandardKeyboard> {
        UIHostingController(rootView: SimpleStandardKeyboard(settings: $settings)
    }
}

When initializing a new object of that struct, one has to pass the language and textField. Now makeViewController() can be called e.g. pushed onto a NavigationController.

GitHub

link
Stars: 6
Last commit: Yesterday

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Release Notes

0.3
35 weeks ago

Mostly bugfixes and update to the newest Swift version

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API