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

未关闭
#1,923 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
50/100
Issue 类型
重构
描述清晰度
描述清楚
活跃度
停滞
技术栈
android, kotlin
领域
mobile, tooling

调研方向

首先阅读 core/designsystem/ThemePreviews.kt 和 core/ui/DevicePreviews.kt,然后在整个项目中查找它们的使用位置。将这些使用位置替换为 androidx.compose.ui.tooling.preview 中的 PreviewLightDark 和 PreviewScreenSizes,删除这两个自定义注解文件,并验证项目能够成功构建,且预览仍然覆盖预期的主题和屏幕尺寸。

由索引模型根据 Issue 内容生成。

描述

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
主要语言
Kotlin
星标
22.1k
派生
4.7k
PR 合并指标
30 天内没有已合并 PR

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

android/nowinandroid 的其他 Issue

查看 android/nowinandroid 的全部 Issue

相似的 Issue

更多 Kotlin Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。