From 3ae5ed8ee91e82b838dcd7479120ed6657ccd27d Mon Sep 17 00:00:00 2001 From: Yury Korolev Date: Tue, 7 Apr 2020 12:58:05 +0300 Subject: [PATCH] Better selection --- Blink/KBTracker.swift | 1 + Blink/SmarterKeys/KBProxy.swift | 7 ++--- Blink/SmarterKeys/KBView.swift | 1 + Blink/SmarterKeys/SmarterTermInput.swift | 28 ++++++++++++-------- Blink/SpaceController.swift | 33 +++++++++++------------- Blink/TermDevice.m | 6 ----- 6 files changed, 38 insertions(+), 38 deletions(-) diff --git a/Blink/KBTracker.swift b/Blink/KBTracker.swift index 230c72532..a938a973c 100644 --- a/Blink/KBTracker.swift +++ b/Blink/KBTracker.swift @@ -241,5 +241,6 @@ class KBTracker { @objc private func _keyboardDidShow(_ notification: Notification) { debugPrint("_keyboardDidShow") +// kbTraits.isPortrait = } } diff --git a/Blink/SmarterKeys/KBProxy.swift b/Blink/SmarterKeys/KBProxy.swift index e432cbbab..879dff5b4 100644 --- a/Blink/SmarterKeys/KBProxy.swift +++ b/Blink/SmarterKeys/KBProxy.swift @@ -91,12 +91,13 @@ class KBProxy: UIView { bKBframe.size.width -= (bKBframe.size.width - rightBottom.x) - 6 hardwareKBAttached = true } - var traits = _kbView.traits +// var traits = _kbView.traits // traits.isHKBAttached = hardwareKBAttached - traits.isPortrait = win.bounds.width < win.bounds.height +// traits.isPortrait = win.bounds.width < win.bounds.height +// debugPrint("KBProxy isPortatit", traits.isPortrait) - _kbView.traits = traits +// _kbView.traits = traits _kbView.safeBarWidth = barButtonView.frame.width _kbView.frame = bKBframe } diff --git a/Blink/SmarterKeys/KBView.swift b/Blink/SmarterKeys/KBView.swift index c3718ff7b..e123e8bcb 100644 --- a/Blink/SmarterKeys/KBView.swift +++ b/Blink/SmarterKeys/KBView.swift @@ -153,6 +153,7 @@ class KBView: UIView { let strictSpace = !traits.isHKBAttached && traits.hasSuggestions self.kbSizes = kbDevice.sizesFor(portrait: traits.isPortrait) + debugPrint("isPortrait", traits.isPortrait) let top: CGFloat = 0; diff --git a/Blink/SmarterKeys/SmarterTermInput.swift b/Blink/SmarterKeys/SmarterTermInput.swift index e94cc45ac..bc97eab9d 100644 --- a/Blink/SmarterKeys/SmarterTermInput.swift +++ b/Blink/SmarterKeys/SmarterTermInput.swift @@ -105,6 +105,10 @@ class SmarterTermInput: KBWebView { if traitCollection.userInterfaceIdiom == .phone { kbView.traits.isPortrait = scene.interfaceOrientation.isPortrait + } else if kbView.traits.isFloatingKB { + kbView.traits.isPortrait = true + } else { + kbView.traits.isPortrait = scene.interfaceOrientation.isPortrait } } @@ -114,10 +118,10 @@ class SmarterTermInput: KBWebView { super.ready() reportLang() - device?.focus() +// device?.focus() kbView.isHidden = false kbView.invalidateIntrinsicContentSize() - _refreshInputViews() +// _refreshInputViews() if let v = selectionView() { _caretHider = CaretHider(view: v) @@ -125,14 +129,14 @@ class SmarterTermInput: KBWebView { } - // overriding chain - override var next: UIResponder? { - guard let responder = device?.delegate?.viewController() - else { - return super.next - } - return responder - } +// // overriding chain +// override var next: UIResponder? { +// guard let responder = device?.view?.superview +// else { +// return super.next +// } +// return responder +// } func reset() { @@ -166,6 +170,8 @@ class SmarterTermInput: KBWebView { device?.focus() kbView.isHidden = false + setNeedsLayout() + _inputAccessoryView?.isHidden = false spaceController?.cleanupControllers() @@ -231,7 +237,7 @@ class SmarterTermInput: KBWebView { } override var inputAccessoryView: UIView? { - return _inputAccessoryView + _inputAccessoryView } func sync(traits: KBTraits, device: KBDevice, hideSmartKeysWithHKB: Bool) { diff --git a/Blink/SpaceController.swift b/Blink/SpaceController.swift index 8bbee7cdd..1249cf0d9 100644 --- a/Blink/SpaceController.swift +++ b/Blink/SpaceController.swift @@ -124,25 +124,20 @@ class SpaceController: UIViewController { term.delegate = self _termControllers.insert(term) term.bgColor = view.backgroundColor ?? .black - _viewportsController.setViewControllers([term], direction: .forward, animated: false) { (didComplete) in - if KBTracker.shared.input?.device == nil { - DispatchQueue.main.async { - self._attachInputToCurrentTerm() - } - } - } + _viewportsController.setViewControllers([term], direction: .forward, animated: false) } } -// public override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) { -// super.viewWillTransition(to: size, with: coordinator) -// if view.window?.isKeyWindow == true { -// DispatchQueue.main.async { + public override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) { + super.viewWillTransition(to: size, with: coordinator) + if view.window?.isKeyWindow == true { + DispatchQueue.main.async { +// self.currentTerm()?.termDevice.view?.webView?.kbView.reset() // SmarterTermInput.shared.contentView()?.reloadInputViews() -// } -// } -// } + } + } + } deinit { NotificationCenter.default.removeObserver(self) @@ -202,14 +197,12 @@ class SpaceController: UIViewController { SessionRegistry.shared.track(session: term) - self._currentKey = term.meta.key + _currentKey = term.meta.key _viewportsController.setViewControllers([term], direction: .forward, animated: animated) { (didComplete) in DispatchQueue.main.async { self._displayHUD() self._attachInputToCurrentTerm() - if let completion = completion { - completion(didComplete) - } + completion?(didComplete) } } } @@ -532,6 +525,10 @@ extension SpaceController { _focusOnShell() } + @objc public func scaleWithPich(_ pinch: UIPinchGestureRecognizer) { + currentTerm()?.scaleWithPich(pinch) + } + @objc func newShellAction() { _createShell(userActivity: nil, animated: true) } diff --git a/Blink/TermDevice.m b/Blink/TermDevice.m index 02aa482d5..5de757854 100644 --- a/Blink/TermDevice.m +++ b/Blink/TermDevice.m @@ -358,12 +358,6 @@ - (void)attachInput:(UIView *)termInput - (void)focus { [_view focus]; [_delegate deviceFocused]; -// dispatch_async(dispatch_get_main_queue(), ^{ -// if (![_input isFirstResponder]) { -// [_input becomeFirstResponder]; -// } -// }); - } - (void)blur {