mirror of
https://github.com/immich-app/immich.git
synced 2026-05-18 03:10:24 +03:00
refactor: remove debug print statements from _ReorderableGrid drag-and-drop handling
This commit is contained in:
@@ -200,16 +200,10 @@ class _ReorderableGridState extends State<_ReorderableGrid> {
|
|||||||
newOrder.removeAt(draggedOrderIndex);
|
newOrder.removeAt(draggedOrderIndex);
|
||||||
newOrder.insert(targetOrderIndex, draggedIndex);
|
newOrder.insert(targetOrderIndex, draggedIndex);
|
||||||
_itemOrder = newOrder;
|
_itemOrder = newOrder;
|
||||||
|
|
||||||
// ignore: avoid_print
|
|
||||||
print('[D&D] Hover: dragged=$draggedIndex -> target=$targetIndex, visualOrder=$_itemOrder');
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void _handleDragEnd(int draggedIndex, int? targetIndex) {
|
void _handleDragEnd(int draggedIndex, int? targetIndex) {
|
||||||
// ignore: avoid_print
|
|
||||||
print('[D&D] DragEnd called: draggedIndex=$draggedIndex, targetIndex=$targetIndex, visualOrder=$_itemOrder');
|
|
||||||
|
|
||||||
// Use targetIndex if available, otherwise check if visual position changed
|
// Use targetIndex if available, otherwise check if visual position changed
|
||||||
final effectiveTargetIndex =
|
final effectiveTargetIndex =
|
||||||
targetIndex ??
|
targetIndex ??
|
||||||
@@ -222,23 +216,8 @@ class _ReorderableGridState extends State<_ReorderableGrid> {
|
|||||||
return null;
|
return null;
|
||||||
})();
|
})();
|
||||||
|
|
||||||
// ignore: avoid_print
|
|
||||||
print('[D&D] Effective target: $effectiveTargetIndex');
|
|
||||||
|
|
||||||
if (effectiveTargetIndex != null && draggedIndex != effectiveTargetIndex) {
|
if (effectiveTargetIndex != null && draggedIndex != effectiveTargetIndex) {
|
||||||
// Find the visual positions in _itemOrder
|
|
||||||
final oldVisualPosition = _itemOrder.indexOf(draggedIndex);
|
|
||||||
final newVisualPosition = _itemOrder.indexOf(effectiveTargetIndex);
|
|
||||||
// ignore: avoid_print
|
|
||||||
print('[D&D] Visual positions: old=$oldVisualPosition, new=$newVisualPosition');
|
|
||||||
// Pass the actual indices (draggedIndex is old, effectiveTargetIndex is new)
|
|
||||||
// But we need to pass the position in the visual order
|
|
||||||
widget.onReorder(draggedIndex, effectiveTargetIndex);
|
widget.onReorder(draggedIndex, effectiveTargetIndex);
|
||||||
// ignore: avoid_print
|
|
||||||
print('[D&D] Called onReorder: oldIndex=$draggedIndex, newIndex=$effectiveTargetIndex');
|
|
||||||
} else {
|
|
||||||
// ignore: avoid_print
|
|
||||||
print('[D&D] Skipping onReorder: no valid target or same position');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Trigger snap animation for all items
|
// Trigger snap animation for all items
|
||||||
@@ -252,9 +231,6 @@ class _ReorderableGridState extends State<_ReorderableGrid> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _armSnapNow() {
|
void _armSnapNow() {
|
||||||
// ignore: avoid_print
|
|
||||||
print('[D&D] Snap animation triggered for all items');
|
|
||||||
// 直後のレイアウト更新でだけ duration を 0 にする
|
|
||||||
setState(() => _snapNow = true);
|
setState(() => _snapNow = true);
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
if (!mounted) return;
|
if (!mounted) return;
|
||||||
@@ -301,8 +277,6 @@ class _ReorderableGridState extends State<_ReorderableGrid> {
|
|||||||
left: left,
|
left: left,
|
||||||
top: top,
|
top: top,
|
||||||
onDragStarted: () {
|
onDragStarted: () {
|
||||||
// ignore: avoid_print
|
|
||||||
print('[D&D] DragStarted: index=$index');
|
|
||||||
setState(() {
|
setState(() {
|
||||||
_draggingIndex = index;
|
_draggingIndex = index;
|
||||||
_lastHoveredIndex = index;
|
_lastHoveredIndex = index;
|
||||||
@@ -354,7 +328,6 @@ class _AnimatedGridItem extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
// ドロップ直後は全アイテムが 0ms でスナップ
|
|
||||||
final Duration animDuration = snapNow ? Duration.zero : const Duration(milliseconds: 150);
|
final Duration animDuration = snapNow ? Duration.zero : const Duration(milliseconds: 150);
|
||||||
|
|
||||||
return AnimatedPositioned(
|
return AnimatedPositioned(
|
||||||
@@ -397,11 +370,9 @@ class _AnimatedGridItem extends StatelessWidget {
|
|||||||
childWhenDragging: const SizedBox.shrink(),
|
childWhenDragging: const SizedBox.shrink(),
|
||||||
onDragStarted: onDragStarted,
|
onDragStarted: onDragStarted,
|
||||||
onDragCompleted: () {
|
onDragCompleted: () {
|
||||||
// DragTargetに受け入れられた場合
|
|
||||||
onDragCompleted(index);
|
onDragCompleted(index);
|
||||||
},
|
},
|
||||||
onDraggableCanceled: (_, __) {
|
onDraggableCanceled: (_, __) {
|
||||||
// DragTarget外にドロップした場合
|
|
||||||
onDragCompleted(index);
|
onDragCompleted(index);
|
||||||
},
|
},
|
||||||
child: child,
|
child: child,
|
||||||
|
|||||||
Reference in New Issue
Block a user