@@ -20,12 +20,8 @@ import UIKit
20
20
21
21
// MARK: - CustomKeyboard
22
22
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 ?
29
25
30
26
// MARK: CustomKeyobardShiftState
31
27
public enum CustomKeyboardShiftState {
@@ -77,8 +73,6 @@ public class CustomKeyboard: UIView, KeyboardLayoutDelegate {
77
73
}
78
74
}
79
75
80
- public weak var delegate : CustomKeyboardDelegate ?
81
-
82
76
// MARK: Init
83
77
public init ( ) {
84
78
super. init ( frame: CGRect . zero)
@@ -96,7 +90,7 @@ public class CustomKeyboard: UIView, KeyboardLayoutDelegate {
96
90
}
97
91
98
92
private func defaultInit( ) {
99
- keyboardLayoutStyleDidChange ( )
93
+ keyboardLayout = CustomKeyboardLayout ( )
100
94
keyboardLayoutStateDidChange ( oldState: nil , newState: keyboardLayoutState)
101
95
}
102
96
@@ -134,10 +128,6 @@ public class CustomKeyboard: UIView, KeyboardLayoutDelegate {
134
128
return getKeyboardLayout ( ofState: keyboardLayoutState)
135
129
}
136
130
137
- public func keyboardLayoutStyleDidChange( ) {
138
- keyboardLayout = CustomKeyboardLayout ( style: keyboardStyle)
139
- }
140
-
141
131
public func keyboardLayoutStateDidChange( oldState oldState: CustomKeyboardLayoutState ? , newState: CustomKeyboardLayoutState ) {
142
132
// Remove old keyboard layout
143
133
if let oldState = oldState {
@@ -157,6 +147,21 @@ public class CustomKeyboard: UIView, KeyboardLayoutDelegate {
157
147
}
158
148
}
159
149
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
+
160
165
// MARK: Backspace Auto Delete
161
166
private func startBackspaceAutoDeleteModeTimer( ) {
162
167
backspaceAutoDeleteModeTimer = NSTimer . scheduledTimerWithTimeInterval (
0 commit comments