Skip to content

Commit

Permalink
Add a static input set provider
Browse files Browse the repository at this point in the history
  • Loading branch information
danielsaidi committed Dec 1, 2020
1 parent 50be722 commit 7e77c2d
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 10 deletions.
4 changes: 2 additions & 2 deletions KeyboardKitDemo.xcodeproj/project.pbxproj
Expand Up @@ -1586,8 +1586,8 @@
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/danielsaidi/KeyboardKitSwiftUI";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 3.1.1;
branch = layout;
kind = branch;
};
};
/* End XCRemoteSwiftPackageReference section */
Expand Down
Expand Up @@ -14,9 +14,9 @@
"package": "KeyboardKitSwiftUI",
"repositoryURL": "https://github.com/danielsaidi/KeyboardKitSwiftUI",
"state": {
"branch": null,
"revision": "f1a400dbd3bef57c59327c8080eba9db6ebdfb96",
"version": "3.1.1"
"branch": "layout",
"revision": "bc4dbbd35b3d1cb1c86471e16128f5b73baa3549",
"version": null
}
}
]
Expand Down
11 changes: 6 additions & 5 deletions RELEASE_NOTES.md
Expand Up @@ -8,11 +8,12 @@ KeyboardKit will only deprecate code in `minor` versions. Deprecated code will b
This release contains input set improvements:

* There is a new `KeyboardInputSetProvider` protocol.
* The `InputSet+English` has been renamed to `InputSet+Locale` and has more sets.
* There is now built-in support for basic English, German, Italian and Swedish.
* `KeyboardContext` gets a `StandardKeyboardInputSetProvider` instance at launch.
* You can replace this instance at any time by setting the context's `inputSetProvider` to something else.
* The standard provider uses the current locale to retrieve a suitable input set from the supported ones.
* `StandardKeyboardInputSetProvider` uses the current locale and can be inherited.
* `StaticKeyboardInputSetProvider` uses three static input sets.
* `InputSet+English` has been renamed to `InputSet+Locale` and has more sets.
* `InputSet+Locale` extension has support for basic English, German, Italian and Swedish.
* `StandardKeyboardInputSetProvider` will be used by default, but you can change this at anytime.
* `StandardKeyboardInputSetProvider` tries to retrieve a suitable input set from the supported locales, else falls back to English.

This release also improves the UIKit layout:

Expand Down
35 changes: 35 additions & 0 deletions Sources/KeyboardKit/Input/StaticKeyboardInputSetProvider.swift
@@ -0,0 +1,35 @@
//
// StandardKeyboardInputSetProvider.swift
// KeyboardKit
//
// Created by Daniel Saidi on 2020-12-01.
// Copyright © 2020 Daniel Saidi. All rights reserved.
//

import Foundation

/**
This standard keyboard inputset provider is used by default
by KeyboardKit, and provides the standard input set for the
current locale, if any. You can inherit and customize it to
create your own provider that builds on this foundation.
The dictionaries contain the currently supported input sets.
They are not part of the protocol, but you can use them and
extend them in your own subclasses.
*/
public class StaticKeyboardInputSetProvider: KeyboardInputSetProvider {

public init(
alphabeticInputSet: AlphabeticKeyboardInputSet,
numericInputSet: NumericKeyboardInputSet,
symbolicInputSet: SymbolicKeyboardInputSet) {
self.alphabeticInputSet = alphabeticInputSet
self.numericInputSet = numericInputSet
self.symbolicInputSet = symbolicInputSet
}

public let alphabeticInputSet: AlphabeticKeyboardInputSet
public let numericInputSet: NumericKeyboardInputSet
public let symbolicInputSet: SymbolicKeyboardInputSet
}
Expand Up @@ -37,6 +37,7 @@ class StandardKeyboardContextTests: QuickSpec {
expect(context.controller).to(be(controller))
expect(context.hasDictationKey).to(equal(controller.hasDictationKey))
expect(context.hasFullAccess).to(equal(controller.hasFullAccess))
expect(context.inputSetProvider is StandardKeyboardInputSetProvider).to(beTrue())
expect(context.keyboardType).to(equal(.images))
expect(context.needsInputModeSwitchKey).to(equal(controller.needsInputModeSwitchKey))
expect(context.primaryLanguage).to(beNil())
Expand Down

0 comments on commit 7e77c2d

Please sign in to comment.