OudsMediumTopAppBar

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

Top app bars display information and actions at the top of a screen.

This medium top app bar has slots for a title, navigation icon, and actions. In its default expanded state, the title is displayed in a second row under the navigation and actions.

OudsMediumTopAppBar 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 OudsMediumTopAppBar with translucent parameter set to true and follow these steps:

  1. Add Haze dependency

  2. Follow Haze basic usage instructions:

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

  • Use hazeEffect Modifier on OudsMediumTopAppBar providing OUDS blur radius: Modifier.hazeEffect(state = hazeState, style = HazeStyle(tint = null, blurRadius = OudsTheme.components.bar.blurRadius.dp)),

  • 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 OudsMediumTopAppBar.

Design

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

Parameters

title

The title to be displayed in the top app bar. This title will be used in the app bar's expanded and collapsed states, although in its collapsed state it will be composed with a smaller sized TextStyle.

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.

collapsedHeight

This app bar height when collapsed by a provided scrollBehavior. This value must be specified and finite, otherwise it will be ignored and replaced with TopAppBarDefaults.MediumAppBarCollapsedHeight.

expandedHeight

This app bar's maximum height. When a specified scrollBehavior causes the app bar to collapse or expand, this value will represent the maximum height that the app-bar will be allowed to expand. The expanded height is expected to be greater or equal to the collapsedHeight, and the function will throw an IllegalArgumentException otherwise. Also, this value must be specified and finite, otherwise it will be ignored and replaced with TopAppBarDefaults.MediumAppBarExpandedHeight.

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.

Throws

if the provided expandedHeight is smaller than the collapsedHeight

Samples

import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.FavoriteBorder
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.tooling.preview.PreviewLightDark
import com.orange.ouds.core.component.OudsCenterAlignedTopAppBar
import com.orange.ouds.core.component.OudsLargeTopAppBar
import com.orange.ouds.core.component.OudsMediumTopAppBar
import com.orange.ouds.core.component.OudsTopAppBar
import com.orange.ouds.core.component.OudsTopAppBarAction
import com.orange.ouds.core.component.OudsTopAppBarNavigationIcon
import com.orange.ouds.core.utilities.OudsPreview

fun main() { 
   //sampleStart 
   OudsMediumTopAppBar(
    title = "Title",
    navigationIcon = OudsTopAppBarNavigationIcon.Back {},
    actions = listOf(
        OudsTopAppBarAction.Icon(Icons.Outlined.FavoriteBorder, "") {},
        OudsTopAppBarAction.Avatar(monogram = 'A', color = Color.Black, backgroundColor = Color(0xfffbcd00), "") {}
    )
) 
   //sampleEnd
}