How to animate the dismissal of an IfLetStore view #953
-
Take an example of the My question is: how to animate the dismissal? I have tried:
Button("Dismiss") {
- viewStore.send(.dismissButtonTapped)
+ viewStore.send(.dismissButtonTapped, animation: .easeInOut)
}
let factPromptReducer = Reducer<FactPromptState, FactPromptAction, FactPromptEnvironment> { state, action, environment in
switch action {
case .dismissButtonTapped:
return .none
+ .receive(on: environment.mainQueue.animation(.easeInOut))
+ .eraseToEffect()
case .getAnotherFactButtonTapped:
case .factPrompt(.dismissButtonTapped):
state.factPrompt = nil
return .none
+ .receive(on: environment.mainQueue.animation(.easeInOut))
+ .eraseToEffect()
+ withAnimation(.easeInOut) {
IfLetStore(
self.store.scope(
state: \.factPrompt,
action: AppAction.factPrompt
),
then: FactPrompt.init(store:)
)
+ } Unfortunately, none of them above works. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
Hmm this is actually something that might be able to be fixed at a library level... ZStack {
IfLetStore(
self.store.scope(
state: \.factPrompt,
action: AppAction.factPrompt
),
then: FactPrompt.init(store:)
)
} then Let me know how you go. |
Beta Was this translation helpful? Give feedback.
-
After some thinking I still think the extra work for the animation to work (i.e. |
Beta Was this translation helpful? Give feedback.
Hmm this is actually something that might be able to be fixed at a library level...
I've worked around it a few different ways before, but the simplest is probably to wrap
IfLetStore
in aZStack
then
viewStore.send(.dismissButtonTapped, animation: .easeInOut)
should work.Let me know how you go.