Appearance tweaks

This commit is contained in:
James Magahern
2021-07-20 19:17:04 -07:00
parent 777b079f5e
commit 864260bad3
6 changed files with 65 additions and 34 deletions

View File

@@ -118,9 +118,7 @@ class TitlebarView: UIView
let edgePadding: CGFloat = 8.0
// Thought it would be cool to have a different style for regular, but eh.
let securityLabelOnTrailingSide = false // (traitCollection.horizontalSizeClass == .regular)
securityIndicatorView.labelVisible = securityLabelOnTrailingSide
securityIndicatorView.labelVisible = false
var securityIndicatorSize = showsSecurityIndicator ? securityIndicatorView.sizeThatFits(bounds.size) : .zero
securityIndicatorSize.height = 10.0
@@ -133,23 +131,14 @@ class TitlebarView: UIView
if showsSecurityIndicator {
securityIndicatorView.isHidden = false
securityIndicatorView.frame = CGRect(
origin: CGPoint(x: edgePadding + layoutMargins.left, y: 0.0),
size: CGSize(width: securityIndicatorSize.height, height: securityIndicatorSize.height)
)
if !securityLabelOnTrailingSide {
securityIndicatorView.frame = CGRect(
origin: CGPoint(x: edgePadding + layoutMargins.left, y: 0.0),
size: CGSize(width: securityIndicatorSize.height, height: securityIndicatorSize.height)
)
// Scooch the title over a bit
titleLabelView.frame.origin.x = securityIndicatorView.frame.maxX + 4.0
} else {
securityIndicatorView.frame = CGRect(
x: bounds.width - layoutMargins.right - securityIndicatorSize.width, y: 0.0,
width: securityIndicatorSize.width,
height: securityIndicatorSize.height
)
}
// Scooch the title over a bit
titleLabelView.frame.origin.x = securityIndicatorView.frame.maxX + 4.0
securityIndicatorView.frame = securityIndicatorView.frame.centeredY(inRect: titleLabelView.frame)
} else {
securityIndicatorView.isHidden = true

View File

@@ -50,7 +50,7 @@ class ToolbarView: UIView
override func sizeThatFits(_ size: CGSize) -> CGSize
{
return CGSize(width: size.width, height: 44.0)
return CGSize(width: size.width, height: 42.0)
}
override func layoutSubviews()

View File

@@ -30,14 +30,39 @@ class URLBar: ReliefButton
weak var delegate: URLBarDelegate?
public enum LoadProgress {
public enum LoadProgress: Equatable {
case idle
case complete
case loading(progress: Double)
case error(error: Error)
public static func == (lhs: URLBar.LoadProgress, rhs: URLBar.LoadProgress) -> Bool {
switch lhs {
case .idle:
if case .idle = rhs { return true }
else { return false }
case .complete:
if case .complete = rhs { return true }
else { return false }
case let .loading(progress: mine):
if case .loading(progress: let theirs) = rhs {
return mine == theirs
} else {
return false
}
case .error:
if case .error(error: _) = rhs { return true }
else { return false }
}
}
}
public var loadProgress: LoadProgress = .complete {
didSet { updateProgressIndicator() }
public var loadProgress: LoadProgress = .idle {
didSet {
if oldValue != loadProgress {
updateProgressIndicator()
}
}
}
override var isPointerInteractionEnabled: Bool {
@@ -70,8 +95,9 @@ class URLBar: ReliefButton
textField.keyboardType = .webSearch
textField.autocorrectionType = .no
textField.autocapitalizationType = .none
textField.font = .systemFont(ofSize: 14.0)
textField.font = .systemFont(ofSize: 13.0)
textField.clearButtonMode = .whileEditing
textField.placeholder = "URL or search term"
textField.addAction(UIAction(handler: { [unowned self] _ in
// Mask view visibility is affected by editing state.
self.layoutSubviews()
@@ -129,7 +155,14 @@ class URLBar: ReliefButton
UIView.animate(withDuration: 0.4) { [unowned self] in
switch self.loadProgress {
case .idle:
self.refreshButton.isHidden = true
self.setErrorButtonAnimating(false)
self.progressIndicatorView.alpha = 0.0
self.progressIndicatorView.progress = 0.0
case .complete:
self.refreshButton.isHidden = false
self.refreshButton.setImage(self.refreshImage, for: .normal)
self.progressIndicatorView.progress = 1.0
self.progressIndicatorAnimating = true
@@ -142,11 +175,13 @@ class URLBar: ReliefButton
}
case .loading(let progress):
self.refreshButton.isHidden = false
self.refreshButton.setImage(self.stopImage, for: .normal)
self.progressIndicatorView.progress = progress
self.progressIndicatorView.alpha = 1.0
case .error(let error):
self.refreshButton.isHidden = false
self.setErrorButtonAnimating(true)
self.progressIndicatorView.alpha = 0.0
self.progressIndicatorView.progress = 0.0
@@ -236,7 +271,7 @@ class URLBar: ReliefButton
documentSeparatorView.frame = documentSeparatorView.frame.insetBy(dx: 0.0, dy: 3.0)
// Text field
let textFieldPadding: CGFloat = 5.0
let textFieldPadding: CGFloat = 6.0
let textFieldOrigin = CGPoint(x: documentButton.frame.maxX + textFieldPadding, y: 0.0)
textField.frame = CGRect(
origin: textFieldOrigin,