Skip to content

Screen UI Providers

Andrés Pedraza Míguez edited this page Dec 6, 2025 · 4 revisions

Screen UI Providers

The ScreenUiProvider pattern is a mechanism used to decouple the "Chrome" of a screen (TopAppBar, FloatingActionButton) from the screen's content and the main navigation host.

The Problem

In a modular app, the MainScreen (which holds the Scaffold) doesn't know about specific screens inside feature modules. We wanted to avoid a monolithic when(route) statement in MainScreen to determine which Title or FAB to show.

The Solution

We define an interface ScreenUiProvider in :core:ui. Each Feature module implements this interface for its screens if they need a TopBar or FAB.

1. The Interface

interface ScreenUiProvider {
    val route: String
    val topBar: (@Composable () -> Unit)? get() = null
    val fab: (@Composable () -> Unit)? get() = null
}

Clone this wiki locally