Open Bug 1890796 Opened 11 months ago Updated 2 months ago

Add an abstract ComposeViewBottomSheetFragment

Categories

(Fenix :: Design System and Theming, task, P3)

All
Android
task

Tracking

(Not tracked)

ASSIGNED

People

(Reporter: gl, Assigned: gl)

References

(Blocks 1 open bug)

Details

(Whiteboard: [fxdroid])

Discussed in https://phabricator.services.mozilla.com/D206791#7108663

The task is to implement a reusable abstract ComposeViewBottomSheetFragment that can be used for all our compose bottom sheet fragment. The benefit here is that we will a common view with the correct composition strategy set so that other developers will not have to worry about which composition strategy to use.

abstract class ComposeViewBottomSheetFragment : BottomSheetDialogFragment() {

    final override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?,
    ): View = ComposeView(requireContext()).apply {
        setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed)
        setContent {
            content()
        }
    }

    abstract fun content(): @Composable () -> Unit
}

class MenuBottomSheetFragment : ComposeViewBottomSheetFragment() {
    override fun content(): @Composable () -> Unit = {
        // Composable content
    }
}
Whiteboard: [fxdroid]
Blocks: menu-redesign-followup
No longer blocks: menu-redesign
Severity: -- → N/A

The Bugbug bot thinks this bug should belong to the 'Fenix::Design System and Theming' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Component: General → Design System and Theming
You need to log in before you can comment on or make changes to this bug.