chore: disable children receive events under fake drag target

This commit is contained in:
appflowy 2022-08-23 17:21:08 +08:00
parent aec5c3e807
commit d941db29a1
2 changed files with 36 additions and 11 deletions

View File

@ -277,6 +277,31 @@ class IgnorePointerWidget extends StatelessWidget {
}
}
class AbsorbPointerWidget extends StatelessWidget {
final Widget? child;
final bool useIntrinsicSize;
const AbsorbPointerWidget({
required this.child,
this.useIntrinsicSize = false,
Key? key,
}) : super(key: key);
@override
Widget build(BuildContext context) {
final sizedChild = useIntrinsicSize
? child
: SizedBox(width: 0.0, height: 0.0, child: child);
final opacity = useIntrinsicSize ? 0.3 : 0.0;
return AbsorbPointer(
child: Opacity(
opacity: opacity,
child: sizedChild,
),
);
}
}
class PhantomWidget extends StatelessWidget {
final Widget? child;
final double opacity;
@ -442,7 +467,7 @@ class _FakeDragTargetState<T extends DragTargetData>
return SizeTransitionWithIntrinsicSize(
sizeFactor: widget.deleteAnimationController,
axis: Axis.vertical,
child: IgnorePointerWidget(
child: AbsorbPointerWidget(
child: widget.child,
),
);
@ -450,7 +475,7 @@ class _FakeDragTargetState<T extends DragTargetData>
return SizeTransitionWithIntrinsicSize(
sizeFactor: widget.insertAnimationController,
axis: Axis.vertical,
child: IgnorePointerWidget(
child: AbsorbPointerWidget(
useIntrinsicSize: true,
child: widget.child,
),

View File

@ -204,16 +204,16 @@ class BoardPhantomController extends OverlapDragTargetDelegate
@override
int canMoveTo(String dragTargetId) {
// if (columnsState.isDragging(dragTargetId)) {
// return -1;
// }
if (columnsState.isDragging(dragTargetId)) {
return -1;
}
// final controller = delegate.controller(dragTargetId);
// if (controller != null) {
// return controller.columnData.items.length;
// } else {
// return 0;
// }
final controller = delegate.controller(dragTargetId);
if (controller != null) {
return controller.columnData.items.length;
} else {
return 0;
}
if (delegate.controller(dragTargetId)?.columnData.items.isEmpty ?? false) {
return 0;