Fix warnings

This commit is contained in:
James Magahern
2021-02-15 23:06:23 -08:00
parent a56c647a99
commit 101f8f17e7
4 changed files with 56 additions and 60 deletions

View File

@@ -9,8 +9,7 @@ import Combine
import UIKit import UIKit
import UniformTypeIdentifiers import UniformTypeIdentifiers
class BrowserViewController: UIViewController, WKNavigationDelegate, WKUIDelegate, class BrowserViewController: UIViewController, WKNavigationDelegate, WKUIDelegate, ScriptPolicyViewControllerDelegate,
UITextFieldDelegate, ScriptPolicyViewControllerDelegate,
UIPopoverPresentationControllerDelegate, TabDelegate, TabPickerViewControllerDelegate, UIPopoverPresentationControllerDelegate, TabDelegate, TabPickerViewControllerDelegate,
AutocompleteViewControllerDelegate, ShortcutResponder AutocompleteViewControllerDelegate, ShortcutResponder
{ {
@@ -596,55 +595,6 @@ class BrowserViewController: UIViewController, WKNavigationDelegate, WKUIDelegat
completionHandler(menuConfig) 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 // MARK: Tab Delegate
func didBlockScriptOrigin(_ origin: String, forTab: Tab) { 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 extension BrowserViewController: ReaderViewControllerDelegate
{ {
func readerViewController(_ reader: ReaderViewController, didRequestNavigationToURL navigationURL: URL) { func readerViewController(_ reader: ReaderViewController, didRequestNavigationToURL navigationURL: URL) {

View File

@@ -103,18 +103,10 @@
"size" : "83.5x83.5" "size" : "83.5x83.5"
}, },
{ {
"filename" : "iconios~marketing-1.png",
"idiom" : "ios-marketing", "idiom" : "ios-marketing",
"scale" : "1x", "scale" : "1x",
"size" : "1024x1024" "size" : "1024x1024"
},
{
"filename" : "icon@ios~marketing.png",
"scale" : "1x"
},
{
"filename" : "iconios~marketing.png",
"scale" : "1x",
"unassigned" : true
} }
], ],
"info" : { "info" : {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 336 KiB