Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add onTappedSquare to Chessboard widget, add squareHighlights field #66

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

tom-anders
Copy link
Contributor

We'll need this if we want to switch the coordinate trainer in the app
from ChessboardEditor to Chessboard in order to fix lichess-org/mobile#1017

We'll need this if we want to switch the coordinate trainer in the app
from `ChessboardEditor` to `Chessboard` in order to fix lichess-org/mobile#1017
@tom-anders tom-anders changed the title feat: add onTappedSquare to Chessboard widget, add sqaureHighlights field feat: add onTappedSquare to Chessboard widget, add squareHighlights field Dec 26, 2024
lib/src/widgets/board.dart Outdated Show resolved Hide resolved
@@ -549,6 +570,8 @@ class _BoardState extends State<Chessboard> {
final square = widget.offsetSquare(details.localPosition);
if (square == null) return;

widget.onTappedSquare?.call(square);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Calling this onTapped is misleading since the callback is executed on pointer down.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm yeah I wasn't sure whether to put this into pointer down or up - Now that I think about it again, if we call it onTapped it should probably be in pointer up instead? And we should only invoke the callback if the pointer up happened on the same square as the previous pointer down event

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or should we keep it in _onPointerDown and change the callback's name instead?

test/widgets/board_test.dart Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sliding your finger in coordinate trainer continues to select squares
2 participants