Large-title navigation: content top padding uses fixed estimates (64/112 dp) instead of the measured top bar height

Open
#619 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 4 days

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
android, kotlin, swift
Domain
mobile-dev

Research direction

The padding is computed in Navigation.swift from hard-coded estimatedCollapsedTopBarHeight and estimatedExpandedTopBarHeight values, while the inline path already uses a measured effectiveTopBarBottomPx. Start by comparing those two code paths in that file and see how the large-title branch could read the bar's measured height instead. Done means large-title content starts at the measured bar bottom, and the Form example lines up with iOS spacing on Android.

Written by the indexing model from the issue text.

Description

Version: skip-ui 1.66.4, Skip Fuse, Android emulator (440 dpi)

What happens

With .navigationBarTitleDisplayMode(.large) (including in a sheet), the content below the MediumTopAppBar is padded using hard-coded estimates rather than the actual height of the bar. In Navigation.swift:

let estimatedCollapsedTopBarHeight = 64.dp
let estimatedExpandedTopBarHeight = 112.dp
...
let topBarHeightDp = estimatedCollapsedTopBarHeight + ((estimatedExpandedTopBarHeight - estimatedCollapsedTopBarHeight) * Float(1.0 - scrollBehavior.state.collapsedFraction))
topBarBottomDp = localSafeAreaTopDp + topBarHeightDp

The inline mode measures the bar (effectiveTopBarBottomPx); the large mode doesn't.

Consequences

  1. A List/Form under a large title starts ~40 dp lower than on iOS: the 112 dp Material bar (with its bottom padding below the title) plus the first section's header inset. On iOS the first section sits right under the large title.
  2. The space can't be reduced from app code: shrinking the bar with .material3TopAppBar { ... } (e.g. a custom Modifier.layout that reports a smaller height) has no effect on where the content starts, because the padding never reads the bar's height.

Steps

NavigationStack {
    Form {
        Section("First") { Text("Row") }
    }
    .navigationTitle("New item")
    .navigationBarTitleDisplayMode(.large)
}

Compare the space between the title and "FIRST" on iOS and Android.

Expected

The content's top padding follows the measured height of the top bar in large mode too (as it already does in inline mode), so the bar can be customized and the content follows it. A way to set the expanded height / bottom padding of the large title would also help to match iOS spacing.

Happy to test a fix. Thanks for Skip!

Dominant language
Swift
Stars
334
Forks
95
Avg merge
2d 10h
Merged PRs (30d)
8

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from skiptools/skip-ui

All issues in skiptools/skip-ui

Similar issues

More Swift issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.