URLBar shouldn't show cancel button on iPad, visual tweaks
This commit is contained in:
@@ -22,6 +22,8 @@ class TitlebarView: UIView
|
||||
titleLabelView.layer.shadowRadius = 0.0
|
||||
titleLabelView.layer.shadowOffset = CGSize(width: 0.0, height: 2.0)
|
||||
titleLabelView.font = UIFont.boldSystemFont(ofSize: 12.0)
|
||||
|
||||
backgroundImageView.alpha = 0.98
|
||||
}
|
||||
|
||||
private func backgroundImageForSize(_ size: CGSize) -> UIImage? {
|
||||
|
||||
@@ -98,9 +98,10 @@ class ToolbarView: UIView
|
||||
|
||||
// Cancel button
|
||||
let urlBarPadding: CGFloat = 8.0
|
||||
let cancelButtonSize = cancelButton.sizeThatFits(containerView.bounds.size)
|
||||
var cancelButtonSize = cancelButton.sizeThatFits(containerView.bounds.size)
|
||||
cancelButtonSize.width += (urlBarPadding * 2)
|
||||
cancelButton.frame = CGRect(origin: CGPoint(x: (containerView.bounds.maxX - cancelButtonSize.width), y: 0),
|
||||
size: CGSize(width: cancelButtonSize.width, height: containerView.bounds.height))
|
||||
size: CGSize(width: cancelButtonSize.width + urlBarPadding, height: containerView.bounds.height))
|
||||
|
||||
// Leading toolbar buttons
|
||||
if leadingButtonsView.numberOfButtonViews > 0 {
|
||||
@@ -189,9 +190,11 @@ class ToolbarViewController: UIViewController
|
||||
forwardButton.setImage(UIImage(systemName: "chevron.right"), for: .normal)
|
||||
|
||||
let toolbarAnimationDuration: TimeInterval = 0.3
|
||||
urlBar.textField.addAction(.init(handler: { [toolbarView, urlBar] _ in
|
||||
UIView.animate(withDuration: toolbarAnimationDuration) {
|
||||
toolbarView.cancelButtonVisible = urlBar.textField.isFirstResponder
|
||||
urlBar.textField.addAction(.init(handler: { [traitCollection, toolbarView, urlBar] _ in
|
||||
if traitCollection.horizontalSizeClass == .compact {
|
||||
UIView.animate(withDuration: toolbarAnimationDuration) {
|
||||
toolbarView.cancelButtonVisible = urlBar.textField.isFirstResponder
|
||||
}
|
||||
}
|
||||
}), for: [ .editingDidBegin, .editingDidEnd ])
|
||||
|
||||
|
||||
@@ -52,6 +52,10 @@ class URLBar: UIView
|
||||
textField.font = .systemFont(ofSize: 14.0)
|
||||
textField.clearingBehavior = .clearOnInsertionAndShowSelectionTint
|
||||
textField.clearButtonMode = .whileEditing
|
||||
textField.addAction(UIAction(handler: { [unowned self] _ in
|
||||
// Mask view visibility is affected by editing state.
|
||||
self.layoutSubviews()
|
||||
}), for: [ .editingDidBegin, .editingDidEnd ])
|
||||
addSubview(textField)
|
||||
|
||||
textField.addAction(.init(handler: { [textField, refreshButton] _ in
|
||||
|
||||
Reference in New Issue
Block a user