Skip to content

Commit 37377bc

Browse files
authored
Merge pull request #33 from cemolcay/fix/cemolcay-0.8.9
Fix/cemolcay 0.8.9
2 parents 6ea3319 + 700e639 commit 37377bc

File tree

6 files changed

+362
-370
lines changed

6 files changed

+362
-370
lines changed

Keyboard/DefaultKeyboard/CustomKeyboard.swift

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,8 @@ import UIKit
2020

2121
// MARK: - CustomKeyboard
2222
public class CustomKeyboard: UIView, KeyboardLayoutDelegate {
23-
public var keyboardLayout: CustomKeyboardLayout!
24-
public var keyboardStyle = CustomKeyboardLayoutStyle() {
25-
didSet {
26-
keyboardLayoutStyleDidChange()
27-
}
28-
}
23+
public var keyboardLayout = CustomKeyboardLayout()
24+
public weak var delegate: CustomKeyboardDelegate?
2925

3026
// MARK: CustomKeyobardShiftState
3127
public enum CustomKeyboardShiftState {
@@ -77,8 +73,6 @@ public class CustomKeyboard: UIView, KeyboardLayoutDelegate {
7773
}
7874
}
7975

80-
public weak var delegate: CustomKeyboardDelegate?
81-
8276
// MARK: Init
8377
public init() {
8478
super.init(frame: CGRect.zero)
@@ -96,7 +90,7 @@ public class CustomKeyboard: UIView, KeyboardLayoutDelegate {
9690
}
9791

9892
private func defaultInit() {
99-
keyboardLayoutStyleDidChange()
93+
keyboardLayout = CustomKeyboardLayout()
10094
keyboardLayoutStateDidChange(oldState: nil, newState: keyboardLayoutState)
10195
}
10296

@@ -134,10 +128,6 @@ public class CustomKeyboard: UIView, KeyboardLayoutDelegate {
134128
return getKeyboardLayout(ofState: keyboardLayoutState)
135129
}
136130

137-
public func keyboardLayoutStyleDidChange() {
138-
keyboardLayout = CustomKeyboardLayout(style: keyboardStyle)
139-
}
140-
141131
public func keyboardLayoutStateDidChange(oldState oldState: CustomKeyboardLayoutState?, newState: CustomKeyboardLayoutState) {
142132
// Remove old keyboard layout
143133
if let oldState = oldState {
@@ -157,6 +147,21 @@ public class CustomKeyboard: UIView, KeyboardLayoutDelegate {
157147
}
158148
}
159149

150+
public func reload() {
151+
// Remove current
152+
let currentLayout = getCurrentKeyboardLayout()
153+
currentLayout.delegate = nil
154+
currentLayout.removeFromSuperview()
155+
// Reload layout
156+
keyboardLayout = CustomKeyboardLayout()
157+
keyboardLayoutStateDidChange(oldState: nil, newState: keyboardLayoutState)
158+
}
159+
160+
// MARK: Capitalize
161+
public func capitalize() {
162+
keyboardLayoutState = .Letters(shiftState: .Once)
163+
}
164+
160165
// MARK: Backspace Auto Delete
161166
private func startBackspaceAutoDeleteModeTimer() {
162167
backspaceAutoDeleteModeTimer = NSTimer.scheduledTimerWithTimeInterval(

0 commit comments

Comments
 (0)