SwiftUI implementation of Compose Children widget #21
plusmobileapps
started this conversation in
Show and tell
Replies: 1 comment 1 reply
-
Thanks! I am also still learning iOS dev, this may be useful for the community. One thing I can note is that instead of the class ChildAnimationHelper<T : Any>(
private val routerState: Value<RouterState<*, T>>,
// ...
) : Value<List<AnimatedChildBloc>> {
// Implementation here
} I also have plans to play with SwiftUI animations at some point. Will provide updates here as well. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Posting new part of this old discussion here since the fork.
The iOS todo sample uses the SwiftUI
transition()
API for adding/removing the second view in the router into view of the user, however if a third screen is added using a similar approach the animation looks wonky with the second screen leaving to the right side (trailing) while the new screen is also entering from the right. This wasn't an issue on a compose project because of the compose extensions that exist, however with Swift not being able to publish a companion library that leads to copy paste type of solutions. So I would like to share a solution I have come up with that might be a little hacky but accomplished the following slide animation in my project, hoping this helps someone else with an iOS project and open to suggestions if anybody has more experience with SwiftUI to solve this problem.So for this example, the following
RootBloc
will be used:The model for the animated router will have an enum to indicate animation direction and the type of view in the stack it is.
The
RootBlocImpl
will now implement the logic for this animated router by tracking the previously active child/backstack and will determine based off the new router state to determine the values for theAnimatedChildBloc
.Finally in SwiftUI code, you can create a
RouterView
that takes in theanimatedRouter
state.Still learning Swift, so open to suggestions to improve this as I'm sure there are some optimizations that could be made after views have finished animating.
Beta Was this translation helpful? Give feedback.
All reactions