You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

68 lines
2.0 KiB

2 years ago
2 years ago
2 years ago
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_riverpod/flutter_riverpod.dart';
  3. import 'package:my_flutter_puzzle/providers.dart';
  4. import 'package:my_flutter_puzzle/utils/puzzle_solver.dart';
  5. import 'package:my_flutter_puzzle/widgets/solo_screen/moves_tiles_widget/moves_tiles_text.dart';
  6. class MovesTilesWidget extends StatelessWidget {
  7. const MovesTilesWidget({
  8. Key? key,
  9. required PuzzleSolverClient solverClient,
  10. this.fontSize = 24,
  11. }) : _solverClient = solverClient,
  12. super(key: key);
  13. final PuzzleSolverClient _solverClient;
  14. final double fontSize;
  15. @override
  16. Widget build(BuildContext context) {
  17. return Consumer(
  18. builder: (context, ref, child) {
  19. final state = ref.watch(puzzleNotifierProvider(_solverClient));
  20. return state.when(
  21. () => MovesTilesText(
  22. moves: 0,
  23. tiles: 0,
  24. fontSize: fontSize,
  25. ),
  26. initializing: () => MovesTilesText(
  27. moves: 0,
  28. tiles: 0,
  29. fontSize: fontSize,
  30. ),
  31. scrambling: (_) => MovesTilesText(
  32. moves: 0,
  33. tiles: 0,
  34. fontSize: fontSize,
  35. ),
  36. current: (puzzleData) => MovesTilesText(
  37. moves: puzzleData.moves,
  38. tiles: puzzleData.tiles,
  39. fontSize: fontSize,
  40. ),
  41. computingSolution: (puzzleData) => MovesTilesText(
  42. moves: puzzleData.moves,
  43. tiles: puzzleData.tiles,
  44. fontSize: fontSize,
  45. ),
  46. autoSolving: (puzzleData) => MovesTilesText(
  47. moves: puzzleData.moves,
  48. tiles: puzzleData.tiles,
  49. fontSize: fontSize,
  50. ),
  51. solved: (puzzleData) => MovesTilesText(
  52. moves: puzzleData.moves,
  53. tiles: puzzleData.tiles,
  54. fontSize: fontSize,
  55. ),
  56. error: (_) => MovesTilesText(
  57. moves: 0,
  58. tiles: 0,
  59. fontSize: fontSize,
  60. ),
  61. );
  62. },
  63. );
  64. }
  65. }