Appearance tweaks
This commit is contained in:
@@ -402,8 +402,10 @@ class BrowserViewController: UIViewController
|
||||
toolbarController.urlBar.loadProgress = .error(error: loadError)
|
||||
} else if webView.estimatedProgress == 1.0 {
|
||||
toolbarController.urlBar.loadProgress = .complete
|
||||
} else {
|
||||
} else if webView.isLoading {
|
||||
toolbarController.urlBar.loadProgress = .loading(progress: webView.estimatedProgress)
|
||||
} else {
|
||||
toolbarController.urlBar.loadProgress = .idle
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ class ReliefButton: UIButton
|
||||
{
|
||||
public var constrainedToSquare = true
|
||||
|
||||
internal var cornerRadius = CGFloat(8.0) { didSet { setNeedsLayout() } }
|
||||
internal var cornerRadius = CGFloat(6.0) { didSet { setNeedsLayout() } }
|
||||
internal let shadowView = UIView(frame: .zero)
|
||||
internal let backgroundView = GradientView(direction: .vertical, colors: ReliefButton.gradientColors(inverted: false, darkMode: false))
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ class TabView: UIControl
|
||||
|
||||
addSubview(label)
|
||||
label.text = "Tab View"
|
||||
label.font = .boldSystemFont(ofSize: 11.0)
|
||||
label.font = .systemFont(ofSize: 11.0)
|
||||
|
||||
addSubview(closeButton)
|
||||
closeButton.setImage(UIImage(systemName: "xmark.square.fill"), for: .normal)
|
||||
@@ -53,16 +53,16 @@ class TabView: UIControl
|
||||
let closeButtonPadding = CGFloat(5.0)
|
||||
let closeButtonSize = CGSize(width: bounds.height, height: bounds.height)
|
||||
closeButton.frame = CGRect(
|
||||
x: insetBounds.width - closeButtonSize.height, y: 0.0,
|
||||
x: (insetBounds.width - closeButton.imageView!.image!.size.height).rounded(), y: 0.0,
|
||||
width: closeButtonSize.width, height: closeButtonSize.height
|
||||
)
|
||||
|
||||
var xOffset = insetBounds.minX
|
||||
var xOffset = layoutMargins.left
|
||||
imageView.frame = CGRect(
|
||||
x: xOffset, y: insetBounds.minY,
|
||||
width: insetBounds.height, height: insetBounds.height
|
||||
)
|
||||
xOffset += imageView.frame.width + 12.0
|
||||
xOffset += imageView.frame.width + 8.0
|
||||
|
||||
label.frame = CGRect(
|
||||
x: xOffset, y: insetBounds.minY,
|
||||
@@ -80,6 +80,11 @@ class TabView: UIControl
|
||||
width: separatorWidth, height: bounds.height
|
||||
)
|
||||
|
||||
let alphaMod = !active ? 0 : 1.0
|
||||
label.alpha = CGFloat.maximum(alphaMod, 0.4)
|
||||
imageView.alpha = CGFloat.maximum(alphaMod, 0.4)
|
||||
closeButton.alpha = CGFloat.maximum(alphaMod, 0.5)
|
||||
|
||||
if isTracking {
|
||||
backgroundColor = .systemFill
|
||||
} else if active {
|
||||
@@ -87,7 +92,7 @@ class TabView: UIControl
|
||||
if traitCollection.userInterfaceStyle == .light {
|
||||
return .secondarySystemGroupedBackground
|
||||
} else {
|
||||
return .secondarySystemFill
|
||||
return .secondarySystemGroupedBackground
|
||||
}
|
||||
})
|
||||
} else {
|
||||
@@ -95,7 +100,7 @@ class TabView: UIControl
|
||||
if traitCollection.userInterfaceStyle == .light {
|
||||
return .secondarySystemFill
|
||||
} else {
|
||||
return .secondarySystemGroupedBackground
|
||||
return UIColor(white: 0.1, alpha: 1.0)
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -292,7 +297,7 @@ class TabBarView: UIView
|
||||
tabView.frame = CGRect(
|
||||
x: xOffset,
|
||||
y: tabContainerBounds.minY,
|
||||
width: tabView.collapsed ? 1.0 : tabWidth,
|
||||
width: tabView.collapsed ? 0.0 : tabWidth,
|
||||
height: tabContainerBounds.height
|
||||
)
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user