123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184 |
- import 'dart:async';
- import 'package:flutter/material.dart';
- Future<void> showScore(
- BuildContext context, {
- required final int score,
- required final int time,
- }) {
- return Navigator.push(
- context,
- RawDialogRoute(
- barrierDismissible: false,
- pageBuilder: (_, __, ___) {
- return _ScoreContent(score: score, time: time);
- },
- ));
- }
- class _ScoreContent extends StatefulWidget {
- final int score;
- final int time;
- const _ScoreContent({
- super.key,
- required this.score,
- required this.time,
- });
- @override
- State<_ScoreContent> createState() => _ScoreContentState();
- }
- class _ScoreContentState extends State<_ScoreContent> {
- @override
- Widget build(BuildContext context) {
- return Material(
- type: MaterialType.transparency,
- child: Center(
- child: Container(
- constraints: const BoxConstraints(maxWidth: 320),
- child: Container(
- width: double.infinity,
- height: 280,
- alignment: Alignment.center,
- decoration: BoxDecoration(
- color: const Color(0xFFFFF3E2),
- borderRadius: BorderRadius.circular(40),
- ),
- child: Stack(
- children: [
- Positioned.fill(
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- const SizedBox(height: 64),
- Center(
- child: Container(
- height: 80,
- width: double.infinity,
- margin: const EdgeInsets.symmetric(horizontal: 32),
- decoration: BoxDecoration(
- color: Color(0xFFF8DEC3),
- borderRadius: BorderRadius.circular(16),
- ),
- child: Row(
- children: [
- Expanded(
- child: Row(
- children: [
- SizedBox(width: 8),
- Icon(
- Icons.timer,
- color: Color(0xFFA3C5FF),
- size: 32,
- ),
- SizedBox(width: 8),
- Expanded(
- child: Column(
- mainAxisAlignment: MainAxisAlignment.center,
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Text(
- '${widget.time}秒',
- style: TextStyle(
- fontSize: 18,
- color: Theme.of(context).colorScheme.primary,
- ),
- ),
- Text(
- '本次用时',
- style: TextStyle(
- fontSize: 12,
- color: Theme.of(context).colorScheme.secondary,
- ),
- ),
- ],
- ),
- ),
- ],
- ),
- ),
- Expanded(
- child: Row(
- children: [
- SizedBox(width: 8),
- Icon(
- Icons.check_circle,
- color: Color(0xFFF98170),
- size: 32,
- ),
- SizedBox(width: 8),
- Expanded(
- child: Column(
- mainAxisAlignment: MainAxisAlignment.center,
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Text(
- '${widget.score}分',
- style: TextStyle(
- fontSize: 18,
- color: Theme.of(context).colorScheme.primary,
- ),
- ),
- Text(
- '本次得分',
- style: TextStyle(
- fontSize: 12,
- color: Theme.of(context).colorScheme.secondary,
- ),
- ),
- ],
- ),
- ),
- ],
- ),
- ),
- ],
- ),
- ),
- ),
- Expanded(
- child: Center(
- child: Text(
- '小朋友你的呢?',
- style: TextStyle(
- fontSize: 24,
- color: Theme.of(context).colorScheme.onPrimaryContainer,
- ),
- ),
- ),
- ),
- ],
- ),
- ),
- Positioned(
- top: 16,
- right: 16,
- child: GestureDetector(
- onTap: () {
- Navigator.pop(context);
- },
- child: Container(
- width: 32,
- height: 32,
- decoration: BoxDecoration(
- borderRadius: BorderRadius.circular(16),
- color: Color(0x7F666666),
- ),
- child: Icon(
- Icons.close_rounded,
- color: Colors.white,
- ),
- ),
- ),
- ),
- ],
- ),
- ),
- ),
- ),
- );
- }
- }
|