KeyboardKit

KeyboardKit is a Swift SDK that lets you create fully customizable keyboards with a few lines of code, using SwiftUI.

MIT License

Stars
1.5K
Committers
29

Bot releases are visible (Hide)

KeyboardKit -

Published by danielsaidi almost 4 years ago

This release fixes so that the secondary input gesture triggers a tap if there were no secondary actions in the callout.

The release also makes the entire autocomplete button tappable, instead of just the text.

KeyboardKit -

Published by danielsaidi almost 4 years ago

This release makes it easier to inject custom views into the SwiftUI-based SystemKeyboard and AutocompleteToolbar.

There is also a new SystemKeyboardSpaceButton which lets you present the current locale before fading to "space".

The release also adds a spacebar drag gesture and deprecates some haptic properties as well as some system properties in favor of the standard naming concept (since the system behavior is the standard behavior).

New features

  • AutocompleteSuggestion is a new protocol that makes the autocomplete provider concept more general.

  • HapticFeedback has a new longPressOnSpace case.

  • KeyboardAppearanceProvider is a protocol for providing button content and style.

  • KeyboardContext has a new keyboardAppearanceProvider property.

  • StandardKeyboardActionHandler has new functionality for handling the space drag gesture.

  • StandardKeyboardAppearanceProvider is a standard appearance provider that returns standard values.

  • SystemKeyboardButtonContent is new view that extracts content logic from SystemKeyboardButton.

  • SystemKeyboardButtonRowItem can now be created with generic views.

  • SystemKeyboardSpaceButton is new view that wraps SystemKeyboardSpaceButtonContent and applies styles & gesture to it.

  • SystemKeyboardSpaceButtonContent is new view that animates between a locale text and a space text.

Behavior changes

  • HapticFeedback.standard has almost no haptic feedback now, since that is the standard behavior.
  • SystemKeyboard now wraps the buttonBuilder generated views in a SystemKeyboardButtonRowItem.
  • SystemKeyboardButton now applies a fallback text from the new appearance provider.
  • The standard SystemKeyboard button builder generates SystemKeyboardButtonContent instead of SystemKeyboardButton.

Deprecations

  • HapticFeedback standard cases have been deprecated, since native keyboards have almost no haptic feedback.

  • KeyboardAction systemFont is renamed to standardButtonFont.

  • KeyboardAction systemKeyboardButtonText is renamed to standardButtonText.

  • KeyboardAction systemTextStyle is renamed to standardButtonTextStyle.

  • KeyboardType systemKeyboardButtonText is deprecated.

  • String implements AutocompleteSuggestion to avoid breaking changes in 3.5+. You should provide custom types, though.

  • Color systemKeyboardButtonBackgroundColorDark has been renamed to standardDarkButtonBackgroundColor

  • Color systemKeyboardButtonBackgroundColorLight has been renamed to standardLightButtonBackgroundColor

  • Color systemKeyboardButtonForegroundColor has been renamed to standardButtonForegroundColor

  • Color systemKeyboardButtonShadowColor has been renamed to standardButtonShadowColor

  • KeyboardAction systemKeyboardButtonBackgroundColor has been renamed to standardButtonBackgroundColor

  • KeyboardAction systemKeyboardButtonImage has been renamed to standardButtonImage

  • KeyboardAction systemKeyboardButtonShadowColor has been renamed to standardButtonShadowColor

  • KeyboardShiftState systemImage has been renamed to standardButtonImage

  • KeyboardShiftState systemKeyboardButtonImage was unused and has been deprecated.

  • KeyboardType systemKeyboardButtonImage has been renamed to standardButtonImage

  • View systemKeyboardButtonStyle has been renamed to standardButtonStyle

  • View systemKeyboardButtonBackground has been renamed to standardButtonBackground

  • View systemKeyboardButtonFont has been renamed to standardButtonFont

  • View systemKeyboardButtonForeground has been renamed to standardButtonForeground

  • View systemKeyboardButtonShadow has been renamed to standardButtonShadow

Breaking changes

  • AutocompleteToolbarView and AutocompleteToolbar now use AutocompleteSuggestion instead of String. It makes them MUCH more powerful, so I hope this breaking change is acceptable.
  • SystemKeyboardButtonRowItem has been made generic.
  • SystemKeyboard.ButtonBuilder now returns an AnyView since you may want to use any custom view for any button.
KeyboardKit -

Published by danielsaidi almost 4 years ago

This release adds curves and behavior changes to the callout bubbles.

Behavior changes

  • The disabled secondary % callout actions have been re-enabled.
  • CalloutStyle now applies button frame insets when configured for a system keyboard.
  • InputCallout has curves between the button area and the callout.
  • InputCalloutContext has a new isEnabled property that is only true for phones, since it should not be displayed on iPads.
  • InputCalloutContext no longer insets the button rect.
  • SecondaryInputCallout has curves between the button area and the callout and the design is improved.
  • SystemInputCalloutContext no longer insets the button rect.

New features

  • CalloutCurve is a new shape that can be used to smoothen the two parts of a callout bubble.
KeyboardKit -

Published by danielsaidi almost 4 years ago

This release fixes some visual artefacts in the callout bubbles.

KeyboardKit -

Published by danielsaidi almost 4 years ago

This release adds support for input callouts and secondary input callouts.

New features

This release has new features for secondary callout actions.

  • KeyboardAction+SecondaryCalloutActions specifies standard, locale-specific secondary callout actions for keyboard actions.
  • KeyboardContext has a new secondaryCalloutActionProvider property.
  • SecondaryCalloutActionProvider is a protocol for providing secondary callout actions for keyboard actions.
  • StandardSecondaryCalloutActionProvider is a standard action provider that returns the standard secondary callout actions.

Behavior changes

Since the new secondary input callout, which triggers on long press, I have removed the standard long press action for all actions except backspace.

This also makes standard KeyboardKit keyboards behave more like native iOS keyboards.

Breaking changes

This release also has breaking changes to experimental features.

  • KeyboardInputProvider has been renamed to KeyboardInputSetProvider
  • KeyboardInputSetProviders properties are now context-based functions
  • KeyboardContext keyboardInputProvider has been renamed to keyboardInputSetProvider
KeyboardKit -

Published by danielsaidi almost 4 years ago

This release contains a bunch of new features that makes the keyboard behave more like the native keyboards when typing, for instance auto-capitalization and auto-lowercasing.

Keyboard behavior

This release separates action handling from behavior, which I hope makes the code cleaner and easier to test and simplifies reusing behavior outside of an action handling context.

  • KeyboardBehavior specifies how a keyboard should behave.
  • StandardKeyboardBehavior specifies the standard behavior of a western keyboard.

You can create your own behaviors as well as subclass and override parts of the standard behavior.

Note that this is an experimental feature that may have to be revisited before 4.0.

New features

  • KeyboardContext has a new preferredKeyboardType property.
  • KeyboardContext has a new actionBehavior property.
  • StandardKeyboardBehavior has caps-lock double tap logic.
  • UITextDocumentProxy has a new isCursorAtNewSentence property.
  • UITextDocumentProxy has a new isCursorAtNewWord property.
  • UITextDocumentProxy has a new endSentence function that removes any space before the cursor, then closes the sentence.
  • UITextDocumentProxy has a new sentenceDelimiters property.
  • UITextDocumentProxy has a new wordDelimiters property.

Behavior changes

  • The caps-lock double tap logic is moved from double-tap on shift to the new keyboard behavior.
  • The sentence ending logic is moved from double-tap on space to the new keyboard behavior.
  • The sentence ending logic is no longer based on double-tap, which makes it easier to use.
  • KeyboardAction standardDoubleTapAction is not defined for any actions anymore.
  • KeyboardInputViewController changeKeyboardType has no time interval anymore.
  • StandardKeyboardContext initializer now has a default value for the keyboard type.

Bug fixes

  • The standard keyboard layout has been fixed to use the correct caps-lock button image.

Deprecations

  • KeyboardAction endSentenceAction has been moved to UITextDocumentProxy+EndSentence.
  • KeyboardAction standardDoubleTapAction is not used internally anymore.
  • KeyboardContext changeKeyboardType is not used internally anymore.
  • KeyboardType canBeReplaced is not used internally anymore.
  • StandardKeyboardActionHandler handleKeyboardSwitch is renamed to handleKeyboardTypeChange.
  • StandardKeyboardActionHandler preferredKeyboardType has been moved to the keyboard behavior.

These deprecations will be removed in v 4.0.

KeyboardKit -

Published by danielsaidi almost 4 years ago

This release contains improvements to the input set functionality:

  • There is a new KeyboardInputProvider protocol.
  • StandardKeyboardInputProvider tries to use the current locale (fallback to English) and can be inherited.
  • StaticKeyboardInputProvider 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.
  • StandardKeyboardInputProvider is used by default in the context, but you can change this at anytime.

The release also introduces a new "keyboard layout" concept, where a keyboard layout is an input set with surrounding actions:

  • There is a new KeyboardLayout struct.
  • There is a new KeyboardLayoutProvider protocol.
    • StandardKeyboardLayoutProvider uses the current context and can be inherited.
    • StaticKeyboardLayoutProvider uses a static layout that is provided at init.
  • StandardKeyboardLayoutProvider is used by default in the context, but you can change this at anytime.

There are new properties in the KeyboardContext.

This release also makes it easier to resolve system keyboard dimensions:

  • CGFloat+Keyboard has utils to resolve the standard keyboard row height.
  • KeyboardStackViewComponents use this new standard height as default height.
  • UIEdgeInsets+Keyboard has utils to resolve the standard keyboard row item insets.
  • KeyboardButtonRowComponents use these new standard insets as default insets.

The demos have been updated with these changes.

Bug fixes:

  • The context controller propertis are marked as @unowned to fix a memory leak.

Deprecations:

  • CGFloat+KeyboardDimensions is deprecated and will be removed in 4.0.
  • KeyboardContext's controller is now deprecated and will be removed in 4.0 .Usage is strongly discouraged. Use the context instead.

Breaking:

  • KeyboardContext has new properties to make the new input and layout additions possible. If you have created your own context, you will have to add these.
KeyboardKit -

Published by danielsaidi about 4 years ago

This version contains new features:

  • EmojiCategory is now Codable.
  • EmojiCategory has a fallbackDisplayEmoji that is used as system button text if no custom button image used.
  • KeyboardAction now has a standard tap action for .emojiCategory.
  • KeyboardContext now has an emojiCategory property.
KeyboardKit -

Published by danielsaidi about 4 years ago

In this version:

  • A memory leak was fixed by making all StandardBookActionHandler actions use [weak self].
  • The UIKit button shadow logic was improved by @jackhumbert.
KeyboardKit -

Published by danielsaidi about 4 years ago

This version contains new protocols and classes:

  • KeyboardInputViewController has new, empty performAutocomplete and resetAutocomplete functions that are called by the system at proper times.
  • The new AutocompleteSuggestions typealias makes the autocomplete apis cleaner.
  • There is a new AutocompleteContext protocol that can be used to manage suggestions.
  • There is a new StandardAutocompleteContext implementation of AutocompleteContext.
  • There is a new UITextDocumentProxy property to check if the proxy cursor is at the end of the current word.

Bug fixes:

  • The "end sentence" action that is used by space double taps, uses the new proxy property to only close when the cursor is at the end of a word.
KeyboardKit -

Published by danielsaidi over 4 years ago

This version fixes a bug, where the globe button that is used by the demo keyboards didn't do anything.

This version also fixes the system image's font weight.

KeyboardKit -

Published by danielsaidi over 4 years ago

This version removes all previously deprecated parts of the library and adds improved support for SwiftUI and iOS 13.

If you upgrade from an older version to 3.0 and have many breaking changes, upgrading to 2.9 first provides deprecation help that may make the transition easier.

New functionality

