Skip to content

Compose

qiibeta edited this page Aug 16, 2024 · 2 revisions

To use Compose in a Scene, return a ComposeView in the onCreateView() lifecycle method of your Scene. ComposeView has a setContent() method where you can provide a composable function.

class NewFeatureScene : Scene() {
    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup,
        savedInstanceState: Bundle?
    ): View {
        return ComposeView(requireSceneContext()).apply {
            setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed)
            setContent {
                NewFeatureScreen()
            }
        }
    }
}