Skip to content

Commit 8c3ff14

Browse files
dadachiclaude
andauthored
Reveal swipe actions from trailing (right) edge (#34)
Flip SwipeableItemWithActions so users drag the row right-to-left to reveal action buttons, with the buttons sitting on the trailing (right) edge instead of the leading (left) edge. Matches the iOS app's swipeActions(edge: .trailing) and the platform-conventional swipe-to-reveal gesture. - Actions Row aligned to Alignment.CenterEnd of the wrapping Box - Drag offset coerced to [-contextMenuWidth, 0f] - Revealed anchor flipped to -contextMenuWidth; half-way fling threshold checks <= -contextMenuWidth / 2f Public API (isRevealed, actions, onExpanded, onCollapsed, content, modifier) is unchanged, so both call sites pick up the new direction with no edits: - ShopDetailView — Complete / Idle actions on item-tag rows - ItemTagListView — Delete action on item-tag rows Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent c138771 commit 8c3ff14

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

app/src/main/kotlin/com/nativeapptemplate/nativeapptemplatefree/ui/common/SwipeableItemWithActions.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ fun SwipeableItemWithActions(
4646

4747
LaunchedEffect(key1 = isRevealed, contextMenuWidth) {
4848
if (isRevealed) {
49-
offset.animateTo(contextMenuWidth)
49+
offset.animateTo(-contextMenuWidth)
5050
} else {
5151
offset.animateTo(0f)
5252
}
@@ -59,6 +59,7 @@ fun SwipeableItemWithActions(
5959
) {
6060
Row(
6161
modifier = Modifier
62+
.align(Alignment.CenterEnd)
6263
.onSizeChanged {
6364
contextMenuWidth = it.width.toFloat()
6465
},
@@ -75,15 +76,15 @@ fun SwipeableItemWithActions(
7576
onHorizontalDrag = { _, dragAmount ->
7677
scope.launch {
7778
val newOffset = (offset.value + dragAmount)
78-
.coerceIn(0f, contextMenuWidth)
79+
.coerceIn(-contextMenuWidth, 0f)
7980
offset.snapTo(newOffset)
8081
}
8182
},
8283
onDragEnd = {
8384
when {
84-
offset.value >= contextMenuWidth / 2f -> {
85+
offset.value <= -contextMenuWidth / 2f -> {
8586
scope.launch {
86-
offset.animateTo(contextMenuWidth)
87+
offset.animateTo(-contextMenuWidth)
8788
onExpanded()
8889
}
8990
}

0 commit comments

Comments
 (0)