Appearance tweaks
This commit is contained in:
@@ -402,8 +402,10 @@ class BrowserViewController: UIViewController
|
|||||||
toolbarController.urlBar.loadProgress = .error(error: loadError)
|
toolbarController.urlBar.loadProgress = .error(error: loadError)
|
||||||
} else if webView.estimatedProgress == 1.0 {
|
} else if webView.estimatedProgress == 1.0 {
|
||||||
toolbarController.urlBar.loadProgress = .complete
|
toolbarController.urlBar.loadProgress = .complete
|
||||||
} else {
|
} else if webView.isLoading {
|
||||||
toolbarController.urlBar.loadProgress = .loading(progress: webView.estimatedProgress)
|
toolbarController.urlBar.loadProgress = .loading(progress: webView.estimatedProgress)
|
||||||
|
} else {
|
||||||
|
toolbarController.urlBar.loadProgress = .idle
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ class ReliefButton: UIButton
|
|||||||
{
|
{
|
||||||
public var constrainedToSquare = true
|
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 shadowView = UIView(frame: .zero)
|
||||||
internal let backgroundView = GradientView(direction: .vertical, colors: ReliefButton.gradientColors(inverted: false, darkMode: false))
|
internal let backgroundView = GradientView(direction: .vertical, colors: ReliefButton.gradientColors(inverted: false, darkMode: false))
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ class TabView: UIControl
|
|||||||
|
|
||||||
addSubview(label)
|
addSubview(label)
|
||||||
label.text = "Tab View"
|
label.text = "Tab View"
|
||||||
label.font = .boldSystemFont(ofSize: 11.0)
|
label.font = .systemFont(ofSize: 11.0)
|
||||||
|
|
||||||
addSubview(closeButton)
|
addSubview(closeButton)
|
||||||
closeButton.setImage(UIImage(systemName: "xmark.square.fill"), for: .normal)
|
closeButton.setImage(UIImage(systemName: "xmark.square.fill"), for: .normal)
|
||||||
@@ -53,16 +53,16 @@ class TabView: UIControl
|
|||||||
let closeButtonPadding = CGFloat(5.0)
|
let closeButtonPadding = CGFloat(5.0)
|
||||||
let closeButtonSize = CGSize(width: bounds.height, height: bounds.height)
|
let closeButtonSize = CGSize(width: bounds.height, height: bounds.height)
|
||||||
closeButton.frame = CGRect(
|
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
|
width: closeButtonSize.width, height: closeButtonSize.height
|
||||||
)
|
)
|
||||||
|
|
||||||
var xOffset = insetBounds.minX
|
var xOffset = layoutMargins.left
|
||||||
imageView.frame = CGRect(
|
imageView.frame = CGRect(
|
||||||
x: xOffset, y: insetBounds.minY,
|
x: xOffset, y: insetBounds.minY,
|
||||||
width: insetBounds.height, height: insetBounds.height
|
width: insetBounds.height, height: insetBounds.height
|
||||||
)
|
)
|
||||||
xOffset += imageView.frame.width + 12.0
|
xOffset += imageView.frame.width + 8.0
|
||||||
|
|
||||||
label.frame = CGRect(
|
label.frame = CGRect(
|
||||||
x: xOffset, y: insetBounds.minY,
|
x: xOffset, y: insetBounds.minY,
|
||||||
@@ -80,6 +80,11 @@ class TabView: UIControl
|
|||||||
width: separatorWidth, height: bounds.height
|
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 {
|
if isTracking {
|
||||||
backgroundColor = .systemFill
|
backgroundColor = .systemFill
|
||||||
} else if active {
|
} else if active {
|
||||||
@@ -87,7 +92,7 @@ class TabView: UIControl
|
|||||||
if traitCollection.userInterfaceStyle == .light {
|
if traitCollection.userInterfaceStyle == .light {
|
||||||
return .secondarySystemGroupedBackground
|
return .secondarySystemGroupedBackground
|
||||||
} else {
|
} else {
|
||||||
return .secondarySystemFill
|
return .secondarySystemGroupedBackground
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
@@ -95,7 +100,7 @@ class TabView: UIControl
|
|||||||
if traitCollection.userInterfaceStyle == .light {
|
if traitCollection.userInterfaceStyle == .light {
|
||||||
return .secondarySystemFill
|
return .secondarySystemFill
|
||||||
} else {
|
} else {
|
||||||
return .secondarySystemGroupedBackground
|
return UIColor(white: 0.1, alpha: 1.0)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -292,7 +297,7 @@ class TabBarView: UIView
|
|||||||
tabView.frame = CGRect(
|
tabView.frame = CGRect(
|
||||||
x: xOffset,
|
x: xOffset,
|
||||||
y: tabContainerBounds.minY,
|
y: tabContainerBounds.minY,
|
||||||
width: tabView.collapsed ? 1.0 : tabWidth,
|
width: tabView.collapsed ? 0.0 : tabWidth,
|
||||||
height: tabContainerBounds.height
|
height: tabContainerBounds.height
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -118,9 +118,7 @@ class TitlebarView: UIView
|
|||||||
|
|
||||||
let edgePadding: CGFloat = 8.0
|
let edgePadding: CGFloat = 8.0
|
||||||
|
|
||||||
// Thought it would be cool to have a different style for regular, but eh.
|
securityIndicatorView.labelVisible = false
|
||||||
let securityLabelOnTrailingSide = false // (traitCollection.horizontalSizeClass == .regular)
|
|
||||||
securityIndicatorView.labelVisible = securityLabelOnTrailingSide
|
|
||||||
|
|
||||||
var securityIndicatorSize = showsSecurityIndicator ? securityIndicatorView.sizeThatFits(bounds.size) : .zero
|
var securityIndicatorSize = showsSecurityIndicator ? securityIndicatorView.sizeThatFits(bounds.size) : .zero
|
||||||
securityIndicatorSize.height = 10.0
|
securityIndicatorSize.height = 10.0
|
||||||
@@ -133,8 +131,6 @@ class TitlebarView: UIView
|
|||||||
|
|
||||||
if showsSecurityIndicator {
|
if showsSecurityIndicator {
|
||||||
securityIndicatorView.isHidden = false
|
securityIndicatorView.isHidden = false
|
||||||
|
|
||||||
if !securityLabelOnTrailingSide {
|
|
||||||
securityIndicatorView.frame = CGRect(
|
securityIndicatorView.frame = CGRect(
|
||||||
origin: CGPoint(x: edgePadding + layoutMargins.left, y: 0.0),
|
origin: CGPoint(x: edgePadding + layoutMargins.left, y: 0.0),
|
||||||
size: CGSize(width: securityIndicatorSize.height, height: securityIndicatorSize.height)
|
size: CGSize(width: securityIndicatorSize.height, height: securityIndicatorSize.height)
|
||||||
@@ -142,13 +138,6 @@ class TitlebarView: UIView
|
|||||||
|
|
||||||
// Scooch the title over a bit
|
// Scooch the title over a bit
|
||||||
titleLabelView.frame.origin.x = securityIndicatorView.frame.maxX + 4.0
|
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
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
securityIndicatorView.frame = securityIndicatorView.frame.centeredY(inRect: titleLabelView.frame)
|
securityIndicatorView.frame = securityIndicatorView.frame.centeredY(inRect: titleLabelView.frame)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ class ToolbarView: UIView
|
|||||||
|
|
||||||
override func sizeThatFits(_ size: CGSize) -> CGSize
|
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()
|
override func layoutSubviews()
|
||||||
|
|||||||
@@ -30,14 +30,39 @@ class URLBar: ReliefButton
|
|||||||
|
|
||||||
weak var delegate: URLBarDelegate?
|
weak var delegate: URLBarDelegate?
|
||||||
|
|
||||||
public enum LoadProgress {
|
public enum LoadProgress: Equatable {
|
||||||
|
case idle
|
||||||
case complete
|
case complete
|
||||||
case loading(progress: Double)
|
case loading(progress: Double)
|
||||||
case error(error: Error)
|
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 {
|
public var loadProgress: LoadProgress = .idle {
|
||||||
didSet { updateProgressIndicator() }
|
didSet {
|
||||||
|
if oldValue != loadProgress {
|
||||||
|
updateProgressIndicator()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override var isPointerInteractionEnabled: Bool {
|
override var isPointerInteractionEnabled: Bool {
|
||||||
@@ -70,8 +95,9 @@ class URLBar: ReliefButton
|
|||||||
textField.keyboardType = .webSearch
|
textField.keyboardType = .webSearch
|
||||||
textField.autocorrectionType = .no
|
textField.autocorrectionType = .no
|
||||||
textField.autocapitalizationType = .none
|
textField.autocapitalizationType = .none
|
||||||
textField.font = .systemFont(ofSize: 14.0)
|
textField.font = .systemFont(ofSize: 13.0)
|
||||||
textField.clearButtonMode = .whileEditing
|
textField.clearButtonMode = .whileEditing
|
||||||
|
textField.placeholder = "URL or search term"
|
||||||
textField.addAction(UIAction(handler: { [unowned self] _ in
|
textField.addAction(UIAction(handler: { [unowned self] _ in
|
||||||
// Mask view visibility is affected by editing state.
|
// Mask view visibility is affected by editing state.
|
||||||
self.layoutSubviews()
|
self.layoutSubviews()
|
||||||
@@ -129,7 +155,14 @@ class URLBar: ReliefButton
|
|||||||
|
|
||||||
UIView.animate(withDuration: 0.4) { [unowned self] in
|
UIView.animate(withDuration: 0.4) { [unowned self] in
|
||||||
switch self.loadProgress {
|
switch self.loadProgress {
|
||||||
|
case .idle:
|
||||||
|
self.refreshButton.isHidden = true
|
||||||
|
self.setErrorButtonAnimating(false)
|
||||||
|
self.progressIndicatorView.alpha = 0.0
|
||||||
|
self.progressIndicatorView.progress = 0.0
|
||||||
|
|
||||||
case .complete:
|
case .complete:
|
||||||
|
self.refreshButton.isHidden = false
|
||||||
self.refreshButton.setImage(self.refreshImage, for: .normal)
|
self.refreshButton.setImage(self.refreshImage, for: .normal)
|
||||||
self.progressIndicatorView.progress = 1.0
|
self.progressIndicatorView.progress = 1.0
|
||||||
self.progressIndicatorAnimating = true
|
self.progressIndicatorAnimating = true
|
||||||
@@ -142,11 +175,13 @@ class URLBar: ReliefButton
|
|||||||
}
|
}
|
||||||
|
|
||||||
case .loading(let progress):
|
case .loading(let progress):
|
||||||
|
self.refreshButton.isHidden = false
|
||||||
self.refreshButton.setImage(self.stopImage, for: .normal)
|
self.refreshButton.setImage(self.stopImage, for: .normal)
|
||||||
self.progressIndicatorView.progress = progress
|
self.progressIndicatorView.progress = progress
|
||||||
self.progressIndicatorView.alpha = 1.0
|
self.progressIndicatorView.alpha = 1.0
|
||||||
|
|
||||||
case .error(let error):
|
case .error(let error):
|
||||||
|
self.refreshButton.isHidden = false
|
||||||
self.setErrorButtonAnimating(true)
|
self.setErrorButtonAnimating(true)
|
||||||
self.progressIndicatorView.alpha = 0.0
|
self.progressIndicatorView.alpha = 0.0
|
||||||
self.progressIndicatorView.progress = 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)
|
documentSeparatorView.frame = documentSeparatorView.frame.insetBy(dx: 0.0, dy: 3.0)
|
||||||
|
|
||||||
// Text field
|
// Text field
|
||||||
let textFieldPadding: CGFloat = 5.0
|
let textFieldPadding: CGFloat = 6.0
|
||||||
let textFieldOrigin = CGPoint(x: documentButton.frame.maxX + textFieldPadding, y: 0.0)
|
let textFieldOrigin = CGPoint(x: documentButton.frame.maxX + textFieldPadding, y: 0.0)
|
||||||
textField.frame = CGRect(
|
textField.frame = CGRect(
|
||||||
origin: textFieldOrigin,
|
origin: textFieldOrigin,
|
||||||
|
|||||||
Reference in New Issue
Block a user