dialog_checked2.dart 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. import 'package:flutter/material.dart';
  2. import 'package:get/get.dart';
  3. import 'package:trackoffical_app/model/m_control_point.dart';
  4. import 'package:trackoffical_app/styles/theme.dart';
  5. const horizontalEdge = 20.0;
  6. const cardHeight = 225.4;
  7. double _getCardTop(BuildContext context) {
  8. return (context.height - cardHeight) / 2.7;
  9. }
  10. class DialogChecked2 extends StatelessWidget {
  11. final VoidCallback? onConfirm;
  12. final MControlPoint currentPoint;
  13. final MControlPoint? nextPoint;
  14. final mainColor = const Color(0xffff8000);
  15. const DialogChecked2({
  16. super.key,
  17. this.onConfirm,
  18. required this.currentPoint,
  19. this.nextPoint,
  20. });
  21. @override
  22. Widget build(BuildContext context) {
  23. final backColor = currentPoint.isSuccess
  24. ? const Color(0xff0aad81)
  25. : const Color(0xffff8000);
  26. final bordColor = currentPoint.isSuccess
  27. ? const Color(0xff64cbb0)
  28. : const Color(0xffffd6d6);
  29. var text = '';
  30. Widget bean = const SizedBox();
  31. final cardTop = _getCardTop(context);
  32. if (currentPoint.isSuccess) {
  33. if (currentPoint.sn == MControlPoint.snStart) {
  34. text = '游戏开始';
  35. } else if (currentPoint.sn == MControlPoint.snFinish) {
  36. text = '恭喜完赛';
  37. } else {
  38. text = '打卡成功';
  39. bean = Positioned(
  40. top: cardHeight + 40,
  41. child: Column(
  42. mainAxisSize: MainAxisSize.min,
  43. children: [
  44. Row(
  45. mainAxisSize: MainAxisSize.min,
  46. children: [
  47. Image.asset('assets/images/ic_bean.png',
  48. height: 52, fit: BoxFit.fitHeight),
  49. Text(' X 1',
  50. style: context.textTheme.titleLarge
  51. ?.copyWith(color: Colors.white, fontSize: 24))
  52. ],
  53. ),
  54. const SizedBox(height: 17),
  55. Text('获得百味豆1个哦',
  56. style: context.textTheme.titleLarge?.copyWith(
  57. color: const Color(0xff9d9d9d), fontSize: 15))
  58. ],
  59. ));
  60. }
  61. } else {
  62. text = '顺序错误';
  63. }
  64. return Padding(
  65. padding:
  66. EdgeInsets.fromLTRB(horizontalEdge, cardTop, horizontalEdge, 80),
  67. child: GestureDetector(
  68. onTap: () => Get.back(),
  69. child: SizedBox(
  70. width: double.infinity,
  71. height: double.infinity,
  72. child: Stack(
  73. alignment: Alignment.topCenter,
  74. children: [
  75. CustomPaint(
  76. painter: _BackGround(color: backColor),
  77. child: Container(
  78. margin: const EdgeInsets.all(10),
  79. width: 276.5,
  80. height: cardHeight,
  81. decoration: BoxDecoration(
  82. border: Border.all(color: bordColor, width: 2),
  83. borderRadius: BorderRadius.circular(7.62)),
  84. child: Column(
  85. children: [
  86. Expanded(
  87. child: Row(
  88. children: [
  89. Expanded(child: Center(child: _getSn(context))),
  90. VerticalDivider(width: 2, color: bordColor),
  91. Expanded(
  92. child: Column(
  93. mainAxisSize: MainAxisSize.min,
  94. children: [
  95. Text('检查点',
  96. style: context.textTheme.bodyLarge
  97. ?.copyWith(
  98. color: Colors.white,
  99. fontSize: 33.76)),
  100. Container(
  101. height: 48,
  102. width: 102.36,
  103. alignment: Alignment.center,
  104. decoration: BoxDecoration(
  105. color: Colors.white,
  106. borderRadius:
  107. BorderRadius.circular(3.27)),
  108. child: Text(currentPoint.areaId,
  109. style: context.textTheme.bodyLarge
  110. ?.copyWith(
  111. height: 0.77,
  112. color: backColor,
  113. fontSize: 49,
  114. fontWeight: FontWeight.w600)),
  115. )
  116. ],
  117. )),
  118. ],
  119. )),
  120. Divider(height: 2, color: bordColor),
  121. Expanded(
  122. child: Center(
  123. child: Text(text,
  124. style: context.textTheme.titleLarge
  125. ?.copyWith(
  126. color: Colors.white,
  127. fontSize: 49,
  128. fontWeight: FontWeight.w700))))
  129. ],
  130. ),
  131. ),
  132. ),
  133. bean
  134. // Positioned(top: 20, left: 0, child: _okMsg(context)),
  135. // Positioned(top: 120, left: 0, child: _topCard(context)),
  136. // Positioned(top: 320, left: 0, child: _memo(context)),
  137. // Positioned(top: 400, left: 0, child: _closeBtn(context)),
  138. ],
  139. ))));
  140. }
  141. Widget _getSn(BuildContext context) {
  142. var src = '';
  143. if (currentPoint.isSuccess) {
  144. if (currentPoint.sn == MControlPoint.snStart) {
  145. src = 'ic_checked_start.png';
  146. } else if (currentPoint.sn == MControlPoint.snFinish) {
  147. src = 'ic_checked_finish.png';
  148. } else {
  149. return Text("${currentPoint.sn}号",
  150. style: context.textTheme.titleLarge?.copyWith(
  151. color: Colors.white,
  152. fontSize: 54.44,
  153. fontWeight: FontWeight.w500));
  154. }
  155. } else {
  156. src = 'ic_checked_fail.png';
  157. }
  158. return Image.asset('assets/images/$src', height: 60, fit: BoxFit.fitHeight);
  159. }
  160. }
  161. class _BackGround extends CustomPainter {
  162. final Color color;
  163. _BackGround({required this.color});
  164. @override
  165. void paint(Canvas canvas, Size size) {
  166. var paint = Paint()
  167. ..color = color
  168. ..maskFilter = const MaskFilter.blur(BlurStyle.solid, 12);
  169. canvas.drawRRect(
  170. RRect.fromRectAndRadius(Rect.fromLTWH(0, 0, size.width, size.height),
  171. const Radius.circular(12)),
  172. paint);
  173. }
  174. @override
  175. bool shouldRepaint(covariant CustomPainter oldDelegate) {
  176. return this != oldDelegate;
  177. }
  178. }
  179. class DialogGiveUp extends StatelessWidget {
  180. final VoidCallback onConfirm;
  181. final VoidCallback onCancel;
  182. const DialogGiveUp(
  183. {super.key, required this.onConfirm, required this.onCancel});
  184. @override
  185. Widget build(BuildContext context) {
  186. return Padding(
  187. padding: EdgeInsets.fromLTRB(
  188. horizontalEdge, _getCardTop(context), horizontalEdge, 80),
  189. child: Stack(
  190. alignment: Alignment.topCenter,
  191. children: [
  192. CustomPaint(
  193. painter: _BackGround(color: const Color(0xffff0000)),
  194. child: Container(
  195. margin: const EdgeInsets.all(10),
  196. width: 276.5,
  197. height: cardHeight,
  198. alignment: Alignment.center,
  199. decoration: BoxDecoration(
  200. border: Border.all(
  201. color: const Color(0xffffd6d6), width: 2),
  202. borderRadius: BorderRadius.circular(7.62)),
  203. child: Column(
  204. crossAxisAlignment: CrossAxisAlignment.center,
  205. mainAxisSize: MainAxisSize.min,
  206. children: [
  207. Text('退出比赛',
  208. style: context.textTheme.titleLarge?.copyWith(
  209. color: Colors.white,
  210. fontSize: 35.93,
  211. fontWeight: FontWeight.w700)),
  212. const SizedBox(height: 19),
  213. Text(
  214. '是否强制结束?',
  215. style: context.textTheme.titleLarge
  216. ?.copyWith(color: Colors.white, fontSize: 19.6),
  217. ),
  218. const SizedBox(height: 35),
  219. Row(
  220. mainAxisSize: MainAxisSize.min,
  221. children: [
  222. SizedBox(
  223. width: 100,
  224. height: 41,
  225. child: OutlinedButton(
  226. onPressed: onCancel,
  227. style: OutlinedButton.styleFrom(side: BorderSide(width: 1, color: Colors.white)),
  228. child: const Text(
  229. '否',
  230. style: TextStyle(height: 0.1,
  231. color: Colors.white, fontSize: 26),
  232. ))),
  233. const SizedBox(width: 23),
  234. SizedBox(
  235. width: 100,
  236. height: 41,
  237. child: FilledButton(
  238. onPressed: onConfirm,
  239. style: FilledButton.styleFrom(backgroundColor: Colors.white),
  240. child: const Text('是',
  241. style: TextStyle(
  242. height: 0.1,
  243. color: Color(0xffff0000),
  244. fontSize: 26))))
  245. ],
  246. )
  247. ],
  248. )))
  249. ],
  250. ));
  251. }
  252. }
  253. class _Empty extends StatelessWidget {
  254. @override
  255. Widget build(BuildContext context) {
  256. _showDialog();
  257. return const Scaffold();
  258. }
  259. }
  260. Future<void> _showDialog() async {
  261. await Future.delayed(2.seconds);
  262. if (Get.isOverlaysOpen) {
  263. Get.back();
  264. }
  265. Get.dialog(DialogChecked2(
  266. onConfirm: () {},
  267. currentPoint: MControlPoint(
  268. // sn: ControlPointText.snFinish,
  269. sn: "12",
  270. areaId: 'A51',
  271. isSuccess: true),
  272. nextPoint: MControlPoint(
  273. sn: MControlPoint.snFinish, areaId: 'A52', isSuccess: true),
  274. ));
  275. }
  276. void main() async {
  277. runApp(GetMaterialApp(theme: appThemeData(), home: _Empty()));
  278. }