Can you make the sheet music be right next to each other and fill out the whole screen like the current iOS version. It will allow users to see the sheet music a little better if it auto fits and utilizes the whole screen without having a lot of empty space in the margins and in between the pages
Can you share some screenshots?
Triage & Root Cause Analysis
Thank you for the feedback, @dkladd! We investigated how 2-page Sheet Music spreads (isSideBySide) are laid out and rendered in Fullscreen Present Mode on iOS/iPadOS (HfwFullscreenSheetMusicPresenter), macOS (HfwZoomableScorePageView), and the External Display / AirPlay Stage (HfwExternalStageView).
There are four compounding layout factors creating excessive empty space in the outer margins and between the two pages when presenting a 2-page spread:
1. Each Page Centers Independently Inside Its Half-Screen (contentMode = .scaleAspectFit + .fillEqually)
- File:
packages/hfw_flutter/ios/Runner/HfwHymnDetailViews.swift(lines1886–1922) - In
HfwZoomScrollView,stackViewusesdistribution = .fillEquallyandspacing = 10, dividing the screen into two wide containers (leftPageContainerandrightPageContainer), each nearly square on a landscape iPad. - Because
leftImageViewandrightImageViewboth usecontentMode = .scaleAspectFit(lines 1898, 1911) and fill their respective half-width containers, each portrait page is independently centered horizontally inside its own half of the screen. - Resulting Gap Math: On a landscape iPad (
1366 × 1024), each page container is~668 ptwide and~992 pttall. A portrait score page (aspect ratio~0.68–0.75) fitted to height renders at~675–744 ptwide, or on wider aspect ratios (such as16:9external displays or iPad Pro 11"1194 × 834where each half is582 × 802and a page renders at~545 ptwide), each page leaves unused horizontal letterbox space on both its left and right sides. The inner right margin of the left page and the inner left margin of the right page add together across the center spine—creating a wide empty gap down the middle instead of abutting like an open hymnal book. - The same issue occurs on the External Display / AirPlay Stage (
packages/hfw_flutter/ios/Runner/HfwExternalDisplayManager.swift, lines778–813), where bothImageviews have.frame(maxWidth: .infinity, maxHeight: .infinity)inside anHStack(spacing: 12)(lines 791, 811), centering each page in its16:9half-screen and leaving a massive gap in the center.
2. Hardcoded Outer Insets & Inter-Page Spacing in HfwZoomScrollView
- File:
packages/hfw_flutter/ios/Runner/HfwHymnDetailViews.swift(lines1889–1892and1973–1975) stackViewapplies a fixedspacing = 10between page containers and insets the entire spread byUIEdgeInsets(top: 8, left: 10, bottom: 24, right: 10):stackView.spacing = 10 stackView.frame = zoomContainerView.bounds.inset( by: UIEdgeInsets(top: 8, left: 10, bottom: 24, right: 10) )- macOS Compatibility View:
packages/hfw_flutter/ios/Runner/HfwPlatformCompat.swift(lines585, 621–623) similarly hardcodesHStack(spacing: 10)plus.padding(.horizontal, 10),.padding(.top, 8), and.padding(.bottom, 24). - External Stage View:
packages/hfw_flutter/ios/Runner/HfwExternalDisplayManager.swift(lines778, 814, 836) usesHStack(spacing: 12)and.padding(16)around the score pages. - While the
24 ptbottom inset was originally intended for the inline tab pager indicator,HfwFullscreenSheetMusicPresenterhides page indicators (showIndicators: false,HfwPresenterAndPitchViews.swift:2606, 2704) and uses floating HUD overlays that can be toggled off—so these permanent insets shrink the maximum height and width of the score even when the HUD is hidden.
3. Safe Area Container Clipping in HfwFullscreenSheetMusicPresenter
- File:
packages/hfw_flutter/ios/Runner/HfwPresenterAndPitchViews.swift(lines2345, 2407–2709) - While the background
theme.surface.ignoresSafeArea()(line 2408) extends edge-to-edge, theGeometryReader(line 2345) and theTabView/HfwZoomableScorePageView(lines 2502–2709) remain constrained within the iOS safe area insets (status bar / top & bottom home indicator regions), preventing the sheet music canvas from utilizing 100% of the physical screen height and width in Present mode.
4. Baked-in Whitespace Margins in Rendered Sheet Music PNGs
- The source sheet music PNGs in the
.hymnbundles include standard print page margins around the engraved staff systems. - When two pages are placed side by side without margin trimming or spine abutment, the right print margin of Page 1 +
stackView.spacing+ horizontal aspect-fit centering + the left print margin of Page 2 all accumulate between the two pages.
Proposed Fixes & Implementation Plan
-
Abut Pages Together at the Center Spine (Book-Spread Layout):
- Instead of centering each page independently within
bounds.width / 2(distribution = .fillEqually), compute the exact aspect-fitted rect for the 2-page spread as a unified pair (or align the left page to.right/ trailing edge of the left half and the right page to.left/ leading edge of the right half with0–2 ptspine gap). - Update
HfwAnnotationCanvasUIView.resolvedDrawingRect()(HfwPresenterAndPitchViews.swift:4169–4177) so annotation stroke normalization maps accurately to the aligned image rect within each page container. - In
HfwExternalStageView(HfwExternalDisplayManager.swift:778–814), remove.frame(maxWidth: .infinity, maxHeight: .infinity)on the individual page images and reduceHStack(spacing:)from12to0(or2), centering the combined 2-page spread tightly in the stage frame.
- Instead of centering each page independently within
-
Eliminate Outer Padding & Inter-Page Gap in Present Mode:
- Add an
isFullscreenPresentation: Bool = false(orcontentInsets: UIEdgeInsets/pageSpacing: CGFloat) parameter toHfwZoomableScorePageViewandHfwZoomScrollView(HfwHymnDetailViews.swift:1889–1892, 1973–1975, 2147andHfwPlatformCompat.swift:563–623). - In Present Mode (
HfwFullscreenSheetMusicPresenter,HfwPresenterAndPitchViews.swift:2502–2709), use.zeroouter insets (UIEdgeInsets.zero) and0(or1–2 pthairline) inter-page spacing so the 2-page spread scales to fill the entire viewport edge-to-edge. - Allow the score canvas in
HfwFullscreenSheetMusicPresenterto ignore safe area insets when presenting so the sheet music utilizes the full screen height and width.
- Add an
-
Auto-Trim / Tight-Crop Redundant Page Whitespace Margins:
- Add an optional fast alpha/luminance bounding-box trim (cached per page path alongside
hfwLoadLocalImageinHfwSearchViews.swift:1039) or inner margin crop for Present Mode so excess outer paper margins and inner gutter margins are minimized, maximizing staff and lyric legibility across the screen.
- Add an optional fast alpha/luminance bounding-box trim (cached per page path alongside
Cross-Platform Applicability & Audit
Following up on the iOS triage above, I audited the sheet music viewer, fullscreen Present mode, and external stage/cast renderers across all four platforms in the monorepo (iOS/iPadOS, macOS, Android, and Web). Every platform is affected by either the exact same layout issue or a closely related variant:
| Platform | Inline Sheet Music | Fullscreen “Present” Mode | External Stage / Cast | Status & Key Findings |
|---|---|---|---|---|
| iOS / iPadOS | HfwHymnDetailViews.swift:1886–1975 |
HfwPresenterAndPitchViews.swift:2345, 2407–2709 |
HfwExternalDisplayManager.swift:768–838 |
Affected (Primary Report): UIStackView(distribution: .fillEqually, spacing: 10) centers each .scaleAspectFit page inside its 50%-width column, creating a wide gap down the center spine. Compounded by hardcoded UIEdgeInsets(top: 8, left: 10, bottom: 24, right: 10), safe-area clipping in fullscreen (HfwPresenterAndPitchViews.swift:2693), and baked-in PNG margins (~7%–10% per side). |
| macOS | HfwPlatformCompat.swift:563–636 |
HfwPresenterAndPitchViews.swift:2522–2557, 2640–2665 |
HfwExternalDisplayManager.swift:351–391, 768–838 |
Affected: • In-app ( HfwZoomableScorePageView): Uses HStack(spacing: 10) with .padding(.horizontal, 10), .padding(.top, 8), and .padding(.bottom, 24) (HfwPlatformCompat.swift:580–607). While Image(nsImage:).resizable().scaledToFit() sizes to its aspect-fitted width rather than a 50% screen box, the two pages are still separated by spacing: 10 plus each PNG’s ~7%–10% white margin, and the hardcoded outer padding (top: 8, bottom: 24, horizontal: 10) shrinks the score even inside HfwFullscreenSheetMusicPresenter.• External Stage Window: Shares HfwExternalStageView (HfwExternalDisplayManager.swift:782–810), which applies .frame(maxWidth: .infinity, maxHeight: .infinity) to each page inside HStack(spacing: 12) + .padding(16), reproducing the exact half-screen centering gap on 16:9 external displays. |
| Android | HfwHymnDetailComposeViews.kt:2500–2533, 3005–3066 |
HfwHymnDetailComposeViews.kt:4772–5350 |
HfwCastAndStageManager.kt:612–627, 681–693 |
Affected (Identical Bug to iOS): • Fullscreen ( HfwFullscreenSheetMusicDialog, lines 5092–5131) & Inline (HfwSheetMusicPagerView, lines 2500–2533): Renders 2-page spreads in a Row (padding(8.dp) / spacedBy(8.dp) in fullscreen; padding(10.dp) / spacedBy(10.dp) inline) where each page is wrapped in Box(modifier = Modifier.weight(1f).fillMaxHeight(), contentAlignment = Alignment.Center) and HfwScorePageBitmapImage (lines 3018–3033) centers the bitmap in BoxWithConstraints(Modifier.fillMaxSize(), contentAlignment = Alignment.Center). On a landscape tablet/foldable, each portrait page centers inside its half-screen weight(1f) box instead of abutting at the spine. Furthermore, when showHud = true (default on launch, line 4786), the top and bottom HUD bars are laid out in a Column above and below the Box(Modifier.weight(1f)) (lines 4879–5029, 5304–5316) rather than overlaying the canvas, vertically compressing the score.• External Display / Cast ( HfwCastAndStageManager.kt:612–627, 681–693): Splits the 1920×1080 canvas into two 948px half-rects (Rect(8, 8, 8 + halfW, height - 8) and Rect(16 + halfW, 8, width - 8, height - 8)) and centers each ~740px-wide portrait page via drawCenteredFitBitmapInBounds, leaving a ~216px gap down the middle of the 16:9 stage output. |
Web (hfw_jaspr) |
hymn_workspace_island_views.dart:1178–1290 |
packages/hfw_jaspr/web/styles.css:1615–1647, 1689–1723 |
N/A (Browser Fullscreen / /present route) |
Affected (Missing 2-Page Spread + Fullscreen Chrome): • No 2-Page Side-by-Side Spread in Active Component: hymn_workspace_island_views.dart:1178–1290 only renders a single active page (pageIdx == safePageIdx) inside .sheet-page-frame with no 2-page spread toggle (note: legacy CSS for .sheet-pages-stack.has-multiple-pages still exists in build/jaspr/web/styles.css:1616–1647, which used gap: 1rem and padding: 0.45rem, but was removed from web/styles.css).• Fullscreen Padding & Persistent Bars: In Present / fullscreen mode ( .workspace-island.is-fit-screen), .workspace-stage applies padding: 0.75rem 1.15rem; gap: 0.65rem (web/styles.css:1615–1622), .sheet-page-frame.fit-screen adds padding: 0.45rem and a 1px border (web/styles.css:1640–1646, 1689–1697), and .workspace-toolbar, .sheet-pages-quick-bar, and .slide-controls-bar remain in the vertical flex flow alongside the ~7%–10% baked-in PNG whitespace. |
Unified Cross-Platform Recommendations
- Abutting Book-Spread Alignment (iOS, macOS, Android, Web):
- In 2-page side-by-side mode, align the left page to the trailing/right edge of its container and the right page to the leading/left edge of its container (or size each page container to its aspect-fitted width inside a centered row with
0–2pt/dp/pxspine spacing) so the two pages meet at the center spine like an open hymnal. - Apply the same spine-abutting alignment to external 16:9 stage renderers (
HfwExternalStageViewon iOS/macOS andHfwCastAndStageManager.renderCurrentStageBitmapon Android).
- In 2-page side-by-side mode, align the left page to the trailing/right edge of its container and the right page to the leading/left edge of its container (or size each page container to its aspect-fitted width inside a centered row with
- Edge-to-Edge Fullscreen Canvas & Overlay HUD (iOS, macOS, Android, Web):
- Remove outer container padding (
UIEdgeInsetson iOS/macOS,Modifier.padding(8.dp)on Android,.workspace-stage/.sheet-page-frame.fit-screenpadding on Web) when in fullscreen Present mode. - On Android (
HfwFullscreenSheetMusicDialog) and Web (.workspace-island.is-fit-screen), float the top/bottom HUD toolbars as overlays (Box/ZStack/ absolute overlay) rather than stacking them in aColumnthat steals vertical height from the score. - On Web, restore or add a 2-page spread option (
2-Pagetoggle or automatic wide-screen spread inhymn_workspace_island_views.dart) that abuts pages at the center spine.
- Remove outer container padding (
- Auto-Trim / Crop Outer PNG Margins in 2-Page Spread Mode (All Platforms):
- Because the engraved
1980×2850/2050×2950PNGs have~7%–10%white margins baked into all four sides (~140px–205pxleft/right), abutting the raw bitmaps still leaves a combined~14%–20%white gutter at the spine. Trimming or cropping ~50%–65% of the outer white margin (either via a shared crop rect / UV inset at render time or during bundle asset generation) will allow the staves to fill the screen across all platforms.
- Because the engraved
Cross-Platform Fix Implemented (#24)
Implemented the cross-platform fix for Sheet Music on “Present” Mode across iOS/iPadOS, macOS, Android, and Web (hfw_jaspr):
1. iOS / iPadOS (packages/hfw_flutter/ios/Runner/)
HfwHymnDetailViews.swift(lines 1838–2340):- Added
isFullscreenPresentation: Bool = falsetoHfwZoomScrollViewandHfwZoomableScorePageView. - In
HfwZoomScrollView.updateStackAndPageFrames(), whenisFullscreenPresentation == true, outerstackViewinsets are set toUIEdgeInsets.zeroandstackView.spacing = 0(2ptinline). - In 2-page spread mode (
!rightPageContainer.isHidden),computeEdgeAlignedAspectFitRect(...)positionsleftImageView.frame+leftAnnotationCanvas.framedirectly against the trailing (center-spine) edge ofleftPageContainer(alignHorizontal = 1) andrightImageView.frame+rightAnnotationCanvas.frameagainst the leading (center-spine) edge ofrightPageContainer(alignHorizontal = -1). BecausetargetImageView.framematches the exact aspect-fitted rect,HfwAnnotationCanvasUIView.resolvedDrawingRect()maps(0..1, 0..1)strokes 1:1 automatically.
- Added
HfwPresenterAndPitchViews.swift(lines 2516–2748):- Passed
isFullscreenPresentation: truetoHfwZoomableScorePageViewacross all fullscreen presentation branches and applied.ignoresSafeArea()to the score views andTabViewpager so the score uses the full screen edge-to-edge.
- Passed
HfwExternalDisplayManager.swift(lines 777–827):- Updated
HfwExternalStageView2-page sheet music spreads to useHStack(spacing: 0)with.padding(0), aligning the left page to.trailingand the right page to.leadingso both pages abut at the center spine on external AirPlay/HDMI displays.
- Updated
2. macOS (packages/hfw_flutter/ios/Runner/)
HfwPlatformCompat.swift(lines 563–636):- Added
isFullscreenPresentation: Bool = falseto macOSHfwZoomableScorePageView. - Changed the spread stack to
HStack(spacing: isFullscreenPresentation ? 0 : 4)and zeroed outer.padding(.horizontal / .top / .bottom)whenisFullscreenPresentation == true.
- Added
HfwPresenterAndPitchViews.swift(lines 2553–2690) &HfwExternalDisplayManager.swift(lines 777–827):- Enabled
isFullscreenPresentation: trueand.ignoresSafeArea()in macOSHfwFullscreenSheetMusicPresenterand sharedHfwExternalStageView.
- Enabled
3. Android (packages/hfw_flutter/android/app/src/main/kotlin/com/appleeducate/hfw/)
HfwHymnDetailComposeViews.kt(lines 2500–2545, 3009–3071, 5122–5185):- Added
contentAlignment: Alignment = Alignment.CentertoHfwScorePageBitmapImageand forwarded it to bothBoxWithConstraints(annotated view) andImage(unannotated view). - In
HfwFullscreenSheetMusicDialogandHfwSheetMusicPagerView, aligned the left page toAlignment.CenterEndand the right page toAlignment.CenterStartwithArrangement.spacedBy(0.dp)andModifier.padding(0.dp)in fullscreen mode so 2-page spreads abut at the center spine.
- Added
HfwCastAndStageManager.kt(lines 620–638, 692–718):- Added
drawAlignedFitBitmapInBounds(...)and updatedrenderCurrentStageBitmapto align the left page bitmap against the center spine (Rect(0, 0, width / 2, height),alignHorizontal = 1) and the right page bitmap against the center spine (Rect(width / 2, 0, width, height),alignHorizontal = -1), eliminating the216pxgap on 16:9 HDMI/Cast displays.
- Added
4. Web (packages/hfw_jaspr/)
lib/components/hymn_workspace_island_views.dart(lines 1185–1285) &web/styles.css(lines 1615–1760):- Added
has-multiple-pagesto.sheet-page-frameandis-spread-left/is-spread-rightto the active 2-page spread images (spreadLeftIdx = (safePageIdx ~/ 2) * 2,spreadRightIdx = spreadLeftIdx + 1). - Updated
.workspace-island.is-fit-screen .workspace-stageand.sheet-page-frame.fit-screento remove excess outer padding and display 2-page spreads side-by-side abutting at the center spine (gap: 0,margin: 0) on wide viewports (@media (min-width: 960px) and (min-height: 540px)).
- Added