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.

63 lines
2.0 KiB

2 years ago
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_riverpod/flutter_riverpod.dart';
  3. import 'package:my_flutter_puzzle/application/states/puzzle_state.dart';
  4. import 'package:my_flutter_puzzle/providers.dart';
  5. import 'package:my_flutter_puzzle/screens/solo/solo_screen_large.dart';
  6. import 'package:my_flutter_puzzle/screens/solo/solo_screen_small.dart';
  7. import 'package:my_flutter_puzzle/utils/puzzle_solver.dart';
  8. import 'package:my_flutter_puzzle/utils/responsive_layout.dart';
  9. import 'package:rive/rive.dart';
  10. import '../../models/puzzle_data.dart';
  11. import 'solo_screen_medium.dart';
  12. class SoloScreen extends ConsumerWidget {
  13. const SoloScreen({
  14. required this.solverClient,
  15. required this.initialPuzzleData,
  16. required this.puzzleSize,
  17. required this.puzzleType,
  18. required this.riveController,
  19. Key? key,
  20. }) : super(key: key);
  21. final PuzzleSolverClient solverClient;
  22. final PuzzleData initialPuzzleData;
  23. final int puzzleSize;
  24. final String puzzleType;
  25. final RiveAnimationController riveController;
  26. @override
  27. Widget build(BuildContext context, WidgetRef ref) {
  28. ref.listen(puzzleNotifierProvider(solverClient),
  29. (previous, PuzzleState next) {
  30. if (next is PuzzleSolved) {
  31. ref.read(timerNotifierProvider.notifier).stopTimer();
  32. }
  33. });
  34. return ResponsiveLayout(
  35. largeChild: SoloScreenLarge(
  36. solverClient: solverClient,
  37. puzzleType: puzzleType,
  38. initialPuzzleData: initialPuzzleData,
  39. puzzleSize: puzzleSize,
  40. riveController: riveController,
  41. ),
  42. mediumChild: SoloScreenMedium(
  43. solverClient: solverClient,
  44. initialPuzzleData: initialPuzzleData,
  45. puzzleSize: puzzleSize,
  46. puzzleType: puzzleType,
  47. riveController: riveController,
  48. ),
  49. smallChild: SoloScreenSmall(
  50. solverClient: solverClient,
  51. initialPuzzleData: initialPuzzleData,
  52. puzzleSize: puzzleSize,
  53. puzzleType: puzzleType,
  54. riveController: riveController,
  55. ),
  56. );
  57. }
  58. }