Skip to content

Commit

Permalink
fix(shuffle) : fix shuffle button and shuffle puzzle on generation (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanvandeperre97 authored Feb 21, 2022
1 parent 2632229 commit 8685916
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/bloc/puzzle_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import 'package:puzzle/models/models.dart';
import 'package:puzzle/services/audio_service.dart';

class PuzzleCubit extends Cubit<PuzzleState> {
PuzzleCubit() : super(PuzzleState(Puzzle.generate(4)));
PuzzleCubit() : super(PuzzleState(Puzzle.generate(4)..shuffle()));
AudioService audioService = GetIt.I.get<AudioService>();

void shuffle() {
Expand Down
6 changes: 4 additions & 2 deletions lib/view/puzzle_page/puzzle_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,10 @@ class _PuzzlePageState extends State<PuzzlePage> {

/// Shuffle the puzzle.
void _shuffle(BuildContext context) {
context.read<PuzzleCubit>().shuffle();
_puzzleFocusNode.requestFocus();
setState(() {
context.read<PuzzleCubit>().shuffle();
_puzzleFocusNode.requestFocus();
});
}

/// Reset the puzzle.
Expand Down

0 comments on commit 8685916

Please sign in to comment.