From 05f7da681437e4131bb2749cc5d2ac3e027bd06b Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 17 Jul 2026 18:35:14 +0000 Subject: [PATCH] refactor(commons): extract activity-card building blocks to commons MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Seventh batch of the note-ui-commons extraction. The activity-card slot composables — the gradient frame, kind badge, header row, amount row, and pill shared by the reaction / zap / nutzap renderings — are pure value/slot-in with no strings, so they move as-is. - commons/ui/note/ActivityCard.kt: ActivityCardFrame, ActivityBadge, ActivityPill, ActivityHeaderRow, ActivityAmountRow, and the LikeTint color. - commons/ui/theme/Sizes.kt: shared Size16Modifier (and Size5dp for the next batch), mirroring the Android ui/theme values. - Consumers (Reaction, ZapEvent, Nutzap) re-point their imports to commons. Verified: :commons:compileKotlinJvm and :amethyst:compileFdroidDebugKotlin both pass. Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_01Gmrt3jwYPDJ38MJGJ6GaNr --- .../amethyst/ui/note/types/Nutzap.kt | 4 +++ .../amethyst/ui/note/types/Reaction.kt | 4 +++ .../amethyst/ui/note/types/ZapEvent.kt | 4 +++ .../amethyst/commons/ui/note}/ActivityCard.kt | 4 +-- .../amethyst/commons/ui/theme/Sizes.kt | 35 +++++++++++++++++++ 5 files changed, 49 insertions(+), 2 deletions(-) rename {amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types => commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/ui/note}/ActivityCard.kt (98%) create mode 100644 commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/ui/theme/Sizes.kt diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/Nutzap.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/Nutzap.kt index 1fcf052518..c19596ec0c 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/Nutzap.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/Nutzap.kt @@ -30,6 +30,10 @@ import androidx.compose.ui.graphics.Color import androidx.compose.ui.unit.dp import com.vitorpamplona.amethyst.commons.hashtags.Cashu import com.vitorpamplona.amethyst.commons.hashtags.CustomHashTagIcons +import com.vitorpamplona.amethyst.commons.ui.note.ActivityAmountRow +import com.vitorpamplona.amethyst.commons.ui.note.ActivityBadge +import com.vitorpamplona.amethyst.commons.ui.note.ActivityCardFrame +import com.vitorpamplona.amethyst.commons.ui.note.ActivityHeaderRow import com.vitorpamplona.amethyst.model.Note import com.vitorpamplona.amethyst.ui.navigation.navs.INav import com.vitorpamplona.amethyst.ui.note.CrossfadeToDisplayComment diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/Reaction.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/Reaction.kt index 6772cc4130..41a1f8d630 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/Reaction.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/Reaction.kt @@ -26,6 +26,10 @@ import androidx.compose.runtime.MutableState import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.unit.dp +import com.vitorpamplona.amethyst.commons.ui.note.ActivityBadge +import com.vitorpamplona.amethyst.commons.ui.note.ActivityCardFrame +import com.vitorpamplona.amethyst.commons.ui.note.ActivityHeaderRow +import com.vitorpamplona.amethyst.commons.ui.note.LikeTint import com.vitorpamplona.amethyst.model.Note import com.vitorpamplona.amethyst.ui.navigation.navs.INav import com.vitorpamplona.amethyst.ui.note.DisplayBlankAuthor diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/ZapEvent.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/ZapEvent.kt index 9c7ce8efe5..a1d68ab445 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/ZapEvent.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/ZapEvent.kt @@ -40,6 +40,10 @@ import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import com.vitorpamplona.amethyst.commons.icons.symbols.Icon import com.vitorpamplona.amethyst.commons.icons.symbols.MaterialSymbols +import com.vitorpamplona.amethyst.commons.ui.note.ActivityAmountRow +import com.vitorpamplona.amethyst.commons.ui.note.ActivityBadge +import com.vitorpamplona.amethyst.commons.ui.note.ActivityCardFrame +import com.vitorpamplona.amethyst.commons.ui.note.ActivityHeaderRow import com.vitorpamplona.amethyst.model.LocalCache import com.vitorpamplona.amethyst.model.Note import com.vitorpamplona.amethyst.model.User diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/ActivityCard.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/ui/note/ActivityCard.kt similarity index 98% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/ActivityCard.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/ui/note/ActivityCard.kt index 08a6375273..8d14e9bfe8 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/ActivityCard.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/ui/note/ActivityCard.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.note.types +package com.vitorpamplona.amethyst.commons.ui.note import androidx.compose.foundation.background import androidx.compose.foundation.border @@ -48,7 +48,7 @@ import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.dp import com.vitorpamplona.amethyst.commons.icons.symbols.Icon import com.vitorpamplona.amethyst.commons.icons.symbols.MaterialSymbols -import com.vitorpamplona.amethyst.ui.theme.Size16Modifier +import com.vitorpamplona.amethyst.commons.ui.theme.Size16Modifier /** * Heart color of the Liked icon vector; tints reaction activity cards the way diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/ui/theme/Sizes.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/ui/theme/Sizes.kt new file mode 100644 index 0000000000..37100cdebe --- /dev/null +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/ui/theme/Sizes.kt @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.vitorpamplona.amethyst.commons.ui.theme + +import androidx.compose.foundation.layout.size +import androidx.compose.ui.Modifier +import androidx.compose.ui.unit.dp + +// Fixed-size icon modifiers shared by the event-kind renderers pulled down from +// the Android app. Mirror the values in the app's ui/theme/Shape.kt; the Android +// copies become dead code as each renderer moves and are deleted at the end. + +/** 5dp fixed size. */ +val Size5dp = 5.dp + +/** 16dp square icon modifier. */ +val Size16Modifier = Modifier.size(16.dp)