Conversation
Also update Compose version
…h phone and tablet annotations
There was a problem hiding this comment.
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 : PreviewWrapperProviderand 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
AnimatedPreviewstill wraps its content inAppColourMode, but@PreviewAllDeviceBothModealready applies@PreviewWrapper(AppColourWrapper::class)(which wraps inAppColourMode). This double-wrap causes redundantisSystemInDarkTheme()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.
| @Composable | ||
| @PreviewPhoneBothMode | ||
| @PreviewTabletBothMode | ||
| @PreviewAllDeviceBothMode | ||
| @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE) | ||
| internal fun SourceTextButtonPreview() = AppColourMode { | ||
| val validPriorities = listOf( |
…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
|
@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 |
Description
Adds an
AppColourModepreview wrapper to the existing@PreviewPhoneBothModeand@PreviewTabletBothModeannotations. Also adds a new@PreviewAllDeviceBothModeannotation 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
AppColourModesince the preview under test no longer does that.Related changes:
Checklist