Skip to content

[Health] Add AppColourMode wrapper to multi-preview annotations - #425

Draft
adi-gnm wants to merge 6 commits into
mainfrom
ab/health/multi-preview-app-colour-wrapper
Draft

adi-gnm wants to merge 6 commits into
mainfrom
ab/health/multi-preview-app-colour-wrapper

Conversation

@adi-gnm

@adi-gnm adi-gnm commented Aug 13, 2026

Copy link
Copy Markdown
Member

Description

Adds an AppColourMode preview wrapper to the existing @PreviewPhoneBothMode and @PreviewTabletBothMode annotations. Also adds a new @PreviewAllDeviceBothMode annotation since we now can't apply both phone and tablet annotations to the same preview.

This change means that we now don't need to wrap our previews with AppColourMode. The multi preview annotations will automatically do it.

This change also means that the screenshot tests will need to wrap their content with AppColourMode since the preview under test no longer does that.

Related changes:
  1. Updated Compose BOM to 2026.08.00 that allows preview wrappers on multi preview annotations
  2. Upgraded Gradle wrapper, AGP, compileSdk and Kotlinter to match minimum Compose requirements

Checklist

  • Changes have been checked by the developer
  • Changes have been checked by the reviewers
  • Unit tested

@adi-gnm adi-gnm added the maintenance Departmental tracking: maintenance work, not a fix or a feature label Aug 13, 2026
@adi-gnm
adi-gnm requested a lite review from Copilot August 13, 2026 15:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an AppColourMode wrapper at the multi-preview annotation level (via Compose @PreviewWrapper) so that previews using AppColour.current render correctly in day/night previews without each preview function manually wrapping itself. This is applied across Source components, Paparazzi tests, and sample previews, alongside a Compose BOM bump.

Changes:

  • Introduces AppColourWrapper : PreviewWrapperProvider and applies it to multi-preview annotations (PreviewPhoneBothMode, PreviewTabletBothMode, PreviewAllDeviceBothMode).
  • Removes per-preview AppColourMode { ... } wrappers from many preview composables and updates Paparazzi tests to wrap snapshots explicitly.
  • Updates Compose BOM version and detekt baselines for newly surfaced rules.

Reviewed changes

Copilot reviewed 25 out of 25 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
android/source/src/test/kotlin/com/gu/source/components/promosticker/PromoStickerTest.kt Wraps Paparazzi snapshots in AppColourMode.
android/source/src/test/kotlin/com/gu/source/components/pager/PagerProgressBarTest.kt Wraps Paparazzi snapshot in AppColourMode.
android/source/src/test/kotlin/com/gu/source/components/buttons/SourceIconButtonTest.kt Wraps Paparazzi snapshots in AppColourMode.
android/source/src/test/kotlin/com/gu/source/components/buttons/SourceButtonTest.kt Wraps Paparazzi snapshots in AppColourMode.
android/source/src/test/kotlin/com/gu/source/components/buttons/PlainSourceButtonTest.kt Wraps Paparazzi snapshot in AppColourMode.
android/source/src/test/kotlin/com/gu/source/components/banner/SourceAlertBannerTest.kt Wraps Paparazzi snapshot in AppColourMode.
android/source/src/main/kotlin/com/gu/source/utils/PreviewAnnotations.kt Adds @PreviewWrapper(AppColourWrapper::class) to multi-preview annotations; expands/clarifies preview sets.
android/source/src/main/kotlin/com/gu/source/utils/AppColourWrapper.kt New wrapper provider that applies AppColourMode to previews.
android/source/src/main/kotlin/com/gu/source/components/rating/SourceRating.kt Removes preview-local AppColourMode wrapper in favor of annotation wrapper.
android/source/src/main/kotlin/com/gu/source/components/promosticker/PromoSticker.kt Removes preview-local AppColourMode wrapper in favor of annotation wrapper.
android/source/src/main/kotlin/com/gu/source/components/pager/PagerProgressButtons.kt Switches to @PreviewAllDeviceBothMode; removes preview-local AppColourMode wrapper.
android/source/src/main/kotlin/com/gu/source/components/pager/PagerProgressBar.kt Switches to @PreviewAllDeviceBothMode; removes preview-local AppColourMode wrapper in one preview but not all.
android/source/src/main/kotlin/com/gu/source/components/chips/SourceChip.kt Removes preview-local AppColourMode wrapper in favor of annotation wrapper.
android/source/src/main/kotlin/com/gu/source/components/chips/SourceBaseChip.kt Removes preview-local AppColourMode wrapper in favor of annotation wrapper.
android/source/src/main/kotlin/com/gu/source/components/buttons/SourceTextButton.kt Switches preview annotation to @PreviewAllDeviceBothMode; retains preview-local AppColourMode.
android/source/src/main/kotlin/com/gu/source/components/buttons/SourceIconButton.kt Removes preview-local AppColourMode wrappers in favor of annotation wrapper.
android/source/src/main/kotlin/com/gu/source/components/buttons/SourceButton.kt Removes preview-local AppColourMode wrappers in favor of annotation wrapper.
android/source/src/main/kotlin/com/gu/source/components/buttons/PlainSourceButton.kt Removes preview-local AppColourMode wrapper in favor of annotation wrapper.
android/source/src/main/kotlin/com/gu/source/components/banner/SourceAlertBanner.kt Removes preview-local AppColourMode wrapper in favor of annotation wrapper.
android/source/detekt-baseline.xml Adds new baseline entries surfaced by the preview changes.
android/sample/src/main/kotlin/com/gu/source/previews/TextButtonPreview.kt Switches to @PreviewAllDeviceBothMode and removes explicit AppColourMode wrapper.
android/sample/src/main/kotlin/com/gu/source/previews/ImagePagerWithProgressIndicator.kt Switches to @PreviewAllDeviceBothMode and removes explicit AppColourMode wrapper.
android/sample/src/main/kotlin/com/gu/source/Home.kt Removes explicit AppColourMode wrapper from HomePreview.
android/sample/detekt-baseline.xml Adds new baseline entries for preview functions.
android/gradle/libs.versions.toml Updates Compose BOM version.
Suppressed comments (1)

