Some multiple tab fixes
This commit is contained in:
@@ -17,12 +17,15 @@ class Tab: NSObject, SBRProcessBundleBridgeDelegate
|
||||
{
|
||||
public weak var delegate: TabDelegate?
|
||||
|
||||
public let homeURL: URL
|
||||
public let homeURL: URL?
|
||||
public let bridge = SBRProcessBundleBridge()
|
||||
public var webView: WKWebView {
|
||||
if self.loadedWebView == nil {
|
||||
self.loadedWebView = bridge.webView
|
||||
beginLoadingURL(homeURL)
|
||||
|
||||
if let homeURL = homeURL {
|
||||
beginLoadingURL(homeURL)
|
||||
}
|
||||
}
|
||||
|
||||
return bridge.webView
|
||||
@@ -49,11 +52,15 @@ class Tab: NSObject, SBRProcessBundleBridgeDelegate
|
||||
private var titleObservation: NSKeyValueObservation?
|
||||
private var urlObservation: NSKeyValueObservation?
|
||||
|
||||
convenience init(urlString: String, policyManager: ResourcePolicyManager) {
|
||||
self.init(url: URL(string: urlString)!, policyManager: policyManager)
|
||||
convenience init(policyManager: ResourcePolicyManager) {
|
||||
self.init(url: nil, policyManager: policyManager)
|
||||
}
|
||||
|
||||
init(url: URL, policyManager: ResourcePolicyManager) {
|
||||
convenience init(urlString: String, policyManager: ResourcePolicyManager) {
|
||||
self.init(url: URL(string: urlString), policyManager: policyManager)
|
||||
}
|
||||
|
||||
init(url: URL?, policyManager: ResourcePolicyManager) {
|
||||
self.homeURL = url
|
||||
self.policyManager = policyManager
|
||||
bridge.policyDataSource = policyManager
|
||||
|
||||
@@ -26,7 +26,7 @@ class TabController
|
||||
}
|
||||
|
||||
func createNewTab() -> Tab {
|
||||
let tab = Tab(urlString: "about:blank", policyManager: policyManager)
|
||||
let tab = Tab(policyManager: policyManager)
|
||||
tabs.append(tab)
|
||||
|
||||
return tab
|
||||
|
||||
@@ -63,20 +63,28 @@ class TabPickerViewController: UIViewController, UICollectionViewDelegate
|
||||
var config = listCell.defaultContentConfiguration()
|
||||
|
||||
if let tab = self.tabController.tab(forIdentifier: item) {
|
||||
if let title = tab.title {
|
||||
if let title = tab.title, title.count > 0 {
|
||||
config.text = title
|
||||
config.secondaryText = tab.url?.absoluteString
|
||||
} else if let url = tab.url {
|
||||
config.text = url.absoluteString
|
||||
config.secondaryText = url.absoluteString
|
||||
} else {
|
||||
config.text = tab.url?.absoluteString
|
||||
config.secondaryText = tab.url?.absoluteString
|
||||
config.text = "New Tab"
|
||||
}
|
||||
|
||||
config.textProperties.numberOfLines = 1
|
||||
config.secondaryTextProperties.numberOfLines = 1
|
||||
|
||||
if let image = tab.favicon {
|
||||
config.image = image
|
||||
config.imageProperties.maximumSize = CGSize(width: 21.0, height: 21.0)
|
||||
config.imageProperties.cornerRadius = 3.0
|
||||
} else {
|
||||
config.image = UIImage(systemName: "safari")
|
||||
}
|
||||
|
||||
config.imageProperties.maximumSize = CGSize(width: 21.0, height: 21.0)
|
||||
config.imageProperties.cornerRadius = 3.0
|
||||
|
||||
if tab == self.selectedTab {
|
||||
listCell.accessories = [ .checkmark() ]
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user