-
Notifications
You must be signed in to change notification settings - Fork 86
Description
Description
I am implementing a button in a large scrollview LazyVStack that contains a button similar to a heart / like button for content.
I'm not sure if this is a Rive issue or an understanding issue on my part.
When the user taps the button, it will toggle state. Which seems to be working.
The issue is happens upon view loading, it does not seem to initialize in the proper state.
Provide a Repro
LazyVStack {
RiveLikeButtonView(fileName: fileName, text: "100", isLiked: isLiked) {
toggle()
}.id(1)
RiveLikeButtonView(fileName: fileName, text: "100", isLiked: isLiked) {
toggle()
}.id(2)
RiveLikeButtonView(fileName: fileName, text: "100", isLiked: isLiked) {
toggle()
}.id(3)
///.... a bunch of times to make it render off screen
}
Not working:
riveViewModel.view()
.onAppear {
print("on appear: (isLiked)")
// riveViewModel.setInput("hasLiked", value: isLiked)
// riveViewModel.reset()
riveViewModel.setInput("hasLiked", value: isLiked)
}
Working: but not exactly sure why?
riveViewModel.view()
.onAppear {
print("on appear: (isLiked)")
riveViewModel.setInput("hasLiked", value: isLiked)
riveViewModel.reset()
riveViewModel.setInput("hasLiked", value: isLiked)
}
Expected behavior
The state of the input for hasLiked to be reflected in the animation state machine.
Screenshots
actual: icons don't start in the proper state:
expected: icons in the proper state:
Device & Versions (please complete the following information)
- Device: ios simulator + live devices
- iOS version ios 17, 18 +