|
|
@@ -19,7 +19,7 @@ enum KeyboardType: Int {
|
|
|
class KeyboardViewController: UIInputViewController {
|
|
|
|
|
|
struct UX {
|
|
|
- static let keyboardHeight = 292.0
|
|
|
+ static let keyboardHeight = 318.0
|
|
|
}
|
|
|
|
|
|
// 选择的键盘类型
|
|
|
@@ -63,6 +63,11 @@ class KeyboardViewController: UIInputViewController {
|
|
|
let animate = LottieAnimationView(name: "heart")
|
|
|
animate.loopMode = .loop
|
|
|
animate.backgroundColor = .clear
|
|
|
+
|
|
|
+ animate.isUserInteractionEnabled = true
|
|
|
+ let tap = UITapGestureRecognizer(target: self, action: #selector(heartBtnClickAction))
|
|
|
+ animate.addGestureRecognizer(tap)
|
|
|
+
|
|
|
return animate
|
|
|
}()
|
|
|
|
|
|
@@ -72,6 +77,11 @@ class KeyboardViewController: UIInputViewController {
|
|
|
label.text = "30%"
|
|
|
label.font = .boldSystemFont(ofSize: 10)
|
|
|
label.textColor = .white
|
|
|
+
|
|
|
+ label.isUserInteractionEnabled = true
|
|
|
+ let tap = UITapGestureRecognizer(target: self, action: #selector(heartBtnClickAction))
|
|
|
+ label.addGestureRecognizer(tap)
|
|
|
+
|
|
|
return label
|
|
|
}()
|
|
|
|
|
|
@@ -79,6 +89,7 @@ class KeyboardViewController: UIInputViewController {
|
|
|
|
|
|
let button = UIButton()
|
|
|
button.setImage(UIImage(named: "keyboard_exchange_btn"), for: .normal)
|
|
|
+ button.addTarget(self, action: #selector(exchangeBtnClickAction), for: .touchUpInside)
|
|
|
return button
|
|
|
}()
|
|
|
|
|
|
@@ -205,6 +216,26 @@ class KeyboardViewController: UIInputViewController {
|
|
|
view.loginBtnClosure = {
|
|
|
self.navigateToLogin()
|
|
|
}
|
|
|
+ view.backBtnClosure = {
|
|
|
+ self.clearPopView()
|
|
|
+ self.loginView.isHidden = true
|
|
|
+ self.nowShowView?.isHidden = false
|
|
|
+ }
|
|
|
+ return view
|
|
|
+ }()
|
|
|
+
|
|
|
+ lazy var vipView: KeyboardVipTipView = {
|
|
|
+
|
|
|
+ let view = KeyboardVipTipView()
|
|
|
+ view.isHidden = true
|
|
|
+ view.unlockBtnClosure = {
|
|
|
+ self.navigateToMembership()
|
|
|
+ }
|
|
|
+ view.backBtnClosure = {
|
|
|
+ self.clearPopView()
|
|
|
+ self.vipView.isHidden = true
|
|
|
+ self.nowShowView?.isHidden = false
|
|
|
+ }
|
|
|
return view
|
|
|
}()
|
|
|
|
|
|
@@ -219,6 +250,8 @@ class KeyboardViewController: UIInputViewController {
|
|
|
super.viewDidLoad()
|
|
|
|
|
|
setUI()
|
|
|
+
|
|
|
+ checkFullAccess()
|
|
|
|
|
|
KeyboardApi.initParams()
|
|
|
requestKeyboardList()
|
|
|
@@ -315,7 +348,7 @@ extension KeyboardViewController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // 获取键盘人设列表
|
|
|
+ // 获取键盘开场白列表
|
|
|
func requestPrologueList() {
|
|
|
|
|
|
KeyboardNetworkManager.request(.prologue_list(params: [:])) { response in
|
|
|
@@ -368,7 +401,11 @@ extension KeyboardViewController {
|
|
|
complete("")
|
|
|
|
|
|
if code == 1006 {
|
|
|
+ // 弹出登录页
|
|
|
self.popLoginView()
|
|
|
+ } else if code == 1008 {
|
|
|
+ // 弹出会员页
|
|
|
+ self.popVipView()
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -394,7 +431,11 @@ extension KeyboardViewController {
|
|
|
complete([String]())
|
|
|
|
|
|
if code == 1006 {
|
|
|
+ // 弹出登录页
|
|
|
self.popLoginView()
|
|
|
+ } else if code == 1008 {
|
|
|
+ // 弹出会员页
|
|
|
+ self.popVipView()
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -418,7 +459,11 @@ extension KeyboardViewController {
|
|
|
complete([String]())
|
|
|
|
|
|
if code == 1006 {
|
|
|
+ // 弹出登录页
|
|
|
self.popLoginView()
|
|
|
+ } else if code == 1008 {
|
|
|
+ // 弹出会员页
|
|
|
+ self.popVipView()
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -426,6 +471,19 @@ extension KeyboardViewController {
|
|
|
|
|
|
// MARK: - 点击事件
|
|
|
extension KeyboardViewController: KeyboardMenuViewDelegate, KeyboardExchangeViewDelegate {
|
|
|
+
|
|
|
+ // 亲密度按钮点击
|
|
|
+ @objc func heartBtnClickAction() {
|
|
|
+
|
|
|
+ let url = URL(string: "com.qihuan.zhuiaijianpan:///intimacy")!
|
|
|
+ openURL(url)
|
|
|
+ }
|
|
|
+
|
|
|
+ // 切换系统键盘
|
|
|
+ @objc func exchangeBtnClickAction() {
|
|
|
+
|
|
|
+ self.advanceToNextInputMode()
|
|
|
+ }
|
|
|
|
|
|
// 功能按钮选择点击
|
|
|
@objc func functionBtnClickAction() {
|
|
|
@@ -455,6 +513,20 @@ extension KeyboardViewController: KeyboardMenuViewDelegate, KeyboardExchangeView
|
|
|
navigateToMembership()
|
|
|
}
|
|
|
|
|
|
+ // 定制人设
|
|
|
+ func diyBtnClickAction() {
|
|
|
+
|
|
|
+ let url = URL(string: "com.qihuan.zhuiaijianpan:///character/custom")!
|
|
|
+ openURL(url)
|
|
|
+ }
|
|
|
+
|
|
|
+ // 人设市场
|
|
|
+ func marketBtnClickAction() {
|
|
|
+
|
|
|
+ let url = URL(string: "com.qihuan.zhuiaijianpan:///character/market")!
|
|
|
+ openURL(url)
|
|
|
+ }
|
|
|
+
|
|
|
// 跳转到主应用的登录页面
|
|
|
@objc func navigateToLogin() {
|
|
|
let url = URL(string: "com.qihuan.zhuiaijianpan:///login")!
|
|
|
@@ -530,19 +602,37 @@ extension KeyboardViewController: KeyboardMenuViewDelegate, KeyboardExchangeView
|
|
|
extension KeyboardViewController: KeyboardHelpViewDelegate, KeyboardTeachViewDelegate, KeyboardPrologueViewDelegate {
|
|
|
|
|
|
// 帮聊点击cell
|
|
|
- func helpCollectionViewDidSelectItem(characterId: String, content: String, complete: @escaping (() -> ())) {
|
|
|
+ func helpCollectionViewDidSelectItem(characterId: String, content: String, complete: @escaping ((Bool) -> ())) {
|
|
|
+
|
|
|
+ // 判断是否登录
|
|
|
+ let isLogin = KeyboardSharedDataManager.shared.isLoggedIn()
|
|
|
+ if !isLogin {
|
|
|
+ popLoginView()
|
|
|
+ complete(false)
|
|
|
+ return
|
|
|
+ }
|
|
|
|
|
|
self.requestSuperReply(characterId: characterId, content: content) { text in
|
|
|
self.insertText(text)
|
|
|
- complete()
|
|
|
+ complete(true)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 教你说点击cell
|
|
|
- func teachCollectionViewDidSelectItem(characterId: String, content: String, complete: @escaping (([String]) -> ())) {
|
|
|
+ func teachCollectionViewDidSelectItem(characterId: String, content: String, complete: @escaping (([String], Bool, Bool) -> ())) {
|
|
|
|
|
|
+ // 判断是否登录
|
|
|
+ let isLogin = KeyboardSharedDataManager.shared.isLoggedIn()
|
|
|
+ if !isLogin {
|
|
|
+ popLoginView()
|
|
|
+ complete([String](), false, false)
|
|
|
+ return
|
|
|
+ } else {
|
|
|
+ complete([String](), true, false)
|
|
|
+ }
|
|
|
+
|
|
|
self.requestSuperSpeak(characterId: characterId, content: content) { list in
|
|
|
- complete(list)
|
|
|
+ complete(list, true, true)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -553,10 +643,20 @@ extension KeyboardViewController: KeyboardHelpViewDelegate, KeyboardTeachViewDel
|
|
|
}
|
|
|
|
|
|
// 开场白点击cell
|
|
|
- func prologueCollectionViewDidSelectItem(name: String, complete: @escaping (([String]) -> ())) {
|
|
|
+ func prologueCollectionViewDidSelectItem(name: String, complete: @escaping (([String], Bool, Bool) -> ())) {
|
|
|
+
|
|
|
+ // 判断是否登录
|
|
|
+ let isLogin = KeyboardSharedDataManager.shared.isLoggedIn()
|
|
|
+ if !isLogin {
|
|
|
+ popLoginView()
|
|
|
+ complete([String](), false, false)
|
|
|
+ return
|
|
|
+ } else {
|
|
|
+ complete([String](), true, false)
|
|
|
+ }
|
|
|
|
|
|
self.requestSuperPrologue(name: name) { list in
|
|
|
- complete(list)
|
|
|
+ complete(list, true, true)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -584,6 +684,12 @@ extension KeyboardViewController: KeyboardBaseViewDelegate {
|
|
|
if isShowing {
|
|
|
print("系统正在显示剪贴板权限弹窗")
|
|
|
self.view.toast(text: "请允许访问剪贴板")
|
|
|
+// self.teachView.topView.isHidden = false
|
|
|
+ self.helpView.topView.isHidden = false
|
|
|
+ self.helpView.topView.snp.updateConstraints { make in
|
|
|
+ make.height.equalTo(32)
|
|
|
+ }
|
|
|
+// self.teachView.topView.isHidden = false
|
|
|
}
|
|
|
if let content = self.getPasteboardContent() {
|
|
|
print("获取到剪贴板内容: \(content)")
|
|
|
@@ -673,6 +779,9 @@ extension KeyboardViewController: KeyboardBaseViewDelegate {
|
|
|
|
|
|
let currentChangeCount = UIPasteboard.general.changeCount
|
|
|
if currentChangeCount != initialChangeCount {
|
|
|
+
|
|
|
+ // 记录访问前的时间
|
|
|
+ let startTime = Date()
|
|
|
// 剪贴板计数已变化,检查内容是否真的变化
|
|
|
if let copiedString = UIPasteboard.general.string {
|
|
|
// 只有当内容真的不同时才处理
|
|
|
@@ -683,10 +792,22 @@ extension KeyboardViewController: KeyboardBaseViewDelegate {
|
|
|
initialChangeCount = currentChangeCount
|
|
|
// 处理复制的内容
|
|
|
self.handleCopiedContent(copiedString)
|
|
|
+
|
|
|
+ // 检查访问后的时间延迟
|
|
|
+ let timeDelay = Date().timeIntervalSince(startTime)
|
|
|
+
|
|
|
+ // 如果访问剪贴板的时间超过一定阈值,可能是因为系统弹出了权限弹窗
|
|
|
+ // 通常正常访问剪贴板的时间应该很短,如果超过100毫秒,可能是弹出了弹窗
|
|
|
+ if timeDelay > 0.1 {
|
|
|
+ self.openPasteTipView()
|
|
|
+ } else {
|
|
|
+
|
|
|
+ }
|
|
|
} else {
|
|
|
// 内容相同或为空,只更新计数
|
|
|
initialChangeCount = currentChangeCount
|
|
|
print("剪贴板计数变化但内容未变或为空")
|
|
|
+ self.openPasteTipView()
|
|
|
}
|
|
|
} else {
|
|
|
// 剪贴板内容为nil,更新计数
|
|
|
@@ -759,6 +880,50 @@ extension KeyboardViewController: KeyboardBaseViewDelegate {
|
|
|
|
|
|
extension KeyboardViewController {
|
|
|
|
|
|
+ // 打开弹窗
|
|
|
+ func openPasteTipView() {
|
|
|
+
|
|
|
+ self.helpView.topView.isHidden = false
|
|
|
+ self.helpView.topView.snp.updateConstraints { make in
|
|
|
+ make.height.equalTo(32)
|
|
|
+ }
|
|
|
+
|
|
|
+ self.teachView.topView.isHidden = false
|
|
|
+ self.teachView.topView.snp.updateConstraints { make in
|
|
|
+ make.height.equalTo(32)
|
|
|
+ }
|
|
|
+
|
|
|
+ self.prologueView.topView.isHidden = false
|
|
|
+ self.prologueView.topView.snp.updateConstraints { make in
|
|
|
+ make.height.equalTo(32)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 检查是否有完全访问权限
|
|
|
+ func checkFullAccess() {
|
|
|
+
|
|
|
+ let isFullAccess = self.hasFullAccess
|
|
|
+
|
|
|
+ if !isFullAccess {
|
|
|
+
|
|
|
+ let tipView = KeyboardTipsPopView()
|
|
|
+ tipView.settingBtnClosure = {
|
|
|
+
|
|
|
+ if let url = URL(string: UIApplication.openSettingsURLString) {
|
|
|
+ self.openURL(url)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ tipView.backBtnClosure = {
|
|
|
+
|
|
|
+ }
|
|
|
+ self.view.addSubview(tipView)
|
|
|
+ tipView.snp.makeConstraints { make in
|
|
|
+ make.left.right.bottom.equalTo(0)
|
|
|
+ make.top.equalTo(56)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
// 跳转登录页
|
|
|
func popLoginView() {
|
|
|
|
|
|
@@ -766,9 +931,18 @@ extension KeyboardViewController {
|
|
|
self.loginView.isHidden = false
|
|
|
}
|
|
|
|
|
|
+ // 弹出vip页面
|
|
|
+ func popVipView() {
|
|
|
+
|
|
|
+ self.clearPopView()
|
|
|
+ self.vipView.isHidden = false
|
|
|
+ }
|
|
|
+
|
|
|
// 关闭其他弹出页
|
|
|
func clearPopView() {
|
|
|
|
|
|
+ self.vipView.isHidden = true
|
|
|
+ self.loginView.isHidden = true
|
|
|
self.menuView.isHidden = true
|
|
|
self.exchangeView.isHidden = true
|
|
|
self.helpView.isHidden = true
|
|
|
@@ -835,6 +1009,7 @@ extension KeyboardViewController {
|
|
|
|
|
|
if let chooseKeyboard = self.chooseKeyboard {
|
|
|
self.userChangeLabel.text = chooseKeyboard.name
|
|
|
+ self.heartLabel.text = "\(chooseKeyboard.intimacy ?? 0)%"
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -861,7 +1036,8 @@ extension KeyboardViewController {
|
|
|
|
|
|
self.view.addSubview(heartLabel)
|
|
|
heartLabel.snp.makeConstraints { make in
|
|
|
- make.center.equalTo(heartAnimation.center)
|
|
|
+ make.centerY.equalTo(heartAnimation.snp.centerY).offset(-2)
|
|
|
+ make.centerX.equalTo(heartAnimation.snp.centerX)
|
|
|
}
|
|
|
|
|
|
self.view.addSubview(exchangeBtn)
|
|
|
@@ -886,7 +1062,7 @@ extension KeyboardViewController {
|
|
|
self.view.addSubview(prologueView)
|
|
|
prologueView.snp.makeConstraints { make in
|
|
|
make.left.right.bottom.equalTo(0)
|
|
|
- make.top.equalTo(menuBtn.snp.bottom)
|
|
|
+ make.top.equalTo(60)
|
|
|
}
|
|
|
|
|
|
self.view.addSubview(chooseView)
|
|
|
@@ -914,6 +1090,11 @@ extension KeyboardViewController {
|
|
|
make.top.left.right.bottom.equalTo(0)
|
|
|
}
|
|
|
|
|
|
+ self.view.addSubview(vipView)
|
|
|
+ vipView.snp.makeConstraints { make in
|
|
|
+ make.top.left.right.bottom.equalTo(0)
|
|
|
+ }
|
|
|
+
|
|
|
chooseView.addSubview(functionView)
|
|
|
functionView.snp.makeConstraints { make in
|
|
|
make.top.left.equalTo(1)
|