| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
- import 'package:flutter/material.dart';
- import 'package:flutter/cupertino.dart';
- import 'package:flutter_screenutil/flutter_screenutil.dart';
- import 'OpenRoom.dart'; //创建房间
- class StartWindow extends StatefulWidget {
- @override
- StartWindowState createState() => StartWindowState();
- }
- class StartWindowState extends State<StartWindow> {
- int _num = 10;
- bool isNext = true;
- getNum() async {
- if (!isNext) {
- Navigator.of(context).pop(true);
- return;
- }
- await Future.delayed(const Duration(seconds: 1));
- if (_num == 0) {
- if (isNext) {
- Navigator.pop(context);
- }
- return;
- }
- if (isNext) {
- setState(() {
- _num--;
- });
- getNum();
- } else {
- Navigator.of(context).pop(true);
- return;
- }
- }
- @override
- void initState() {
- super.initState();
-
- Future.delayed(Duration.zero, () {
- getNum();
- });
- }
- @override
- Widget build(BuildContext context) {
- ScreenUtil.instance = ScreenUtil(width: 375, height: 667)..init(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: 29, bottom: 21),
- width: ScreenUtil().setWidth(272),
- height: ScreenUtil().setWidth(319),
- decoration: BoxDecoration(
- image: DecorationImage(
- image: AssetImage('images/img_kaishiyouxi.png'),
- )),
- child: Column(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: <Widget>[
- Text('点击确认开始游戏',
- style: TextStyle(
- color: Color(0xFFFDC372),
- fontSize: 20,
- fontWeight: FontWeight.w600)),
- _centerContent(),
- Container(
- child: RaisedButton(
- textTheme: ButtonTextTheme.primary,
- child: Text('确认'),
- onPressed: () {
- isNext = false;
- },
- ),
- )
- ],
- ),
- )),
- ),
- ),
- onWillPop: () {
-
- },
- ),
- );
- }
- Widget _centerContent() {
- return Container(
- width: ScreenUtil().setWidth(131),
- height: ScreenUtil().setWidth(131),
- decoration: BoxDecoration(
- borderRadius: BorderRadius.all(Radius.circular(100)),
- gradient: LinearGradient(
- colors: [Color(0xFFC18C4A), Color(0xFFE2AD5C)],
- begin: Alignment.topCenter,
- end: Alignment.bottomCenter,
- ),
- ),
- child: Center(
- child: Container(
- width: ScreenUtil().setWidth(80),
- height: ScreenUtil().setWidth(80),
- decoration: BoxDecoration(
- borderRadius: BorderRadius.all(Radius.circular(100)),
- color: Color(0xFFF5C271),
- ),
- child: Center(
- child: Container(
- width: ScreenUtil().setWidth(60),
- height: ScreenUtil().setWidth(60),
- decoration: BoxDecoration(
- borderRadius: BorderRadius.all(Radius.circular(100)),
- gradient: LinearGradient(
- colors: [Color(0xFFDF605C), Color(0xFFB34B48)],
- begin: Alignment.topLeft,
- end: Alignment.bottomRight,
- ),
- ),
- child: Center(
- child: Text(
- "$_num",
- style: TextStyle(
- color: Colors.white,
- fontSize: 32,
- fontWeight: FontWeight.w600),
- ),
- ),
- ),
- ),
- ),
- ),
- );
- }
- }
|