Presentation of multiple bottom sheets
I am facing issues with the presentation of multiple bottom sheets, particularly when one is triggered before the other has finished its presentation,
One of scenarios as an example: LoadingBottomSheet is presented. An error response is received from server and ErrorBottomSheet should be presented. So, Loading dismiss is called and it gets dismissed but the EroorBottomSheet is not presented because: Attempt to present <ErrorBottomSheet: 0x113e1e2e0> while a presentation is in progress.
Is there a solution for this in the current version like creating a queue when calling present or not?
Hello, thank you for you question!
So, Loading dismiss is called and it gets dismissed but the EroorBottomSheet is not presented because
If you're triggering this action by yourself then I suppose you need to sync presentation logic by yourself. As I understand it would be the same (the same error) as if you try to dismiss and present at the same time some view controller modally and it's not directly related to BottomSheet
I would try to invoke the next screen when completion handler is invoked. If it works, you can indeed try to implement queue like structure to dismiss / present view controller in a sequential manner
What do you think?
Thank you. You're right about creating a queue. As you mentioned, I need a completion handler. the default modal present method has completion like this: func present(_ viewControllerToPresent: UIViewController, animated flag: Bool, completion: (() -> Void)? = nil)
however the presentBottomSheet in the library lacks it. func presentBottomSheet( viewController: UIViewController, configuration: BottomSheetConfiguration, canBeDismissed: @escaping (() -> Bool) = { true }, dismissCompletion: (() -> Void)? = nil )
Please let me know if i'm not right or i can create queue other way.