Modern Apps git

← Modern-Apps.git

library-wearlink: theme watch buttons and codify detail order

Commit
bf335680f4c8b9d8e0b454c0667896d396d0704b
Author
Vayun Mathur <[email protected]>
When
2026-12-06 04:27 UTC (8 hours ago)
Parents
04da0f1
WearFilledButton now provides its content color as LocalContentColor and renders its label in that color, so a leading icon tinted with LocalContentColor.current always matches the text. Containers follow the watch Material theme (primary/onPrimary); WearDeleteButton alone stays red (error, white content). The KDoc and AGENTS.md now state the owner rules for every watch app: detail screens order content actions first, then Open on phone last, with only the red Delete button directly after it; buttons are icon+label pairs with icons tinted to the content color.

Verified: :library:wearlink:lint and :library:wearlink:testDevUnitTest green.

Diff

library/wearlink/AGENTS.md
diff --git a/library/wearlink/AGENTS.md b/library/wearlink/AGENTS.mdindex 83ae14fa09..eb70ed4ec4 100644--- a/library/wearlink/AGENTS.md+++ b/library/wearlink/AGENTS.md@@ -20,6 +20,18 @@   `WearDeleteButton`, and the `wearOpenOnPhoneItem`/`wearDeleteItem`   list helpers; the open-on-phone conduit path suffix is   `WEAR_OPEN_ON_PHONE_PATH_SUFFIX`).+- Watch detail-screen button order (owner rule): content-specific+  actions first, then "Open on phone" as the last button, with only+  the red Delete button allowed directly after it; nothing follows+  Delete. Delete appears only where the phone can really delete over+  the app's conduit protocol (add the op end-to-end when missing);+  never a dead or fake delete button.+- Watch button theming (owner rule): action buttons follow the watch+  Material theme (`primary`/`onPrimary`); Delete alone stays red+  (`error`, white content). Buttons are icon+label pairs wherever the+  generated icon set has a fitting glyph, and the icon is tinted with+  `LocalContentColor.current` so it always matches the label text โ€”+  never a hard-coded or mismatched tint.  ## Purpose First-party replacement for the proprietary Play-services Wearable Data
library/wearlink/src/main/java/com/vayunmathur/library/wearlink/WearActionButtons.kt
diff --git a/library/wearlink/src/main/java/com/vayunmathur/library/wearlink/WearActionButtons.kt b/library/wearlink/src/main/java/com/vayunmathur/library/wearlink/WearActionButtons.ktindex f9fef1468b..dca1f18b0d 100644--- a/library/wearlink/src/main/java/com/vayunmathur/library/wearlink/WearActionButtons.kt+++ b/library/wearlink/src/main/java/com/vayunmathur/library/wearlink/WearActionButtons.kt@@ -8,6 +8,7 @@ import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.width import androidx.compose.runtime.Composable+import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color@@ -16,6 +17,7 @@ import androidx.compose.ui.unit.dp import androidx.wear.compose.foundation.lazy.ScalingLazyListScope import androidx.wear.compose.material.Button import androidx.wear.compose.material.ButtonDefaults+import androidx.wear.compose.material.LocalContentColor import androidx.wear.compose.material.MaterialTheme import androidx.wear.compose.material.Text @@ -26,6 +28,18 @@ import androidx.wear.compose.material.Text  * The leading [icon] is supplied by the caller from `library/ui`  * (`IconMobileArrowRight()` for open-on-phone, `IconDelete()` for delete)  * so this transport library stays free of the phone icon set.+ *+ * Theming (owner rule): the container follows the watch Material theme+ * (`primary`/`onPrimary` by default) and the delete button alone stays+ * red (`error` container, white content). Callers tint the leading icon+ * with `LocalContentColor.current` โ€” provided here as [contentColor] โ€”+ * so the icon always matches the label text; never hard-code a tint.+ * Pass a real icon wherever the generated icon set has a fitting glyph:+ * watch action buttons are icon+label pairs, not text-only.+ *+ * Detail-screen ordering (owner rule): content-specific actions first,+ * then "Open on phone" as the last button, with only the red Delete+ * button allowed directly after it. Nothing follows Delete.  */ @Composable fun WearFilledButton(@@ -44,16 +58,23 @@ fun WearFilledButton(         ),         modifier = modifier.fillMaxWidth().padding(horizontal = 8.dp).height(48.dp),     ) {-        Row(-            horizontalArrangement = Arrangement.Center,-            verticalAlignment = Alignment.CenterVertically,-            modifier = Modifier.fillMaxWidth(),-        ) {-            if (icon != null) {-                icon()-                Spacer(Modifier.width(8.dp))+        CompositionLocalProvider(LocalContentColor provides contentColor) {+            Row(+                horizontalArrangement = Arrangement.Center,+                verticalAlignment = Alignment.CenterVertically,+                modifier = Modifier.fillMaxWidth(),+            ) {+                if (icon != null) {+                    icon()+                    Spacer(Modifier.width(8.dp))+                }+                Text(+                    text = label,+                    color = contentColor,+                    maxLines = 1,+                    textAlign = TextAlign.Center,+                )             }-            Text(text = label, maxLines = 1, textAlign = TextAlign.Center)         }     } }@@ -76,7 +97,7 @@ fun WearDeleteButton(     ) } -/** Bottom "Open on phone" filled button in a [ScalingLazyListScope]. */+/** Bottom "Open on phone" filled button in a [ScalingLazyListScope]: the last button on a detail screen (Delete, when present, goes directly after it via [wearDeleteItem]). */ fun ScalingLazyListScope.wearOpenOnPhoneItem(     onClick: () -> Unit,     icon: (@Composable () -> Unit)? = null,@@ -87,7 +108,7 @@ fun ScalingLazyListScope.wearOpenOnPhoneItem(     } } -/** Bottom red delete filled button in a [ScalingLazyListScope], below open-on-phone. */+/** Bottom red delete filled button in a [ScalingLazyListScope], directly below open-on-phone; nothing may follow it on a detail screen. */ fun ScalingLazyListScope.wearDeleteItem(     label: String,     onClick: () -> Unit,