Browse Source

fix some bug

handle finish timer state
master
mohsen zamani 2 years ago
parent
commit
3eb46e4836
  1. 1
      lib/main.dart
  2. 26
      lib/screens/photo/photo_screen_large.dart
  3. 94
      lib/widgets/photo_screen/image_viewer.dart
  4. 3
      lib/widgets/solo_screen/game_button_widget.dart
  5. 4
      lib/widgets/solo_screen/puzzle_widget/puzzle_board.dart

1
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(

26
lib/screens/photo/photo_screen_large.dart

@ -80,6 +80,9 @@ class _SoloScreenLargeState extends ConsumerState<PhotoScreenLarge> {
_previousImage = next.image;
_previousPalette = next.palette;
});
ref.read(puzzleNotifierProvider(_solverClient).notifier).initializePuzzle(
initialPuzzleData: _initialPuzzleData,
);
}
});
@ -100,13 +103,18 @@ class _SoloScreenLargeState extends ConsumerState<PhotoScreenLarge> {
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<PhotoScreenLarge> {
CountdownWidget(
isStartPressed: _isStartPressed,
onFinish: () {
// ref.read(timerNotifierProvider.notifier).startTimer();
BlocProvider.of<CountDownTimerCubit>(context).start();
setState(() {
_isStartPressed = false;
@ -196,15 +203,6 @@ class _SoloScreenLargeState extends ConsumerState<PhotoScreenLarge> {
},
initialSpeed: kInitialSpeed,
),
Visibility(
visible: !_isStartPressed,
child: ImageViewer(
puzzleSize: _puzzleSize,
previousImage: _previousImage,
previousPalette: _previousPalette,
imageSize: 200,
),
),
],
),
],

94
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(

3
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 {

4
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],
),

Loading…
Cancel
Save