CompetitionNotice.dart 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter/cupertino.dart';
  3. import '../styles/colors.dart';
  4. import 'dart:math';
  5. void showNotice(BuildContext context) {
  6. Navigator.of(context).push(
  7. PageRouteBuilder(
  8. opaque: false,
  9. transitionDuration: Duration(milliseconds: 300),
  10. transitionsBuilder: (BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation, Widget child) {
  11. return FadeTransition(
  12. opacity: CurvedAnimation(parent: animation, curve: Curves.linear),
  13. child: child,
  14. );
  15. },
  16. pageBuilder: (BuildContext context, _, __) {
  17. return CompetitionNotice();
  18. },
  19. ),
  20. );
  21. }
  22. class CompetitionNotice extends StatefulWidget {
  23. @override
  24. State<StatefulWidget> createState() {
  25. return CompetitionNoticeState();
  26. }
  27. }
  28. class CompetitionNoticeState extends State<CompetitionNotice> {
  29. final pageController = PageController(initialPage: 0);
  30. bool showPrev = false;
  31. bool showNext = true;
  32. @override
  33. Widget build(BuildContext context) {
  34. final iconSize = (MediaQuery.of(context).size.width - 286) / 2;
  35. return WillPopScope(
  36. onWillPop: () {
  37. return Future.value(true);
  38. },
  39. child: Scaffold(
  40. backgroundColor: Color(0xb3000000),
  41. body: Stack(
  42. children: <Widget>[
  43. PageView(
  44. controller: pageController,
  45. onPageChanged: (page) {
  46. print(page);
  47. if (page == 0) {
  48. setState(() {
  49. showPrev = false;
  50. showNext = true;
  51. });
  52. } else if (page == 3) {
  53. setState(() {
  54. showPrev = true;
  55. showNext = false;
  56. });
  57. } else {
  58. setState(() {
  59. showPrev = true;
  60. showNext = true;
  61. });
  62. }
  63. },
  64. children: <Widget>[
  65. _page(
  66. context,
  67. title: '竞赛须知 1/4',
  68. onNext: () {
  69. pageController.nextPage(duration: Duration(milliseconds: 500), curve: Curves.linearToEaseOut);
  70. },
  71. body: Container(
  72. margin: EdgeInsets.only(top: 65),
  73. child: Column(
  74. children: <Widget>[
  75. Image.asset('images/icon_jifen_da.png'),
  76. Container(
  77. width: 230,
  78. margin: EdgeInsets.only(top: 10),
  79. child: Text.rich(
  80. TextSpan(text: '每局比赛按照吃鸡单人游戏的', children: [
  81. TextSpan(text: '评分', style: TextStyle(color: Colors.yellow)),
  82. TextSpan(text: '进行排序,评分相同游戏时长短的优胜'),
  83. ]),
  84. textAlign: TextAlign.center,
  85. style: TextStyle(
  86. color: Colors.white,
  87. fontSize: 13,
  88. ),
  89. ),
  90. ),
  91. Container(
  92. margin: EdgeInsets.only(top: 10),
  93. child: Row(
  94. mainAxisAlignment: MainAxisAlignment.center,
  95. crossAxisAlignment: CrossAxisAlignment.start,
  96. children: <Widget>[
  97. Text(
  98. '注:',
  99. style: TextStyle(color: Color(0x66FFFFFF), fontSize: 12),
  100. ),
  101. Text(
  102. '第一名获得40积分\n剩余10%获得20积分\n剩余20%获得10积分\n剩余30%获得0积分\n剩余40%获得-10积分\n吃鸡选手额外获得10积分',
  103. style: TextStyle(color: Color(0x66FFFFFF), fontSize: 12),
  104. ),
  105. ],
  106. ),
  107. )
  108. ],
  109. ),
  110. ),
  111. ),
  112. _page(
  113. context,
  114. title: '竞赛须知 2/4',
  115. onNext: () {
  116. pageController.nextPage(duration: Duration(milliseconds: 500), curve: Curves.linearToEaseOut);
  117. },
  118. body:Container(
  119. margin: EdgeInsets.only(top: 75),
  120. child: Column(
  121. children: <Widget>[
  122. Image.asset('images/img_xuzhi_02.png'),
  123. Container(
  124. width: 230,
  125. margin: EdgeInsets.only(top: 10),
  126. child: Text.rich(
  127. TextSpan(text: '竞赛开始前请在此耐心等待,在开始时会有上图所示弹窗,', children: [
  128. TextSpan(text: '玩家必须在10秒内点击确认', style: TextStyle(color: Colors.yellow)),
  129. TextSpan(text: ',否则视为放弃此次竞赛'),
  130. ]),
  131. textAlign: TextAlign.center,
  132. style: TextStyle(
  133. color: Colors.white,
  134. fontSize: 13,
  135. ),
  136. ),
  137. ),
  138. ],
  139. ),
  140. ),
  141. ),
  142. _page(
  143. context,
  144. title: '竞赛须知 3/4',
  145. onNext: () {
  146. pageController.nextPage(duration: Duration(milliseconds: 500), curve: Curves.linearToEaseOut);
  147. },
  148. body:Container(
  149. margin: EdgeInsets.only(top: 75),
  150. child: Column(
  151. children: <Widget>[
  152. Image.asset('images/img_xuzhi_03.png'),
  153. Container(
  154. width: 230,
  155. margin: EdgeInsets.only(top: 10),
  156. child: Text.rich(
  157. TextSpan(text: '确认竞赛后会有弹窗提示授权进行录屏的操作,请一定', children: [
  158. TextSpan(text: '点击“确定”', style: TextStyle(color: Colors.yellow)),
  159. TextSpan(text: '或“允许”此操作,否则竞赛判定失败'),
  160. ]),
  161. textAlign: TextAlign.center,
  162. style: TextStyle(
  163. color: Colors.white,
  164. fontSize: 13,
  165. ),
  166. ),
  167. ),
  168. ],
  169. ),
  170. ),
  171. ),
  172. _page(
  173. context,
  174. title: '竞赛须知 4/4',
  175. nextText: '关闭',
  176. onNext: () {
  177. Navigator.of(context).pop();
  178. },
  179. showCancel: false,
  180. body: Container(
  181. margin: EdgeInsets.only(top: 75),
  182. child: Column(
  183. children: <Widget>[
  184. Image.asset('images/img_xuzhi_04.png'),
  185. Container(
  186. width: 230,
  187. margin: EdgeInsets.only(top: 10),
  188. child: Text.rich(
  189. TextSpan(text: '在游戏比赛结束后,', children: [
  190. TextSpan(text: '请一定要点击查看游戏最后的分数名次结算页面', style: TextStyle(color: Colors.yellow)),
  191. TextSpan(text: ',返回游戏主页,最后再切换到我们竞赛app中,点击完成比赛,方可成功长传本次成绩,赢取积分'),
  192. ]),
  193. textAlign: TextAlign.center,
  194. style: TextStyle(
  195. color: Colors.white,
  196. fontSize: 13,
  197. ),
  198. ),
  199. ),
  200. ],
  201. ),
  202. ),
  203. ),
  204. ],
  205. ),
  206. Align(
  207. alignment: Alignment.centerLeft,
  208. child: Container(
  209. margin: EdgeInsets.only(left: 4),
  210. child: showPrev
  211. ? GestureDetector(
  212. onTap: () {
  213. pageController.previousPage(duration: Duration(milliseconds: 500), curve: Curves.linearToEaseOut);
  214. },
  215. child: Transform.rotate(
  216. angle: pi,
  217. child: Image.asset('images/icon_xiayiye.png', width: iconSize),
  218. ),
  219. )
  220. : null,
  221. ),
  222. ),
  223. Align(
  224. alignment: Alignment.centerRight,
  225. child: showNext
  226. ? Container(
  227. margin: EdgeInsets.only(left: 4),
  228. child: GestureDetector(
  229. onTap: () {
  230. pageController.nextPage(duration: Duration(milliseconds: 500), curve: Curves.linearToEaseOut);
  231. },
  232. child: Image.asset('images/icon_xiayiye.png', width: iconSize),
  233. ),
  234. )
  235. : null,
  236. ),
  237. ],
  238. ),
  239. ),
  240. );
  241. }
  242. }
  243. Widget _page(
  244. BuildContext context, {
  245. @required String title,
  246. @required Widget body,
  247. void Function() onNext,
  248. String nextText = '下一个',
  249. bool showCancel = true,
  250. }) {
  251. return Stack(
  252. children: <Widget>[
  253. Center(
  254. child: Container(
  255. width: 270,
  256. height: 422,
  257. decoration: BoxDecoration(
  258. color: Color(0xE6293559),
  259. border: Border.all(
  260. width: 1,
  261. color: PRIMARY_COLOR,
  262. )),
  263. child: Stack(
  264. children: <Widget>[
  265. Align(
  266. alignment: Alignment.topRight,
  267. child: Container(
  268. margin: EdgeInsets.only(top: 7),
  269. child: Image.asset('images/icon_tanchuang_01.png'),
  270. ),
  271. ),
  272. Align(
  273. alignment: Alignment.bottomLeft,
  274. child: Container(
  275. margin: EdgeInsets.only(bottom: 7),
  276. child: Image.asset('images/icon_tanchuang_02.png'),
  277. ),
  278. ),
  279. Align(
  280. alignment: Alignment.topCenter,
  281. child: Container(
  282. margin: EdgeInsets.only(top: 27),
  283. child: Text(
  284. title,
  285. style: TextStyle(
  286. fontSize: 20,
  287. fontWeight: FontWeight.bold,
  288. color: Colors.white,
  289. ),
  290. ),
  291. ),
  292. ),
  293. Align(
  294. alignment: Alignment.topCenter,
  295. child: body,
  296. ),
  297. Align(
  298. alignment: Alignment.bottomCenter,
  299. child: Container(
  300. margin: EdgeInsets.only(bottom: 62),
  301. child: MaterialButton(
  302. elevation: 0,
  303. highlightElevation: 0,
  304. minWidth: 200,
  305. color: PRIMARY_COLOR,
  306. child: Text(
  307. nextText,
  308. style: TextStyle(
  309. fontSize: 14,
  310. fontWeight: FontWeight.bold,
  311. color: Colors.white,
  312. ),
  313. ),
  314. onPressed: () {
  315. if (onNext != null) {
  316. onNext();
  317. }
  318. },
  319. ),
  320. ),
  321. ),
  322. Align(
  323. alignment: Alignment.bottomCenter,
  324. child: Container(
  325. margin: EdgeInsets.only(bottom: 25),
  326. child: showCancel
  327. ? CupertinoButton(
  328. padding: EdgeInsets.fromLTRB(10, 7, 10, 7),
  329. child: Text(
  330. '取消',
  331. style: TextStyle(
  332. color: Color(0xB0FFFFFF),
  333. fontSize: 13,
  334. ),
  335. ),
  336. onPressed: () {
  337. Navigator.of(context).pop();
  338. },
  339. )
  340. : null,
  341. ),
  342. )
  343. ],
  344. ),
  345. ),
  346. ),
  347. ],
  348. );
  349. }