wear-compose-m3
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePrerequisites and compatibility
前提条件与兼容性
- Current Wear OS Compose version in-use: To find the installed library version, read or
gradle/libs.versions.tomldirectly. Don't runbuild.gradle.ktsor other shell commands to resolve versions../gradlew dependencies - Wear OS Compose Material3 version: If an internal tool is available to establish the latest stable version of
{VERSION}, use that tool.androidx.wear.compose:compose-material3- Otherwise, fetch the official Maven metadata XML to identify (highest number, ignoring
{VERSION},-alpha, or-beta).-rc
- Otherwise, fetch the official Maven metadata XML to identify
- Strict compliance: If a version is listed as stable, you MUST use it, unless overridden by the user. Do not downgrade based on initial "Unresolved reference" errors in the editor or outdated web search results.
- Kotlin version: For Wear Compose Material3, use Kotlin 2.0.0 or higher.
- Compose compiler:
- If Kotlin version is 2.0.0+ , the project must use the Gradle plugin.
org.jetbrains.kotlin.plugin.compose - If Kotlin version is < 2.0.0 , the project must use in
kotlinCompilerExtensionVersion, matching the Compose to Kotlin Compatibility Map.composeOptions
- If Kotlin version is 2.0.0+ , the project must use the
- Min SDK: Ensure is at least 25.
minSdk - Sample extraction mandate: Wear Compose libraries ship with an additional JAR file which contains individual samples for each and every component. You mustn't propose code changes, other than previews or basic changes such as color changes, until the samples in Capability 3 are extracted to the local cache. Library source files are incomplete and NOT a substitute for these samples; bypassing extraction is an environment setup failure.
- 当前使用的Wear OS Compose版本:要查看已安装的库版本,请直接读取或
gradle/libs.versions.toml文件。不要运行build.gradle.kts或其他shell命令来解析版本。./gradlew dependencies - Wear OS Compose Material3版本:如果有内部工具可获取的最新稳定版本
androidx.wear.compose:compose-material3,请使用该工具。{VERSION}- 若没有,则获取官方Maven元数据XML来确定(选择最高版本号,忽略
{VERSION}、-alpha或-beta后缀的版本)。-rc
- 若没有,则获取官方Maven元数据XML来确定
- 严格合规要求:如果某个版本标记为稳定版,除非用户另行指定,否则必须使用该版本。不要因编辑器中出现的初始"Unresolved reference"错误或过时的网页搜索结果而降级版本。
- Kotlin版本:对于Wear Compose Material3,请使用Kotlin 2.0.0或更高版本。
- Compose编译器:
- 若Kotlin版本为2.0.0+,项目必须使用Gradle插件。
org.jetbrains.kotlin.plugin.compose - 若Kotlin版本**< 2.0.0**,项目必须在中配置
composeOptions,并与Compose与Kotlin兼容性映射表匹配。kotlinCompilerExtensionVersion
- 若Kotlin版本为2.0.0+,项目必须使用
- 最低SDK版本:确保至少为25。
minSdk - 示例提取要求:Wear Compose库附带一个额外的JAR文件,其中包含每个组件的独立示例。在将功能3中的示例提取到本地缓存之前,除了预览或颜色修改等基础更改外,不得提议任何代码变更。库源文件不完整,不能替代这些示例;跳过提取步骤属于环境设置失败。
Gotchas
注意事项
- Mandatory sync and validation: After updating versions in or
libs.versions.toml, you must perform a Gradle sync before refactoring any code. This ensures the environment has resolved the libraries correctly.build.gradle.kts - Prohibition of guessing (error protocol): If you encounter an 'Unresolved Reference' or API mismatch after a successful sync, do not attempt to 'fix' it by downgrading the library version.
- 强制同步与验证:在或
libs.versions.toml中更新版本后,必须先执行Gradle同步,再重构任何代码。这确保环境已正确解析库文件。build.gradle.kts - 禁止猜测(错误处理规则):如果同步成功后仍遇到'Unresolved Reference'或API不匹配问题,请勿通过降级库版本尝试"修复"。
Capabilities and tools
功能与工具
Capability 1: Migration
功能1:迁移
Use this guidance when migrating from an older version of Wear OS Compose or Horologist.
- Unless otherwise indicated by the developer, use the latest stable version of Wear Compose Material3 from .
{VERSION} - Read the migration guide.
- Use the official component mappings from the migration guide.
- Before refactoring any component (for example, ->
Chip), check the parameter names, slot types, and "Expressive" design tokens.Button - Do not use the Horologist Composables, Compose Layout, or Compose Material libraries.
- Always check against the component guidance in Capability 4.
- Expect screenshot tests to fail when a migration has been performed: Even when migrating to very similar components, expected defaults for padding and positioning will have changed. Do not seek to artificially match the pre-migration screenshot, but give preference to the Material3 defaults.
当从旧版本Wear OS Compose或Horologist迁移时,请遵循以下指导。
- 除非开发者另行指定,否则使用中的Wear Compose Material3最新稳定版本。
{VERSION} - 阅读迁移指南。
- 使用迁移指南中的官方组件映射关系。
- 在重构任何组件(例如->
Chip)之前,检查参数名称、插槽类型和"Expressive"设计标记。Button - 不要使用Horologist Composables、Compose Layout或Compose Material库。
- 务必对照功能4中的组件指导进行检查。
- 迁移完成后,截图测试可能会失败:即使迁移到非常相似的组件,内边距和位置的默认值也可能已更改。请勿刻意匹配迁移前的截图,应优先使用Material3的默认值。
Capability 2: Adding Wear OS Compose Material3 features or updating the app
功能2:添加Wear OS Compose Material3功能或更新应用
Use this guidance when the developer asks to update a project which is using an earlier version of Wear OS Compose Material3, or when they ask to add further features.
- Unless otherwise indicated by the developer, use the latest stable version of Wear Compose Material3 from .
{VERSION} - Do not use the Horologist Composables, Compose Layout, or Compose Material libraries.
- Always check against the component guidance in Capability 4.
- Expect screenshot tests to fail when a migration has been performed: Even when migrating to very similar components, expected defaults for padding and positioning will have changed. Do not seek to artificially match the pre-migration screenshot, but give preference to the Material3 defaults.
当开发者要求更新使用早期版本Wear OS Compose Material3的项目,或要求添加更多功能时,请遵循以下指导。
- 除非开发者另行指定,否则使用中的Wear Compose Material3最新稳定版本。
{VERSION} - 不要使用Horologist Composables、Compose Layout或Compose Material库。
- 务必对照功能4中的组件指导进行检查。
- 迁移完成后,截图测试可能会失败:即使迁移到非常相似的组件,内边距和位置的默认值也可能已更改。请勿刻意匹配迁移前的截图,应优先使用Material3的默认值。
Capability 3: Component samples
功能3:组件示例
Use this table of reference to find canonical samples for Wear Compose components. When working with a Wear Compose component, you must use the samples linked from the table to ensure you know how to correctly use it.
使用此参考表查找Wear Compose组件的标准示例。在使用Wear Compose组件时,必须使用表中链接的示例,以确保正确使用组件。
Material 3 components in androidx.wear.compose.material3.*
androidx.wear.compose.material3.*androidx.wear.compose.material3.*
中的Material 3组件
androidx.wear.compose.material3.*| Component / Symbol | Reference Samples |
|---|---|
| AlertDialogSample |
| OneHandedGestureSamples, PageIndicatorSample, PagerScaffoldSample |
| AnimatedTextSample |
| CardSample |
| ListHeaderSample, PagerScaffoldSample, ScaffoldSample, SurfaceTransformationSample, TransformingLazyColumnNotificationsSample, TransformingLazyColumnSample |
| ProgressIndicatorSample |
| AlertDialogSample, AnimatedTextSample, ButtonGroupSample, ButtonSample, DatePickerSample, DynamicColorSchemeSample, FadingExpandingLabelSample, ListHeaderSample, OneHandedGestureSamples, PageIndicatorSample, PagerScaffoldSample, PickerSample, ScaffoldSample, ScrollIndicatorSample, StepperSample, SurfaceTransformationSample, SwipeToRevealSample, TimePickerSample, TransformationSpecSample, TransformingLazyColumnSample, TransformingLazyColumnSample |
| ButtonSample, CurvedTextSamples, DynamicColorSchemeSample, EdgeButtonSample, ListHeaderSample, PlaceholderSample, ScaffoldSample, ScrollAwaySample, ScrollIndicatorSample, SurfaceTransformationSample, TextButtonSample, TransformationSpecSample, TransformingLazyColumnSample, TransformingLazyColumnSample |
| ButtonGroupSample, TransformationSpecSample |
| CardSample, SwipeToRevealSample, TransformingLazyColumnSample |
| CardSample, SurfaceTransformationSample, SwipeToRevealSample, TransformingLazyColumnSample, TransformingLazyColumnSample |
| CheckboxButtonSample, SwipeToDismissBoxSample |
| ButtonSample |
| DynamicColorSchemeSample |
| ButtonSample, TransformingLazyColumnSample |
| ConfirmationDialogSample |
| CurvedTextSamples |
| DatePickerSample |
| EdgeButtonSample, OneHandedGestureSamples, ScaffoldSample, TransformingLazyColumnSample |
| EdgeButtonSample |
| FadingExpandingLabelSample |
| IconButtonSample |
| AlertDialogSample, ButtonSample, ConfirmationDialogSample, OpenOnPhoneDialogSample, PlaceholderSample, ScrollAwaySample, SwipeToDismissBoxSample |
| ButtonSample, CardSample, OneHandedGestureSamples |
| OneHandedGestureSamples |
| StepperSample |
| PageIndicatorSample |
| AlertDialogSample, ButtonSample, CardSample, CheckboxButtonSample, ConfirmationDialogSample, CurvedTextSamples, DatePickerSample, EdgeButtonSample, IconButtonSample, ListHeaderSample, PlaceholderSample, ProgressIndicatorSample, RadioButtonSample, SwipeToRevealSample, SwitchButtonSample, TimePickerSample |
| IconButtonSample, LevelIndicatorSample, ProgressIndicatorSample |
| IconButtonSample, ProgressIndicatorSample |
| IconToggleButtonSample |
| LevelIndicatorSample |
| LinearProgressIndicatorSample |
| ListHeaderSample, ScrollAwaySample, TransformingLazyColumnNotificationsSample, TransformingLazyColumnSample |
| ListHeaderSample, ScrollAwaySample, TransformingLazyColumnSample |
| ListHeaderSample |
| AlertDialogSample, ButtonSample, CardSample, CurvedTextSamples, DynamicColorSchemeSample, LinearProgressIndicatorSample, PagerScaffoldSample, ProgressIndicatorSample, SwipeToDismissBoxSample, TimeTextSample, TransformingLazyColumnNotificationsSample |
| OpenOnPhoneDialogSample |
| CardSample, TransformingLazyColumnSample |
| PageIndicatorSample, PagerScaffoldSample |
| PickerSample |
| PickerGroupSample |
| RadioButtonSample |
| SurfaceTransformationSample, TransformationSpecSample |
| SwipeToRevealSample |
| ListHeaderSample, OneHandedGestureSamples, PagerScaffoldSample, ScaffoldSample, SurfaceTransformationSample, TransformingLazyColumnNotificationsSample, TransformingLazyColumnSample |
| ScrollIndicatorSample |
| ScrollAwaySample |
| SliderSample |
| CheckboxButtonSample |
| SwitchButtonSample |
| LevelIndicatorSample, StepperSample |
| AlertDialogSample, DynamicColorSchemeSample, ListHeaderSample, ScaffoldSample, SurfaceTransformationSample, TransformationSpecSample, TransformingLazyColumnNotificationsSample, TransformingLazyColumnSample, TransformingLazyColumnSample |
| SwipeToDismissBoxSample |
| AlertDialogSample, OneHandedGestureSamples, SwitchButtonSample |
| AlertDialogSample, AnimatedTextSample, ButtonGroupSample, ButtonSample, CardSample, CheckboxButtonSample, ConfirmationDialogSample, DatePickerSample, DynamicColorSchemeSample, EdgeButtonSample, ListHeaderSample, OneHandedGestureSamples, OpenOnPhoneDialogSample, PageIndicatorSample, PagerScaffoldSample, PickerGroupSample, PickerSample, PlaceholderSample, RadioButtonSample, ScaffoldSample, ScrollAwaySample, ScrollIndicatorSample, StepperSample, SurfaceTransformationSample, SwipeToDismissBoxSample, SwipeToRevealSample, SwitchButtonSample, TextButtonSample, TextToggleButtonSample, TimePickerSample, TransformationSpecSample, TransformingLazyColumnNotificationsSample, TransformingLazyColumnSample |
| TextButtonSample |
| TextButtonSample, TextToggleButtonSample |
| TextToggleButtonSample |
| TimePickerSample |
| ScrollAwaySample, ScrollIndicatorSample, TimeTextSample |
| TimeTextSample |
| CardSample, SurfaceTransformationSample, SwipeToRevealSample, TransformingLazyColumnNotificationsSample, TransformingLazyColumnSample |
| TransformationSpecSample |
| CurvedTextSamples, ScrollAwaySample, TimeTextSample |
| TransformingLazyColumnSample |
| PlaceholderSample |
| PickerGroupSample, PickerSample |
| AlertDialogSample, DynamicColorSchemeSample, ListHeaderSample, ScaffoldSample, SurfaceTransformationSample, SwipeToRevealSample, TransformationSpecSample, TransformingLazyColumnNotificationsSample, TransformingLazyColumnSample, TransformingLazyColumnSample |
| ScrollAwaySample, TimeTextSample |
| 组件 / 符号 | 参考示例 |
|---|---|
| AlertDialogSample |
| OneHandedGestureSamples, PageIndicatorSample, PagerScaffoldSample |
| AnimatedTextSample |
| CardSample |
| ListHeaderSample, PagerScaffoldSample, ScaffoldSample, SurfaceTransformationSample, TransformingLazyColumnNotificationsSample, TransformingLazyColumnSample |
| ProgressIndicatorSample |
| AlertDialogSample, AnimatedTextSample, ButtonGroupSample, ButtonSample, DatePickerSample, DynamicColorSchemeSample, FadingExpandingLabelSample, ListHeaderSample, OneHandedGestureSamples, PageIndicatorSample, PagerScaffoldSample, PickerSample, ScaffoldSample, ScrollIndicatorSample, StepperSample, SurfaceTransformationSample, SwipeToRevealSample, TimePickerSample, TransformationSpecSample, TransformingLazyColumnSample, TransformingLazyColumnSample |
| ButtonSample, CurvedTextSamples, DynamicColorSchemeSample, EdgeButtonSample, ListHeaderSample, PlaceholderSample, ScaffoldSample, ScrollAwaySample, ScrollIndicatorSample, SurfaceTransformationSample, TextButtonSample, TransformationSpecSample, TransformingLazyColumnSample, TransformingLazyColumnSample |
| ButtonGroupSample, TransformationSpecSample |
| CardSample, SwipeToRevealSample, TransformingLazyColumnSample |
| CardSample, SurfaceTransformationSample, SwipeToRevealSample, TransformingLazyColumnSample, TransformingLazyColumnSample |
| CheckboxButtonSample, SwipeToDismissBoxSample |
| ButtonSample |
| DynamicColorSchemeSample |
| ButtonSample, TransformingLazyColumnSample |
| ConfirmationDialogSample |
| CurvedTextSamples |
| DatePickerSample |
| EdgeButtonSample, OneHandedGestureSamples, ScaffoldSample, TransformingLazyColumnSample |
| EdgeButtonSample |
| FadingExpandingLabelSample |
| IconButtonSample |
| AlertDialogSample, ButtonSample, ConfirmationDialogSample, OpenOnPhoneDialogSample, PlaceholderSample, ScrollAwaySample, SwipeToDismissBoxSample |
| ButtonSample, CardSample, OneHandedGestureSamples |
| OneHandedGestureSamples |
| StepperSample |
| PageIndicatorSample |
| AlertDialogSample, ButtonSample, CardSample, CheckboxButtonSample, ConfirmationDialogSample, CurvedTextSamples, DatePickerSample, EdgeButtonSample, IconButtonSample, ListHeaderSample, PlaceholderSample, ProgressIndicatorSample, RadioButtonSample, SwipeToRevealSample, SwitchButtonSample, TimePickerSample |
| IconButtonSample, LevelIndicatorSample, ProgressIndicatorSample |
| IconButtonSample, ProgressIndicatorSample |
| IconToggleButtonSample |
| LevelIndicatorSample |
| LinearProgressIndicatorSample |
| ListHeaderSample, ScrollAwaySample, TransformingLazyColumnNotificationsSample, TransformingLazyColumnSample |
| ListHeaderSample, ScrollAwaySample, TransformingLazyColumnSample |
| ListHeaderSample |
| AlertDialogSample, ButtonSample, CardSample, CurvedTextSamples, DynamicColorSchemeSample, LinearProgressIndicatorSample, PagerScaffoldSample, ProgressIndicatorSample, SwipeToDismissBoxSample, TimeTextSample, TransformingLazyColumnNotificationsSample |
| OpenOnPhoneDialogSample |
| CardSample, TransformingLazyColumnSample |
| PageIndicatorSample, PagerScaffoldSample |
| PickerSample |
| PickerGroupSample |
| RadioButtonSample |
| SurfaceTransformationSample, TransformationSpecSample |
| SwipeToRevealSample |
| ListHeaderSample, OneHandedGestureSamples, PagerScaffoldSample, ScaffoldSample, SurfaceTransformationSample, TransformingLazyColumnNotificationsSample, TransformingLazyColumnSample |
| ScrollIndicatorSample |
| ScrollAwaySample |
| SliderSample |
| CheckboxButtonSample |
| SwitchButtonSample |
| LevelIndicatorSample, StepperSample |
| AlertDialogSample, DynamicColorSchemeSample, ListHeaderSample, ScaffoldSample, SurfaceTransformationSample, TransformationSpecSample, TransformingLazyColumnNotificationsSample, TransformingLazyColumnSample, TransformingLazyColumnSample |
| SwipeToDismissBoxSample |
| AlertDialogSample, OneHandedGestureSamples, SwitchButtonSample |
| AlertDialogSample, AnimatedTextSample, ButtonGroupSample, ButtonSample, CardSample, CheckboxButtonSample, ConfirmationDialogSample, DatePickerSample, DynamicColorSchemeSample, EdgeButtonSample, ListHeaderSample, OneHandedGestureSamples, OpenOnPhoneDialogSample, PageIndicatorSample, PagerScaffoldSample, PickerGroupSample, PickerSample, PlaceholderSample, RadioButtonSample, ScaffoldSample, ScrollAwaySample, ScrollIndicatorSample, StepperSample, SurfaceTransformationSample, SwipeToDismissBoxSample, SwipeToRevealSample, SwitchButtonSample, TextButtonSample, TextToggleButtonSample, TimePickerSample, TransformationSpecSample, TransformingLazyColumnNotificationsSample, TransformingLazyColumnSample |
| TextButtonSample |
| TextButtonSample, TextToggleButtonSample |
| TextToggleButtonSample |
| TimePickerSample |
| ScrollAwaySample, ScrollIndicatorSample, TimeTextSample |
| TimeTextSample |
| CardSample, SurfaceTransformationSample, SwipeToRevealSample, TransformingLazyColumnNotificationsSample, TransformingLazyColumnSample |
| TransformationSpecSample |
| CurvedTextSamples, ScrollAwaySample, TimeTextSample |
| TransformingLazyColumnSample |
| PlaceholderSample |
| PickerGroupSample, PickerSample |
| AlertDialogSample, DynamicColorSchemeSample, ListHeaderSample, ScaffoldSample, SurfaceTransformationSample, SwipeToRevealSample, TransformationSpecSample, TransformingLazyColumnNotificationsSample, TransformingLazyColumnSample, TransformingLazyColumnSample |
| ScrollAwaySample, TimeTextSample |
Foundation components in androidx.wear.compose.foundation.*
androidx.wear.compose.foundation.*androidx.wear.compose.foundation.*
中的Foundation组件
androidx.wear.compose.foundation.*| Component / Symbol | Reference Samples |
|---|---|
| AmbientModeSample |
| ScalingLazyColumnSample |
| SwipeToDismissBoxSample |
| CurvedWorldSample |
| CurvedTextSamples, CurvedWorldSample |
| CurvedTextSamples, CurvedWorldSample, TimeTextSample |
| SwipeToRevealSample |
| OneHandedGestureSamples, PageIndicatorSample, PagerSamples, PagerScaffoldSample |
| TransformingLazyColumnSample |
| PagerScaffoldSample |
| PagerScaffoldSample, RotarySamples, ScalingLazyColumnSample, TransformingLazyColumnSample |
| RotarySamples |
| ExpandableSample, HierarchicalFocusSample, OneHandedGestureSamples, ScalingLazyColumnSample, SwipeToRevealSample, SwipeToRevealSample |
| ScrollAwaySample |
| SwipeToDismissBoxSample, SwipeToDismissBoxSample |
| DynamicColorSchemeSample, ListHeaderSample, OneHandedGestureSamples, ScaffoldSample, ScrollAwaySample, ScrollIndicatorSample, SurfaceTransformationSample, SwipeToRevealSample, TransformationSpecSample, TransformingLazyColumnNotificationsSample, TransformingLazyColumnSample, TransformingLazyColumnSample |
| TransformingLazyColumnSample, TransformingLazyColumnSample |
| TransformationSpecSample |
| ExpandableSample |
| ExpandableSample, SwipeToRevealSample |
| HierarchicalFocusSample |
| SwipeToRevealSample, TransformingLazyColumnNotificationsSample |
| TransformingLazyColumnSample |
| OneHandedGestureSamples, ScalingLazyColumnSample, SwipeToRevealSample |
| ListHeaderSample, OneHandedGestureSamples, ScaffoldSample, ScrollAwaySample, ScrollIndicatorSample, SurfaceTransformationSample, SwipeToRevealSample, TransformingLazyColumnNotificationsSample, TransformingLazyColumnSample, TransformingLazyColumnSample |
| HierarchicalFocusSample, RotarySamples |
| CurvedWorldSample, TimeTextSample |
| 组件 / 符号 | 参考示例 |
|---|---|
| AmbientModeSample |
| ScalingLazyColumnSample |
| SwipeToDismissBoxSample |
| CurvedWorldSample |
| CurvedTextSamples, CurvedWorldSample |
| CurvedTextSamples, CurvedWorldSample, TimeTextSample |
| SwipeToRevealSample |
| OneHandedGestureSamples, PageIndicatorSample, PagerSamples, PagerScaffoldSample |
| TransformingLazyColumnSample |
| PagerScaffoldSample |
| PagerScaffoldSample, RotarySamples, ScalingLazyColumnSample, TransformingLazyColumnSample |
| RotarySamples |
| ExpandableSample, HierarchicalFocusSample, OneHandedGestureSamples, ScalingLazyColumnSample, SwipeToRevealSample, SwipeToRevealSample |
| ScrollAwaySample |
| SwipeToDismissBoxSample, SwipeToDismissBoxSample |
| DynamicColorSchemeSample, ListHeaderSample, OneHandedGestureSamples, ScaffoldSample, ScrollAwaySample, ScrollIndicatorSample, SurfaceTransformationSample, SwipeToRevealSample, TransformationSpecSample, TransformingLazyColumnNotificationsSample, TransformingLazyColumnSample, TransformingLazyColumnSample |
| TransformingLazyColumnSample, TransformingLazyColumnSample |
| TransformationSpecSample |
| ExpandableSample |
| ExpandableSample, SwipeToRevealSample |
| HierarchicalFocusSample |
| SwipeToRevealSample, TransformingLazyColumnNotificationsSample |
| TransformingLazyColumnSample |
| OneHandedGestureSamples, ScalingLazyColumnSample, SwipeToRevealSample |
| ListHeaderSample, OneHandedGestureSamples, ScaffoldSample, ScrollAwaySample, ScrollIndicatorSample, SurfaceTransformationSample, SwipeToRevealSample, TransformingLazyColumnNotificationsSample, TransformingLazyColumnSample, TransformingLazyColumnSample |
| HierarchicalFocusSample, RotarySamples |
| CurvedWorldSample, TimeTextSample |
Capability 4: Component guidance
功能4:组件指导
Mandatory: Use this capability as a checklist against any component use. It provides more holistic guidance on how to use each component in practice, beyond the component syntax.
-
and
AppScaffoldScreenScaffold- [ ] Use as the outer container, with
AppScaffoldchildren.ScreenScaffold - [ ] Use only ONE and any number of
AppScaffold.ScreenScaffold
- [ ] Use
-
- Use
ScalingLazyColumninstead.TransformingLazyColumn -
<br />- You will need the following imports:
TransformingLazyColumn<br />kotlinimport androidx.wear.compose.foundation.lazy.TransformingLazyColumn import androidx.wear.compose.foundation.lazy.TransformingLazyColumnDefaults import androidx.wear.compose.foundation.lazy.rememberTransformingLazyColumnState // ... import androidx.wear.compose.material3.lazy.rememberTransformationSpec import androidx.wear.compose.material3.lazy.transformedHeightCanonical example:<br /><br />kotlinval columnState = rememberTransformingLazyColumnState() val transformationSpec = rememberTransformationSpec() ScreenScaffold( scrollState = columnState ) { contentPadding -> TransformingLazyColumn( state = columnState, contentPadding = contentPadding ) { item { ListHeader( modifier = Modifier .fillMaxWidth() .transformedHeight(this, transformationSpec) .minimumVerticalContentPadding(ListHeaderDefaults.minimumTopListContentPadding), transformation = SurfaceTransformation(transformationSpec) ) { Text(text = "Header") } } // ... other items item { Button( modifier = Modifier .fillMaxWidth() .transformedHeight(this, transformationSpec) .minimumVerticalContentPadding(ButtonDefaults.minimumVerticalListContentPadding), transformation = SurfaceTransformation(transformationSpec), onClick = { /* ... */ }, icon = { Icon( imageVector = Icons.Default.Build, contentDescription = "build", ) }, ) { Text( text = "Build", maxLines = 1, overflow = TextOverflow.Ellipsis, ) } } } }- [ ] Use instead of
TransformingLazyColumn.ScalingLazyColumn - [ ] You must pass the parameter from
contentPaddingto theScreenScaffold.TransformingLazyColumn - [ ] Use the modifier to achieve required padding top and bottom.
minimumVerticalContentPadding- This expects a value from defaults, such as ,
ButtonDefaults, `ListHeaderDefaults.CardDefaults - Note: This is a scoped modifier available within .
TransformingLazyColumnItemScope
- This expects a value from defaults, such as
- [ ] Ensure the list morphs and scales.
- [ ] Use modifier.
transformedHeight - [ ] Use .
transform = SurfaceTransform(...) - [ ] If configuring a list for snapping, use and
flingBehaviortogether:rotaryScrollableBehavior
<br />kotlinval columnState = rememberTransformingLazyColumnState() ScreenScaffold(scrollState = columnState) { contentPadding -> TransformingLazyColumn( state = columnState, flingBehavior = TransformingLazyColumnDefaults.snapFlingBehavior(columnState), rotaryScrollableBehavior = RotaryScrollableDefaults.snapBehavior(columnState) ) { // ... // ... } } - [ ] Use
-
ScreenScaffold- [ ] Guard the with
scrollIndicator.!LocalScrollCaptureInProgress.current
- [ ] Guard the
-
EdgeButton- [ ] Do NOT use as the final item within a . Instead, use the slot in
TransformingLazyColumn.ScreenScaffold - [ ] When used in a , add the required overscroll behavior:
TransformingLazyColumn
<br />kotlinval columnState = rememberTransformingLazyColumnState() ScreenScaffold( scrollState = columnState, edgeButton = { EdgeButton( onClick = { /* TODO */ }, modifier = Modifier.scrollable( columnState, orientation = Orientation.Vertical, reverseDirection = true, // Apply overscroll to the EdgeButton for proper scrolling behavior. overscrollEffect = rememberOverscrollEffect(), ) ) { Text("More") } } ) { contentPadding -> TransformingLazyColumn( contentPadding = contentPadding, state = columnState, ) { // ... // ... } } - [ ] Do NOT use as the final item within a
-
Column- [ ] USE as a direct child of if the screen is will never scroll, even with the largest system font.
ScreenScaffold - [ ] Use instead for all other cases.
TransformingLazyColumn
- [ ] USE as a direct child of
-
Styles
- [ ] Do NOT hard-code text sizes, use from
typography.MaterialTheme - [ ] Do NOT hard-code colors, use from
colorScheme.MaterialTheme
- [ ] Do NOT hard-code text sizes, use
-
Use component defaults:
- [ ] Components such as have a corresponding
Buttonobject.ButtonDefaults - [ ] Check for and use the object for any component when working with padding and styling values, in preference to hard-coded values.
*Defaults
- [ ] Components such as
-
Use Wear specific previews:
- [ ]
WearPreviewDevices - [ ]
WearPreviewFontScales
- [ ]
-
Ambient mode
- [ ] Use instead of
LocalAmbientModeManager.AmbientLifecycleObserver
- [ ] Use
-
Navigation
- [ ] When adding navigation fresh, use Navigation3.
- [ ] For Navigation3 in Wear OS, use from the Wear Compose
SwipeDismissableSceneStrategy()library.compose-navigation3
-
Comments
- [ ] Where any Kotlin file has been modified, ensure that the existing comments are up to date and accurately reflect any changes to the implementation.
-
or
HorizontalPagerVerticalPager- [ ] Use the Composable hierarchy in this order: ,
AppScaffold,HorizontalPagerScaffold,HorizontalPager,AnimatedPage. Or similarly forScreenScaffold.VerticalPager
- [ ] Use the Composable hierarchy in this order:
强制要求:将此功能作为使用任何组件的检查清单。它提供了比组件语法更全面的实践指导,说明如何实际使用每个组件。
-
和
AppScaffoldScreenScaffold- [ ] 将作为外部容器,子容器使用
AppScaffold。ScreenScaffold - [ ] 仅使用一个,可使用任意数量的
AppScaffold。ScreenScaffold
- [ ] 将
-
- 改用
ScalingLazyColumn。TransformingLazyColumn -
<br />- 需要以下导入:
TransformingLazyColumn<br />kotlinimport androidx.wear.compose.foundation.lazy.TransformingLazyColumn import androidx.wear.compose.foundation.lazy.TransformingLazyColumnDefaults import androidx.wear.compose.foundation.lazy.rememberTransformingLazyColumnState // ... import androidx.wear.compose.material3.lazy.rememberTransformationSpec import androidx.wear.compose.material3.lazy.transformedHeight标准示例:<br /><br />kotlinval columnState = rememberTransformingLazyColumnState() val transformationSpec = rememberTransformationSpec() ScreenScaffold( scrollState = columnState ) { contentPadding -> TransformingLazyColumn( state = columnState, contentPadding = contentPadding ) { item { ListHeader( modifier = Modifier .fillMaxWidth() .transformedHeight(this, transformationSpec) .minimumVerticalContentPadding(ListHeaderDefaults.minimumTopListContentPadding), transformation = SurfaceTransformation(transformationSpec) ) { Text(text = "Header") } } // ... 其他条目 item { Button( modifier = Modifier .fillMaxWidth() .transformedHeight(this, transformationSpec) .minimumVerticalContentPadding(ButtonDefaults.minimumVerticalListContentPadding), transformation = SurfaceTransformation(transformationSpec), onClick = { /* ... */ }, icon = { Icon( imageVector = Icons.Default.Build, contentDescription = "build", ) }, ) { Text( text = "Build", maxLines = 1, overflow = TextOverflow.Ellipsis, ) } } } }- [ ] 改用而非
TransformingLazyColumn。ScalingLazyColumn - [ ] 必须将的
ScreenScaffold参数传递给contentPadding。TransformingLazyColumn - [ ] 使用修饰符来设置所需的顶部和底部内边距。
minimumVerticalContentPadding- 该修饰符需要使用默认值,例如、
ButtonDefaults、CardDefaults中的值。ListHeaderDefaults - 注意:这是中可用的作用域修饰符。
TransformingLazyColumnItemScope
- 该修饰符需要使用默认值,例如
- [ ] 确保列表可变形和缩放。
- [ ] 使用修饰符。
transformedHeight - [ ] 使用。
transform = SurfaceTransform(...) - [ ] 如果要配置列表的吸附功能,请同时使用和
flingBehavior:rotaryScrollableBehavior
<br />kotlinval columnState = rememberTransformingLazyColumnState() ScreenScaffold(scrollState = columnState) { contentPadding -> TransformingLazyColumn( state = columnState, flingBehavior = TransformingLazyColumnDefaults.snapFlingBehavior(columnState), rotaryScrollableBehavior = RotaryScrollableDefaults.snapBehavior(columnState) ) { // ... // ... } } - [ ] 改用
-
ScreenScaffold- [ ] 使用来保护
!LocalScrollCaptureInProgress.current。scrollIndicator
- [ ] 使用
-
EdgeButton- [ ] 不要将其用作中的最后一个条目,而是使用
TransformingLazyColumn中的插槽。ScreenScaffold - [ ] 当在中使用时,添加所需的过度滚动行为:
TransformingLazyColumn
<br />kotlinval columnState = rememberTransformingLazyColumnState() ScreenScaffold( scrollState = columnState, edgeButton = { EdgeButton( onClick = { /* TODO */ }, modifier = Modifier.scrollable( columnState, orientation = Orientation.Vertical, reverseDirection = true, // 为EdgeButton应用过度滚动以实现正确的滚动行为。 overscrollEffect = rememberOverscrollEffect(), ) ) { Text("More") } } ) { contentPadding -> TransformingLazyColumn( contentPadding = contentPadding, state = columnState, ) { // ... // ... } } - [ ] 不要将其用作
-
Column- [ ] 如果屏幕永远不会滚动(即使使用最大系统字体),则将其用作的直接子容器。
ScreenScaffold - [ ] 其他所有情况均改用。
TransformingLazyColumn
- [ ] 如果屏幕永远不会滚动(即使使用最大系统字体),则将其用作
-
样式
- [ ] 不要硬编码文本大小,请使用中的
MaterialTheme。typography - [ ] 不要硬编码颜色,请使用中的
MaterialTheme。colorScheme
- [ ] 不要硬编码文本大小,请使用
-
使用组件默认值:
- [ ] 诸如之类的组件有对应的
Button对象。ButtonDefaults - [ ] 在处理内边距和样式值时,优先检查并使用组件对应的对象,而非硬编码值。
*Defaults
- [ ] 诸如
-
使用Wear专用预览:
- [ ]
WearPreviewDevices - [ ]
WearPreviewFontScales
- [ ]
-
环境模式
- [ ] 使用而非
LocalAmbientModeManager。AmbientLifecycleObserver
- [ ] 使用
-
导航
- [ ] 新建导航时,请使用Navigation3。
- [ ] 对于Wear OS中的Navigation3,请使用Wear Compose 库中的
compose-navigation3。SwipeDismissableSceneStrategy()
-
注释
- [ ] 任何Kotlin文件被修改后,确保现有注释是最新的,并准确反映实现中的任何变更。
-
或
HorizontalPagerVerticalPager- [ ] 按以下顺序使用Composable层次结构:、
AppScaffold、HorizontalPagerScaffold、HorizontalPager、AnimatedPage。ScreenScaffold同理。VerticalPager
- [ ] 按以下顺序使用Composable层次结构: