UserGuid.dart 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter/cupertino.dart';
  3. import '../styles/colors.dart';
  4. import 'dart:math';
  5. Future showUserGuide(BuildContext context) {
  6. return 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 UserGuide();
  18. },
  19. ),
  20. );
  21. }
  22. class UserGuide extends StatefulWidget {
  23. @override
  24. State<StatefulWidget> createState() {
  25. return UserGuideState();
  26. }
  27. }
  28. class UserGuideState extends State<UserGuide> {
  29. final pageController = PageController(initialPage: 0);
  30. @override
  31. Widget build(BuildContext context) {
  32. return WillPopScope(
  33. onWillPop: () {
  34. return Future.value(true);
  35. },
  36. child: Scaffold(
  37. backgroundColor: Color(0xb3000000),
  38. body: Stack(
  39. children: <Widget>[
  40. PageView(
  41. controller: pageController,
  42. children: <Widget>[
  43. // _page(context, children: [
  44. // Align(
  45. // alignment: Alignment.topLeft,
  46. // child: Container(
  47. // margin: EdgeInsets.only(top: 23, left: 40),
  48. // child: Image.asset('images/zhezhao_01.png'),
  49. // ),
  50. // ),
  51. // Align(
  52. // alignment: Alignment.topCenter,
  53. // child: Container(
  54. // margin: EdgeInsets.only(top: 177),
  55. // child: Text(
  56. // '01、此处是您拥有金币的数量',
  57. // style: TextStyle(color: Colors.white, fontSize: 15),
  58. // ),
  59. // ),
  60. // )
  61. // ]),
  62. _page(context, children: [
  63. Align(
  64. alignment: Alignment.topLeft,
  65. child: Container(
  66. margin: EdgeInsets.only(top: 128),
  67. child: Image.asset('images/zhezhao_02.png'),
  68. ),
  69. ),
  70. Align(
  71. alignment: Alignment.topLeft,
  72. child: Container(
  73. margin: EdgeInsets.only(top: 159, left: 106),
  74. child: Text(
  75. '01、带此标示的为VIP赛事\n 相对于普通赛事奖励更为丰厚',
  76. style: TextStyle(color: Colors.white, fontSize: 15),
  77. ),
  78. ),
  79. )
  80. ]),
  81. _page(context, children: [
  82. Align(
  83. alignment: Alignment.topRight,
  84. child: Container(
  85. margin: EdgeInsets.only(top: 126),
  86. child: Image.asset('images/zhezhao_03.png'),
  87. ),
  88. ),
  89. Align(
  90. alignment: Alignment.topLeft,
  91. child: Container(
  92. margin: EdgeInsets.only(top: 175, left: 30),
  93. child: Text(
  94. '02、这是您在此赛事中的排名情况',
  95. style: TextStyle(color: Colors.white, fontSize: 15),
  96. ),
  97. ),
  98. )
  99. ]),
  100. _page(context, isLast: true, children: [
  101. Align(
  102. alignment: Alignment.topCenter,
  103. child: Container(
  104. margin: EdgeInsets.only(top: (MediaQuery.of(context).size.width - 30) * 150 / 345 + 133),
  105. child: Image.asset('images/zhezhao_04.png'),
  106. ),
  107. ),
  108. Align(
  109. alignment: Alignment.topCenter,
  110. child: Container(
  111. margin: EdgeInsets.only(
  112. top: (MediaQuery.of(context).size.width - 30) * 150 / 345 + 285,
  113. ),
  114. child: Text(
  115. '03、点击进入,开始您的比赛吧',
  116. style: TextStyle(color: Colors.white, fontSize: 15),
  117. ),
  118. ),
  119. )
  120. ]),
  121. ],
  122. ),
  123. ],
  124. ),
  125. ),
  126. );
  127. }
  128. Widget _page(BuildContext context, {@required List<Widget> children, bool isLast = false}) {
  129. List<Widget> list = [
  130. Align(
  131. alignment: Alignment.bottomCenter,
  132. child: Container(
  133. margin: EdgeInsets.only(bottom: 92),
  134. child: SizedBox(
  135. width: 220,
  136. height: 36,
  137. child: OutlineButton(
  138. borderSide: BorderSide(color: PRIMARY_COLOR),
  139. highlightColor: Colors.transparent,
  140. color: PRIMARY_COLOR,
  141. onPressed: () {
  142. if (isLast) {
  143. Navigator.of(context).pop();
  144. return;
  145. }
  146. pageController.nextPage(duration: Duration(milliseconds: 300), curve: Curves.linearToEaseOut);
  147. },
  148. child: Text(
  149. isLast ? '知道了' : '下一步',
  150. style: TextStyle(color: PRIMARY_COLOR, fontSize: 14),
  151. ),
  152. ),
  153. ),
  154. ),
  155. ),
  156. Align(
  157. alignment: Alignment.bottomCenter,
  158. child: Container(
  159. margin: EdgeInsets.only(bottom: 50),
  160. child: CupertinoButton(
  161. padding: EdgeInsets.all(0),
  162. child: Text(
  163. '关闭',
  164. style: TextStyle(color: Color(0xFF4F5C87), fontSize: 14),
  165. ),
  166. onPressed: () {
  167. Navigator.of(context).pop();
  168. }),
  169. ),
  170. )
  171. ];
  172. for (Widget widget in children) {
  173. list.add(widget);
  174. }
  175. return Stack(
  176. children: list,
  177. );
  178. }
  179. }
  180. Future showUserGuide1(BuildContext context) {
  181. return Navigator.of(context).push(
  182. PageRouteBuilder(
  183. opaque: false,
  184. transitionDuration: Duration(milliseconds: 300),
  185. transitionsBuilder: (BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation, Widget child) {
  186. return FadeTransition(
  187. opacity: CurvedAnimation(parent: animation, curve: Curves.linear),
  188. child: child,
  189. );
  190. },
  191. pageBuilder: (BuildContext context, _, __) {
  192. return Material(
  193. color: Colors.black87,
  194. child: GestureDetector(
  195. child: Container(
  196. child: Stack(
  197. children: <Widget>[
  198. Container(
  199. margin: EdgeInsets.only(top: (MediaQuery.of(context).size.width - 30) * 186 / 345 + 133, right: 0),
  200. child: Align(
  201. alignment: Alignment.topRight,
  202. child: Image.asset('images/zhezhao_01.png'),
  203. ),
  204. ),
  205. Align(
  206. alignment: Alignment.topCenter,
  207. child: Container(
  208. width: 200,
  209. margin: EdgeInsets.only(top: (MediaQuery.of(context).size.width - 30) * 186 / 345 + 90),
  210. child: Text(
  211. '成为VIP后可以参与专属赛事赢得精美大奖',
  212. style: TextStyle(color: Colors.white, fontSize: 16, fontWeight: FontWeight.bold),
  213. ),
  214. ),
  215. )
  216. ],
  217. ),
  218. ),
  219. onTap: () {
  220. Navigator.of(context).pop();
  221. },
  222. ),
  223. );
  224. },
  225. ),
  226. );
  227. }
  228. Future showUserGuide2(BuildContext context) {
  229. return Navigator.of(context).push(
  230. PageRouteBuilder(
  231. opaque: false,
  232. transitionDuration: Duration(milliseconds: 300),
  233. transitionsBuilder: (BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation, Widget child) {
  234. return FadeTransition(
  235. opacity: CurvedAnimation(parent: animation, curve: Curves.linear),
  236. child: child,
  237. );
  238. },
  239. pageBuilder: (BuildContext context, _, __) {
  240. return Material(
  241. color: Colors.black87,
  242. child: GestureDetector(
  243. child: Container(
  244. child: Stack(
  245. children: <Widget>[
  246. Positioned(
  247. top: (MediaQuery.of(context).size.width - 30) * 186 / 345 + 0,
  248. right: 6,
  249. left: 6,
  250. child: Container(
  251. child: Image.asset(
  252. 'images/zhezhao_02.png',
  253. fit: BoxFit.fitWidth,
  254. ),
  255. ),
  256. ),
  257. Align(
  258. alignment: Alignment.topCenter,
  259. child: Container(
  260. width: 200,
  261. margin: EdgeInsets.only(top: (MediaQuery.of(context).size.width - 30) * 186 / 345, right: 60),
  262. child: Text(
  263. '选择一个等待中的房间进入即可参与本次比赛',
  264. style: TextStyle(color: Colors.white, fontSize: 16, fontWeight: FontWeight.bold),
  265. ),
  266. ),
  267. )
  268. ],
  269. ),
  270. ),
  271. onTap: () {
  272. Navigator.of(context).pop();
  273. },
  274. ),
  275. );
  276. },
  277. ),
  278. );
  279. }
  280. Future showUserGuide3(BuildContext context) {
  281. return Navigator.of(context).push(
  282. PageRouteBuilder(
  283. opaque: false,
  284. transitionDuration: Duration(milliseconds: 300),
  285. transitionsBuilder: (BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation, Widget child) {
  286. return FadeTransition(
  287. opacity: CurvedAnimation(parent: animation, curve: Curves.linear),
  288. child: child,
  289. );
  290. },
  291. pageBuilder: (BuildContext context, _, __) {
  292. return Material(
  293. color: Colors.black87,
  294. child: GestureDetector(
  295. child: Container(
  296. child: Stack(
  297. children: <Widget>[
  298. Positioned(
  299. bottom: 5,
  300. right: 6,
  301. left: 6,
  302. child: Container(
  303. child: Image.asset(
  304. 'images/zhezhao_03.png',
  305. fit: BoxFit.fitWidth,
  306. ),
  307. ),
  308. ),
  309. Align(
  310. alignment: Alignment.bottomCenter,
  311. child: Container(
  312. width: 200,
  313. margin: EdgeInsets.only(bottom: 122, right: 60),
  314. child: Text(
  315. '加入房间后等待倒计时结束\n或者房主手动开启比赛',
  316. style: TextStyle(color: Colors.white, fontSize: 16, fontWeight: FontWeight.bold),
  317. ),
  318. ),
  319. )
  320. ],
  321. ),
  322. ),
  323. onTap: () {
  324. Navigator.of(context).pop();
  325. },
  326. ),
  327. );
  328. },
  329. ),
  330. );
  331. }