| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171 |
- import 'package:flutter/material.dart';
- import 'package:flutter/cupertino.dart';
- import 'OpenRoom.dart'; //创建房间
- import 'dart:async';
- import '../styles/colors.dart';
- class StartWindow extends StatefulWidget {
- @override
- StartWindowState createState() => StartWindowState();
- }
- class StartWindowState extends State<StartWindow> with SingleTickerProviderStateMixin {
- int _num = 10;
- bool isNext = true;
- Timer timer;
- AnimationController animationController;
- @override
- void initState() {
- super.initState();
- animationController = AnimationController(
- vsync: this,
- duration: Duration(seconds: 10),
- );
- animationController.repeat();
- timer = Timer.periodic(Duration(seconds: 1), (timer) {
- if (_num == 0) {
- Navigator.of(context).pop(false);
- timer.cancel();
- } else {
- setState(() {
- _num--;
- });
- }
- });
- }
- @override
- Widget build(BuildContext context) {
- return GestureDetector(
- // onTap: () {
- // Navigator.of(context).pop();
- // },
- child: WillPopScope(
- child: Scaffold(
- backgroundColor: Color(0xCC000000),
- body: Container(
- child: Center(
- child: Container(
- padding: EdgeInsets.only(top: 28, bottom: 30),
- width: 270,
- height: 334,
- decoration: BoxDecoration(
- color: Color(0xE6293559),
- border: Border.all(width: 1, color: PRIMARY_COLOR),
- image: DecorationImage(image: AssetImage('images/img_guangmang.png'), fit: BoxFit.contain),
- ),
- child: Stack(
- children: <Widget>[
- Align(
- alignment: Alignment.topCenter,
- child: Text(
- '点击确认开始游戏',
- style: TextStyle(
- color: PRIMARY_COLOR,
- fontSize: 20,
- fontWeight: FontWeight.bold,
- ),
- ),
- ),
- _centerContent(),
- Align(
- alignment: Alignment.bottomCenter,
- child: Container(
- padding: EdgeInsets.fromLTRB(25, 0, 25, 0),
- width: double.infinity,
- child: MaterialButton(
- highlightElevation: 0,
- height: 36,
- color: PRIMARY_COLOR,
- child: Text(
- '确认',
- style: TextStyle(
- fontSize: 14,
- fontWeight: FontWeight.bold,
- color: Colors.white,
- ),
- ),
- onPressed: () {
- timer.cancel();
- Navigator.of(context).pop(true);
- },
- ),
- ),
- ),
- ],
- ),
- ),
- ),
- ),
- ),
- onWillPop: () {
- return Future.value(false);
- },
- ),
- );
- }
- Widget _centerContent() {
- return Stack(
- children: <Widget>[
- Center(
- child: Container(
- width: 128,
- height: 128,
- decoration: BoxDecoration(
- borderRadius: BorderRadius.all(Radius.circular(100)),
- color: PRIMARY_COLOR,
- boxShadow: [
- BoxShadow(
- color: Color(0xD41990F8),
- offset: Offset.zero,
- blurRadius: 17,
- ),
- ],
- ),
- ),
- ),
- Center(
- child: Container(
- width: 80,
- height: 80,
- decoration: BoxDecoration(
- color: Color(0xFF26D1FB),
- borderRadius: BorderRadius.all(Radius.circular(40)),
- ),
- ),
- ),
- Center(
- child: Container(
- width: 64,
- height: 64,
- decoration: BoxDecoration(
- color: Color(0xFF0E88CA),
- borderRadius: BorderRadius.all(Radius.circular(32)),
- ),
- ),
- ),
- Center(
- child: AnimatedBuilder(
- animation: animationController,
- child: Image.asset('images/spinner.png'),
- builder: (context, widget) {
- return Transform.rotate(
- angle: -animationController.value * 6.3,
- child: widget,
- );
- },
- ),
- ),
- Center(
- child: Text(
- '$_num',
- style: TextStyle(color: Colors.white, fontSize: 34, fontWeight: FontWeight.bold),
- ),
- ),
- ],
- );
- }
- }
|