[FR]: Replace custom preview annotations with androidx.compose.ui.tooling.preview alternatives

Open
#1,923 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
50/100
Issue type
Refactor
Clarity
Clearly specified
Activity status
Stale
Tech stack
android, kotlin
Domain
mobile, tooling

Research direction

Start by reading core/designsystem/ThemePreviews.kt and core/ui/DevicePreviews.kt, then locate their usages across the project. Replace those usages with PreviewLightDark and PreviewScreenSizes from androidx.compose.ui.tooling.preview, remove the two custom annotation files, and verify that the project builds and previews still cover the intended themes and screen sizes.

Written by the indexing model from the issue text.

Description

enhancement
Is there an existing issue for this?
  • I have searched the existing issues
Describe the problem

The current nowinandroid project uses custom annotations for previews that replicate functionality already available in the Jetpack Compose tooling library:

  • com.google.samples.apps.nowinandroid.core.designsystem.ThemePreviews for showing light and dark themes.

  • com.google.samples.apps.nowinandroid.core.ui.DevicePreviews for showing different device sizes.

This introduces boilerplate code and maintenance overhead for a feature that is now officially supported by the Compose library itself.

Describe the solution

Replace the custom annotations with the standard androidx.compose.ui.tooling.preview alternatives:

  1. Replace ThemePreviews with PreviewLightDark:
    PreviewLightDark from androidx.compose.ui.tooling.preview provides a cleaner, built-in way to render composables in both light and dark themes. This would allow for the removal of the ThemePreviews.kt file.
  2. Replace DevicePreviews with PreviewScreenSizes:
    PreviewScreenSizes from androidx.compose.ui.tooling.preview offers a direct and idiomatic way to display a composable across a range of screen sizes. This would allow for the removal of the DevicePreviews.kt file.
Additional context

No response

Code of Conduct
  • I agree to follow this project's Code of Conduct
Dominant language
Kotlin
Stars
22.1k
Forks
4.7k
PR merge metrics
No merged PRs in 30d

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 android/nowinandroid

All issues in android/nowinandroid

Similar issues

More Kotlin issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.