Skip to content

fix(reader): draw Mushaf previews like the reader and keep page colors in dark mode - #1317

Merged
mohamede1945 merged 11 commits into
mainfrom
afifi/mushaf-preview-rendering
Nov 18, 2026
Merged

mohamede1945 merged 11 commits into
mainfrom
afifi/mushaf-preview-rendering

Conversation

@mohamede1945

Copy link
Copy Markdown
Collaborator

Summary

In dark mode, the Mushaf picker previews for Madani 1441 and 1439 turned pink and orange, while the reader draws them green and blue. The previews were bundled screenshots with sura headers and ayah markers baked in, and dark mode inverts the whole image. This PR draws the previews the way the reader draws pages and tidies the page color handling around it.

  • Line-page previews (1439, 1441): the page 604 samples are now composed from each Mushaf's own 15 line images with LinePageGeometryEngine. Sura headers and ayah markers are drawn at runtime with the reader's views and colors, at positions computed from the reading's ayahinfo database.
  • Hue-preserving dark inversion: page images use colorInvert() followed by hueRotation(180°), so 1440's blue and tajweed's green headers keep their colors, and tajweed rule colors keep their meaning in dark mode.
  • One chrome palette: QuranPageChromeStyle in NoorUI is shared by line pages, 1421 full pages and the previews. 1421 moves from pageMarkerTint ring-only markers to the green palette with filled markers. The dark green header and ring go from #047857 to #10B981.
  • Quiet theme: pages always use the dark palette in Quiet (quranPageColorScheme). Before, Quiet with Light appearance drew 1439/1441 markers as light dots with unreadable numbers.
  • Dead code removed: QuranThemedImage.RenderingMode, Reading.usesInvertedQuranImageRenderingInDarkMode, the unused async tint/invert code, AyahNumberView's color initializer and UIColor.adjustedBrightness.

The shipping app's copies of the two preview images need a matching update in quran-ios-private. That PR is up and should merge right after this one, together with a Package.resolved bump.

Screenshots

Private app, no-sync build, iPhone 17 Pro simulator, page 604.

Before After
Picker 1441, dark
Picker 1439, dark
Picker tajweed, dark
Picker 1440, dark
Reader 1441, Quiet
Reader 1421, light
Reader 1421, dark
Reader tajweed, dark

Test plan

  • make format-lint
  • make build-no-sync, make build-sync
  • make test-no-sync / test-sync for NoorUITests and QuranImageFeatureTests; test-no-sync for ReadingSelectorFeatureTests (new), QuranKitTests and QuranGeometryTests
  • make build-example-no-sync
  • Simulator check of the picker and reader in light, dark and Quiet for 1405, 1421, 1439, 1440, 1441 and tajweed (private app on a local quran-ios)
  • Device check of tajweed and 1440 in dark mode: hue rotation brightens saturated colors

🤖 Generated with Claude Code

mohamede1945 and others added 11 commits November 17, 2026 21:27
QuranThemedImage.RenderingMode never changed anything: .tinted fell
through to .invertInDarkMode, both returned no image, and every page got
the same colorInvert() from invertThemedColorIfNeeded(). Drop the enum,
the renderingMode parameters threaded through AdaptiveImageScrollView,
the content views and the reading selector, the async image processing,
Reading.usesInvertedQuranImageRenderingInDarkMode, and the now unused
UIImage inverted()/tintedImageUsingFalseColorFilter helpers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A plain colorInvert() turns green chrome pink, blue chrome orange and
changes what tajweed colors mean. Rotate the hue by 180 degrees after
inverting so colors keep their hue while lightness flips. Grays, and so
monochrome pages, are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Move the reading to chrome style mapping and its palette from
QuranImageFeature's LinePageChromeStyle to NoorUI's QuranPageChromeStyle,
so line pages, full pages and the reading selector preview draw sura
headers and ayah markers from one source. ImageDecorations carries the
style and ImageDecorationsView resolves it with themeColorScheme, like
the line pages.

Full pages of the 1421 mushaf now use the green palette with filled
markers instead of Color.pageMarkerTint ring-only markers, which is
removed. SuraHeaderView and AyahNumberView keep explicit color
initializers, and AyahNumberView gains one that takes a palette.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The dark green sura header and ayah marker ring used #047857, the light
mode color, which is dim on black and quiet backgrounds. Use #10B981 in
dark mode. The other green and blue values stay the same.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Quiet pages are dark even when the appearance mode is light, and
invertThemedColorIfNeeded() already treats them that way. The chrome
palette followed themeColorScheme alone, so a light appearance drew
light marker fills with unreadable numbers on the quiet background.
Pick the dark palette whenever the theme is quiet, for line pages, full
pages and the reading selector previews.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The 1439 and 1441 previews had the blue and green sura header frames and
ayah markers baked into the PNG, so dark mode inverted them while the
reader, which draws that chrome at runtime, kept its colors. Replace both
samples with text-only versions (1441 from the shipping app's newer
sample) and draw the headers and markers over them with SuraHeaderView
and AyahNumberView in the reading's chrome palette, as the 1421 preview
already does.

Positions come from the removed chrome: header frames are sized like the
reader's (1038/1080 of the page width, at the asset's aspect ratio) and
markers use the reader's line-page size, now shared as
LinePageGeometryEngine.ayahMarkerWidthRatio through a new
ImageDecorations.ayahNumberWidthRatio. ReadingSelectorFeature gains a
test target to keep the preview chrome complete and inside the sample.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every AyahNumberView caller passes a chrome palette, so keep only the
palette initializer and always draw the filled marker. Also remove
UIColor.adjustedBrightness(by:), which only the deleted false-color
tinting used.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Image inversion and ayah dimming checked colorScheme plus the quiet
theme, while the chrome palette checked themeColorScheme plus the quiet
theme. Add EnvironmentValues.quranPageColorScheme, dark for the quiet
theme and otherwise themeColorScheme, the scheme the page background
resolves with, and use it for all three. Views derive the chrome palette
from that one value.

Drop the redundant Equatable conformances on the chrome style and
palette, and the palette tests that only restated its values.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Drop the test that re-derived the line-page preview positions; the
remaining test still guards that every reading drawing chrome at runtime
has a complete preview.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ImageDecorations now takes the chrome style without a default and the
ayah marker width ratio as an init parameter, from the new
AyahMarkerWidthRatio constants shared with the line-page geometry. The
reading selector preview passes the reading's own
drawsAyahNumbersAndSuraHeaders, and ReadingSelectorFeature declares the
QuranGeometry and QuranKit modules its sources import.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Build the 1439 and 1441 page 604 samples from the mushaf's own 15 line
images, laid out by LinePageGeometryEngine with the reader's
ContentLineLayoutBuilder input, instead of stripping chrome from old
screenshots. The engine fills the existing 1080x1728 and 1440x2304
samples exactly.

Take the preview's sura header and ayah marker positions from the same
layout of each reading's ayahinfo database, rounded to whole pixels.
1439 headers become 110 px tall so SuraHeaderView fits their width, as
in the reader. No position moved by more than 1 px.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mohamede1945
mohamede1945 merged commit a9c1ceb into main Nov 18, 2026
8 checks passed
@mohamede1945
mohamede1945 deleted the afifi/mushaf-preview-rendering branch November 18, 2026 15:57
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