|
|
@@ -19,12 +19,14 @@ enum KeyboardType: Int {
|
|
|
class KeyboardViewController: UIInputViewController {
|
|
|
|
|
|
struct UX {
|
|
|
- static let keyboardHeight = 318.0
|
|
|
+ static let keyboardDefaultHeight = 292.0
|
|
|
+ static let keyboardWithTipsHeight = 318.0
|
|
|
}
|
|
|
|
|
|
// 选择的键盘类型
|
|
|
var chooseType: KeyboardType = .help {
|
|
|
didSet {
|
|
|
+ UserDefaults.standard.setValue(chooseType.rawValue, forKey: "KeyboardChooseType")
|
|
|
self.updateMainViewUI()
|
|
|
}
|
|
|
}
|
|
|
@@ -264,6 +266,11 @@ class KeyboardViewController: UIInputViewController {
|
|
|
requestKeyboardList()
|
|
|
requestPrologueList()
|
|
|
}
|
|
|
+
|
|
|
+ if let defaultType = UserDefaults.standard.value(forKey: "KeyboardChooseType") as? Int, let type = KeyboardType(rawValue: defaultType) {
|
|
|
+ self.chooseType = type
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
startMonitoringPasteboard()
|
|
|
startListenGuide()
|
|
|
@@ -311,12 +318,12 @@ class KeyboardViewController: UIInputViewController {
|
|
|
if self.heightConstriaint == nil {
|
|
|
|
|
|
if let view = self.view {
|
|
|
- self.heightConstriaint = NSLayoutConstraint(item: view, attribute: NSLayoutConstraint.Attribute.height, relatedBy: NSLayoutConstraint.Relation.equal, toItem: nil, attribute: NSLayoutConstraint.Attribute.notAnAttribute, multiplier: 0.0, constant: UX.keyboardHeight)
|
|
|
- self.heightConstriaint?.priority = UILayoutPriority(750)
|
|
|
+ self.heightConstriaint = NSLayoutConstraint(item: view, attribute: NSLayoutConstraint.Attribute.height, relatedBy: NSLayoutConstraint.Relation.equal, toItem: nil, attribute: NSLayoutConstraint.Attribute.notAnAttribute, multiplier: 0.0, constant: UX.keyboardDefaultHeight)
|
|
|
+// self.heightConstriaint?.priority = UILayoutPriority(750)
|
|
|
self.view.addConstraint(self.heightConstriaint!)
|
|
|
}
|
|
|
} else {
|
|
|
- self.heightConstriaint?.constant = UX.keyboardHeight
|
|
|
+ self.heightConstriaint?.constant = UX.keyboardDefaultHeight
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -988,6 +995,11 @@ extension KeyboardViewController: KeyboardBaseViewDelegate {
|
|
|
self.prologueView.topView.snp.updateConstraints { make in
|
|
|
make.height.equalTo(0)
|
|
|
}
|
|
|
+
|
|
|
+ self.view.removeConstraint(self.heightConstriaint!)
|
|
|
+ self.heightConstriaint = NSLayoutConstraint(item: self.view, attribute: NSLayoutConstraint.Attribute.height, relatedBy: NSLayoutConstraint.Relation.equal, toItem: nil, attribute: NSLayoutConstraint.Attribute.notAnAttribute, multiplier: 0.0, constant: UX.keyboardDefaultHeight)
|
|
|
+// newHeightConstriaint.priority = UILayoutPriority(750)
|
|
|
+ self.view.addConstraint(self.heightConstriaint!)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -1010,6 +1022,11 @@ extension KeyboardViewController {
|
|
|
self.prologueView.topView.snp.updateConstraints { make in
|
|
|
make.height.equalTo(32)
|
|
|
}
|
|
|
+
|
|
|
+ self.view.removeConstraint(self.heightConstriaint!)
|
|
|
+ self.heightConstriaint = NSLayoutConstraint(item: self.view, attribute: NSLayoutConstraint.Attribute.height, relatedBy: NSLayoutConstraint.Relation.equal, toItem: nil, attribute: NSLayoutConstraint.Attribute.notAnAttribute, multiplier: 0.0, constant: UX.keyboardWithTipsHeight)
|
|
|
+// newHeightConstriaint.priority = UILayoutPriority(750)
|
|
|
+ self.view.addConstraint(self.heightConstriaint!)
|
|
|
}
|
|
|
|
|
|
// 检查是否有完全访问权限
|