summary_page.dart 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. import 'dart:async';
  2. import 'package:flutter/material.dart';
  3. Future<void> showScore(
  4. BuildContext context, {
  5. required final int score,
  6. required final int time,
  7. }) {
  8. return Navigator.push(
  9. context,
  10. RawDialogRoute(
  11. barrierDismissible: false,
  12. pageBuilder: (_, __, ___) {
  13. return _ScoreContent(score: score, time: time);
  14. },
  15. ));
  16. }
  17. class _ScoreContent extends StatefulWidget {
  18. final int score;
  19. final int time;
  20. const _ScoreContent({
  21. super.key,
  22. required this.score,
  23. required this.time,
  24. });
  25. @override
  26. State<_ScoreContent> createState() => _ScoreContentState();
  27. }
  28. class _ScoreContentState extends State<_ScoreContent> {
  29. @override
  30. Widget build(BuildContext context) {
  31. return Material(
  32. type: MaterialType.transparency,
  33. child: Center(
  34. child: Container(
  35. constraints: const BoxConstraints(maxWidth: 320),
  36. child: Container(
  37. width: double.infinity,
  38. height: 280,
  39. alignment: Alignment.center,
  40. decoration: BoxDecoration(
  41. color: const Color(0xFFFFF3E2),
  42. borderRadius: BorderRadius.circular(40),
  43. ),
  44. child: Stack(
  45. children: [
  46. Positioned.fill(
  47. child: Column(
  48. crossAxisAlignment: CrossAxisAlignment.start,
  49. children: [
  50. const SizedBox(height: 64),
  51. Center(
  52. child: Container(
  53. height: 80,
  54. width: double.infinity,
  55. margin: const EdgeInsets.symmetric(horizontal: 32),
  56. decoration: BoxDecoration(
  57. color: Color(0xFFF8DEC3),
  58. borderRadius: BorderRadius.circular(16),
  59. ),
  60. child: Row(
  61. children: [
  62. Expanded(
  63. child: Row(
  64. children: [
  65. SizedBox(width: 8),
  66. Icon(
  67. Icons.timer,
  68. color: Color(0xFFA3C5FF),
  69. size: 32,
  70. ),
  71. SizedBox(width: 8),
  72. Expanded(
  73. child: Column(
  74. mainAxisAlignment: MainAxisAlignment.center,
  75. crossAxisAlignment: CrossAxisAlignment.start,
  76. children: [
  77. Text(
  78. '${widget.time}秒',
  79. style: TextStyle(
  80. fontSize: 18,
  81. color: Theme.of(context).colorScheme.primary,
  82. ),
  83. ),
  84. Text(
  85. '本次用时',
  86. style: TextStyle(
  87. fontSize: 12,
  88. color: Theme.of(context).colorScheme.secondary,
  89. ),
  90. ),
  91. ],
  92. ),
  93. ),
  94. ],
  95. ),
  96. ),
  97. Expanded(
  98. child: Row(
  99. children: [
  100. SizedBox(width: 8),
  101. Icon(
  102. Icons.check_circle,
  103. color: Color(0xFFF98170),
  104. size: 32,
  105. ),
  106. SizedBox(width: 8),
  107. Expanded(
  108. child: Column(
  109. mainAxisAlignment: MainAxisAlignment.center,
  110. crossAxisAlignment: CrossAxisAlignment.start,
  111. children: [
  112. Text(
  113. '${widget.score}分',
  114. style: TextStyle(
  115. fontSize: 18,
  116. color: Theme.of(context).colorScheme.primary,
  117. ),
  118. ),
  119. Text(
  120. '本次得分',
  121. style: TextStyle(
  122. fontSize: 12,
  123. color: Theme.of(context).colorScheme.secondary,
  124. ),
  125. ),
  126. ],
  127. ),
  128. ),
  129. ],
  130. ),
  131. ),
  132. ],
  133. ),
  134. ),
  135. ),
  136. Expanded(
  137. child: Center(
  138. child: Text(
  139. '小朋友你的呢?',
  140. style: TextStyle(
  141. fontSize: 24,
  142. color: Theme.of(context).colorScheme.onPrimaryContainer,
  143. ),
  144. ),
  145. ),
  146. ),
  147. ],
  148. ),
  149. ),
  150. Positioned(
  151. top: 16,
  152. right: 16,
  153. child: GestureDetector(
  154. onTap: () {
  155. Navigator.pop(context);
  156. },
  157. child: Container(
  158. width: 32,
  159. height: 32,
  160. decoration: BoxDecoration(
  161. borderRadius: BorderRadius.circular(16),
  162. color: Color(0x7F666666),
  163. ),
  164. child: Icon(
  165. Icons.close_rounded,
  166. color: Colors.white,
  167. ),
  168. ),
  169. ),
  170. ),
  171. ],
  172. ),
  173. ),
  174. ),
  175. ),
  176. );
  177. }
  178. }