Skip to content

Commit

Permalink
Fixed row-copying as it felt laggy when putting a color on a color-op…
Browse files Browse the repository at this point in the history
…tion as it waited for a double tap. To Copy a row you have to drag down a bit now, instead of double-tapping.
  • Loading branch information
PyFlat-JR committed Oct 28, 2024
1 parent 66c0b60 commit afebc98
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
19 changes: 15 additions & 4 deletions lib/screens/game_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class MastermindGameState extends State<MastermindGame> {
bool finished = false;
bool isWin = false;
Color? _selectedColor;
DragStartDetails? _dragStartDetails;

@override
void initState() {
Expand Down Expand Up @@ -354,10 +355,20 @@ class MastermindGameState extends State<MastermindGame> {
child: Row(children: [
for (int i = 0; i < rowSize; i++) buildColorButton(row, i),
]),
onDoubleTap: () {
setState(() {
guesses[currentGuess] = List.from(guesses[row]);
});
onVerticalDragStart: (DragStartDetails verticalDragStart) {
_dragStartDetails = verticalDragStart;
},
onVerticalDragEnd: (DragEndDetails verticalDragEnd) {
final dragDistance = _dragStartDetails!.globalPosition.dy -
verticalDragEnd.globalPosition.dy;

if (dragDistance < -5) {
if (mounted) {
setState(() {
guesses[currentGuess] = List.from(guesses[row]);
});
}
}
},
),
buildTexts(row, true)
Expand Down
3 changes: 2 additions & 1 deletion lib/screens/start_screen.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';

import '../components/game_mode_button.dart';
Expand Down Expand Up @@ -44,7 +45,7 @@ class StartScreen extends StatelessWidget {
),
),
Spacer(),
Text("© 2024 PyFlat - v1.0.0"),
if (kIsWeb) Text("© 2024 PyFlat - v1.0.0"),
SizedBox(
height: 10,
)
Expand Down

0 comments on commit afebc98

Please sign in to comment.