Compare commits

..

3 Commits

3 changed files with 22 additions and 4 deletions

View File

@ -34,6 +34,10 @@ class BrowserNavigationController: UIViewController {
if (oldValue <= 0.5 && toolbarOffset > 0.5) || (oldValue > 0.5 && toolbarOffset <= 0.5) {
setNeedsStatusBarAppearanceUpdate()
if navBarView.textField.isFirstResponder {
navBarView.textField.resignFirstResponder()
}
}
}
}
@ -205,6 +209,10 @@ class BrowserNavigationController: UIViewController {
if position == .end {
self.navigator.goBack()
}
if self.navBarView.textField.isFirstResponder {
self.navBarView.textField.resignFirstResponder()
}
}
gestureState = .backwards(animator)
} else if location.x > view.bounds.width - startEdgeNavigationSwipeDistance && velocity.x < 0 && navigator.forwardStack.count > 0 {
@ -236,6 +244,10 @@ class BrowserNavigationController: UIViewController {
if position == .end {
self.navigator.goForward()
}
if self.navBarView.textField.isFirstResponder {
self.navBarView.textField.resignFirstResponder()
}
}
gestureState = .forwards(animator)
}

View File

@ -81,6 +81,7 @@ class BrowserWebViewController: UIViewController {
webView.scrollView.delegate = scrollViewDelegate
// this doesn't default to .default :S
webView.scrollView.indicatorStyle = .default
webView.scrollView.keyboardDismissMode = .interactive
webView.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(webView)
NSLayoutConstraint.activate([

View File

@ -14,7 +14,7 @@ class NavigationBarView: UIView {
let navigator: NavigationManager
private var border: UIView!
private var textField: UITextField!
private(set) var textField: UITextField!
private var cancellables = [AnyCancellable]()
@ -40,9 +40,10 @@ class NavigationBarView: UIView {
textField.text = navigator.displayURL
textField.borderStyle = .roundedRect
textField.keyboardType = .URL
textField.returnKeyType = .go
textField.autocapitalizationType = .none
textField.autocorrectionType = .no
textField.addTarget(self, action: #selector(commitURL), for: .editingDidEnd)
textField.addTarget(self, action: #selector(commitURL), for: .primaryActionTriggered)
textField.translatesAutoresizingMaskIntoConstraints = false
addSubview(textField)
NSLayoutConstraint.activate([
@ -75,8 +76,12 @@ class NavigationBarView: UIView {
}
@objc private func commitURL() {
if let text = textField.text, let url = URL(string: text) {
navigator.changeURL(url)
textField.resignFirstResponder()
if let text = textField.text, var components = URLComponents(string: text) {
if components.scheme == nil {
components.scheme = "gemini"
}
navigator.changeURL(components.url!)
} else {
textField.text = navigator.displayURL
}