Skip to main content
Version: 12.10.0

OCScaffold

The OCScaffold function is a composable in Jetpack Compose that sets up the basic structure for our application's user interface.

Usage

 @Composable
fun AppScreen() {
val navController = rememberNavController()

OCScaffold(
title = "App Screen",
showBackButton = true,
navController = navController,
floatingActionButton = { FloatingActionButton(onClick = { /* Handle click */ }) {
Icon(Icons.Filled.Add, contentDescription = null)
} },
content = { innerPadding ->
// screen content goes here
}
)
}

Parameters

  • title: The title to be displayed in the top app bar.
  • icon: The icon to be displayed in the top app bar.
  • showBackButton: A boolean that determines whether a back button should be displayed in the top app bar.
  • navController: The navigation controller used for handling navigation events.
  • snackBarHost: The composable function to host snackbars, by default it's a simple SnackbarHost.
  • floatingActionButton: The composable function to display a floating action button.
  • floatingActionButtonPosition: This parameter controls the position of the floating action button, by default, it's at the end.
  • isFloatingActionButtonDocked: A boolean that decides if the floating action button should be docked.
  • onClickCloseButton: Handler for the close button click event.
  • actions: The actions to be placed on the top app bar.
  • content: The main content of the scaffold.

In the complete version of OCScaffold, it allows further customizations like adding bottom bar, drawer content and controlling drawer gestures. It also provides control over different aspects of the view like background color, content color, etc.

These two scaffold composables can be used as a quick and consistent way to setup your screens. The complete variant gives extended flexibility for screens with more requirements.