-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support blueprint update animations in coordinator updates #274
Conversation
e53faa7
to
ea3cfe2
Compare
…lueprint-backed item content.
ea3cfe2
to
eda97ec
Compare
…-action * origin/main: [SwipeActions] Limit overscrolling to the right (#270)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this looks good other than a timer/race condition question
{ | ||
self.willDisplay_calls.append(view) | ||
self.willDisplay_calls.append(()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really understand what these arrays are doing, what's the purpose?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's for tracking the number of calls to the func during testing, so I can make sure the number of calls is right. It could also just be a counter since the type here is Void
, but I kept it like this since thats what the rest of the file does.
var new = self.currentProvider() | ||
|
||
update(&new) | ||
|
||
self.update(animated: animated, new) | ||
if delay > 0 { | ||
Timer.scheduledTimer(withTimeInterval: delay, repeats: false) { _ in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this timer need to be retained? I can never remember. Separately, does it need to be canceled if another update happened? e.g., what if update A happened with a 1s delay, then B with 0.3s, would be occur and then get reverted back to A?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't need to be retained, it gets retained by the Runloop itself, and then fires and then is deallocated.
I didn't figure any queueing / collapsing of info was useful here, since it's a lot of extra behaviour, and might not be expected.
Good point about the disparate delays – I guess I should update the backing value immediately; OR alternatively, not pull the current value until the block executes (that actually seems better?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Going to go with the latter:
public func update(
animation: ViewAnimation = .default,
after delay: TimeInterval = 0,
update : @escaping (inout Item<Content>) -> ()
) {
if delay > 0 {
Timer.scheduledTimer(withTimeInterval: delay, repeats: false) { _ in
var new = self.currentProvider()
update(&new)
self.updateCallback(new, animation)
}
} else {
var new = self.currentProvider()
update(&new)
self.updateCallback(new, animation)
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
17e3b5a
to
5aa80f6
Compare
This PR updates the somewhat experimental
ItemContentCoordinator
APIs to properly support animations for Blueprint-based cells. It has a few changes:ViewAnimation
type across both scrolling and item content updates, by renamingScrollAnimation
toViewAnimation
.View
/view
from theItemContentCoordinator
– exposing this makes no sense for blueprint cells, and also, all updates to the item content should be done through apply updates, not through manually poking the view.