checkForYAxisMovement method
void
checkForYAxisMovement(
{ - required int listIndex,
- required int itemIndex,
})
Implementation
void checkForYAxisMovement({required int listIndex, required int itemIndex}) {
var prov = ref.read(ProviderList.boardProvider);
var item = prov.board.lists[listIndex].items[itemIndex];
bool willPlaceHolderAtBottom = false;
bool willPlaceHolderAtTop = false;
willPlaceHolderAtBottom = ((itemIndex ==
prov.board.lists[listIndex].items.length - 1) &&
((prov.draggedItemState!.height * 0.6) + prov.valueNotifier.value.dy >
item.y! + item.height!) &&
!item.bottomPlaceholder! && prov.board.lists[listIndex].items[itemIndex].addedBySystem!=true );
willPlaceHolderAtTop =
((prov.valueNotifier.value.dy < item.y! + (item.height! * 0.5)) &&
(prov.draggedItemState!.height + prov.valueNotifier.value.dy >
item.y! + (item.height! * 0.5)))&& prov.board.lists[listIndex].items[itemIndex].addedBySystem!=true;
// print(willPlaceHolderAtTop);
if (((willPlaceHolderAtTop || willPlaceHolderAtBottom) &&
prov.board.dragItemOfListIndex! == listIndex) &&
(prov.board.dragItemIndex != itemIndex ||
(willPlaceHolderAtBottom &&
!prov.board.lists[listIndex].items[itemIndex]
.bottomPlaceholder!) ||
(prov.board.lists[listIndex].items[itemIndex].bottomPlaceholder! &&
(itemIndex == prov.board.lists[listIndex].items.length - 1)))) {
// log("UP/DOWNN");
if (willPlaceHolderAtBottom && item.bottomPlaceholder!) return;
if (prov.board.dragItemIndex! < itemIndex && prov.move != 'other') {
prov.move = "DOWN";
}
resetCardWidget();
item.bottomPlaceholder = willPlaceHolderAtBottom;
if (willPlaceHolderAtBottom) {
log("BOTTOM PLACEHOLDER ^");
prov.move = "LAST";
}
var isItemHidden = itemIndex - 1 >= 0 &&
prov.draggedItemState!.itemIndex == itemIndex - 1 &&
prov.draggedItemState!.listIndex == listIndex;
if ((item.addedBySystem == null || !item.addedBySystem!)) {
addPlaceHolder(listIndex: listIndex, itemIndex: itemIndex);
}
if (isPrevSystemCard(listIndex: listIndex, itemIndex: itemIndex)) return;
var temp = prov.board.dragItemIndex;
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
// log("PREVIOUS |${prov.board.dragItemOfListIndex}| LIST= ${prov.board.dragItemIndex}");
if (!prov.board.lists[prov.board.dragItemOfListIndex!].items[temp!]
.context!.mounted) return;
if (isItemHidden) {
prov.move = "DOWN";
}
prov.board.dragItemIndex = itemIndex;
prov.board.dragItemOfListIndex = listIndex;
prov.board.lists[prov.board.dragItemOfListIndex!].items[temp]
.setState!();
// log("UP/DOWN $listIndex $itemIndex");
item.setState!();
});
}
}