|
|
@@ -27,6 +27,18 @@ class CliqzURLBar: URLBarView { |
|
|
static let LineHeight: CGFloat = 0.0 |
|
|
} |
|
|
|
|
|
override var currentURL: URL? { |
|
|
get { |
|
|
return locationView.url as URL? |
|
|
} |
|
|
|
|
|
set(newURL) { |
|
|
locationView.url = newURL |
|
|
line.isHidden = newURL?.isAboutHomeURL ?? true |
|
|
pageOptionsButton.alpha = 0 |
|
|
} |
|
|
} |
|
|
|
|
|
let ghostyHeight = 54.0 |
|
|
let ghostyWidth = 54.0 |
|
|
|
|
|
@@ -55,11 +67,27 @@ class CliqzURLBar: URLBarView { |
|
|
return button |
|
|
}() |
|
|
|
|
|
lazy var pageOptionsButton: UIButton = { |
|
|
let pageOptionsButton = UIButton(frame: .zero) |
|
|
pageOptionsButton.setImage(UIImage.templateImageNamed("menu-More-Options"), for: .normal) |
|
|
pageOptionsButton.addTarget(self, action: #selector(SELDidPressPageOptionsButton), for: .touchUpInside) |
|
|
pageOptionsButton.isAccessibilityElement = true |
|
|
pageOptionsButton.imageView?.contentMode = .left |
|
|
pageOptionsButton.accessibilityIdentifier = "UrlBar.pageOptionsButton" |
|
|
pageOptionsButton.tintColor = UIColor.cliqzBluePrimary |
|
|
return pageOptionsButton |
|
|
}() |
|
|
|
|
|
@objc func SELdidClickGhosty(button: UIButton) { |
|
|
debugPrint("pressed ghosty") |
|
|
NotificationCenter.default.post(name: Notification.Name.GhosteryButtonPressed, object: self.currentURL?.absoluteString) |
|
|
} |
|
|
|
|
|
|
|
|
@objc func SELDidPressPageOptionsButton(button: UIButton) { |
|
|
self.delegate?.urlBarDidPressCliqzPageOptions(self, from: button) |
|
|
} |
|
|
|
|
|
override func commonInit() { |
|
|
super.commonInit() |
|
|
helper = CliqzTabToolbarHelper(toolbar: self) |
|
|
@@ -70,6 +98,9 @@ class CliqzURLBar: URLBarView { |
|
|
if ghosteryButton.superview == nil { |
|
|
addSubview(ghosteryButton) |
|
|
} |
|
|
if pageOptionsButton.superview == nil { |
|
|
addSubview(pageOptionsButton) |
|
|
} |
|
|
|
|
|
line.snp.makeConstraints { make in |
|
|
make.bottom.leading.trailing.equalTo(self) |
|
|
@@ -135,6 +166,12 @@ class CliqzURLBar: URLBarView { |
|
|
make.trailing.equalTo(self.safeArea.trailing)//.offset(-URLBarViewUX.Padding) |
|
|
} |
|
|
|
|
|
pageOptionsButton.snp.makeConstraints { (make) in |
|
|
make.size.equalTo(TabLocationViewUX.ButtonSize) |
|
|
make.centerY.equalTo(self) |
|
|
make.trailing.equalTo(self.ghosteryButton.snp.leading) |
|
|
} |
|
|
|
|
|
setStyle() |
|
|
} |
|
|
|
|
|
@@ -146,11 +183,17 @@ class CliqzURLBar: URLBarView { |
|
|
override func prepareOverlayAnimation() { |
|
|
super.prepareOverlayAnimation() |
|
|
bringSubview(toFront: ghosteryButton) |
|
|
bringSubview(toFront: pageOptionsButton) |
|
|
} |
|
|
|
|
|
override func transitionToOverlay(_ didCancel: Bool = false) { |
|
|
super.transitionToOverlay() |
|
|
ghosteryButton.alpha = inOverlayMode ? 0 : 1 |
|
|
if inOverlayMode { |
|
|
pageOptionsButton.alpha = 0 |
|
|
} else { |
|
|
pageOptionsButton.alpha = self.currentURL == nil ? 1 : 0 |
|
|
} |
|
|
} |
|
|
|
|
|
override func updateConstraints() { |
|
|
@@ -214,7 +257,7 @@ class CliqzURLBar: URLBarView { |
|
|
} |
|
|
|
|
|
override func tabLocationViewDidTapPageOptions(_ tabLocationView: TabLocationView, from button: UIButton) { |
|
|
self.delegate?.urlBarDidPressCliqzPageOptions(self, from: tabLocationView.pageOptionsButton) |
|
|
self.delegate?.urlBarDidPressCliqzPageOptions(self, from: button) |
|
|
} |
|
|
|
|
|
// MARK:- keyboard Accessory View |
|
|
|