From 3eb46e483686a69fd92990155101c1bebc4a5bf6 Mon Sep 17 00:00:00 2001 From: mohsen zamani Date: Thu, 2 Mar 2023 22:35:26 +0330 Subject: [PATCH] fix some bug handle finish timer state --- lib/main.dart | 1 + lib/screens/photo/photo_screen_large.dart | 26 +++-- lib/widgets/photo_screen/image_viewer.dart | 94 +++---------------- .../solo_screen/game_button_widget.dart | 3 - .../puzzle_widget/puzzle_board.dart | 4 +- 5 files changed, 26 insertions(+), 102 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index cc4788e..90829a5 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -25,6 +25,7 @@ class MyApp extends StatelessWidget { DeviceOrientation.landscapeLeft, DeviceOrientation.landscapeRight, ]); + SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: []); return BlocProvider( create: (context) => CountDownTimerCubit(), child: MaterialApp( diff --git a/lib/screens/photo/photo_screen_large.dart b/lib/screens/photo/photo_screen_large.dart index ca307d3..669555b 100644 --- a/lib/screens/photo/photo_screen_large.dart +++ b/lib/screens/photo/photo_screen_large.dart @@ -80,6 +80,9 @@ class _SoloScreenLargeState extends ConsumerState { _previousImage = next.image; _previousPalette = next.palette; }); + ref.read(puzzleNotifierProvider(_solverClient).notifier).initializePuzzle( + initialPuzzleData: _initialPuzzleData, + ); } }); @@ -100,13 +103,18 @@ class _SoloScreenLargeState extends ConsumerState { mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ + Visibility( + visible: !_isStartPressed, + child: ImageViewer( + puzzleSize: _puzzleSize, + previousImage: _previousImage, + previousPalette: _previousPalette, + imageSize: 200, + ), + ), const SizedBox(height: 32), MovesTilesWidget(solverClient: _solverClient, fontSize: 16), const SizedBox(height: 32), - GameButtonWidget( - solverClient: _solverClient, - initialPuzzleData: _initialPuzzleData, - ), ], ), ), @@ -188,7 +196,6 @@ class _SoloScreenLargeState extends ConsumerState { CountdownWidget( isStartPressed: _isStartPressed, onFinish: () { - // ref.read(timerNotifierProvider.notifier).startTimer(); BlocProvider.of(context).start(); setState(() { _isStartPressed = false; @@ -196,15 +203,6 @@ class _SoloScreenLargeState extends ConsumerState { }, initialSpeed: kInitialSpeed, ), - Visibility( - visible: !_isStartPressed, - child: ImageViewer( - puzzleSize: _puzzleSize, - previousImage: _previousImage, - previousPalette: _previousPalette, - imageSize: 200, - ), - ), ], ), ], diff --git a/lib/widgets/photo_screen/image_viewer.dart b/lib/widgets/photo_screen/image_viewer.dart index 5640164..7073dba 100644 --- a/lib/widgets/photo_screen/image_viewer.dart +++ b/lib/widgets/photo_screen/image_viewer.dart @@ -24,90 +24,18 @@ class ImageViewer extends ConsumerWidget { final state = ref.watch(imageSplitterNotifierProvider); return state.maybeWhen( () => const SizedBox(), - complete: (image, images, palette) => Padding( - padding: const EdgeInsets.only(right: 0.0), - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(20), - // border: Border.all(color: Colors.white, width: 3), - ), - child: ClipRRect( - borderRadius: BorderRadius.circular(20), - child: Image( - image: image.image, - height: imageSize, - width: imageSize, - ), - ), - ), - Padding( - padding: const EdgeInsets.only(top: 8.0), - child: SizedBox( - width: imageSize, - child: Padding( - padding: const EdgeInsets.symmetric( - vertical: 4, - horizontal: 16, - ), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - Container( - width: imageSize / 5, - height: imageSize / 5, - decoration: BoxDecoration( - color: palette.colors.elementAt(0), - shape: BoxShape.circle, - border: Border.all( - color: Colors.white60, - width: 3, - ), - ), - ), - Container( - width: imageSize / 5, - height: imageSize / 5, - decoration: BoxDecoration( - color: palette.colors.elementAt(1), - shape: BoxShape.circle, - border: Border.all( - color: Colors.white60, - width: 3, - ), - ), - ), - Container( - width: imageSize / 5, - height: imageSize / 5, - decoration: BoxDecoration( - color: palette.colors.elementAt(2), - shape: BoxShape.circle, - border: Border.all( - color: Colors.white60, - width: 3, - ), - ), - ), - ], - ), - ), - ), + complete: (image, images, palette) => Column( + mainAxisSize: MainAxisSize.min, + children: [ + ClipRRect( + borderRadius: BorderRadius.circular(20), + child: Image( + image: image.image, + height: imageSize, + width: imageSize, ), - const SizedBox(height: 16), - // PickImageButton( - // text: 'Pick Image', - // onTap: () => ref - // .read(imageSplitterNotifierProvider.notifier) - // .generateImages( - // picker: imagePicker, - // puzzleSize: puzzleSize, - // ), - // ), - ], - ), + ), + ], ), orElse: () => previousImage != null ? Padding( diff --git a/lib/widgets/solo_screen/game_button_widget.dart b/lib/widgets/solo_screen/game_button_widget.dart index acd82ba..b2bdf48 100644 --- a/lib/widgets/solo_screen/game_button_widget.dart +++ b/lib/widgets/solo_screen/game_button_widget.dart @@ -1,11 +1,8 @@ import 'package:flutter/material.dart'; -import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:my_flutter_puzzle/cubits/count_down_timer_cubit.dart'; import 'package:my_flutter_puzzle/models/puzzle_data.dart'; import 'package:my_flutter_puzzle/providers.dart'; import 'package:my_flutter_puzzle/utils/puzzle_solver.dart'; - import 'game_button_widget/puzzle_game_button.dart'; class GameButtonWidget extends StatelessWidget { diff --git a/lib/widgets/solo_screen/puzzle_widget/puzzle_board.dart b/lib/widgets/solo_screen/puzzle_widget/puzzle_board.dart index 13b9ed2..08b5433 100644 --- a/lib/widgets/solo_screen/puzzle_widget/puzzle_board.dart +++ b/lib/widgets/solo_screen/puzzle_widget/puzzle_board.dart @@ -59,7 +59,7 @@ class PuzzleBoard extends ConsumerWidget { elevation: 4, color: Theme.of(context).colorScheme.primary.withOpacity(isEnabled ? 1 : 0.5), shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(borderRadius), + borderRadius: BorderRadius.circular(10), ), child: SizedBox( height: eachBoxSize, @@ -82,7 +82,7 @@ class PuzzleBoard extends ConsumerWidget { child: Opacity( opacity: isEnabled ? 1 : 0.5, child: ClipRRect( - borderRadius: BorderRadius.circular(borderRadius), + borderRadius: BorderRadius.circular(10), child: images![int.parse(puzzleData.offsetMap.entries.toList()[i].key.toString()) - 1], ),