Skip to content

Drag to reorder tracking categories (v0.22.0-beta.1)#80

Closed
mapgie wants to merge 2 commits into
mainfrom
claude/goflo-sprint-4b-drag-reorder
Closed

Drag to reorder tracking categories (v0.22.0-beta.1)#80
mapgie wants to merge 2 commits into
mainfrom
claude/goflo-sprint-4b-drag-reorder

Conversation

@mapgie
Copy link
Copy Markdown
Owner

@mapgie mapgie commented Jun 2, 2026

Summary

  • Drag to reorder active categories — long-press the drag handle (≡) on any active tracking category to pick it up and drag it to a new position. Items animate smoothly as you drag. The new order is written to displayOrder on release and persists across app restarts.
  • Works alongside existing swipe-to-archive (left) and swipe-to-delete (right) gestures — the long-press requirement prevents accidental activation during swipes.
  • System categories (Flow, Symptoms) are also reorderable.
  • Archived categories have no drag handle (reordering archived items makes no sense).

Implementation notes

  • No DB migration needed — displayOrder: Int column already exists on TrackingCategory.
  • SnapshotStateList (localActive) mirrors the ViewModel's active list locally. Drag swaps happen immediately in the local list for instant visual feedback; reorderCategories() is called on drag end to persist the order.
  • detectDragGesturesAfterLongPress on the handle icon; items swap at the midpoint threshold using LazyListState.layoutInfo.visibleItemsInfo for item height.
  • Modifier.animateItem() on each active row for smooth swap animation.

Test plan

  • Long-press drag handle on a category and drag up/down — items should swap smoothly
  • Release drag — order should persist after navigating away and back
  • Swipe left/right on a category — archive/delete should still work normally
  • App restart — reordered categories should appear in the new order
  • Archived section still collapsible and unaffected by reorder

https://claude.ai/code/session_01AGmvoYfqqkLA9SUWV6myXW


Generated by Claude Code

claude added 2 commits June 2, 2026 06:07
Long-press the drag handle on any active tracking category to pick it
up and drag it to a new position. Items animate into place as you drag.
The new order is written to displayOrder on release and persists across
app restarts. Works alongside the existing swipe-to-archive / delete
gestures.

https://claude.ai/code/session_01AGmvoYfqqkLA9SUWV6myXW
animateItem() was introduced in Compose 1.7; BOM 2024.06.00 ships 1.6.x.
The predecessor animateItemPlacement() is the correct call here.

https://claude.ai/code/session_01AGmvoYfqqkLA9SUWV6myXW
@mapgie mapgie marked this pull request as ready for review June 2, 2026 07:12
@mapgie mapgie closed this Jun 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants