Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit baeb7428 authored by Chaohui Wang's avatar Chaohui Wang Committed by Android (Google) Code Review
Browse files

Merge "Fine tune the CustomizedAppBar"

parents 4b0c1ed1 da2d88ee
Loading
Loading
Loading
Loading
+6 −6
Original line number Original line Diff line number Diff line
@@ -119,7 +119,6 @@ internal fun CustomizedLargeTopAppBar(
        actions = actions,
        actions = actions,
        colors = topAppBarColors(),
        colors = topAppBarColors(),
        windowInsets = TopAppBarDefaults.windowInsets,
        windowInsets = TopAppBarDefaults.windowInsets,
        maxHeightWithoutTitle = 120.dp,
        pinnedHeight = ContainerHeight,
        pinnedHeight = ContainerHeight,
        scrollBehavior = scrollBehavior,
        scrollBehavior = scrollBehavior,
    )
    )
@@ -261,7 +260,7 @@ private fun SingleRowTopAppBar(
 * A two-rows top app bar that is designed to be called by the Large and Medium top app bar
 * A two-rows top app bar that is designed to be called by the Large and Medium top app bar
 * composables.
 * composables.
 *
 *
 * @throws [IllegalArgumentException] if the given [maxHeightWithoutTitle] is equal or smaller than
 * @throws [IllegalArgumentException] if the given [MaxHeightWithoutTitle] is equal or smaller than
 * the [pinnedHeight]
 * the [pinnedHeight]
 */
 */
@OptIn(ExperimentalMaterial3Api::class)
@OptIn(ExperimentalMaterial3Api::class)
@@ -277,11 +276,10 @@ private fun TwoRowsTopAppBar(
    actions: @Composable RowScope.() -> Unit,
    actions: @Composable RowScope.() -> Unit,
    windowInsets: WindowInsets,
    windowInsets: WindowInsets,
    colors: TopAppBarColors,
    colors: TopAppBarColors,
    maxHeightWithoutTitle: Dp,
    pinnedHeight: Dp,
    pinnedHeight: Dp,
    scrollBehavior: TopAppBarScrollBehavior?
    scrollBehavior: TopAppBarScrollBehavior?
) {
) {
    if (maxHeightWithoutTitle <= pinnedHeight) {
    if (MaxHeightWithoutTitle <= pinnedHeight) {
        throw IllegalArgumentException(
        throw IllegalArgumentException(
            "A TwoRowsTopAppBar max height should be greater than its pinned height"
            "A TwoRowsTopAppBar max height should be greater than its pinned height"
        )
        )
@@ -289,7 +287,7 @@ private fun TwoRowsTopAppBar(
    val pinnedHeightPx: Float
    val pinnedHeightPx: Float
    val density = LocalDensity.current
    val density = LocalDensity.current
    val maxHeightPx = density.run {
    val maxHeightPx = density.run {
        remember { mutableStateOf((maxHeightWithoutTitle + pinnedHeight).toPx()) }
        remember { mutableStateOf((MaxHeightWithoutTitle + DefaultTitleHeight).toPx()) }
    }
    }
    val titleBottomPaddingPx: Int
    val titleBottomPaddingPx: Int
    density.run {
    density.run {
@@ -380,7 +378,7 @@ private fun TwoRowsTopAppBar(
                    Box(modifier = Modifier.onGloballyPositioned { coordinates ->
                    Box(modifier = Modifier.onGloballyPositioned { coordinates ->
                        density.run {
                        density.run {
                            maxHeightPx.value =
                            maxHeightPx.value =
                                maxHeightWithoutTitle.toPx() + coordinates.size.height.toFloat()
                                MaxHeightWithoutTitle.toPx() + coordinates.size.height.toFloat()
                        }
                        }
                    }) { title() }
                    }) { title() }
                },
                },
@@ -610,6 +608,8 @@ private suspend fun settleAppBar(
// Medium or Large app bar.
// Medium or Large app bar.
private val TopTitleAlphaEasing = CubicBezierEasing(.8f, 0f, .8f, .15f)
private val TopTitleAlphaEasing = CubicBezierEasing(.8f, 0f, .8f, .15f)


private val MaxHeightWithoutTitle = 124.dp
private val DefaultTitleHeight = 52.dp
private val ContainerHeight = 56.dp
private val ContainerHeight = 56.dp
private val LargeTitleBottomPadding = 28.dp
private val LargeTitleBottomPadding = 28.dp
private val TopAppBarHorizontalPadding = 4.dp
private val TopAppBarHorizontalPadding = 4.dp