Page MenuHomePhabricator

[Compose][Spike] Discover the difference of using BottomSheetFragment and ModalBottomSheet
Closed, ResolvedPublic1 Estimated Story Points

Description

The bottomsheet that the app is currently using is from the BottomSheetFragment.

The Jetpack Compose also has its own bottomsheet component called ModalBottomSheet.
https://developer.android.com/develop/ui/compose/components/bottom-sheets

This ticket is to see the pros and cons of using ModalBottomSheet v.s. BottomSheetFragment

Event Timeline

After doing some research I found out that the ModalBottomSheet and BottomSheetFragment offer similar functionality and can both be used. In terms of styling ModalBottomSheet offers more options. However, with the current XML-based bottom sheet implementation, if we switch to Jetpack Compose, we face the challenge of how to display the fragment. Right now, we're using ExclusiveBottomSheetPresenter with its show function to display the bottom sheet.

If we switch to ModalBottomSheet, we’d either need to modify the XML or wait for the screens to be fully converted to Jetpack Compose. Otherwise for every ModalBottomSheet we would need to create a fragment and then add a container on XML in order to show this. Instead, we can continue using the ExtendedBottomSheetDialogFragment and replace the XML layouts with ComposeView.

I believe the best approach is to use ModalBottomSheet once the entire screen is in Jetpack Compose or for newer screens that will only have jetpack compose. This way, the component will work smoothly without needing to add extra logic to the existing implementation.