arkui

Reorderable list

Rows dragged into a new order, the rest sliding out of the way: what a queue is rearranged with.

Desktop

arkui::reorder

A row dragged down past two others, which have slid up out of its way.A row dragged down past two others, which have slid up out of its way.
A row dragged down past two others, which have slid up out of its way.

A press that moves less than reorder::THRESHOLD is a click; past it the row lifts, and the rows it passes slide a row's height out of its way on reorder::SLIDING, a spring.

arkui::reorder

A list whose rows are dragged into a new order: the row lifts and follows the pointer, and the rows it passes slide out of its way.

Rules

rust/arkui/src/reorder.rs

Mobile

Where

  • ui/Reorder.kt: rememberReorder, ReorderableItem

How

  • A LazyColumn drawn in reorder.order(items, key), each row in ReorderableItem(reorder, key, keys): a long press lifts it, and onMove(from, to) is told on the drop.
  • The rows that make way are the list's own animateItem on Springs.MOVE; a tap still does what a tap did.
  • In sections, rememberReorder(list, lead, isHeader) { key, landing -> … }: a row dragged past a header changes section, a header held folds every section to its header and moves its own, and the drop is told as Landing(section, before).

Where

  • swift/ArkUI: Reorderable, ReorderHandle

How

  • Reorderable(items, key:, onMove:) { item, handle in … }: the row places the handle it is given, and is dragged by it, as the Music app's queue is.
  • The rows that make way move on Springs.move; the row keeps its tap and its context menu.