Composables
Docs Login
Vela

Screen Scaffold

Jetpack Compose Component

Download
package com.composables.vela.components

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.BoxScope
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.luminance
import com.composables.systembars.SystemBarContent
import com.composables.systembars.SystemBars
import com.composables.vela.theme.ProvideContentColor
import com.composables.vela.theme.Theme
import com.composeunstyled.DialogHost

@Composable
fun ScreenScaffold(
    modifier: Modifier = Modifier,
    content: @Composable BoxScope.() -> Unit,
) {
    SystemBars(all = systemBarContentOn(Theme.colors.background))
    DialogHost(modifier.fillMaxSize()) {
        Box(Modifier.fillMaxSize().background(Theme.colors.background)) {
            ProvideContentColor(Theme.colors.onBackground) { content() }
        }
    }
}

private fun systemBarContentOn(background: Color): SystemBarContent =
    if (background.luminance() > 0.5f) SystemBarContent.Dark else SystemBarContent.Light

More components from Vela

by Alex Styl

Search screens and components

Screen flows

Screens

UI Elements

One Android lesson, every Wednesday

Building Android apps?

What Alex learned building Android apps for 14 years, so you don't have to. Reads in under a minute.

Join 3,500+ Android developers. Unsubscribe any time.

You're subscribed

The next lesson lands in on Wednesday.