Skip to content

fix: keep the iOS View floating action button off the navigation bar - #68

Merged
AdamMusa merged 2 commits into
codex/engine-initializationfrom
fix/cupertino-view-fab-tab-bar
Nov 2, 2026
Merged

AdamMusa merged 2 commits into
codex/engine-initializationfrom
fix/cupertino-view-fab-tab-bar

Conversation

@AdamMusa

Copy link
Copy Markdown
Owner

Depends on #66 (fix/cupertino-view-bottom-sheet-tab-bar). This branch is stacked on it because it replaces the body-region layout that #66 introduced. Until #66 merges, the diff also shows its commit 658f1c4; review commit 166bad8.

Engine-only fix with no Ruby change. QA asked us to check the suspicion raised in #66.

Bug (confirmed by a geometry test before any fix)

On iOS/macOS, RufletCupertinoPageScaffold aligned the View's floating_action_button over the whole scaffold content, which includes the bottom navigation_bar. The FAB's only spacing was SafeArea(minimum: 16) from the screen edge.

Measured on #66 (800x600, 54/34 px insets, endFloat): FAB at y 494–550 and tab bar at 516–566, so the FAB covered 34 px of the tab bar. It also ignored the persistent bottom_sheet: the FAB sat over its lower part (sheet 452–516).

This affected all 7 bottom spellings (default, start/center/endFloat, start/center/endDocked). Top locations and the no-nav-bar case were already correct.

Fix

lib/src/widgets/cupertino_page_scaffold.dart: the region above the bottom navigation bar is now laid out by a small MultiChildLayoutDelegate (_CupertinoBodyLayout) that follows Material's Scaffold:

  • the body fills the region
  • the persistent bottom sheet sits at the region's bottom, over the body, unchanged from fix: keep the iOS View bottom sheet above the navigation bar #66
  • the FAB keeps the standard 16 px margin (kFloatingActionButtonMargin) from the region's edges, so on bottom locations it sits 16 px above the bar
  • with a sheet, its y becomes min(that, sheetTop - fabHeight/2), which is Flutter's FabFloatOffsetY: like Material, the FAB moves up and rests centred on the sheet's top edge
  • top locations stay 16 px below the top of the content; start/center/end and the custom-map location behave as before
  • LayoutId keys keep the body's state when the sheet or FAB appear or disappear; the drawer overlay stays above everything

Intentional deviation: iOS has no notched tab bar, so *Docked locations are laid out like *Float (above the bar, never over it). On Material, docked FABs keep straddling the bottom bar, as before.

Tests

New test/widgets/view_floating_action_button_geometry_test.dart renders a real Ruby-shaped View (navigation_bar + floating_action_button [+ bottom_sheet]) through PlatformApp:

  • iOS, all 10 location spellings the Cupertino scaffold recognises (default, start/center/end × Float/Docked/Top):
    • nav bar only: the FAB never overlaps the bar; bottom locations have fab.bottom == nav.top - 16; top locations have fab.top == 54 + 16; horizontal margin is 16 or centred; no Material widgets
    • nav bar + sheet: the sheet stands on the bar; bottom locations have fab.top == min(nav.top - 16 - h, sheet.top - h/2) (at most the upper half rests on the sheet); top locations do not touch the sheet
  • iOS without a nav bar (default, startFloat, centerTop): above the 34 px home indicator by 16 px
  • Material reference (default, centerFloat, startFloat): the same rules hold for Flutter's own Scaffold, with and without the sheet, and in the safe area. This is the oracle the iOS assertions follow.
before (on #66) after
new FAB geometry test (27) 14 iOS cases fail (every bottom location overlaps the tab bar) 27/27 pass
view_bottom_sheet_geometry_test (#66), platform_page_scaffold_test, canonical_page_chrome_test, ruby_fab_colors_test pass pass

verify_pr.sh (Flutter 3.41.2; Ruby tree = clean origin/main b34072be because Ruby is unchanged):

PASS ruby:ruflet_core                   145/145 files, 618 runs
PASS engine:ruflet flutter test         +726: All tests passed!   (695 base + 4 from #66 + 27 new)
PASS engine:ruflet analyze              No issues found!
INFO wire-key audit                     NEW vs baseline: 0, fixed: 0

Ruby usage (unchanged API)

Ruflet.view(
  [cart_list],
  navigation_bar: navigation_bar(destinations: [...]),
  bottom_sheet: container(content: text_button("Checkout"), padding: 12), # View bottom_sheet needs ruflet #27
  floating_action_button: floating_action_button(icon: Ruflet::MaterialIcons::ADD),
  floating_action_button_location: "endFloat"   # or centerFloat / startDocked / endTop ...
)

The persistent View bottom_sheet was aligned to the bottom of the whole
Cupertino scaffold content, which includes the bottom navigation bar,
so it covered the tab bar. Like Material's Scaffold.bottomSheet it now
floats over the body inside the region above the navigation bar; the
scaffold SafeArea still keeps it above the home indicator when there is
no bar.
The Cupertino scaffold aligned the floating action button over the whole
content, including the bottom navigation bar, so every bottom location
covered the tab bar (and the persistent bottom sheet). The region above
the bar is now laid out like Material's Scaffold: the FAB keeps the
16 px kFloatingActionButtonMargin above the bar, or rests centred on the
bottom sheet's top edge (FabFloatOffsetY). Docked locations float, as
CupertinoTabBar has no notch.
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