OudsTopAppBar

fun OudsTopAppBar(title: String, background: OudsTopAppBarBackground, modifier: Modifier = Modifier, navigationIcon: OudsTopAppBarNavigationIcon? = null, actions: List<OudsTopAppBarAction> = emptyList(), expandedHeight: Dp = TopAppBarDefaults.TopAppBarExpandedHeight, windowInsets: WindowInsets = TopAppBarDefaults.windowInsets, scrollBehavior: TopAppBarScrollBehavior? = null)

App bar (aka Top app bar on Material 2) is a top-aligned component that displays the screen title and provides access to key actions and navigation elements. It may include an Up button, action icons, overflow menus, search, or tabs. It provides context and controls relevant to the current view.

This small top app bar has slots for a title, navigation icon, and actions.

Background Styles

OudsTopAppBar supports three background styles via the background parameter:

Using Translucent Background with Blur (Recommended)

To implement the translucent blurred top app bar as recommended by OUDS design guidelines, use OudsTopAppBarBackground.Translucent and integrate the Haze library:

  1. Add Haze and Haze Blur dependencies

  2. Follow Haze basic usage instructions:

  • Define Haze state in the screen containing the top app bar: val hazeState = rememberHazeState()

  • Define a variable to store the OUDS blur radius value: val oudsBlurRadius = OudsTheme.components.bar.effect.backgroundBlur.dp

  • Use hazeBlur Modifier on OudsTopAppBar providing OUDS blur radius: Modifier.hazeBlur(input = HazeInput.Sources(hazeState), style = HazeBlurStyle { blurRadius = oudsBlurRadius }),

  • Apply hazeSource Modifier on the content that scrolls behind the top app bar: Modifier.hazeSource(state = hazeState)

  1. As your screen content needs to scroll behind the top app bar, you'll probably need to add an additional bottom padding that will have the height of OudsTopAppBar.

Using Transparent Background

When using OudsTopAppBarBackground.Transparent, ensure sufficient contrast between the top app bar content and the scrolling content behind for accessibility.

Design

NameApp Bar
Guidelinesunified-design-system.orange.com
Version1.0.0

Parameters

title

The title to be displayed in the top app bar.

modifier

The Modifier to be applied to this top app bar.

background

The background of the top app bar among OudsTopAppBarBackground.

navigationIcon

The navigation icon displayed at the start of the top app bar.

actions

The actions displayed at the end of the top app bar. These can be instances of OudsTopAppBarAction.Icon or OudsTopAppBarAction.Avatar. The default layout here is a Row, so actions will be placed horizontally. The maximum recommended number of actions is three. Please use a dropdown menu if you need more than three actions.

expandedHeight

This app bar's height. When a specified scrollBehavior causes the app bar to collapse or expand, this value will represent the maximum height that the bar will be allowed to expand. This value must be specified and finite, otherwise it will be ignored and replaced with TopAppBarDefaults.TopAppBarExpandedHeight.

windowInsets

A window insets that app bar will respect.

scrollBehavior

A TopAppBarScrollBehavior which holds various offset values that will be applied by this top app bar to set up its height and colors. A scroll behavior is designed to work in conjunction with a scrolled content to change the top app bar appearance as the content scrolls. See TopAppBarScrollBehavior.nestedScrollConnection.

Samples

OudsTopAppBar(
    title = "Title",
    background = OudsTopAppBarBackground.Opaque,
    navigationIcon = OudsTopAppBarNavigationIcon.Back {},
    actions = listOf(
        OudsTopAppBarAction.Icon(Icons.Outlined.FavoriteBorder, "") {},
        OudsTopAppBarAction.Avatar(monogram = 'A', color = Color.White, backgroundColor = Color(0xffd5204e), "") {}
    )
)
OudsTopAppBar(
    title = "Title",
    background = OudsTopAppBarBackground.Opaque,
    navigationIcon = OudsTopAppBarNavigationIcon.Back {},
    actions = listOf(
        OudsTopAppBarAction.Icon(
            painter = rememberRainbowHeartPainter(),
            contentDescription = "",
            tinted = false,
            onClick = {}
        )
    )
)