There is a new KeyboardContext, which provides important contextual information.

  • StandardKeyboardContext is the standard, non-observable implementation.
  • ObservableKeyboardContext is an iOS 13+ required, observable implementation.
  • StandardKeyboardActionHandler now automatically handles keyboard type switching and only delays if an action has a double-tap action.
  • StandardKeyboardActionHandler now automatically switches to certain keyboards after certain actions, as defined by handleKeyboardSwitch(after:on:) and preferredKeyboardType(after:on:).

There are new KeyboardAction types and properties:

  • .control represents the system.
  • .systemImage can be used with SF Symbols.
  • .systemFont and .systemTextStyle provide system look information.

There is a new System namespace with utils to help you build native-imitating system keyboards.

There is a new KeyboardInputSet concept that will simplify building language-specific keyboards. For now, it contains English characters, numerics and symbols.

The demo project contains a new KeyboardKitSwiftUIPreviews in which you can preview KeyboardKitSwiftUI views.

SwiftUI

  • This repository has a new SwiftUI-based demo app, which is still in development.
  • KeyboardImageButton supports the new systemImage action.

Non-breaking changes:

  • KeyboardInputViewController deviceOrientation has been converted to a general UIInputViewController extension.
  • setupNextKeyboardButton has been converted to a general UIInputViewController extension.

Breaking changes:

  • KeyboardInputViewController has a new keyboardContext property.

  • StandardKeyboardContext is used by default, whenever a keyboard extension is created.

  • ObservableKeyboardContext is used by whenever a keyboard switches over to use SwiftUI.

  • KeyboardInputViewController keyboardActionHandler has been moved to KeyboardContext.

  • KeyboardInputViewController canChangeKeyboardType has been moved to KeyboardType.

  • KeyboardInputViewController changeKeyboardType has been moved to KeyboardContext.

  • KeyboardInputViewController changeKeyboardTypeDelay is now an argument in changeKeyboardType.

  • KeyboardInputViewController keyboardType has been moved to the context.

  • AutocompleteToolbar has been renamed to AutocompleteToolbarView.

  • EmojiCategory.frequents has been renamed to frequent.

  • KeyboardActionHandler now requires canHandle(_:on:) to be implemented.

  • KeyboardAction has new action types.

  • KeyboardAction has fewer isXXX properties.

  • KeyboardAction .capsLock and shiftDown are now part of KeyboardAction.shift.

  • KeyboardActionRow.from has been changed to an initializer.

  • KeyboardActionRows.from has been changed to an initializer.

  • KeyboardImageActions has been converted to a KeyboardActionRow+Images extension initializer.

  • KeyboardToolbar has been renamed to KeyboardToolbarView.

  • The shouldChangeToAlphabeticLowercase has been replaced with the automatic switching mentioned above.

  • The isKeyboardEnabled function now uses a for as external argument name.

Removed, previously deprecated parts:

  • AutocompleteBugFixTimer
  • AutocompleteSuggestionProvider provideAutocompleteSuggestions
  • KeyboardAction switchKeyboard
  • KeyboardAction switchToKeyboard
  • KeyboardAction standardInputViewControllerAction
  • KeyboardAction standardTextDocumentProxyAction
  • KeyboardActionHandler handleTap/Repeat/LongPress
  • KeyboardActionHandler handle gesture on UIView
  • KeyboardInputViewController addSwitchKeyboardGesture
  • PersistedKeyboardSetting init with key
  • StandardKeyboardActionHandler init with feedback instances
  • StandardKeyboardActionHandler action for view
  • StandardKeyboardActionHandler animationButtonTap
  • StandardKeyboardActionHandler giveHapticFeedbackForLongPress/Repeat/Tap
  • StandardKeyboardActionHandler longPress/repeat/tapAction for view
  • StandardKeyboardActionHandler handleLongPress/Repeat/Tap
  • StandardKeyboardActionHandler triggerAudio/HapticFeedback
  • UIColor clearTappable
  • UIInputViewController createAutocompleteBugFixTimer
  • UIView add/removeLongPress/Repeating/TapAction
  • isKeyboardEnabled global function
KeyboardKit -

Published by danielsaidi over 4 years ago

This version removes the subview fiddling from KeyboardCollectionVew to the built-in subclasses, since it can ruin the view hierarchy for collection views that don't add custom views to the cells.

