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.

59 lines
1.9 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/notifiers/puzzle_type_notifier.dart';
  4. import 'package:my_flutter_puzzle/models/puzzle_data.dart';
  5. import 'package:my_flutter_puzzle/screens/photo/photo_screen_large.dart';
  6. import 'package:my_flutter_puzzle/screens/solo/solo_screen_large.dart';
  7. import 'package:my_flutter_puzzle/utils/puzzle_solver.dart';
  8. import 'package:rive/rive.dart';
  9. import '../../providers.dart';
  10. class PuzzleScreenLarge extends ConsumerWidget {
  11. const PuzzleScreenLarge({
  12. required this.solverClient,
  13. required this.initialPuzzleData,
  14. required this.puzzleSize,
  15. required this.riveController,
  16. Key? key,
  17. }) : super(key: key);
  18. final PuzzleSolverClient solverClient;
  19. final PuzzleData initialPuzzleData;
  20. final int puzzleSize;
  21. final RiveAnimationController riveController;
  22. @override
  23. Widget build(BuildContext context, WidgetRef ref) {
  24. final currentPuzzleType = ref.watch(puzzleTypeNotifierProvider);
  25. final name = currentPuzzleType.name[0].toUpperCase() + currentPuzzleType.name.substring(1);
  26. switch (currentPuzzleType) {
  27. case PuzzleType.normal:
  28. return SoloScreenLarge(
  29. solverClient: solverClient,
  30. initialPuzzleData: initialPuzzleData,
  31. puzzleSize: puzzleSize,
  32. puzzleType: name,
  33. riveController: riveController,
  34. );
  35. case PuzzleType.photo:
  36. return PhotoScreenLarge(
  37. solverClient: solverClient,
  38. initialPuzzleData: initialPuzzleData,
  39. puzzleSize: puzzleSize,
  40. riveController: riveController,
  41. );
  42. case PuzzleType.multiplayer:
  43. default:
  44. return SoloScreenLarge(
  45. solverClient: solverClient,
  46. initialPuzzleData: initialPuzzleData,
  47. puzzleSize: puzzleSize,
  48. puzzleType: name,
  49. riveController: riveController,
  50. );
  51. }
  52. }
  53. }