StartWindow.dart 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter/cupertino.dart';
  3. import 'package:flutter_screenutil/flutter_screenutil.dart';
  4. import 'OpenRoom.dart'; //创建房间
  5. import 'dart:async';
  6. import '../widget/LinearButton.dart';
  7. class StartWindow extends StatefulWidget {
  8. @override
  9. StartWindowState createState() => StartWindowState();
  10. }
  11. class StartWindowState extends State<StartWindow> {
  12. int _num = 10;
  13. bool isNext = true;
  14. Timer timer;
  15. @override
  16. void initState() {
  17. super.initState();
  18. timer = Timer.periodic(Duration(seconds: 1), (timer) {
  19. if (_num == 0) {
  20. Navigator.of(context).pop(false);
  21. timer.cancel();
  22. } else {
  23. setState(() {
  24. _num--;
  25. });
  26. }
  27. });
  28. }
  29. @override
  30. Widget build(BuildContext context) {
  31. ScreenUtil.instance = ScreenUtil(width: 375, height: 667)..init(context);
  32. return GestureDetector(
  33. // onTap: () {
  34. // Navigator.of(context).pop();
  35. // },
  36. child: WillPopScope(
  37. child: Scaffold(
  38. backgroundColor: Color(0xCC000000),
  39. body: Container(
  40. child: Center(
  41. child: Container(
  42. width: ScreenUtil().setWidth(272),
  43. height: ScreenUtil().setWidth(319),
  44. decoration: BoxDecoration(
  45. color: Color(0xFF15151D),
  46. image: DecorationImage(
  47. image: AssetImage('images/img_guangmang2.png'),
  48. ),
  49. border: Border.all(width: 1, color: Theme.of(context).primaryColor)),
  50. child: Stack(
  51. children: <Widget>[
  52. Padding(
  53. padding: EdgeInsets.only(top: 29, bottom: 21),
  54. child: Column(
  55. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  56. children: <Widget>[
  57. Text('点击确认开始游戏',
  58. style: TextStyle(
  59. color: Color(0xFFFDC372),
  60. fontSize: 20,
  61. fontWeight: FontWeight.w600)),
  62. _centerContent(),
  63. Container(
  64. width: double.infinity,
  65. margin: EdgeInsets.symmetric(horizontal: 42),
  66. height: 44,
  67. child: LinearButton(
  68. btntext: '确认',
  69. onTapHomeMenu: () {
  70. timer.cancel();
  71. Navigator.of(context).pop(true);
  72. },
  73. )
  74. // RaisedButton(
  75. // textTheme: ButtonTextTheme.primary,
  76. // child:
  77. // Text('确认'),
  78. // onPressed: () {
  79. // timer.cancel();
  80. // Navigator.of(context).pop(true);
  81. // },
  82. // ),
  83. )
  84. ],
  85. ),
  86. ),
  87. Positioned(
  88. top: 0,
  89. left: 0,
  90. child: Image.asset(
  91. 'images/tancuang_shang.png',
  92. // width: 131,
  93. ),
  94. ),
  95. Positioned(
  96. bottom: 0,
  97. right: 4,
  98. child: Image.asset(
  99. 'images/tancuang_xia.png',
  100. // width: 148,
  101. ),
  102. )
  103. ],
  104. ),
  105. )),
  106. ),
  107. ),
  108. onWillPop: () {
  109. return Future.value(false);
  110. },
  111. ),
  112. );
  113. }
  114. Widget _centerContent() {
  115. return Container(
  116. width: ScreenUtil().setWidth(131),
  117. height: ScreenUtil().setWidth(131),
  118. decoration: BoxDecoration(
  119. borderRadius: BorderRadius.all(Radius.circular(100)),
  120. gradient: LinearGradient(
  121. colors: [Color(0xFFC18C4A), Color(0xFFE2AD5C)],
  122. begin: Alignment.topCenter,
  123. end: Alignment.bottomCenter,
  124. ),
  125. ),
  126. child: Center(
  127. child: Container(
  128. width: ScreenUtil().setWidth(80),
  129. height: ScreenUtil().setWidth(80),
  130. decoration: BoxDecoration(
  131. borderRadius: BorderRadius.all(Radius.circular(100)),
  132. color: Color(0xFFF5C271),
  133. ),
  134. child: Center(
  135. child: Container(
  136. width: ScreenUtil().setWidth(60),
  137. height: ScreenUtil().setWidth(60),
  138. decoration: BoxDecoration(
  139. borderRadius: BorderRadius.all(Radius.circular(100)),
  140. gradient: LinearGradient(
  141. colors: [Color(0xFFDF605C), Color(0xFFB34B48)],
  142. begin: Alignment.topLeft,
  143. end: Alignment.bottomRight,
  144. ),
  145. ),
  146. child: Center(
  147. child: Text(
  148. '$_num',
  149. style: TextStyle(
  150. color: Colors.white,
  151. fontSize: 32,
  152. fontWeight: FontWeight.w600),
  153. ),
  154. ),
  155. ),
  156. ),
  157. ),
  158. ),
  159. );
  160. }
  161. }