KeyboardKit -

Published by danielsaidi over 4 years ago

This version adds an .emoji keyboard action, which can be used if you need to separate characters from emojis.

It also extracts the logic of KeyboardAction standardTapAction into

  • standardTapActionForController
  • standardTapActionForProxy

which makes it possible to use the standard function in more ways.

This version also makes actions of KeyboardCollectionView mutable, causing changes to this property to refresh the view.

KeyboardKit -

Published by danielsaidi over 4 years ago

This is the last minor version before 3.0, which will remove a bunch of deprecated members.

This version adds more features, fixes some bugs and deprecates many parts of the library.

A big change, which is not fully covered in these notes, is that KeyboardInputViewController and StandardKeyboardActionHandler now handles changing keyboard types. Even if you handle what a type should be in your app, KeyboardKit helps you handling this. If you only use a single keyboard in your app, you can ignore this altogether.

Thanks to @eduardoxlau, the demo also has an improved emoji keyboard.

New features

  • KeyboardAction has new standardTap/DoubleTap/LongPress/Repeat action properties.
  • KeyboardInputViewController has a new deviceOrientation property.
  • KeyboardInputViewController has a new keyboardType property.
  • KeyboardInputViewController has new can/changeKeyboardType functions and properties.
  • KeyboardInputViewController has a new setupKeyboard function.
  • StandardKeyboardActionHandler has more logic for handling keyboard type changes.
  • The new EmojiCategory enum represents the native iOS emoji keyboard categories.
  • The new KeyboardStateInspector can be implemented to get info about the keyboard.

Changes

  • The demo now switches to caps lock when shift is double-tapped.
  • The standard tap animation does not scale up as much as before.
  • The standard haptic feedback for tap is light impact instead of medium.

Deprecations

  • KeyboardAction.switchKeyboard has been renamed to nextKeyboard.
  • KeyboardAction.switchToKeyboard has been renamed to keyboardType.
  • KeyboardAction.standardInputViewControllerAction has been renamed to standardTapAction.
  • KeyboardAction.standardTextDocumentProxyAction is no longer used by the system`.
  • addSwitchKeyboardGesture(to:) has been renamed to addNextKeyboardGesture(to:).
  • The global isKeyboardEnabled has been replaced with a new KeyboardStateInspector protocol.

Bug fixes

  • Double tap handling for space no longer inserts an additional space.

Breaking change

  • KeyboardType.alphabetic now uses a KeyboardShiftState property instead of a bool for if it's upper-cased or not.
  • KeyboardAction.switchToKeyboard is now an alias for keyboardType. You can still use it when defining actions, but if you switch over KeyboardAction, you have to use keyboardType instead of switchToKeyboard.
KeyboardKit -

Published by danielsaidi over 4 years ago

These versions adjust the keyboard settings url.

KeyboardKit -

Published by danielsaidi over 4 years ago

These versions adjust the keyboard settings url.

KeyboardKit -

Published by danielsaidi over 4 years ago

This version upgrades its Nimble and Mockery dependencies.

KeyboardKit -

Published by danielsaidi over 4 years ago

This version upgrades the podspec's Swift version.

KeyboardKit -

Published by danielsaidi over 4 years ago

This version fixes a gesture-related memory leak by no longer using the gesture extensions that caused the problem. Instead, KeyboardInputViewController has a new set of internal gesture extensions that helps with adding gestures to a button.

This version also adds double-tap action handling to KeyboardKit. It's handled like taps, long presses and repeating actions, but it has no default logic. To handle it, create a custom action handler and override handle(_ gesture:,on action:, sender:).

KeyboardKit does not put any rules on the gesture handling. If you return an action for both a single tap and a double tap, both will be triggered.

New features

  • A new .doubleTap keyboard gesture.

Deprecations

  • The UIView addLongPressAction extension is deprecated.
  • The UIView removeLongPressAction extension is deprecated.
  • The UIView addRepeatingAction extension is deprecated.
  • The UIView removeRepeatingAction extension is deprecated.
  • The UIView addTapAction extension is deprecated.
  • The UIView removeTapAction extension is deprecated.