Stop/reload button
This commit is contained in:
@@ -24,6 +24,9 @@ class URLBar: UIView
|
||||
private let backgroundView = UIVisualEffectView(effect: UIBlurEffect(style: .systemThickMaterial))
|
||||
private let progressIndicatorView = ProgressIndicatorView()
|
||||
|
||||
private let refreshImage = UIImage(systemName: "arrow.clockwise")
|
||||
private let stopImage = UIImage(systemName: "xmark")
|
||||
|
||||
convenience init() {
|
||||
self.init(frame: .zero)
|
||||
|
||||
@@ -48,7 +51,7 @@ class URLBar: UIView
|
||||
addSubview(textField)
|
||||
|
||||
refreshButton.tintColor = .secondaryLabel
|
||||
refreshButton.setImage(UIImage(systemName: "arrow.clockwise"), for: .normal)
|
||||
refreshButton.setImage(refreshImage, for: .normal)
|
||||
addSubview(refreshButton)
|
||||
}
|
||||
|
||||
@@ -56,17 +59,19 @@ class URLBar: UIView
|
||||
UIView.animate(withDuration: 0.4) {
|
||||
switch self.loadProgress {
|
||||
case .complete:
|
||||
self.refreshButton.setImage(self.refreshImage, for: .normal)
|
||||
self.progressIndicatorView.progress = 1.0
|
||||
self.progressIndicatorView.alpha = 0.0
|
||||
UIView.animate(withDuration: 0.5, delay: 0.5, options: AnimationOptions()) {
|
||||
self.progressIndicatorView.alpha = 0.0
|
||||
} completion: { _ in
|
||||
// Reset back to zero
|
||||
self.progressIndicatorView.progress = 0.0
|
||||
}
|
||||
case .loading(let progress):
|
||||
self.refreshButton.setImage(self.stopImage, for: .normal)
|
||||
self.progressIndicatorView.progress = progress
|
||||
self.progressIndicatorView.alpha = 1.0
|
||||
}
|
||||
} completion: { _ in
|
||||
if case LoadProgress.complete = self.loadProgress {
|
||||
// Reset back to zero
|
||||
self.progressIndicatorView.progress = 0.0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user