fun OudsTopAppBar(title: String, modifier: Modifier = Modifier, translucent: Boolean = false, navigationIcon: OudsTopAppBarNavigationIcon? = null, actions: List<OudsTopAppBarAction> = emptyList(), expandedHeight: Dp = TopAppBarDefaults.TopAppBarExpandedHeight, windowInsets: WindowInsets = TopAppBarDefaults.windowInsets, scrollBehavior: TopAppBarScrollBehavior? = null)

Deprecated

Use OudsTopAppBar with background parameter instead.

Replace with

import com.orange.ouds.core.component.OudsTopAppBarBackground
OudsTopAppBar(title = title, modifier = modifier, background = if (translucent) OudsTopAppBarBackground.Translucent else OudsTopAppBarBackground.Opaque, navigationIcon = navigationIcon, actions = actions, expandedHeight = expandedHeight, windowInsets = windowInsets, scrollBehavior = scrollBehavior)

App bar (aka Top app bar on Material 2) is a top-aligned component that displays the screen title and provides access to key actions and navigation elements. It may include an Up button, action icons, overflow menus, search, or tabs. It provides context and controls relevant to the current view.

This small top app bar has slots for a title, navigation icon, and actions.

OudsTopAppBar default appearance is opaque but, if you need a translucent blurred top app bar as specified on OUDS design side, you can implement it in your app with the help of Haze library. To do this, use OudsTopAppBar with translucent parameter set to true and follow these steps:

  1. Add Haze and Haze Blur dependencies

  2. Follow Haze basic usage instructions:

  • Define Haze state in the screen containing the top app bar: val hazeState = rememberHazeState()

  • Define a variable to store the OUDS blur radius value: val oudsBlurRadius = OudsTheme.components.bar.effect.backgroundBlur.dp

  • Use hazeBlur Modifier on OudsTopAppBar providing OUDS blur radius: Modifier.hazeBlur(input = HazeInput.Sources(hazeState), style = HazeBlurStyle { blurRadius = oudsBlurRadius }),

  • Apply hazeSource Modifier on the content that scrolls behind the top app bar: Modifier.hazeSource(state = hazeState)

  1. As your screen content needs to scroll behind the top app bar, you'll probably need to add an additional bottom padding that will have the height of OudsTopAppBar.

Design

NameApp Bar
Guidelinesunified-design-system.orange.com
Version1.0.0

Parameters

title

The title to be displayed in the top app bar.

modifier

The Modifier to be applied to this top app bar.

translucent

Whether the top app bar should be translucent.

navigationIcon

The navigation icon displayed at the start of the top app bar.

actions

The actions displayed at the end of the top app bar. These can be instances of OudsTopAppBarAction.Icon or OudsTopAppBarAction.Avatar. The default layout here is a Row, so actions will be placed horizontally. The maximum recommended number of actions is three. Please use a dropdown menu if you need more than three actions.

expandedHeight

This app bar's height. When a specified scrollBehavior causes the app bar to collapse or expand, this value will represent the maximum height that the bar will be allowed to expand. This value must be specified and finite, otherwise it will be ignored and replaced with TopAppBarDefaults.TopAppBarExpandedHeight.

windowInsets

A window insets that app bar will respect.

scrollBehavior

A TopAppBarScrollBehavior which holds various offset values that will be applied by this top app bar to set up its height and colors. A scroll behavior is designed to work in conjunction with a scrolled content to change the top app bar appearance as the content scrolls. See TopAppBarScrollBehavior.nestedScrollConnection.

Samples

OudsTopAppBar(
    title = "Title",
    background = OudsTopAppBarBackground.Opaque,
    navigationIcon = OudsTopAppBarNavigationIcon.Back {},
    actions = listOf(
        OudsTopAppBarAction.Icon(Icons.Outlined.FavoriteBorder, "") {},
        OudsTopAppBarAction.Avatar(monogram = 'A', color = Color.White, backgroundColor = Color(0xffd5204e), "") {}
    )
)
OudsTopAppBar(
    title = "Title",
    background = OudsTopAppBarBackground.Opaque,
    navigationIcon = OudsTopAppBarNavigationIcon.Back {},
    actions = listOf(
        OudsTopAppBarAction.Icon(
            painter = rememberRainbowHeartPainter(),
            contentDescription = "",
            tinted = false,
            onClick = {}
        )
    )
)