CompetitionInformation.dart 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  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(
  33. color: Theme.of(context).primaryColor,
  34. disableColor: Colors.transparent),
  35. index: nowSwiperIndex,
  36. itemCount: 3,
  37. scrollDirection: Axis.horizontal,
  38. loop: false,
  39. itemBuilder: (context, index) {
  40. return InfoBox(
  41. houseInfo: widget.houseInfo,
  42. typeIndex: index + 1,
  43. next: () {
  44. _swiperController.next();
  45. },
  46. end: () {
  47. Navigator.of(context).pop();
  48. });
  49. }))),
  50. ),
  51. onWillPop: () {
  52. return Future.value(false);
  53. },
  54. );
  55. }
  56. }
  57. typedef OnTapHomeMenu = void Function();
  58. class InfoBox extends StatelessWidget {
  59. InfoBox({Key key, this.typeIndex, this.next, this.end, this.houseInfo})
  60. : super(key: key);
  61. final int typeIndex;
  62. final OnTapHomeMenu next;
  63. final OnTapHomeMenu end;
  64. final HouseInfo houseInfo;
  65. @override
  66. Widget build(BuildContext context) {
  67. return UnconstrainedBox(
  68. child: Container(
  69. width: 270,
  70. height: 422,
  71. decoration: BoxDecoration(
  72. border: Border.all(width: 1, color: Theme.of(context).primaryColor),
  73. color: Colors.black),
  74. child: Stack(
  75. children: <Widget>[
  76. Container(
  77. width: 270,
  78. padding: EdgeInsets.only(top: 25),
  79. child: Column(
  80. children: <Widget>[
  81. Text('竞赛须知 ' + typeIndex.toString() + '/3',
  82. style: TextStyle(
  83. color: Color(0xFFFDC372),
  84. fontSize: 20,
  85. fontWeight: FontWeight.w600)),
  86. _centerContent(typeIndex,context)
  87. ],
  88. ),
  89. ),
  90. Positioned(
  91. top: 0,
  92. left: 0,
  93. child: Image.asset(
  94. 'images/tancuang_shang.png',
  95. // width: 131,
  96. ),
  97. ),
  98. Positioned(
  99. bottom: 0,
  100. right: 4,
  101. child: Image.asset(
  102. 'images/tancuang_xia.png',
  103. // width: 148,
  104. ),
  105. ),
  106. Positioned(
  107. bottom: 15,
  108. left: 25,
  109. child: Column(
  110. children: <Widget>[
  111. Container(
  112. width: 220,
  113. height: 36,
  114. child:
  115. LinearButton(
  116. btntext: typeIndex != 3 ? '下一个' : '知道了',
  117. onTapHomeMenu:typeIndex != 3 ? next : end ,
  118. )
  119. // RaisedButton(
  120. // textColor: Colors.white,
  121. // child: Text(typeIndex != 4 ? '下一个' : '结束'),
  122. // onPressed: typeIndex != 4 ? next : end,
  123. // ),
  124. ),
  125. FlatButton(
  126. textColor: Color(0xFF727785),
  127. highlightColor: Colors.transparent,
  128. splashColor: Colors.transparent,
  129. child: Text('关闭'),
  130. onPressed: () {
  131. end();
  132. },
  133. )
  134. ],
  135. ),
  136. )
  137. ],
  138. ),
  139. ));
  140. }
  141. // 第一名获得${houseInfo.houseLevel.firstRatio}%,第二名获得${houseInfo.houseLevel.secondRatio}%,第三名获得${houseInfo.houseLevel.thirdRatio}%
  142. Widget _centerContent(int index,BuildContext context) {
  143. Widget useContent = Container();
  144. TextStyle _text = TextStyle(color: Colors.white, fontSize: 14);
  145. if (index == 1) {
  146. useContent = Container(
  147. margin: EdgeInsets.only(top: 20),
  148. padding: EdgeInsets.symmetric(horizontal: 20),
  149. child: Column(
  150. children: <Widget>[
  151. Image.asset('images/img_xuzhi_02.png', width: 136),
  152. Container(
  153. height: 10,
  154. ),
  155. Text.rich(
  156. TextSpan(children: [
  157. TextSpan(
  158. text: '竞赛开始前请在此耐心等待,在开始时会有上图所示弹窗,玩家必须在10秒内',
  159. style: _text,
  160. ),
  161. TextSpan(
  162. text: '点击确认',
  163. style: TextStyle(
  164. color: Theme.of(context).primaryColor,
  165. fontSize: 14,
  166. fontWeight: FontWeight.w500),
  167. ),
  168. TextSpan(
  169. text: ',否则视为放弃此次竞赛,已支付金币概不退换',
  170. style: _text,
  171. )
  172. ]),
  173. textAlign: TextAlign.center)
  174. ],
  175. ),
  176. );
  177. } else if (index ==2) {
  178. useContent = Container(
  179. margin: EdgeInsets.only(top: 20),
  180. padding: EdgeInsets.symmetric(horizontal: 20),
  181. child: Column(
  182. children: <Widget>[
  183. Image.asset('images/img_xuzhi_03.png', width: 176),
  184. Container(
  185. height: 10,
  186. ),
  187. Text.rich(
  188. TextSpan(children: [
  189. TextSpan(
  190. text: '确认竞赛后会有弹窗提示授权进行录屏的操作,请一定',
  191. style: _text,
  192. ),
  193. TextSpan(
  194. text: '点击“确定”',
  195. style: TextStyle(
  196. color: Theme.of(context).primaryColor,
  197. fontSize: 14,
  198. fontWeight: FontWeight.w500),
  199. ),
  200. TextSpan(
  201. text: '或“允许”此操作,否则竞赛判定失败',
  202. style: _text,
  203. )
  204. ]),
  205. textAlign: TextAlign.center)
  206. ],
  207. ),
  208. );
  209. } else if (index == 3) {
  210. useContent = Container(
  211. margin: EdgeInsets.only(top: 20),
  212. padding: EdgeInsets.symmetric(horizontal: 20),
  213. child: Column(
  214. children: <Widget>[
  215. Image.asset('images/img_xuzhi_04.png', width: 216),
  216. Container(
  217. height: 10,
  218. ),
  219. Text.rich(
  220. TextSpan(children: [
  221. TextSpan(
  222. text: '在游戏中吃鸡后,',
  223. style: _text,
  224. ),
  225. TextSpan(
  226. text: '请一定一定一定要点击“继续”按钮',
  227. style: TextStyle(
  228. color: Theme.of(context).primaryColor,
  229. fontSize: 14,
  230. fontWeight: FontWeight.w600),
  231. ),
  232. TextSpan(
  233. text: ',显示到上图所示画面,然后再切换到我们全民APP中,点击完成比赛,方可成功上传本次成绩,赢取大奖',
  234. style: _text,
  235. )
  236. ]),
  237. textAlign: TextAlign.center)
  238. ],
  239. ),
  240. );
  241. }
  242. return useContent;
  243. }
  244. }