expandSelection method

Future<void> expandSelection(
  1. Offset drift
)

Implementation

Future<void> expandSelection(Offset drift) async {
  if (selection.value.isEmpty) {
    return;
  }

  int across = currentLayout.span;
  List<VEntity> view = await getChildren(workingVFolder.value).toList();
  int startIndex = view.indexOf(selection.value.last);
  if (selection.value.length > 1 && drift.dx > 0 || drift.dy > 0) {}

  int newIndex = _SpanUtil.move(
      startIndex, drift.dx.round(), drift.dy.round(),
      span: across);
  newIndex = max(0, min(view.length - 1, newIndex));
  List<VEntity> newSelection = selection.value.toList();
  bool added = false;
  for (int i = min(startIndex, newIndex);
      i <= max(startIndex, newIndex);
      i++) {
    if (!newSelection.contains(view[i])) {
      newSelection.add(view[i]);
      added = true;
    }
  }

  if (!added) {
    newSelection.remove(view[startIndex]);
  }

  selection.add(newSelection);
  _lastTapped = view[newIndex];
}