Open kristofkalai opened 8 months ago
You can you use implicit animations to animate changes. With your example:
struct AsyncBindingView: View {
@AsyncBinding private var color: Color = .red
@StateObject private var viewModel = ViewModel()
var body: some View {
RectangleView(color: color)
.bind {
viewModel.colorSequence.assign(to: $color)
}
.animation(.default, value: color)
.animation(.default, value: $color.hasError)
}
}
Does having support for explicit animations inside the binding block have any advantages?
Can implicit animation support reacting to the completion of the animation? If not, then explicit animations can be the first step to this direction (although I'm not sure the correct way of handling this, i.e. handling animation per state update or by providing a value at initialization)
Problem
Currently
AsyncBinding
cannot be used if theState
change needs to be animated.Feature Request
To broaden the usage of
AsyncBinding
, animation of the state change definitely needs to be supported. We kindly request the implementation of this feature.Value to the community
This library presents a promising approach to connect the async world with the SwiftUI framework. Therefore, enabling animations for updating an
AsyncBinding
value could be the next step in its evolution.Example
Let's say we have a basic
View
, that shows a simpleColor
:In SwiftUI, this is a basic approach to animate the
color
of theView
:However, if I want to implement such a way that the colors are coming from somewhere else, like this:
Then it works, but only without animation. Animations cannot be enabled currently.
I understand the limitation's technical side, but if we can, it would be great to add animation support for this library.