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

Đang mở
#1,923 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
50/100
Loại issue
Tái cấu trúc
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
android, kotlin
Lĩnh vực
mobile, tooling

Hướng nghiên cứu

Bắt đầu bằng cách đọc core/designsystem/ThemePreviews.kt và core/ui/DevicePreviews.kt, sau đó xác định các vị trí sử dụng chúng trong toàn bộ dự án. Thay thế các vị trí sử dụng đó bằng PreviewLightDark và PreviewScreenSizes từ androidx.compose.ui.tooling.preview, xóa hai tệp annotation tùy chỉnh và xác minh rằng dự án build thành công cũng như các preview vẫn bao phủ các theme và kích thước màn hình dự kiến.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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
Ngôn ngữ chính
Kotlin
Star
22.1k
Fork
4.7k
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của android/nowinandroid

Tất cả issue của android/nowinandroid

Issue tương tự

Thêm issue về Kotlin

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.