-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add puzzle completion and game over ui, minor updates
- Loading branch information
1 parent
f6c38ca
commit 4d543ed
Showing
24 changed files
with
878 additions
and
250 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:sudoku/colors/colors.dart'; | ||
import 'package:sudoku/layout/layout.dart'; | ||
import 'package:sudoku/models/models.dart'; | ||
import 'package:sudoku/typography/typography.dart'; | ||
import 'package:sudoku/utilities/utilities.dart'; | ||
import 'package:sudoku/widgets/widgets.dart'; | ||
|
||
class CongratsDialog extends StatelessWidget { | ||
const CongratsDialog({ | ||
required this.difficulty, | ||
required this.timeInSeconds, | ||
super.key, | ||
}); | ||
|
||
final Difficulty difficulty; | ||
final int timeInSeconds; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
const gradient = LinearGradient( | ||
colors: [ | ||
SudokuColors.darkPurple, | ||
SudokuColors.darkPink, | ||
], | ||
begin: Alignment.bottomLeft, | ||
end: Alignment.topRight, | ||
); | ||
|
||
return Dialog( | ||
shape: RoundedRectangleBorder( | ||
borderRadius: BorderRadius.circular(12), | ||
), | ||
child: ConstrainedBox( | ||
constraints: const BoxConstraints( | ||
maxWidth: 440, | ||
), | ||
child: ResponsiveLayoutBuilder( | ||
small: (_, child) => Padding( | ||
key: const Key('congrats_dialog_small'), | ||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 24), | ||
child: child, | ||
), | ||
medium: (_, child) => Padding( | ||
key: const Key('congrats_dialog_medium'), | ||
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 28), | ||
child: child, | ||
), | ||
large: (_, child) => Padding( | ||
key: const Key('congrats_dialog_large'), | ||
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 32), | ||
child: child, | ||
), | ||
child: (layoutSize) { | ||
final gap = switch (layoutSize) { | ||
ResponsiveLayoutSize.small => 16.0, | ||
ResponsiveLayoutSize.medium => 18.0, | ||
ResponsiveLayoutSize.large => 22.0, | ||
}; | ||
|
||
final titleFontSize = switch (layoutSize) { | ||
ResponsiveLayoutSize.small => 16.0, | ||
ResponsiveLayoutSize.medium => 18.0, | ||
ResponsiveLayoutSize.large => 22.0, | ||
}; | ||
|
||
final subtitleFontSize = switch (layoutSize) { | ||
ResponsiveLayoutSize.small => 12.0, | ||
ResponsiveLayoutSize.medium => 14.0, | ||
ResponsiveLayoutSize.large => 16.0, | ||
}; | ||
|
||
return Column( | ||
mainAxisSize: MainAxisSize.min, | ||
children: [ | ||
ShaderMask( | ||
blendMode: BlendMode.srcIn, | ||
shaderCallback: (bounds) => gradient.createShader( | ||
Rect.fromLTWH(0, 0, bounds.width, bounds.height), | ||
), | ||
child: Text( | ||
'Congratulations!!!', | ||
style: SudokuTextStyle.bodyText1.copyWith( | ||
fontWeight: SudokuFontWeight.semiBold, | ||
fontSize: titleFontSize, | ||
), | ||
), | ||
), | ||
SizedBox(height: gap), | ||
RichText( | ||
textAlign: TextAlign.center, | ||
text: TextSpan( | ||
style: SudokuTextStyle.caption.copyWith( | ||
height: 1.4, | ||
fontSize: subtitleFontSize, | ||
color: Theme.of(context).brightness == Brightness.light | ||
? Colors.black | ||
: Colors.white, | ||
), | ||
children: [ | ||
const TextSpan( | ||
text: 'You have finished ', | ||
), | ||
TextSpan( | ||
text: '${difficulty.article} ${difficulty.name}', | ||
style: SudokuTextStyle.caption.copyWith( | ||
fontWeight: SudokuFontWeight.medium, | ||
fontSize: subtitleFontSize, | ||
color: difficulty.color, | ||
), | ||
), | ||
const TextSpan( | ||
text: ' level sudoku in ', | ||
), | ||
TextSpan( | ||
text: timeInSeconds.format, | ||
style: SudokuTextStyle.caption.copyWith( | ||
fontWeight: SudokuFontWeight.semiBold, | ||
), | ||
), | ||
], | ||
), | ||
), | ||
SizedBox(height: gap), | ||
Text( | ||
'Thank you for playing the sudoku puzzle!', | ||
textAlign: TextAlign.center, | ||
style: SudokuTextStyle.caption.copyWith( | ||
fontWeight: SudokuFontWeight.medium, | ||
fontSize: subtitleFontSize, | ||
), | ||
), | ||
SizedBox(height: gap), | ||
SudokuElevatedButton( | ||
buttonText: 'Return to Home Page', | ||
onPressed: () => Navigator.of(context).popUntil( | ||
(route) => route.isFirst, | ||
), | ||
), | ||
], | ||
); | ||
}, | ||
), | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:sudoku/layout/layout.dart'; | ||
import 'package:sudoku/typography/typography.dart'; | ||
import 'package:sudoku/widgets/widgets.dart'; | ||
|
||
class GameOverDialog extends StatelessWidget { | ||
const GameOverDialog({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final theme = Theme.of(context); | ||
|
||
return Dialog( | ||
shape: RoundedRectangleBorder( | ||
borderRadius: BorderRadius.circular(12), | ||
), | ||
child: ConstrainedBox( | ||
constraints: const BoxConstraints( | ||
maxWidth: 440, | ||
), | ||
child: ResponsiveLayoutBuilder( | ||
small: (_, child) => Padding( | ||
key: const Key('game_over_dialog_small'), | ||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 24), | ||
child: child, | ||
), | ||
medium: (_, child) => Padding( | ||
key: const Key('game_over_dialog_medium'), | ||
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 28), | ||
child: child, | ||
), | ||
large: (_, child) => Padding( | ||
key: const Key('game_over_dialog_large'), | ||
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 32), | ||
child: child, | ||
), | ||
child: (layoutSize) { | ||
final gap = switch (layoutSize) { | ||
ResponsiveLayoutSize.small => 16.0, | ||
ResponsiveLayoutSize.medium => 18.0, | ||
ResponsiveLayoutSize.large => 22.0, | ||
}; | ||
|
||
final titleFontSize = switch (layoutSize) { | ||
ResponsiveLayoutSize.small => 16.0, | ||
ResponsiveLayoutSize.medium => 18.0, | ||
ResponsiveLayoutSize.large => 22.0, | ||
}; | ||
|
||
final subtitleFontSize = switch (layoutSize) { | ||
ResponsiveLayoutSize.small => 12.0, | ||
ResponsiveLayoutSize.medium => 14.0, | ||
ResponsiveLayoutSize.large => 16.0, | ||
}; | ||
|
||
return Column( | ||
mainAxisSize: MainAxisSize.min, | ||
children: [ | ||
Text( | ||
'Game Over!!!', | ||
style: SudokuTextStyle.bodyText1.copyWith( | ||
fontWeight: SudokuFontWeight.semiBold, | ||
fontSize: titleFontSize, | ||
color: theme.colorScheme.error, | ||
), | ||
), | ||
SizedBox(height: gap), | ||
RichText( | ||
textAlign: TextAlign.center, | ||
text: TextSpan( | ||
style: SudokuTextStyle.caption.copyWith( | ||
height: 1.4, | ||
fontSize: subtitleFontSize, | ||
color: Theme.of(context).brightness == Brightness.light | ||
? Colors.black | ||
: Colors.white, | ||
), | ||
children: [ | ||
const TextSpan( | ||
text: 'You have exhausted all of the ', | ||
), | ||
TextSpan( | ||
text: '3 allowed mistakes', | ||
style: SudokuTextStyle.caption.copyWith( | ||
fontWeight: SudokuFontWeight.medium, | ||
fontSize: subtitleFontSize, | ||
), | ||
), | ||
const TextSpan( | ||
text: ' in this puzzle.', | ||
), | ||
], | ||
), | ||
), | ||
SizedBox(height: gap), | ||
Text( | ||
'Thank you for playing the sudoku puzzle!', | ||
textAlign: TextAlign.center, | ||
style: SudokuTextStyle.caption.copyWith( | ||
fontWeight: SudokuFontWeight.medium, | ||
fontSize: subtitleFontSize, | ||
), | ||
), | ||
SizedBox(height: gap), | ||
SudokuElevatedButton( | ||
buttonText: 'Return to Home Page', | ||
onPressed: () => Navigator.popUntil( | ||
context, | ||
(route) => route.isFirst, | ||
), | ||
), | ||
], | ||
); | ||
}, | ||
), | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
export 'congrats_dialog.dart'; | ||
export 'game_over_dialog.dart'; | ||
export 'mistakes_count_view.dart'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.