Impossible to set a state that push a view then a modal or another push 🤔 #1099
-
Hello everyone! For debugging purpose, marketing screenshots or deeplinking features, I would like to set my route state deep in my view hierarchy in one shot but some cases doesn't work:
I'm afraid, this is a "bug" in SwiftUI that have limitation by using UIKit under the hood since double modal is ok. I would like to be able to set the state in a reducer for deeplinking like this: case .pushedAndShowModalButtonTapped:
state.route = .details(Pushed1State(route: .modal(Modal1State())))
return .none Or directly as an initial state for debugging or screenshoting like this: AppView(store: .init(
initialState: .init(route: .details(Pushed1State(route: .modal(Modal1State())))),
reducer: appReducer.debug(),
environment: ())
) In some cases, I get errors like this but not always:
So I tried to disable animations like this, but with no success: Button("Pushed View 1 and Show Modal 1") {
viewStore.send(.pushedAndShowModalButtonTapped, animation: .none)
} If anyone have a suggestion, I'll be very thankful ! 🙏 Here is a sample code that demonstrate this with minimum code: |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
I've maybe found my answer in johnpatrickmorgan repo: That he mentions in the #1006 discussion about deeplinking. I'll try to refactor my sample code with TCACoordinators to see if it fixes my issues... |
Beta Was this translation helpful? Give feedback.
-
Ok, I confirm that TCACoordinator is fixing my issue partly :
I've added an Here is the final sample code updated: TCAMultiModalStateWithTCACoordinator.zip Hope that Apple will fix this "bug" in a future iOS release 🤞 |
Beta Was this translation helpful? Give feedback.
Ok, I confirm that TCACoordinator is fixing my issue partly :
I've added an
var initialAction: CoordinatorAction?
to myCoordinatorState
so that I can set a special action that will do all the push/present ScreenActions needed to go where I need using therouteWithDelaysIfUnsupported
effect if necessary. Then I run this action inonAppear
of myCoordinatorView
if not nil. It has the drawbacks to pollute my production code but at least it can be con…