@@ -12,11 +12,17 @@ final gridNotifierProvider = StateNotifierProvider<GridNotifierCubit, GridNotifi
1212 (ref) => GridNotifierCubit (),
1313);
1414
15- Border _allBorder () => Border .all (color: ColorManager .dividerBlue, width: 0.5 .r);
15+ BorderSide _borderSide ([bool isWhite = false ]) =>
16+ BorderSide (color: isWhite ? ColorManager .white : ColorManager .dividerBlue, width: isWhite ? 0.25 .r : 1. r);
1617
17- Border _thineVerticalBorder () {
18- return Border .symmetric (vertical: BorderSide (color: ColorManager .white, width: 0.5 .r));
19- }
18+ BorderDirectional _allBorder () => BorderDirectional (top: _borderSide (), start: _borderSide ());
19+
20+ BorderDirectional _thineVerticalBorder () => BorderDirectional (
21+ top: _borderSide (true ),
22+ start: _borderSide (true ),
23+ end: _borderSide (true ),
24+ bottom: _borderSide (true ),
25+ );
2026
2127class GridPage extends StatelessWidget {
2228 const GridPage ({super .key});
@@ -39,6 +45,29 @@ class GridPage extends StatelessWidget {
3945 Consumer (
4046 builder: (context, ref, _) {
4147 return TextButton (
48+ onPressed: () {
49+ ref.read (gridNotifierProvider.notifier).performDijkstra ();
50+ },
51+ child: const RegularText ("Dijkstra" ),
52+ );
53+ },
54+ ),
55+ Consumer (
56+ builder: (context, ref, _) {
57+ return TextButton (
58+ onPressed: () {
59+ ref.read (gridNotifierProvider.notifier).performBFS ();
60+ },
61+ child: const RegularText ("BFS" ),
62+ );
63+ },
64+ ),
65+ Consumer (
66+ builder: (context, ref, _) {
67+ return TextButton (
68+ onLongPress: () {
69+ ref.read (gridNotifierProvider.notifier).clearTheGrid (keepWall: true );
70+ },
4271 onPressed: () {
4372 ref.read (gridNotifierProvider.notifier).clearTheGrid ();
4473 },
@@ -139,10 +168,13 @@ class _SquareState extends ConsumerState<_Square> {
139168 final isSelected = ref.watch (gridNotifierProvider.select ((it) => it.gridData[widget.index]));
140169
141170 final isColored = isSelected != GridStatus .empty;
171+ final showBorder = isSelected != GridStatus .empty &&
172+ isSelected != GridStatus .startPoint &&
173+ isSelected != GridStatus .targetPoint;
142174
143175 return Container (
144176 decoration: BoxDecoration (
145- border: isColored ? _thineVerticalBorder () : _allBorder (),
177+ border: showBorder ? _thineVerticalBorder () : _allBorder (),
146178 ),
147179 child: AnimatedScale (
148180 scale: isColored ? 1.0 : 0.1 ,
@@ -159,6 +191,8 @@ class _SquareState extends ConsumerState<_Square> {
159191 return const _TargetPointGrid ();
160192 case GridStatus .searcher:
161193 return const _SearcherGrid ();
194+ case GridStatus .path:
195+ return const _PathGrid ();
162196 default :
163197 return const _DefaultGrid ();
164198 }
@@ -169,6 +203,25 @@ class _SquareState extends ConsumerState<_Square> {
169203 }
170204}
171205
206+ class _PathGrid extends StatelessWidget {
207+ const _PathGrid ();
208+
209+ @override
210+ Widget build (BuildContext context) {
211+ return Consumer (
212+ builder: (context, ref, _) {
213+ final size = ref.watch (gridNotifierProvider.select ((it) => it.gridSize));
214+
215+ return Container (
216+ width: size,
217+ height: size,
218+ decoration: const BoxDecoration (color: ColorManager .light2Yellow),
219+ );
220+ },
221+ );
222+ }
223+ }
224+
172225class _WallGrid extends StatelessWidget {
173226 const _WallGrid ();
174227
0 commit comments