CompetitionInformation.dart 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_swiper/flutter_swiper.dart';
  3. import 'package:flutter_redux/flutter_redux.dart';
  4. import '../redux/AppState.dart';
  5. import '../net/Result.dart';
  6. import '../net/HttpManager.dart';
  7. import '../redux/UserRedux.dart';
  8. import '../model/UserInfo.dart';
  9. //竞赛须知
  10. class CompetitionInformation extends StatefulWidget {
  11. @override
  12. CompetitionInformationState createState() => CompetitionInformationState();
  13. }
  14. class CompetitionInformationState extends State<CompetitionInformation> {
  15. int nowSwiperIndex = 0;
  16. SwiperController _swiperController;
  17. @override
  18. void initState() {
  19. super.initState();
  20. _swiperController = SwiperController();
  21. }
  22. @override
  23. Widget build(BuildContext context) {
  24. return WillPopScope(
  25. child: Scaffold(
  26. backgroundColor: Colors.black87,
  27. body: Container(
  28. child: Center(
  29. child: Swiper(
  30. controller: _swiperController,
  31. layout: SwiperLayout.DEFAULT,
  32. itemWidth: 270.0,
  33. itemHeight: 422.0,
  34. control: SwiperControl(
  35. color: Color(0xFFC2524D),
  36. disableColor: Colors.transparent),
  37. index: nowSwiperIndex,
  38. itemCount: 4,
  39. scrollDirection: Axis.horizontal,
  40. loop: false,
  41. itemBuilder: (context, index) {
  42. return InfoBox(
  43. typeIndex: index + 1,
  44. next: () {
  45. _swiperController.next();
  46. },
  47. end: () {
  48. Navigator.of(context).pop();
  49. });
  50. }))),
  51. ),
  52. onWillPop: () {
  53. return Future.value(false);
  54. },
  55. );
  56. }
  57. }
  58. typedef int OnTapHomeMenu();
  59. class InfoBox extends StatelessWidget {
  60. InfoBox({Key key, this.typeIndex, this.next, this.end}) : super(key: key);
  61. final int typeIndex;
  62. final OnTapHomeMenu next;
  63. final OnTapHomeMenu end;
  64. @override
  65. Widget build(BuildContext context) {
  66. return UnconstrainedBox(
  67. child: Container(
  68. width: 270,
  69. height: 422,
  70. decoration: BoxDecoration(
  71. border: Border.all(width: 1, color: Color(0xFFC2524D)),
  72. color: Colors.black),
  73. child: Stack(
  74. children: <Widget>[
  75. Container(
  76. width: 270,
  77. padding: EdgeInsets.only(top: 25),
  78. child: Column(
  79. children: <Widget>[
  80. Text('竞赛须知 ' + typeIndex.toString() + '/4',
  81. style: TextStyle(
  82. color: Color(0xFFFDC372),
  83. fontSize: 20,
  84. fontWeight: FontWeight.w600)),
  85. _centerContent(typeIndex)
  86. ],
  87. ),
  88. ),
  89. Positioned(
  90. top: 0,
  91. left: 0,
  92. child: Image.asset(
  93. 'images/tancuang_shang.png',
  94. width: 131,
  95. ),
  96. ),
  97. Positioned(
  98. bottom: 0,
  99. right: 4,
  100. child: Image.asset(
  101. 'images/tancuang_xia.png',
  102. width: 148,
  103. ),
  104. ),
  105. Positioned(
  106. bottom: 15,
  107. left: 25,
  108. child: Column(
  109. children: <Widget>[
  110. Container(
  111. width: 220,
  112. height: 36,
  113. child: RaisedButton(
  114. textColor: Colors.white,
  115. child: Text(typeIndex != 4 ? '下一个' : '结束'),
  116. onPressed: typeIndex != 4 ? next : end,
  117. ),
  118. ),
  119. FlatButton(
  120. textColor: Color(0xFF727785),
  121. highlightColor: Colors.transparent,
  122. splashColor: Colors.transparent,
  123. child: Text('不再提醒'),
  124. onPressed: () async {
  125. Result res =
  126. await HttpManager.post('userInfo/update', data: {
  127. "id":
  128. StoreProvider.of<AppState>(context).state.userInfo.id,
  129. 'remindFlag': 'N'
  130. });
  131. if (res.success) {
  132. Result res2 =
  133. await HttpManager.get("userInfo/getUserInfo");
  134. if (res2.success) {
  135. StoreProvider.of<AppState>(context).dispatch(
  136. UpdateUserAction(UserInfo.fromJson(res2.data)));
  137. }
  138. }
  139. Navigator.of(context).pop();
  140. },
  141. )
  142. ],
  143. ),
  144. )
  145. ],
  146. ),
  147. ));
  148. }
  149. Widget _centerContent(int index) {
  150. Widget useContent = Container();
  151. TextStyle _text = TextStyle(color: Colors.white, fontSize: 14);
  152. if (index == 1) {
  153. useContent = Container(
  154. margin: EdgeInsets.only(top: 42),
  155. child: Column(
  156. children: <Widget>[
  157. Image.asset('images/icon_jinbi_da_hong.png', width: 30),
  158. Container(
  159. height: 20,
  160. ),
  161. Text(
  162. '房间人数越多,总奖金就越多',
  163. style: _text,
  164. ),
  165. Text('第一名获得50%', style: _text),
  166. Text('第二名获得30%', style: _text),
  167. Text('第三名获得20%', style: _text),
  168. Text('其他名次没有奖励', style: _text)
  169. ],
  170. ),
  171. );
  172. } else if (index == 2) {
  173. useContent = Container(
  174. margin: EdgeInsets.only(top: 20),
  175. padding: EdgeInsets.symmetric(horizontal: 20),
  176. child: Column(
  177. children: <Widget>[
  178. Image.asset('images/img_xuzhi_02.png', width: 136),
  179. Container(
  180. height: 10,
  181. ),
  182. Text.rich(
  183. TextSpan(children: [
  184. TextSpan(
  185. text: '竞赛开始前请在此耐心等待,在开始时会有上图所示弹窗,玩家必须在10秒内',
  186. style: _text,
  187. ),
  188. TextSpan(
  189. text: '点击确认',
  190. style: TextStyle(
  191. color: Color(0xFFC2524D),
  192. fontSize: 14,
  193. fontWeight: FontWeight.w500),
  194. ),
  195. TextSpan(
  196. text: ',否则视为放弃此次竞赛,已支付金币概不退换',
  197. style: _text,
  198. )
  199. ]),
  200. textAlign: TextAlign.center)
  201. ],
  202. ),
  203. );
  204. } else if (index == 3) {
  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(
  223. color: Color(0xFFC2524D),
  224. fontSize: 14,
  225. fontWeight: FontWeight.w500),
  226. ),
  227. TextSpan(
  228. text: '或“允许”此操作,否则竞赛判定失败',
  229. style: _text,
  230. )
  231. ]),
  232. textAlign: TextAlign.center)
  233. ],
  234. ),
  235. );
  236. } else if (index == 4) {
  237. useContent = Container(
  238. margin: EdgeInsets.only(top: 20),
  239. padding: EdgeInsets.symmetric(horizontal: 20),
  240. child: Column(
  241. children: <Widget>[
  242. Image.asset('images/img_xuzhi_04.png', width: 216),
  243. Container(
  244. height: 10,
  245. ),
  246. Text.rich(
  247. TextSpan(children: [
  248. TextSpan(
  249. text: '在游戏中吃鸡后,',
  250. style: _text,
  251. ),
  252. TextSpan(
  253. text: '请一定一定一定要点击“继续”按钮',
  254. style: TextStyle(
  255. color: Color(0xFFC2524D),
  256. fontSize: 14,
  257. fontWeight: FontWeight.w600),
  258. ),
  259. TextSpan(
  260. text: ',显示到上图所示画面,然后再切换到我们全民APP中,点击完成比赛,方可成功上传本次成绩,赢取大奖',
  261. style: _text,
  262. )
  263. ]),
  264. textAlign: TextAlign.center)
  265. ],
  266. ),
  267. );
  268. }
  269. return useContent;
  270. }
  271. }