CompetitionNotice.dart 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362
  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. Container(
  76. margin: EdgeInsets.only(top: 35),
  77. child: Image.asset(
  78. 'images/icon_jifen_da.png',
  79. width: 96,
  80. ),
  81. ),
  82. Container(
  83. width: 230,
  84. margin: EdgeInsets.only(top: 10),
  85. child: Text.rich(
  86. TextSpan(text: '每局比赛按照', children: [
  87. TextSpan(text: '《和平精英》-单人模式', style: TextStyle(color: Colors.yellow)),
  88. TextSpan(text: '中的'),
  89. TextSpan(text: '比赛评分', style: TextStyle(color: Colors.yellow)),
  90. TextSpan(text: '进行排序,评分相同,存活时间长者优胜'),
  91. ]),
  92. textAlign: TextAlign.center,
  93. style: TextStyle(
  94. color: Colors.white,
  95. fontSize: 13,
  96. ),
  97. ),
  98. ),
  99. // Container(
  100. // margin: EdgeInsets.only(top: 10),
  101. // child: Row(
  102. // mainAxisAlignment: MainAxisAlignment.center,
  103. // crossAxisAlignment: CrossAxisAlignment.start,
  104. // children: <Widget>[
  105. // Text(
  106. // '注:',
  107. // style: TextStyle(color: Color(0x66FFFFFF), fontSize: 12),
  108. // ),
  109. // Text(
  110. // '第一名获得40积分\n剩余10%获得20积分\n剩余20%获得10积分\n剩余30%获得0积分\n剩余40%获得-10积分\n吃鸡选手额外获得10积分',
  111. // style: TextStyle(color: Color(0x66FFFFFF), fontSize: 12),
  112. // ),
  113. // ],
  114. // ),
  115. // )
  116. ],
  117. ),
  118. ),
  119. ),
  120. _page(
  121. context,
  122. title: '竞赛须知 2/4',
  123. onNext: () {
  124. pageController.nextPage(duration: Duration(milliseconds: 500), curve: Curves.linearToEaseOut);
  125. },
  126. body: Container(
  127. margin: EdgeInsets.only(top: 75),
  128. child: Column(
  129. children: <Widget>[
  130. Image.asset('images/img_xuzhi_02.png'),
  131. Container(
  132. width: 230,
  133. margin: EdgeInsets.only(top: 10),
  134. child: Text.rich(
  135. TextSpan(text: '竞赛开始前请在此耐心等待,在开始时会有上图所示弹窗,', children: [
  136. TextSpan(text: '玩家必须在10秒内点击确认', style: TextStyle(color: Colors.yellow)),
  137. TextSpan(text: ',否则视为放弃此次竞赛'),
  138. ]),
  139. textAlign: TextAlign.center,
  140. style: TextStyle(
  141. color: Colors.white,
  142. fontSize: 13,
  143. ),
  144. ),
  145. ),
  146. ],
  147. ),
  148. ),
  149. ),
  150. _page(
  151. context,
  152. title: '竞赛须知 3/4',
  153. onNext: () {
  154. pageController.nextPage(duration: Duration(milliseconds: 500), curve: Curves.linearToEaseOut);
  155. },
  156. body: Container(
  157. margin: EdgeInsets.only(top: 75),
  158. child: Column(
  159. children: <Widget>[
  160. Image.asset('images/img_xuzhi_03.png'),
  161. Container(
  162. width: 230,
  163. margin: EdgeInsets.only(top: 10),
  164. child: Text.rich(
  165. TextSpan(text: '确认竞赛后会有弹窗提示授权进行录屏的操作,请一定', children: [
  166. TextSpan(text: '点击“确定”', style: TextStyle(color: Colors.yellow)),
  167. TextSpan(text: '或“允许”此操作,否则竞赛判定失败'),
  168. ]),
  169. textAlign: TextAlign.center,
  170. style: TextStyle(
  171. color: Colors.white,
  172. fontSize: 13,
  173. ),
  174. ),
  175. ),
  176. ],
  177. ),
  178. ),
  179. ),
  180. _page(
  181. context,
  182. title: '竞赛须知 4/4',
  183. nextText: '关闭',
  184. onNext: () {
  185. Navigator.of(context).pop();
  186. },
  187. showCancel: false,
  188. body: Container(
  189. margin: EdgeInsets.only(top: 75),
  190. child: Column(
  191. children: <Widget>[
  192. Image.asset('images/img_xuzhi_04.png'),
  193. Container(
  194. width: 230,
  195. margin: EdgeInsets.only(top: 10),
  196. child: Text.rich(
  197. TextSpan(text: '在游戏比赛结束后,', children: [
  198. TextSpan(text: '请一定要点击查看游戏最后的分数名次结算页面', style: TextStyle(color: Colors.yellow)),
  199. TextSpan(text: ',返回游戏主页,最后再切换到我们竞赛app中,点击完成比赛,方可成功上传本次成绩,赢取积分'),
  200. ]),
  201. textAlign: TextAlign.center,
  202. style: TextStyle(
  203. color: Colors.white,
  204. fontSize: 13,
  205. ),
  206. ),
  207. ),
  208. ],
  209. ),
  210. ),
  211. ),
  212. ],
  213. ),
  214. Align(
  215. alignment: Alignment.centerLeft,
  216. child: Container(
  217. margin: EdgeInsets.only(left: 4),
  218. child: showPrev
  219. ? GestureDetector(
  220. onTap: () {
  221. pageController.previousPage(duration: Duration(milliseconds: 500), curve: Curves.linearToEaseOut);
  222. },
  223. child: Transform.rotate(
  224. angle: pi,
  225. child: Image.asset('images/icon_xiayiye.png', width: iconSize),
  226. ),
  227. )
  228. : null,
  229. ),
  230. ),
  231. Align(
  232. alignment: Alignment.centerRight,
  233. child: showNext
  234. ? Container(
  235. margin: EdgeInsets.only(left: 4),
  236. child: GestureDetector(
  237. onTap: () {
  238. pageController.nextPage(duration: Duration(milliseconds: 500), curve: Curves.linearToEaseOut);
  239. },
  240. child: Image.asset('images/icon_xiayiye.png', width: iconSize),
  241. ),
  242. )
  243. : null,
  244. ),
  245. ],
  246. ),
  247. ),
  248. );
  249. }
  250. }
  251. Widget _page(
  252. BuildContext context, {
  253. @required String title,
  254. @required Widget body,
  255. void Function() onNext,
  256. String nextText = '下一个',
  257. bool showCancel = true,
  258. }) {
  259. return Stack(
  260. children: <Widget>[
  261. Center(
  262. child: Container(
  263. width: 270,
  264. height: 422,
  265. decoration: BoxDecoration(
  266. color: Color(0xE6293559),
  267. border: Border.all(
  268. width: 1,
  269. color: PRIMARY_COLOR,
  270. )),
  271. child: Stack(
  272. children: <Widget>[
  273. Align(
  274. alignment: Alignment.topRight,
  275. child: Container(
  276. margin: EdgeInsets.only(top: 7),
  277. child: Image.asset('images/icon_tanchuang_01.png'),
  278. ),
  279. ),
  280. Align(
  281. alignment: Alignment.bottomLeft,
  282. child: Container(
  283. margin: EdgeInsets.only(bottom: 7),
  284. child: Image.asset('images/icon_tanchuang_02.png'),
  285. ),
  286. ),
  287. Align(
  288. alignment: Alignment.topCenter,
  289. child: Container(
  290. margin: EdgeInsets.only(top: 27),
  291. child: Text(
  292. title,
  293. style: TextStyle(
  294. fontSize: 20,
  295. fontWeight: FontWeight.bold,
  296. color: Colors.white,
  297. ),
  298. ),
  299. ),
  300. ),
  301. Align(
  302. alignment: Alignment.topCenter,
  303. child: body,
  304. ),
  305. Align(
  306. alignment: Alignment.bottomCenter,
  307. child: Container(
  308. margin: EdgeInsets.only(bottom: 62),
  309. child: MaterialButton(
  310. elevation: 0,
  311. highlightElevation: 0,
  312. minWidth: 200,
  313. color: PRIMARY_COLOR,
  314. child: Text(
  315. nextText,
  316. style: TextStyle(
  317. fontSize: 14,
  318. fontWeight: FontWeight.bold,
  319. color: Colors.white,
  320. ),
  321. ),
  322. onPressed: () {
  323. if (onNext != null) {
  324. onNext();
  325. }
  326. },
  327. ),
  328. ),
  329. ),
  330. Align(
  331. alignment: Alignment.bottomCenter,
  332. child: Container(
  333. margin: EdgeInsets.only(bottom: 25),
  334. child: showCancel
  335. ? CupertinoButton(
  336. padding: EdgeInsets.fromLTRB(10, 7, 10, 7),
  337. child: Text(
  338. '取消',
  339. style: TextStyle(
  340. color: Color(0xB0FFFFFF),
  341. fontSize: 13,
  342. ),
  343. ),
  344. onPressed: () {
  345. Navigator.of(context).pop();
  346. },
  347. )
  348. : null,
  349. ),
  350. )
  351. ],
  352. ),
  353. ),
  354. ),
  355. ],
  356. );
  357. }