checkForXAxisMovement method

void checkForXAxisMovement({
  1. required int listIndex,
  2. required int itemIndex,
})

Implementation

void checkForXAxisMovement({required int listIndex, required int itemIndex}) {
  var prov = ref.read(ProviderList.boardProvider);
  var item = prov.board.lists[listIndex].items[itemIndex];

  var canReplaceCurrent = ((prov.valueNotifier.value.dy >= item.y!) &&
      (item.height! + item.y! >
          prov.valueNotifier.value.dy + (prov.draggedItemState!.height / 2)));
  var willPlaceHolderAtBottom = (itemIndex ==
          prov.board.lists[listIndex].items.length - 1 &&
      ((prov.draggedItemState!.height * 0.6) + prov.valueNotifier.value.dy >
          item.y! + item.height!));

  if (canReplaceCurrent || willPlaceHolderAtBottom) {
    //   log("X AXIS");
    prov.move = "other";

    resetCardWidget();

    item.bottomPlaceholder = willPlaceHolderAtBottom;
    if (willPlaceHolderAtBottom) {
      prov.move = "LAST";
      // log("BOTTOM PLACEHOLDER X AXIS");
    }

    var isItemHidden = itemIndex - 1 >= 0 &&
        prov.draggedItemState!.itemIndex == itemIndex - 1 &&
        prov.draggedItemState!.listIndex == listIndex;

    // if (!isItemHidden) {
    addPlaceHolder(listIndex: listIndex, itemIndex: itemIndex);
    //   }
    if (isPrevSystemCard(listIndex: listIndex, itemIndex: itemIndex)) return;

    WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
      prov.board.lists[prov.board.dragItemOfListIndex!]
          .items[prov.board.dragItemIndex!].setState!();
      if (isItemHidden) {
        prov.move = "DOWN";
      }
      prov.board.dragItemIndex = itemIndex;
      prov.board.dragItemOfListIndex = listIndex;
      // log("UPDATED | ITEM= $listIndex | LIST= $itemIndex");
      item.setState!();
    });
  }
}