When the modal prop is false, set the largestUndimmedDetentIdentifier to the expanded detent. Then iOS allows the scene behind to be interacted with while the sheet is open.
<BottomSheet modal={false}>
The tricky part is that iOS allows navigation (back and forward) without closing the sheet. From the Navigation router point of view the sheet lives with the scene so had to close it when navigating. Also decided to reopen the sheet when navigating back to the scene. Kept dismissed separate from selectedDetent. When navigating away retained the selectedDetent but set dismissed to true. Then set dismissed to false when navigating back. It helped that, when programmatically dismissing, iOS doesn't call presentationControllerDidDismiss so detent isn't changed to 'hidden'.
Even dismissing sheet on navigating is tricky. To animate the dismissal had to keep the scene in memory - it's popped when deallocated so the sheet contents disappear. Timing is hard too. Can't just dismiss in didShowViewController because it's too late. If a sheet is shown on the next scene immediately then this happens first and so dismissing in didShow would close this new sheet too. So had to dismiss when presenting a sheet and in didShow (if not presenting) - and then only present the new sheet when the dismiss completes. Also can't just clear the scene in memory in both dismissViewControllerAnimated completions - because if call dismissViewControllerAnimated while there's one already running then the completion fires immediately and so the sheet contents disappear. Had to make sure only the first dismissViewControllerAnimated clears the scene on completion.
Also supported opening multiple sheets, as long as they're opened from each other. So the sheets must be nested inside each other.
Will think about keeping sheet open across scenes if there's demand.
When the
modal
prop is false, set the largestUndimmedDetentIdentifier to the expanded detent. Then iOS allows the scene behind to be interacted with while the sheet is open.The tricky part is that iOS allows navigation (back and forward) without closing the sheet. From the Navigation router point of view the sheet lives with the scene so had to close it when navigating. Also decided to reopen the sheet when navigating back to the scene. Kept
dismissed
separate fromselectedDetent
. When navigating away retained theselectedDetent
but setdismissed
to true. Then setdismissed
to false when navigating back. It helped that, when programmatically dismissing, iOS doesn't callpresentationControllerDidDismiss
so detent isn't changed to 'hidden'.Even dismissing sheet on navigating is tricky. To animate the dismissal had to keep the scene in memory - it's popped when deallocated so the sheet contents disappear. Timing is hard too. Can't just dismiss in
didShowViewController
because it's too late. If a sheet is shown on the next scene immediately then this happens first and so dismissing indidShow
would close this new sheet too. So had to dismiss when presenting a sheet and indidShow
(if not presenting) - and then only present the new sheet when the dismiss completes. Also can't just clear the scene in memory in bothdismissViewControllerAnimated
completions - because if calldismissViewControllerAnimated
while there's one already running then the completion fires immediately and so the sheet contents disappear. Had to make sure only the firstdismissViewControllerAnimated
clears the scene on completion.Also supported opening multiple sheets, as long as they're opened from each other. So the sheets must be nested inside each other.
Will think about keeping sheet open across scenes if there's demand.