CompetitionInformation.dart 11 KB

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