CompetitionInformation.dart 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_swiper/flutter_swiper.dart';
  3. import '../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: 4,
  35. scrollDirection: Axis.horizontal,
  36. loop: false,
  37. itemBuilder: (context, index) {
  38. return InfoBox(
  39. houseInfo: widget.houseInfo,
  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.houseInfo}) : super(key: key);
  58. final int typeIndex;
  59. final OnTapHomeMenu next;
  60. final OnTapHomeMenu end;
  61. final HouseInfo houseInfo;
  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('竞赛须知 ' + typeIndex.toString() + '/4', style: TextStyle(color: Color(0xFFC2524D), fontSize: 20, fontWeight: FontWeight.w600)),
  77. _centerContent(typeIndex, context)
  78. ],
  79. ),
  80. ),
  81. Positioned(
  82. top: 0,
  83. left: 0,
  84. child: Image.asset(
  85. 'images/tancuang_shang.png',
  86. // width: 131,
  87. ),
  88. ),
  89. Positioned(
  90. bottom: 0,
  91. right: 4,
  92. child: Image.asset(
  93. 'images/tancuang_xia.png',
  94. // width: 148,
  95. ),
  96. ),
  97. Positioned(
  98. bottom: 15,
  99. left: 25,
  100. child: Column(
  101. children: <Widget>[
  102. Container(
  103. width: 220,
  104. height: 36,
  105. child: LinearButton(
  106. btntext: typeIndex != 4 ? '下一个' : '知道了',
  107. onTapHomeMenu: typeIndex != 4 ? next : end,
  108. )
  109. // RaisedButton(
  110. // textColor: Colors.white,
  111. // child: Text(typeIndex != 4 ? '下一个' : '结束'),
  112. // onPressed: typeIndex != 4 ? next : end,
  113. // ),
  114. ),
  115. typeIndex!=4? FlatButton(
  116. textColor: Color(0xFF727785),
  117. highlightColor: Colors.transparent,
  118. splashColor: Colors.transparent,
  119. child: Text('关闭'),
  120. onPressed: () {
  121. end();
  122. },
  123. ):Container(
  124. width: 10,
  125. height: 43,
  126. )
  127. ],
  128. ),
  129. )
  130. ],
  131. ),
  132. ));
  133. }
  134. // 第一名获得${houseInfo.houseLevel.firstRatio}%,第二名获得${houseInfo.houseLevel.secondRatio}%,第三名获得${houseInfo.houseLevel.thirdRatio}%
  135. Widget _centerContent(int index, BuildContext context) {
  136. Widget useContent = Container();
  137. TextStyle _text = TextStyle(color: Colors.white, fontSize: 14);
  138. if (index == 1) {
  139. useContent = Container(
  140. margin: EdgeInsets.only(top: 20),
  141. padding: EdgeInsets.symmetric(horizontal: 20),
  142. child: Column(
  143. crossAxisAlignment: CrossAxisAlignment.start,
  144. children: <Widget>[
  145. Text(
  146. '吃鸡模式',
  147. style: TextStyle(color: Color(0xFFFFB726)),
  148. ),
  149. Text('胜利条件:只要在游戏中成功吃鸡,即可获得一枚铂金奖牌,没有吃鸡即算做失败', style: TextStyle(color: Colors.white)),
  150. Container(
  151. height: 15,
  152. ),
  153. Text('评分模式', style: TextStyle(color: Color(0xFFFFB726))),
  154. Text('胜利条件:不管游戏最终是否吃鸡,按游戏最终显示评分数值进行排序,评分相同用时短者优胜,前三名分别获得金银铜奖牌,其它人算做失败', style: TextStyle(color: Colors.white))
  155. ],
  156. ),
  157. );
  158. } else if (index == 2) {
  159. useContent = Container(
  160. margin: EdgeInsets.only(top: 20),
  161. padding: EdgeInsets.symmetric(horizontal: 20),
  162. child: Column(
  163. children: <Widget>[
  164. Image.asset('images/img_xuzhi_02.png', width: 136),
  165. Container(
  166. height: 10,
  167. ),
  168. Text.rich(
  169. TextSpan(children: [
  170. TextSpan(
  171. text: '竞赛开始前请在此耐心等待,在开始时会有上图所示弹窗,',
  172. style: _text,
  173. ),
  174. TextSpan(
  175. text: '玩家必须在10秒内点击确认',
  176. style: TextStyle(color: Color(0xFFFFB726), fontSize: 14, fontWeight: FontWeight.w500),
  177. ),
  178. TextSpan(
  179. text: ',否则视为放弃此次竞赛,已支付参赛券概不退换',
  180. style: _text,
  181. )
  182. ]),
  183. textAlign: TextAlign.center)
  184. ],
  185. ),
  186. );
  187. } else if (index == 3) {
  188. useContent = Container(
  189. margin: EdgeInsets.only(top: 20),
  190. padding: EdgeInsets.symmetric(horizontal: 20),
  191. child: Column(
  192. children: <Widget>[
  193. Image.asset('images/img_xuzhi_03.png', width: 176),
  194. Container(
  195. height: 10,
  196. ),
  197. Text.rich(
  198. TextSpan(children: [
  199. TextSpan(
  200. text: '确认竞赛后会有弹窗提示授权进行录屏的操作,请一定',
  201. style: _text,
  202. ),
  203. TextSpan(
  204. text: '点击“确定”',
  205. style: TextStyle(color: Color(0xFFFFB726), fontSize: 14, fontWeight: FontWeight.w500),
  206. ),
  207. TextSpan(
  208. text: '或',
  209. style: _text,
  210. ),
  211. TextSpan(
  212. text: '“允许”',
  213. style: TextStyle(color: Color(0xFFFFB726), fontSize: 14, fontWeight: FontWeight.w500),
  214. ),
  215. TextSpan(
  216. text: '此操作,否则竞赛判定失败',
  217. style: _text,
  218. )
  219. ]),
  220. textAlign: TextAlign.center)
  221. ],
  222. ),
  223. );
  224. } else if (index == 4) {
  225. useContent = Container(
  226. margin: EdgeInsets.only(top: 20),
  227. padding: EdgeInsets.symmetric(horizontal: 20),
  228. child: Column(
  229. children: <Widget>[
  230. Image.asset('images/img_xuzhi_04.png', width: 216),
  231. Container(
  232. height: 10,
  233. ),
  234. Text.rich(
  235. TextSpan(children: [
  236. TextSpan(
  237. text: '在游戏比赛结束后,',
  238. style: _text,
  239. ),
  240. TextSpan(
  241. text: '请一定要点击查看游戏最后的分数名次结算页面',
  242. style: TextStyle(color:Color(0xFFFFB726), fontSize: 14, fontWeight: FontWeight.w600),
  243. ),
  244. TextSpan(
  245. text: ',返回游戏主页,最后再切换到我们竞赛app中,点击完成比赛,方可成功长传本次成绩,赢取大奖',
  246. style: _text,
  247. )
  248. ]),
  249. textAlign: TextAlign.center)
  250. ],
  251. ),
  252. );
  253. }
  254. return useContent;
  255. }
  256. }