Fix warnings
This commit is contained in:
@@ -9,8 +9,7 @@ import Combine
|
||||
import UIKit
|
||||
import UniformTypeIdentifiers
|
||||
|
||||
class BrowserViewController: UIViewController, WKNavigationDelegate, WKUIDelegate,
|
||||
UITextFieldDelegate, ScriptPolicyViewControllerDelegate,
|
||||
class BrowserViewController: UIViewController, WKNavigationDelegate, WKUIDelegate, ScriptPolicyViewControllerDelegate,
|
||||
UIPopoverPresentationControllerDelegate, TabDelegate, TabPickerViewControllerDelegate,
|
||||
AutocompleteViewControllerDelegate, ShortcutResponder
|
||||
{
|
||||
@@ -595,56 +594,7 @@ class BrowserViewController: UIViewController, WKNavigationDelegate, WKUIDelegat
|
||||
|
||||
completionHandler(menuConfig)
|
||||
}
|
||||
|
||||
// MARK: UITextField Delegate
|
||||
|
||||
func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
|
||||
if let text = textField.text {
|
||||
let matches = BrowserHistory.shared.visitedToplevelHistoryItems(matching: text)
|
||||
autocompleteViewController.historyItems = matches
|
||||
|
||||
autocompleteViewController.view.isHidden = matches.count == 0
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
|
||||
if let text = textField.text?.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines) {
|
||||
|
||||
// Dumb rules for stuff that "looks like" a URL
|
||||
if !text.contains(" "),
|
||||
text.components(separatedBy: ".").count > 1,
|
||||
var url = URL(string: text)
|
||||
{
|
||||
if url.scheme == nil {
|
||||
let urlString = "http://\(text)"
|
||||
if let fixedURL = URL(string: urlString) {
|
||||
url = fixedURL
|
||||
}
|
||||
}
|
||||
|
||||
tab.beginLoadingURL(url)
|
||||
} else {
|
||||
// Assume google search
|
||||
let queryString = text
|
||||
.replacingOccurrences(of: " ", with: "+")
|
||||
.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)!
|
||||
|
||||
let searchURL = URL(string: "https://google.com/search?q=\(queryString)&gbv=1")! // gbv=1: no JS
|
||||
tab.beginLoadingURL(searchURL)
|
||||
}
|
||||
|
||||
textField.resignFirstResponder()
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func textFieldDidEndEditing(_ textField: UITextField) {
|
||||
autocompleteViewController.view.isHidden = true
|
||||
}
|
||||
|
||||
// MARK: Tab Delegate
|
||||
|
||||
func didBlockScriptOrigin(_ origin: String, forTab: Tab) {
|
||||
@@ -750,6 +700,60 @@ class BrowserViewController: UIViewController, WKNavigationDelegate, WKUIDelegat
|
||||
}
|
||||
}
|
||||
|
||||
extension BrowserViewController: UITextFieldDelegate
|
||||
{
|
||||
func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
|
||||
if let text = textField.text {
|
||||
let matches = BrowserHistory.shared.visitedToplevelHistoryItems(matching: text)
|
||||
autocompleteViewController.historyItems = matches
|
||||
|
||||
autocompleteViewController.view.isHidden = matches.count == 0
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
|
||||
if let text = textField.text?.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines) {
|
||||
|
||||
// Dumb rules for stuff that "looks like" a URL
|
||||
if !text.contains(" "),
|
||||
text.components(separatedBy: ".").count > 1,
|
||||
var url = URL(string: text)
|
||||
{
|
||||
if url.scheme == nil {
|
||||
let urlString = "http://\(text)"
|
||||
if let fixedURL = URL(string: urlString) {
|
||||
url = fixedURL
|
||||
}
|
||||
}
|
||||
|
||||
tab.beginLoadingURL(url)
|
||||
} else {
|
||||
// Assume google search
|
||||
let queryString = text
|
||||
.replacingOccurrences(of: " ", with: "+")
|
||||
.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)!
|
||||
|
||||
let searchURL = URL(string: "https://google.com/search?q=\(queryString)&gbv=1")! // gbv=1: no JS
|
||||
tab.beginLoadingURL(searchURL)
|
||||
}
|
||||
|
||||
textField.resignFirstResponder()
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
override func textFieldShouldEndEditing(_ textField: UITextField) -> Bool {
|
||||
true
|
||||
}
|
||||
|
||||
func textFieldDidEndEditing(_ textField: UITextField) {
|
||||
autocompleteViewController.view.isHidden = true
|
||||
}
|
||||
}
|
||||
|
||||
extension BrowserViewController: ReaderViewControllerDelegate
|
||||
{
|
||||
func readerViewController(_ reader: ReaderViewController, didRequestNavigationToURL navigationURL: URL) {
|
||||
|
||||
@@ -103,18 +103,10 @@
|
||||
"size" : "83.5x83.5"
|
||||
},
|
||||
{
|
||||
"filename" : "iconios~marketing-1.png",
|
||||
"idiom" : "ios-marketing",
|
||||
"scale" : "1x",
|
||||
"size" : "1024x1024"
|
||||
},
|
||||
{
|
||||
"filename" : "icon@ios~marketing.png",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "iconios~marketing.png",
|
||||
"scale" : "1x",
|
||||
"unassigned" : true
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
|
||||
|
Before Width: | Height: | Size: 336 KiB After Width: | Height: | Size: 336 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 336 KiB |
Reference in New Issue
Block a user