Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Presentation of multiple bottom sheets #35

Open
mohabbasi1213 opened this issue Jan 1, 2024 · 2 comments
Open

Presentation of multiple bottom sheets #35

mohabbasi1213 opened this issue Jan 1, 2024 · 2 comments
Labels
question Further information is requested

Comments

@mohabbasi1213
Copy link

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?

@mikhailmaslo
Copy link
Collaborator

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?

@mikhailmaslo mikhailmaslo added the question Further information is requested label Jan 6, 2024
@mohabbasi1213
Copy link
Author

mohabbasi1213 commented Jan 21, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants