From 633f29cfc1e116aa46b6806a16f5f2c0438c3f8c Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Mon, 15 Dec 2025 10:29:10 +0000 Subject: [PATCH] Refactor appbar to use updated Composer API Updated `SingleRowTopAppBar`, `CenterAlignedTopAppBar`, and `TwoRowsTopAppBar` in `compose/foundation/material3/appbar/top_app_bar.go`. - Replaced manual conditional logic with `c.When` for cleaner syntax. - Removed redundant `c.Sequence` wrappers. - Simplified title Composable wrapping in `TwoRowsTopAppBar`. --- .../material3/appbar/top_app_bar.go | 62 ++++++++----------- 1 file changed, 27 insertions(+), 35 deletions(-) diff --git a/compose/foundation/material3/appbar/top_app_bar.go b/compose/foundation/material3/appbar/top_app_bar.go index 88712661..4ce741f4 100644 --- a/compose/foundation/material3/appbar/top_app_bar.go +++ b/compose/foundation/material3/appbar/top_app_bar.go @@ -44,16 +44,14 @@ func SingleRowTopAppBar( // Title box.Box( - func(c Composer) Composer { - if title != nil { - return surface.Surface( - title, - surface.WithContentColor(colors.TitleContentColor), - surface.WithColor(color.NRGBA{}), // Transparent - )(c) - } - return c - }, + c.When( + title != nil, + surface.Surface( + title, + surface.WithContentColor(colors.TitleContentColor), + surface.WithColor(color.NRGBA{}), // Transparent + ), + ), box.WithModifier(weight.Weight(1)), // Occupy remaining space box.WithAlignment(layout.W), // Align text to start box.WithModifier(padding.Horizontal(16, 16)), // Horizontal(16, 16) @@ -155,14 +153,12 @@ func CenterAlignedTopAppBar( ), // Layer 2: Centered Title box.Box( - c.Sequence( - c.When( - title != nil, - surface.Surface( - title, - surface.WithContentColor(opts.Colors.TitleContentColor), - surface.WithColor(color.NRGBA{}), - ), + c.When( + title != nil, + surface.Surface( + title, + surface.WithContentColor(opts.Colors.TitleContentColor), + surface.WithColor(color.NRGBA{}), ), ), box.WithAlignment(layout.Center), @@ -208,24 +204,20 @@ func TwoRowsTopAppBar( ), // Bottom Row: Title box.Box( - c.Sequence( - c.When( - title != nil, - surface.Surface( - func(c Composer) Composer { - // Default style for Headline? - // For now, just render title. - // Ideally we should apply Material3 typography h5 or h6. - // But we don't have typography passed in easily yet. - // Rely on user passing Text with style. + c.When( + title != nil, + surface.Surface( + // Default style for Headline? + // For now, just render title. + // Ideally we should apply Material3 typography h5 or h6. + // But we don't have typography passed in easily yet. + // Rely on user passing Text with style. - // Using ProvideTextStyle? Not yet implemented in foundation? - // Just render. - return title(c) - }, - surface.WithContentColor(colors.TitleContentColor), - surface.WithColor(color.NRGBA{}), - ), + // Using ProvideTextStyle? Not yet implemented in foundation? + // Just render. + title, + surface.WithContentColor(colors.TitleContentColor), + surface.WithColor(color.NRGBA{}), ), ), box.WithModifier(size.FillMaxWidth()),