Skip to content

Commit e768b44

Browse files
authored
animate placeholder to graph on goalvc (#609)
## Summary Uses UIView.transition(with:...) when transitioning to the graph image (on the goalvc). The sudden swap of one image for the other was rather abrupt. ## Validation ran app in simulator fixes #608 and is not quite as overreaching as #513
1 parent 332558d commit e768b44

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

BeeSwift/Components/GoalImageView.swift

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,24 +61,35 @@ class GoalImageView : UIView {
6161
object: nil,
6262
queue: OperationQueue.main
6363
) { [weak self] _ in
64-
self?.refresh()
64+
DispatchQueue.main.async {
65+
self?.refresh()
66+
}
6567
}
66-
6768
refresh()
6869
}
6970

71+
@MainActor
7072
private func clearGoalGraph() {
7173
imageView.image = UIImage(named: "GraphPlaceholder")
7274
currentlyShowingGraph = false
7375
beeLemniscateView.isHidden = true
7476
}
7577

78+
@MainActor
7679
private func showGraphImage(image: UIImage) {
77-
imageView.image = image
78-
currentlyShowingGraph = true
79-
beeLemniscateView.isHidden = !(goal?.queued ?? false)
80+
UIView.transition(with: imageView,
81+
duration: 0.8,
82+
options: .transitionCrossDissolve,
83+
animations: { [weak self] in
84+
self?.imageView.image = image
85+
self?.beeLemniscateView.isHidden = self?.goal == nil || self?.goal?.queued == false
86+
87+
}) { [weak self] _ in
88+
self?.currentlyShowingGraph = true
89+
}
8090
}
8191

92+
@MainActor
8293
private func refresh() {
8394
// Invalidate the download token, meaning that any queued download callbacks
8495
// will no-op. This avoids race conditions with downloads finishing out of order.

0 commit comments

Comments
 (0)