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.

260 lines
11 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_bloc/flutter_bloc.dart';
  3. import 'package:flutter_svg/flutter_svg.dart';
  4. import 'package:my_flutter_puzzle/screens/level_list/cubit/level_list_cubit.dart';
  5. import 'package:my_flutter_puzzle/screens/puzzle/puzzle_starter_screen.dart';
  6. import 'package:my_flutter_puzzle/utils/extensions/context_extension.dart';
  7. import 'package:my_flutter_puzzle/utils/extensions/string_extensions.dart';
  8. import 'package:repositories/level_box_domain/model/level_model.dart';
  9. class WinScreen extends StatefulWidget {
  10. final int move;
  11. final int tiles;
  12. final int level;
  13. const WinScreen({
  14. Key? key,
  15. required this.tiles,
  16. required this.move,
  17. required this.level,
  18. }) : super(key: key);
  19. @override
  20. State<WinScreen> createState() => _WinScreenState();
  21. }
  22. class _WinScreenState extends State<WinScreen> {
  23. @override
  24. Widget build(BuildContext context) {
  25. return Scaffold(
  26. backgroundColor: const Color(0xff4400CE),
  27. body: SizedBox(
  28. width: context.width,
  29. height: context.height,
  30. child: Stack(
  31. alignment: AlignmentDirectional.centerEnd,
  32. children: [
  33. Center(
  34. child: Stack(
  35. alignment: Alignment.bottomCenter,
  36. children: [
  37. Container(
  38. width: context.width * 267 / 812,
  39. height: context.height * 284 / 375,
  40. decoration: BoxDecoration(
  41. gradient: const LinearGradient(
  42. colors: [
  43. Color(0xff6236FF),
  44. Color(0xff4706CC),
  45. ],
  46. begin: Alignment.topCenter,
  47. end: Alignment.bottomCenter,
  48. ),
  49. borderRadius: BorderRadius.circular(36),
  50. ),
  51. child: Column(
  52. children: [
  53. const SizedBox(height: 31),
  54. const Text(
  55. 'Well done !',
  56. style: TextStyle(
  57. color: Colors.white,
  58. fontSize: 25,
  59. fontWeight: FontWeight.bold,
  60. ),
  61. ),
  62. const SizedBox(height: 24),
  63. Container(
  64. width: context.width * 114 / 812,
  65. height: context.width * 114 / 812,
  66. decoration: BoxDecoration(
  67. gradient: const LinearGradient(
  68. colors: [
  69. Color(0xff6236FF),
  70. Color(0xff4824CB),
  71. ],
  72. begin: Alignment.topCenter,
  73. end: Alignment.bottomCenter,
  74. ),
  75. shape: BoxShape.circle,
  76. border: Border.all(
  77. color: const Color(0xff6136FE),
  78. width: 1,
  79. ),
  80. ),
  81. child: Container(
  82. margin: EdgeInsets.all(context.width * 20 / 812),
  83. padding: EdgeInsets.all(context.width * 20 / 812),
  84. decoration: const BoxDecoration(
  85. color: Color(0xff6DD400),
  86. shape: BoxShape.circle,
  87. ),
  88. child: SvgPicture.asset(
  89. 'check'.svgPath,
  90. colorFilter: const ColorFilter.mode(
  91. Colors.white,
  92. BlendMode.srcIn,
  93. ),
  94. ),
  95. ),
  96. ),
  97. const SizedBox(height: 19),
  98. Row(
  99. mainAxisAlignment: MainAxisAlignment.center,
  100. children: [
  101. Row(
  102. children: [
  103. const Text(
  104. 'Tiles',
  105. style: TextStyle(
  106. color: Colors.white,
  107. fontSize: 13,
  108. fontWeight: FontWeight.bold,
  109. ),
  110. ),
  111. const SizedBox(width: 9),
  112. Text(
  113. '${widget.tiles}',
  114. style: const TextStyle(
  115. decoration: TextDecoration.underline,
  116. color: Colors.white,
  117. fontSize: 13,
  118. fontWeight: FontWeight.bold,
  119. ),
  120. ),
  121. ],
  122. ),
  123. const SizedBox(width: 42),
  124. Row(
  125. children: [
  126. const Text(
  127. 'Move',
  128. style: TextStyle(
  129. color: Colors.white,
  130. fontSize: 13,
  131. fontWeight: FontWeight.bold,
  132. ),
  133. ),
  134. const SizedBox(width: 9),
  135. Text(
  136. '${widget.move}',
  137. style: const TextStyle(
  138. decoration: TextDecoration.underline,
  139. color: Colors.white,
  140. fontSize: 13,
  141. fontWeight: FontWeight.bold,
  142. ),
  143. ),
  144. ],
  145. ),
  146. ],
  147. ),
  148. ],
  149. ),
  150. ),
  151. Transform.translate(
  152. offset: const Offset(0, 20),
  153. child: GestureDetector(
  154. onTap: _openNextLevel,
  155. child: Container(
  156. width: context.width * 160 / 812,
  157. height: context.height * 51 / 375,
  158. padding: const EdgeInsets.all(3),
  159. decoration: BoxDecoration(
  160. color: const Color(0xff979797).withOpacity(0.12),
  161. borderRadius: BorderRadius.circular(36),
  162. ),
  163. child: Container(
  164. decoration: BoxDecoration(
  165. borderRadius: BorderRadius.circular(31),
  166. gradient: const LinearGradient(
  167. colors: [
  168. Color(0xffFFC600),
  169. Color(0xffFF5A00),
  170. ],
  171. begin: Alignment.topCenter,
  172. end: Alignment.bottomCenter,
  173. ),
  174. ),
  175. child: Row(
  176. mainAxisAlignment: MainAxisAlignment.center,
  177. children: [
  178. const SizedBox(width: 6),
  179. Container(
  180. width: context.width * 31 / 540,
  181. height: context.width * 31 / 540,
  182. padding: const EdgeInsets.all(9),
  183. margin: const EdgeInsets.symmetric(vertical: 3),
  184. decoration: BoxDecoration(
  185. border: Border.all(
  186. color: Colors.white,
  187. width: 1,
  188. ),
  189. gradient: const LinearGradient(
  190. colors: [
  191. Colors.white,
  192. Color(0xffD5D5D5),
  193. ],
  194. begin: Alignment.topCenter,
  195. end: Alignment.bottomCenter,
  196. ),
  197. shape: BoxShape.circle,
  198. ),
  199. child: SvgPicture.asset('next_level'.svgPath),
  200. ),
  201. const SizedBox(width: 8),
  202. const Text(
  203. 'Next level',
  204. style: TextStyle(
  205. color: Colors.white,
  206. fontSize: 14,
  207. fontWeight: FontWeight.bold,
  208. ),
  209. ),
  210. const SizedBox(width: 14),
  211. ],
  212. ),
  213. ),
  214. ),
  215. ),
  216. ),
  217. ],
  218. ),
  219. ),
  220. Container(
  221. margin: EdgeInsetsDirectional.only(end: context.width * 68 / 812),
  222. width: context.width * 142 / 812,
  223. height: context.height * 280 / 375,
  224. child: Image(
  225. image: AssetImage('avatar'.pngPath),
  226. ),
  227. ),
  228. ],
  229. ),
  230. ),
  231. );
  232. }
  233. void _openNextLevel() {
  234. int currentLevel = BlocProvider.of<LevelListCubit>(context).currentLevel;
  235. if (currentLevel == 8) {
  236. // all levels are done
  237. Navigator.popUntil(context, ModalRoute.withName('/'));
  238. } else {
  239. Level level = BlocProvider.of<LevelListCubit>(context).getLevel();
  240. Navigator.pushReplacement(
  241. context,
  242. MaterialPageRoute(
  243. builder: (context) {
  244. return PuzzleStarterScreen(
  245. duration: level.duration,
  246. puzzleSize: level.puzzleSize,
  247. image: level.image,
  248. level: level.level,
  249. );
  250. },
  251. ),
  252. );
  253. }
  254. }
  255. }