Skip to content

feat: add sliver_app_bar - #42

Merged
AdamMusa merged 2 commits into
mainfrom
feat/sliver-app-bar
Oct 29, 2026
Merged

AdamMusa merged 2 commits into
mainfrom
feat/sliver-app-bar

Conversation

@AdamMusa

Copy link
Copy Markdown
Owner

Depends on #35 (custom_scroll_view). This branch is stacked on feat/custom-scroll-view. Until #35 merges, review only the last commit, "feat: add sliver_app_bar".

What

Adds sliver_app_bar (SPEC E2), the collapsing app bar that goes first in a custom_scroll_view. On Android it is the Material small, medium or large top app bar. On iOS it is the large title that shrinks into the navigation bar as the content scrolls.

Engine counterpart (renderer): AdamMusa/ruflet-engine#26

Usage

page.padding = 0
page.add(custom_scroll_view(expand: true, slivers: [
  sliver_app_bar(
    title: "Settings",
    variant: "large",
    actions: [icon_button(icon: "search", on_click: ->(_e) { open_search })]
  ),
  sliver_list(controls: settings.map { |s| list_tile(title: s.name) })
]))

# Hero image header (Material: FlexibleSpaceBar, iOS: plain box under the bar)
sliver_app_bar(title: "Lisbon", pinned: true, expanded_height: 240,
               flexible_space: image(src: "lisbon.jpg", fit: "cover"))

# Bar that hides on scroll and comes back on the first reverse scroll
sliver_app_bar(title: "Feed", floating: true, snap: true)

Wire keys

SliverAppBar (sliver_app_bar, sliverappbar; shared/sliverappbar_control.rb). It is a sliver child: it takes key data visible and its own keywords only, with no box layout keywords and no events.

Keyword Default Notes
title String or control
variant "small" "small" / "medium" / "large"
leading, actions
pinned nil Renderer: true for medium/large, false for small
floating, snap, stretch false
expanded_height, collapsed_height, toolbar_height Material
flexible_space Material FlexibleSpaceBar background; iOS plain box below the bar
bottom, bottom_height (48)
bgcolor
color, elevation, scrolled_under_elevation, shadow_color, center_title Material
automatically_imply_leading true
previous_page_title, border Cupertino
always_show_middle true Cupertino
transition_between_routes false Cupertino; off avoids duplicate nav-bar heroes

Material vs Cupertino

  • Material: SliverAppBar, .medium or .large. Large expands to 152 and collapses to 64.
  • Cupertino:
    • medium and large: CupertinoSliverNavigationBar. The 44pt bar plus the 52pt large title collapses into the always-pinned bar.
    • small: a CupertinoNavigationBar that is pinned, floating or scrolls away.
    • No parallax flexible space on iOS (D-9).

The engine PR has the full mapping table.

Gotchas

  • Do not also set page.appbar when using a sliver_app_bar: you would get two bars.
  • sliver_app_bar outside a custom_scroll_view shows the unknown-control error (D-3).

Tests

test/sliver_app_bar_compatibility_test.rb (6 tests) covers:

  • every keyword serializes, including control-valued leading, actions, bottom and flexible_space, and color normalization
  • defaults
  • pinned left nil
  • compact alias and control(:sliver_app_bar)
  • ArgumentError for box layout keywords and events
  • ordering inside custom_scroll_view(slivers:)
  • page.update(bar, title:) patches the bar's own wire id

team/verify_pr.sh (engine + Ruby worktrees, stacked on E1): PASS

  • engine flutter test (Flutter 3.41.2): +732, all passed (E1's 720 + 12 new)
  • flutter analyze lib test: No issues found
  • ruflet_core: 147/147 files, 635 runs
  • wire-key audit: 0 findings for SliverAppBar, CustomScrollView and the Sliver* types (SliverAppBar keys are read in sliver_app_bar_spec.dart). The "NEW vs baseline: 3" are pre-existing ReorderableListView / ReorderableDragHandle findings whose hint text now also names the new files. They are not new findings.

Add SliverAppBar (sliver_app_bar), the collapsing app bar sliver for
custom_scroll_view: title, variant (small, medium, large), leading,
actions, pinned, floating, snap, stretch, heights, flexible_space,
bottom and colors, plus the iOS previous_page_title, border,
always_show_middle and transition_between_routes. Like the other sliver
children it only accepts key, data, visible and its own keywords.
@AdamMusa
AdamMusa merged commit 86f4cc5 into main Oct 29, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant