CompetitionInformation.dart 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_swiper/flutter_swiper.dart';
  3. import 'package:wanna_battle/model/HouseInfo.dart';
  4. import '../widget/LinearButton.dart';
  5. //竞赛须知
  6. class CompetitionInformation extends StatefulWidget {
  7. HouseInfo houseInfo;
  8. CompetitionInformation({this.houseInfo});
  9. @override
  10. CompetitionInformationState createState() => CompetitionInformationState();
  11. }
  12. class CompetitionInformationState extends State<CompetitionInformation> {
  13. int nowSwiperIndex = 0;
  14. SwiperController _swiperController;
  15. @override
  16. void initState() {
  17. super.initState();
  18. _swiperController = SwiperController();
  19. }
  20. @override
  21. Widget build(BuildContext context) {
  22. return WillPopScope(
  23. child: Scaffold(
  24. backgroundColor: Colors.black87,
  25. body: Container(
  26. child: Center(
  27. child: Swiper(
  28. controller: _swiperController,
  29. layout: SwiperLayout.DEFAULT,
  30. itemWidth: 270.0,
  31. itemHeight: 422.0,
  32. control: SwiperControl(color: Theme.of(context).primaryColor, disableColor: Colors.transparent),
  33. index: nowSwiperIndex,
  34. itemCount: 1,
  35. scrollDirection: Axis.horizontal,
  36. loop: false,
  37. itemBuilder: (context, index) {
  38. return InfoBox(
  39. killNum: widget.houseInfo.killnumber,
  40. typeIndex: index + 1,
  41. next: () {
  42. _swiperController.next();
  43. },
  44. end: () {
  45. Navigator.of(context).pop();
  46. });
  47. }))),
  48. ),
  49. onWillPop: () {
  50. return Future.value(false);
  51. },
  52. );
  53. }
  54. }
  55. typedef OnTapHomeMenu = void Function();
  56. class InfoBox extends StatelessWidget {
  57. InfoBox({Key key, this.typeIndex, this.next, this.end, this.killNum}) : super(key: key);
  58. final int typeIndex;
  59. final OnTapHomeMenu next;
  60. final OnTapHomeMenu end;
  61. final int killNum;
  62. @override
  63. Widget build(BuildContext context) {
  64. return UnconstrainedBox(
  65. child: Container(
  66. width: 270,
  67. height: 422,
  68. decoration: BoxDecoration(border: Border.all(width: 1, color: Theme.of(context).primaryColor), color: Colors.black),
  69. child: Stack(
  70. children: <Widget>[
  71. Container(
  72. width: 270,
  73. padding: EdgeInsets.only(top: 25),
  74. child: Column(
  75. children: <Widget>[
  76. Text('注意啦!', style: TextStyle(color: Color(0xFFC2524D), fontSize: 20, fontWeight: FontWeight.w600)),
  77. Container(height: 10,),
  78. Text(
  79. '本次任务:游戏中最短时间内杀戮${killNum}人',
  80. style: TextStyle(color: Color(0xFFFFB726), fontSize: 13, fontWeight: FontWeight.w500),
  81. ),
  82. _centerContent(typeIndex, context)
  83. ],
  84. ),
  85. ),
  86. Positioned(
  87. top: 0,
  88. left: 0,
  89. child: Image.asset(
  90. 'images/tancuang_shang.png',
  91. // width: 131,
  92. ),
  93. ),
  94. Positioned(
  95. top:-72,
  96. left: 16,
  97. child: Image.asset(
  98. 'images/img_guangmang.png',
  99. // width: 148,
  100. ),
  101. ),
  102. Positioned(
  103. bottom: 0,
  104. right: 4,
  105. child: Image.asset(
  106. 'images/tancuang_xia.png',
  107. // width: 148,
  108. ),
  109. ),
  110. Positioned(
  111. bottom:0,
  112. left: 25,
  113. child: Column(
  114. children: <Widget>[
  115. Container(
  116. width: 220,
  117. height: 36,
  118. child: LinearButton(
  119. btntext: typeIndex != 1 ? '下一个' : '知道了',
  120. onTapHomeMenu: typeIndex != 1 ? next : end,
  121. )
  122. // RaisedButton(
  123. // textColor: Colors.white,
  124. // child: Text(typeIndex != 4 ? '下一个' : '结束'),
  125. // onPressed: typeIndex != 4 ? next : end,
  126. // ),
  127. ),
  128. typeIndex != 1
  129. ? FlatButton(
  130. textColor: Color(0xFF727785),
  131. highlightColor: Colors.transparent,
  132. splashColor: Colors.transparent,
  133. child: Text('关闭'),
  134. onPressed: () {
  135. end();
  136. },
  137. )
  138. : Container(
  139. width: 10,
  140. height: 43,
  141. )
  142. ],
  143. ),
  144. )
  145. ],
  146. ),
  147. ));
  148. }
  149. // 第一名获得${houseInfo.houseLevel.firstRatio}%,第二名获得${houseInfo.houseLevel.secondRatio}%,第三名获得${houseInfo.houseLevel.thirdRatio}%
  150. Widget _centerContent(int index, BuildContext context) {
  151. Widget useContent = Container();
  152. TextStyle _text = TextStyle(color: Colors.white, fontSize: 14);
  153. // if (index == 1) {
  154. // useContent = Container(
  155. // margin: EdgeInsets.only(top: 20),
  156. // padding: EdgeInsets.symmetric(horizontal: 20),
  157. // child: Column(
  158. // crossAxisAlignment: CrossAxisAlignment.start,
  159. // children: <Widget>[
  160. // Text(
  161. // '吃鸡模式',
  162. // style: TextStyle(color: Color(0xFFFFB726)),
  163. // ),
  164. // Text('胜利条件:只要在游戏中成功吃鸡,即可获得一枚铂金奖牌,没有吃鸡即算做失败', style: TextStyle(color: Colors.white)),
  165. // Container(
  166. // height: 15,
  167. // ),
  168. // Text('评分模式', style: TextStyle(color: Color(0xFFFFB726))),
  169. // Text('胜利条件:不管游戏最终是否吃鸡,按游戏最终显示评分数值进行排序,评分相同用时短者优胜,前三名分别获得金银铜奖牌,其它人算做失败', style: TextStyle(color: Colors.white))
  170. // ],
  171. // ),
  172. // );
  173. // } else
  174. // if (index == 1) {
  175. // useContent = Container(
  176. // margin: EdgeInsets.only(top: 20),
  177. // padding: EdgeInsets.symmetric(horizontal: 20),
  178. // child: Column(
  179. // children: <Widget>[
  180. // Image.asset('images/img_xuzhi_02.png', width: 136),
  181. // Container(
  182. // height: 10,
  183. // ),
  184. // Text.rich(
  185. // TextSpan(children: [
  186. // TextSpan(
  187. // text: '竞赛开始前请在此耐心等待,在开始时会有上图所示弹窗,',
  188. // style: _text,
  189. // ),
  190. // TextSpan(
  191. // text: '玩家必须在10秒内点击确认',
  192. // style: TextStyle(color: Color(0xFFFFB726), fontSize: 14, fontWeight: FontWeight.w500),
  193. // ),
  194. // TextSpan(
  195. // text: ',否则视为放弃此次竞赛,已支付参赛券概不退换',
  196. // style: _text,
  197. // )
  198. // ]),
  199. // textAlign: TextAlign.center)
  200. // ],
  201. // ),
  202. // );
  203. // } else if (index == 2) {
  204. // useContent = Container(
  205. // margin: EdgeInsets.only(top: 20),
  206. // padding: EdgeInsets.symmetric(horizontal: 20),
  207. // child: Column(
  208. // children: <Widget>[
  209. // Image.asset('images/img_xuzhi_03.png', width: 176),
  210. // Container(
  211. // height: 10,
  212. // ),
  213. // Text.rich(
  214. // TextSpan(children: [
  215. // TextSpan(
  216. // text: '确认竞赛后会有弹窗提示授权进行录屏的操作,请一定',
  217. // style: _text,
  218. // ),
  219. // TextSpan(
  220. // text: '点击“确定”',
  221. // style: TextStyle(color: Color(0xFFFFB726), fontSize: 14, fontWeight: FontWeight.w500),
  222. // ),
  223. // TextSpan(
  224. // text: '或',
  225. // style: _text,
  226. // ),
  227. // TextSpan(
  228. // text: '“允许”',
  229. // style: TextStyle(color: Color(0xFFFFB726), fontSize: 14, fontWeight: FontWeight.w500),
  230. // ),
  231. // TextSpan(
  232. // text: '此操作,否则竞赛判定失败',
  233. // style: _text,
  234. // )
  235. // ]),
  236. // textAlign: TextAlign.center)
  237. // ],
  238. // ),
  239. // );
  240. // } else
  241. if (index == 1) {
  242. useContent = Container(
  243. margin: EdgeInsets.only(top: 20),
  244. padding: EdgeInsets.symmetric(horizontal: 20),
  245. child: Column(
  246. children: <Widget>[
  247. Image.asset('images/img_xuzhi_04.png', width: 216),
  248. Container(
  249. height: 10,
  250. ),
  251. Text.rich(
  252. TextSpan(children: [
  253. TextSpan(
  254. text: '游戏开始后,将会',
  255. style: _text,
  256. ),
  257. TextSpan(
  258. text: '自动',
  259. style: TextStyle(color: Color(0xFFFFB726), fontSize: 14, fontWeight: FontWeight.w600),
  260. ),
  261. TextSpan(
  262. text: '启动《和平精英》游戏,在任何模式中',
  263. style: _text,
  264. ),
  265. TextSpan(
  266. text: '尽快杀戮${killNum}人',
  267. style: TextStyle(color: Color(0xFFFFB726), fontSize: 14, fontWeight: FontWeight.w600),
  268. ),
  269. TextSpan(
  270. text: '后(具体人数参见房间内信息),',
  271. style: _text,
  272. ),
  273. TextSpan(
  274. text: '千万记得',
  275. style: TextStyle(color: Color(0xFFFFB726), fontSize: 14, fontWeight: FontWeight.w600),
  276. ),
  277. TextSpan(
  278. text: '完成杀人目标后立刻点击',
  279. style: _text,
  280. ),
  281. TextSpan(
  282. text: '悬浮窗',
  283. style: TextStyle(color: Color(0xFFFFB726), fontSize: 14, fontWeight: FontWeight.w600),
  284. ),
  285. TextSpan(
  286. text: '返回房间,取最快的',
  287. style: _text,
  288. ),
  289. TextSpan(
  290. text: '前三名',
  291. style: TextStyle(color: Color(0xFFFFB726), fontSize: 14, fontWeight: FontWeight.w600),
  292. )
  293. ]),)
  294. ],
  295. ),
  296. );
  297. }
  298. return useContent;
  299. }
  300. }