android/source/src/main/kotlin/com/gu/source/components/pager/PagerProgressBar.kt:221

  • AnimatedPreview still wraps its content in AppColourMode, but @PreviewAllDeviceBothMode already applies @PreviewWrapper(AppColourWrapper::class) (which wraps in AppColourMode). This double-wrap causes redundant isSystemInDarkTheme() evaluation for previews.

Suggested resolution: remove the inner AppColourMode { ... } from this preview and also delete the (then-unused) AppColourMode import.

@PreviewAllDeviceBothMode
@Composable
private fun AnimatedPreview() {
    AppColourMode {
        val pagerState = rememberPagerState(0) { 10 }

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines 140 to 144
@Composable
@PreviewPhoneBothMode
@PreviewTabletBothMode
@PreviewAllDeviceBothMode
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
internal fun SourceTextButtonPreview() = AppColourMode {
val validPriorities = listOf(
gu-gradle-library-release Bot added a commit that referenced this pull request Aug 13, 2026
…610.ee69ad5e published by adi-gnm

adi-gnm published release version 10.1.0-PREVIEW.abhealthmulti-preview-app-colour-wrapper.2026-08-13T1610.ee69ad5e
using gha-gradle-library-release-workflow: https://github.com/guardian/gha-gradle-library-release-workflow

Release-Version: 10.1.0-PREVIEW.abhealthmulti-preview-app-colour-wrapper.2026-08-13T1610.ee69ad5e
Release-Initiated-By: https://github.com/adi-gnm
Release-Workflow-Run: https://github.com/guardian/source-apps/actions/runs/31719287680
Release-Notes: #425
@gu-gradle-library-release

Copy link
Copy Markdown
Contributor

@adi-gnm has published a preview version of this PR with release workflow run #259, based on commit ee69ad5:

10.1.0-PREVIEW.abhealthmulti-preview-app-colour-wrapper.2026-08-13T1610.ee69ad5e

Want to make another preview release?

Click 'Run workflow' in the GitHub UI, specifying the ab/health/multi-preview-app-colour-wrapper branch, or use the GitHub CLI command:

gh workflow run release.yml --ref ab/health/multi-preview-app-colour-wrapper

Want to make a full release after this PR is merged?

Click 'Run workflow' in the GitHub UI, leaving the branch as the default, or use the GitHub CLI command:

gh workflow run release.yml

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintenance Departmental tracking: maintenance work, not a fix or a feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants