AppScaffold

Functions summary

Unit
@Composable
AppScaffold(
    modifier: Modifier,
    timeText: @Composable () -> Unit,
    containerColor: Color,
    contentColor: Color,
    content: @Composable BoxScope.() -> Unit
)

AppScaffold is one of the Wear Material3 scaffold components.

Functions

@Composable
fun AppScaffold(
    modifier: Modifier = Modifier,
    timeText: @Composable () -> Unit = { TimeText() },
    containerColor: Color = MaterialTheme.colorScheme.background,
    contentColor: Color = contentColorFor(containerColor),
    content: @Composable BoxScope.() -> Unit
): Unit

AppScaffold is one of the Wear Material3 scaffold components.

The scaffold components AppScaffold and ScreenScaffold lay out the structure of a screen and coordinate transitions of the ScrollIndicator and TimeText components.

AppScaffold allows static screen elements such as TimeText to remain visible during in-app transitions such as swipe-to-dismiss. It provides a slot for the main application content, which will usually be supplied by a navigation component such as SwipeDismissableNavHost.

Example of using AppScaffold and ScreenScaffold:

import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import androidx.wear.compose.foundation.lazy.ScalingLazyColumn
import androidx.wear.compose.foundation.lazy.rememberScalingLazyListState
import androidx.wear.compose.material3.AppScaffold
import androidx.wear.compose.material3.Button
import androidx.wear.compose.material3.EdgeButton
import androidx.wear.compose.material3.ScreenScaffold
import androidx.wear.compose.material3.Text

// Declare just one [AppScaffold] per app such as in the activity.
// [AppScaffold] allows static screen elements (i.e. [TimeText]) to remain visible
// during in-app transitions such as swipe-to-dismiss.
AppScaffold {
    // Define the navigation hierarchy within the AppScaffold,
    // such as using SwipeDismissableNavHost.
    // For this sample, we will define a single screen inline.
    val listState = rememberScalingLazyListState()

    // By default, ScreenScaffold will handle transitions showing/hiding ScrollIndicator,
    // showing/hiding/scrolling away TimeText and optionally hosting the EdgeButton.
    ScreenScaffold(scrollState = listState, contentPadding = PaddingValues(10.dp)) {
        contentPadding ->
        ScalingLazyColumn(
            state = listState,
            contentPadding = contentPadding,
            modifier = Modifier.fillMaxSize(),
        ) {
            items(10) { Button(onClick = {}, label = { Text("Item ${it + 1}") }) }
        }
    }
}
Parameters
modifier: Modifier = Modifier

The modifier for the top level of the scaffold.

timeText: @Composable () -> Unit = { TimeText() }

The default time (and potentially status message) to display at the top middle of the screen in this app. When AppScaffold is used in combination with ScreenScaffold, the time text will be scrolled away and shown/hidden according to the scroll state of the screen.

containerColor: Color = MaterialTheme.colorScheme.background

The container color of the app drawn behind the content, i.e. the color of the background behind the content.

contentColor: Color = contentColorFor(containerColor)

The content color for the application content.

content: @Composable BoxScope.() -> Unit

The main content for this application.