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
68 lines
2.0 KiB
import 'package:flutter/material.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
import 'package:my_flutter_puzzle/providers.dart';
|
|
import 'package:my_flutter_puzzle/utils/puzzle_solver.dart';
|
|
import 'package:my_flutter_puzzle/widgets/solo_screen/moves_tiles_widget/moves_tiles_text.dart';
|
|
|
|
class MovesTilesWidget extends StatelessWidget {
|
|
const MovesTilesWidget({
|
|
Key? key,
|
|
required PuzzleSolverClient solverClient,
|
|
this.fontSize = 24,
|
|
}) : _solverClient = solverClient,
|
|
super(key: key);
|
|
|
|
final PuzzleSolverClient _solverClient;
|
|
final double fontSize;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Consumer(
|
|
builder: (context, ref, child) {
|
|
final state = ref.watch(puzzleNotifierProvider(_solverClient));
|
|
return state.when(
|
|
() => MovesTilesText(
|
|
moves: 0,
|
|
tiles: 0,
|
|
fontSize: fontSize,
|
|
),
|
|
initializing: () => MovesTilesText(
|
|
moves: 0,
|
|
tiles: 0,
|
|
fontSize: fontSize,
|
|
),
|
|
scrambling: (_) => MovesTilesText(
|
|
moves: 0,
|
|
tiles: 0,
|
|
fontSize: fontSize,
|
|
),
|
|
current: (puzzleData) => MovesTilesText(
|
|
moves: puzzleData.moves,
|
|
tiles: puzzleData.tiles,
|
|
fontSize: fontSize,
|
|
),
|
|
computingSolution: (puzzleData) => MovesTilesText(
|
|
moves: puzzleData.moves,
|
|
tiles: puzzleData.tiles,
|
|
fontSize: fontSize,
|
|
),
|
|
autoSolving: (puzzleData) => MovesTilesText(
|
|
moves: puzzleData.moves,
|
|
tiles: puzzleData.tiles,
|
|
fontSize: fontSize,
|
|
),
|
|
solved: (puzzleData) => MovesTilesText(
|
|
moves: puzzleData.moves,
|
|
tiles: puzzleData.tiles,
|
|
fontSize: fontSize,
|
|
),
|
|
error: (_) => MovesTilesText(
|
|
moves: 0,
|
|
tiles: 0,
|
|
fontSize: fontSize,
|
|
),
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|