Skip to content

Commit

Permalink
Better selection
Browse files Browse the repository at this point in the history
  • Loading branch information
yury committed Apr 7, 2020
1 parent d11fb78 commit 3ae5ed8
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 38 deletions.
1 change: 1 addition & 0 deletions Blink/KBTracker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -241,5 +241,6 @@ class KBTracker {

@objc private func _keyboardDidShow(_ notification: Notification) {
debugPrint("_keyboardDidShow")
// kbTraits.isPortrait =
}
}
7 changes: 4 additions & 3 deletions Blink/SmarterKeys/KBProxy.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
1 change: 1 addition & 0 deletions Blink/SmarterKeys/KBView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
28 changes: 17 additions & 11 deletions Blink/SmarterKeys/SmarterTermInput.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand All @@ -114,25 +118,25 @@ 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)
}
}


// 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() {

Expand Down Expand Up @@ -166,6 +170,8 @@ class SmarterTermInput: KBWebView {

device?.focus()
kbView.isHidden = false
setNeedsLayout()

_inputAccessoryView?.isHidden = false

spaceController?.cleanupControllers()
Expand Down Expand Up @@ -231,7 +237,7 @@ class SmarterTermInput: KBWebView {
}

override var inputAccessoryView: UIView? {
return _inputAccessoryView
_inputAccessoryView
}

func sync(traits: KBTraits, device: KBDevice, hideSmartKeysWithHKB: Bool) {
Expand Down
33 changes: 15 additions & 18 deletions Blink/SpaceController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
}
}
}
Expand Down Expand Up @@ -532,6 +525,10 @@ extension SpaceController {
_focusOnShell()
}

@objc public func scaleWithPich(_ pinch: UIPinchGestureRecognizer) {
currentTerm()?.scaleWithPich(pinch)
}

@objc func newShellAction() {
_createShell(userActivity: nil, animated: true)
}
Expand Down
6 changes: 0 additions & 6 deletions Blink/TermDevice.m
Original file line number Diff line number Diff line change
Expand Up @@ -358,12 +358,6 @@ - (void)attachInput:(UIView<TermInput> *)termInput
- (void)focus {
[_view focus];
[_delegate deviceFocused];
// dispatch_async(dispatch_get_main_queue(), ^{
// if (![_input isFirstResponder]) {
// [_input becomeFirstResponder];
// }
// });

}

- (void)blur {
Expand Down

0 comments on commit 3ae5ed8

Please sign in to comment.