Start a tap with drag #7
1
devtools_options.yaml
Normal file
1
devtools_options.yaml
Normal file
@ -0,0 +1 @@
|
|||||||
|
extensions:
|
@ -59,17 +59,23 @@ class ChessSquare extends StatefulWidget {
|
|||||||
class _ChessSquareState extends State<ChessSquare> {
|
class _ChessSquareState extends State<ChessSquare> {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return GestureDetector(
|
var dragTarget = Container(
|
||||||
child: Container(
|
|
||||||
color: widget.color,
|
color: widget.color,
|
||||||
child: ChessSquareOuterDragTarget(
|
child: ChessSquareOuterDragTarget(
|
||||||
coordinate: widget.coordinate,
|
coordinate: widget.coordinate,
|
||||||
containedPiece: widget.containedPiece ?? const ChessPiece.none()),
|
containedPiece: widget.containedPiece ?? const ChessPiece.none()),
|
||||||
),
|
);
|
||||||
|
|
||||||
|
if (widget.containedPiece == null) {
|
||||||
|
return GestureDetector(
|
||||||
|
child: dragTarget,
|
||||||
onTap: () {
|
onTap: () {
|
||||||
TapBloc().add(SquareTappedEvent(
|
TapBloc().add(SquareTappedEvent(
|
||||||
tapped: widget.coordinate, pieceOnSquare: widget.containedPiece));
|
tapped: widget.coordinate, pieceOnSquare: widget.containedPiece));
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
return dragTarget;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,8 @@ class ChessSquareInnerDraggable extends StatelessWidget {
|
|||||||
child: containedPiece ?? Container(),
|
child: containedPiece ?? Container(),
|
||||||
onDragCompleted: () {},
|
onDragCompleted: () {},
|
||||||
onDragStarted: () {
|
onDragStarted: () {
|
||||||
TapBloc().add(CancelTapEvent());
|
TapBloc().add(SquareTappedEvent(
|
||||||
|
tapped: coordinate, pieceOnSquare: containedPiece));
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -3,6 +3,7 @@ import 'package:mchess/chess/chess_square_inner_draggable.dart';
|
|||||||
import 'package:mchess/chess_bloc/chess_bloc.dart';
|
import 'package:mchess/chess_bloc/chess_bloc.dart';
|
||||||
import 'package:mchess/chess_bloc/chess_events.dart';
|
import 'package:mchess/chess_bloc/chess_events.dart';
|
||||||
import 'package:mchess/chess_bloc/promotion_bloc.dart';
|
import 'package:mchess/chess_bloc/promotion_bloc.dart';
|
||||||
|
import 'package:mchess/chess_bloc/tap_bloc.dart';
|
||||||
import 'package:mchess/utils/chess_utils.dart';
|
import 'package:mchess/utils/chess_utils.dart';
|
||||||
|
|
||||||
class ChessSquareOuterDragTarget extends StatelessWidget {
|
class ChessSquareOuterDragTarget extends StatelessWidget {
|
||||||
@ -15,29 +16,31 @@ class ChessSquareOuterDragTarget extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return DragTarget<PieceDragged>(
|
return DragTarget<PieceDragged>(
|
||||||
onWillAccept: (move) {
|
onWillAcceptWithDetails: (details) {
|
||||||
if (move?.fromSquare == coordinate) {
|
if (details.data.fromSquare == coordinate) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
onAccept: (pieceDragged) {
|
onAcceptWithDetails: (details) {
|
||||||
// Replace the dummy value with the actual target of the move.
|
// Replace the dummy value with the actual target of the move.
|
||||||
pieceDragged.toSquare = coordinate;
|
details.data.toSquare = coordinate;
|
||||||
|
|
||||||
|
TapBloc().add(CancelTapEvent());
|
||||||
|
|
||||||
if (isPromotionMove(
|
if (isPromotionMove(
|
||||||
pieceDragged.movedPiece!.pieceClass,
|
details.data.movedPiece!.pieceClass,
|
||||||
ChessBloc.myColor!,
|
ChessBloc.myColor!,
|
||||||
pieceDragged.toSquare,
|
details.data.toSquare,
|
||||||
)) {
|
)) {
|
||||||
var move = ChessMove(
|
var move = ChessMove(
|
||||||
from: pieceDragged.fromSquare, to: pieceDragged.toSquare);
|
from: details.data.fromSquare, to: details.data.toSquare);
|
||||||
PromotionBloc().add(PawnMovedToPromotionField(
|
PromotionBloc().add(PawnMovedToPromotionField(
|
||||||
move: move, colorMoved: ChessBloc.myColor!));
|
move: move, colorMoved: ChessBloc.myColor!));
|
||||||
} else if (coordinate != pieceDragged.fromSquare) {
|
} else if (coordinate != details.data.fromSquare) {
|
||||||
ChessBloc().add(OwnPieceMoved(
|
ChessBloc().add(OwnPieceMoved(
|
||||||
startSquare: pieceDragged.fromSquare,
|
startSquare: details.data.fromSquare,
|
||||||
endSquare: pieceDragged.toSquare));
|
endSquare: details.data.toSquare));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
builder: (context, candidateData, rejectedData) {
|
builder: (context, candidateData, rejectedData) {
|
||||||
|
66
pubspec.lock
66
pubspec.lock
@ -85,10 +85,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: ffi
|
name: ffi
|
||||||
sha256: "7bf0adc28a23d395f19f3f1eb21dd7cfd1dd9f8e1c50051c069122e6853bc878"
|
sha256: "493f37e7df1804778ff3a53bd691d8692ddf69702cf4c1c1096a2e41b4779e21"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.0"
|
version: "2.1.2"
|
||||||
file:
|
file:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -148,10 +148,10 @@ packages:
|
|||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: go_router
|
name: go_router
|
||||||
sha256: "3b40e751eaaa855179b416974d59d29669e750d2e50fcdb2b37f1cb0ca8c803a"
|
sha256: "07ee2436909f749d606f53521dc1725dd738dc5196e5ff815bc254253c594075"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "13.0.1"
|
version: "13.1.0"
|
||||||
http:
|
http:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@ -168,6 +168,30 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "4.0.2"
|
version: "4.0.2"
|
||||||
|
leak_tracker:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: leak_tracker
|
||||||
|
sha256: "78eb209deea09858f5269f5a5b02be4049535f568c07b275096836f01ea323fa"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "10.0.0"
|
||||||
|
leak_tracker_flutter_testing:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: leak_tracker_flutter_testing
|
||||||
|
sha256: b46c5e37c19120a8a01918cfaf293547f47269f7cb4b0058f21531c2465d6ef0
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.0.1"
|
||||||
|
leak_tracker_testing:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: leak_tracker_testing
|
||||||
|
sha256: a597f72a664dbd293f3bfc51f9ba69816f84dcd403cdac7066cb3f6003f3ab47
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.0.1"
|
||||||
lints:
|
lints:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -188,26 +212,26 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: matcher
|
name: matcher
|
||||||
sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e"
|
sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.12.16"
|
version: "0.12.16+1"
|
||||||
material_color_utilities:
|
material_color_utilities:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: material_color_utilities
|
name: material_color_utilities
|
||||||
sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41"
|
sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.5.0"
|
version: "0.8.0"
|
||||||
meta:
|
meta:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: meta
|
name: meta
|
||||||
sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e
|
sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.10.0"
|
version: "1.11.0"
|
||||||
nested:
|
nested:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -220,10 +244,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: path
|
name: path
|
||||||
sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917"
|
sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.8.3"
|
version: "1.9.0"
|
||||||
path_parsing:
|
path_parsing:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -469,22 +493,30 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.4"
|
version: "2.1.4"
|
||||||
|
vm_service:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: vm_service
|
||||||
|
sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "13.0.0"
|
||||||
web:
|
web:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: web
|
name: web
|
||||||
sha256: afe077240a270dcfd2aafe77602b4113645af95d0ad31128cc02bce5ac5d5152
|
sha256: "4188706108906f002b3a293509234588823c8c979dc83304e229ff400c996b05"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.3.0"
|
version: "0.4.2"
|
||||||
web_socket_channel:
|
web_socket_channel:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: web_socket_channel
|
name: web_socket_channel
|
||||||
sha256: d88238e5eac9a42bb43ca4e721edba3c08c6354d4a53063afaa568516217621b
|
sha256: "939ab60734a4f8fa95feacb55804fa278de28bdeef38e616dc08e44a84adea23"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.4.0"
|
version: "2.4.3"
|
||||||
win32:
|
win32:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -510,5 +542,5 @@ packages:
|
|||||||
source: hosted
|
source: hosted
|
||||||
version: "6.5.0"
|
version: "6.5.0"
|
||||||
sdks:
|
sdks:
|
||||||
dart: ">=3.2.0 <4.0.0"
|
dart: ">=3.3.0-279.1.beta <4.0.0"
|
||||||
flutter: ">=3.16.0"
|
flutter: ">=3.16.0"
|
||||||
|
@ -40,7 +40,7 @@ dependencies:
|
|||||||
cupertino_icons: ^1.0.2
|
cupertino_icons: ^1.0.2
|
||||||
flutter_bloc: ^8.1.3
|
flutter_bloc: ^8.1.3
|
||||||
quiver: ^3.1.0
|
quiver: ^3.1.0
|
||||||
web_socket_channel: ^2.4.0
|
web_socket_channel: ^2.4.3
|
||||||
go_router: ^13.0.0
|
go_router: ^13.0.0
|
||||||
http: ^1.0.0
|
http: ^1.0.0
|
||||||
uuid: ^4.0.0
|
uuid: ^4.0.0
|
||||||
|
Loading…
Reference in New Issue
Block a user