SwiftMaterialKeyboard 0.1.11

SwiftMaterialKeyboard 0.1.11

Maintained by Chinh Nguyen.



 
Depends on:
SnapKit~> 4.0
RxSwift~> 4.0
RxCocoa~> 4.0
Material~> 2.12
 

  • By
  • Chinh Nguyen

SwiftMaterialKeyboard

CI Status Version License Platform

Description

In some application, the default keyboard provided by Apple is just not enough, we need more control over the position and also behavior of the on-screen keyboard. For example: we need the Qwerty keyboard to be smaller and always visible that can be tucked to a screen corner instead of taking half of the screen.

Example

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

Requirements

Installation

SwiftMaterialKeyboard is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'SwiftMaterialKeyboard'

Create keyboard

To create a custom keyboard, create a new class which inherits from MaterialKeyboard and define the desired number of rows and columns by overriding rowCount and columnCount. Each key will be placed just like an HTML table's cell with position for row, column and the desired rowSpan or columnSpan.

This is the PinPad which can be found in Example project:

class PinPad: MaterialKeyboard {
    override var rowCount: Int { return 4 }
    override var columnCount: Int { return 4 }
    override func createButtons() -> [KeyboardButton] {
        let prev = KeyboardButton.create(for: FAKMaterialIcons.longArrowTabIcon(withSize: 24), row: 0, column: 3, action: .next)
        prev.transform = CGAffineTransform(rotationAngle: .pi)
        return [
            KeyboardButton.create(for: "1", row: 0, column: 0),
            KeyboardButton.create(for: "2", row: 0, column: 1),
            KeyboardButton.create(for: "3", row: 0, column: 2),
            KeyboardButton.create(for: "4", row: 1, column: 0),
            KeyboardButton.create(for: "5", row: 1, column: 1),
            KeyboardButton.create(for: "6", row: 1, column: 2),
            KeyboardButton.create(for: "7", row: 2, column: 0),
            KeyboardButton.create(for: "8", row: 2, column: 1),
            KeyboardButton.create(for: "9", row: 2, column: 2),
            KeyboardButton.create(for: "0", row: 3, column: 1),
            KeyboardButton.create(for: "CLR", row: 3, column: 0, action: .clear),
            KeyboardButton.create(for: FAKMaterialIcons.arrowLeftIcon(withSize: 24), row: 3, column: 2, action: .backspace),
            prev,
            KeyboardButton.create(for: FAKMaterialIcons.longArrowTabIcon(withSize: 24), row: 1, column: 3, action: .next),
            KeyboardButton.create(for: FAKMaterialIcons.longArrowReturnIcon(withSize: 24), row: 2, column: 3, rowSpan: 2)
        ]
    }
}

And this is how it looks like in a real application:

Author

Chinh Nguyen, [email protected]

License

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