You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Task Description: Add Previews for All Compose Multiplatform Views
Follow the Contribution Guidelines:
Before contributing, make sure to check the Contributing section in the root README.md file for more information on how to contribute to this project.
Goal
Ensure that all Compose Multiplatform views have associated previews, both in light and dark modes. Previews should be placed within the androidMain source set of each module that contains UI components. This will help streamline the development and design review process.
Steps
Update the build.gradle.kts Files:
In every module where views are defined (e.g., :features:details:view), ensure that the build.gradle.kts file is updated to include the required dependencies for Compose previews.
You can follow the example from the features/details/view module:
For every Compose view in the project, add a corresponding preview in the androidMain source set. The preview should include both a light mode and a dark mode version.
The previews should be created similarly to the example below, which comes from PlayerStatItemPreviews.kt:
@Preview(name ="PlayerStatItemPreviewLight", group ="Components")
@Preview(
name ="PlayerStatItemPreviewDark",
group ="Components",
uiMode =Configuration.UI_MODE_NIGHT_YESorConfiguration.UI_MODE_TYPE_NORMAL
)
@Composable
funPlayerStatItemPreview() {
PreviewBox {
PlayerStatItem(
imageUrl =MockPlayer.createMockPlayer().team.imageUrl,
stat = stringResource(Res.string.team),
label =MockPlayer.createMockPlayer().team.label
)
}
}
Use PreviewBox for Previews:
Ensure that all previews use the PreviewBox composable, which wraps the content in the appropriate theme and layout box. Here is the definition for PreviewBox:
Add the preview logic to all modules with UI components. Make sure that every Compose view has a preview.
Each preview should support both light and dark mode by utilizing the uiMode configuration in the @Preview annotations.
The group parameter for the @Preview annotation should be either "Components" or "Screen", depending on whether the view represents a component or an entire screen.
Validate the Previews:
Once the previews are in place, open Android Studio and ensure that all previews render correctly in both light and dark modes.
The previews should appear in the androidMain set and should provide a clear visual of the components in both themes.
Outcome
All Compose views will have corresponding previews in both light and dark modes, making it easier for developers to quickly inspect UI components without running the app. The use of PreviewBox ensures that the previews are consistent with the app's overall theme. This will improve the UI review and development process across modules.
The text was updated successfully, but these errors were encountered:
Task Description: Add Previews for All Compose Multiplatform Views
Follow the Contribution Guidelines:
Before contributing, make sure to check the
Contributing
section in the rootREADME.md
file for more information on how to contribute to this project.Goal
Ensure that all Compose Multiplatform views have associated previews, both in light and dark modes. Previews should be placed within the
androidMain
source set of each module that contains UI components. This will help streamline the development and design review process.Steps
Update the
build.gradle.kts
Files:In every module where views are defined (e.g.,
:features:details:view
), ensure that thebuild.gradle.kts
file is updated to include the required dependencies for Compose previews.You can follow the example from the
features/details/view
module:Create Previews in
androidMain
:For every Compose view in the project, add a corresponding preview in the
androidMain
source set. The preview should include both a light mode and a dark mode version.The previews should be created similarly to the example below, which comes from
PlayerStatItemPreviews.kt
:Use
PreviewBox
for Previews:Ensure that all previews use the
PreviewBox
composable, which wraps the content in the appropriate theme and layout box. Here is the definition forPreviewBox
:Ensure Consistency Across Modules:
uiMode
configuration in the@Preview
annotations.group
parameter for the@Preview
annotation should be either"Components"
or"Screen"
, depending on whether the view represents a component or an entire screen.Validate the Previews:
androidMain
set and should provide a clear visual of the components in both themes.Outcome
All Compose views will have corresponding previews in both light and dark modes, making it easier for developers to quickly inspect UI components without running the app. The use of
PreviewBox
ensures that the previews are consistent with the app's overall theme. This will improve the UI review and development process across modules.The text was updated successfully, but these errors were encountered: