TipInfo.dart 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_redux/flutter_redux.dart';
  3. import 'package:wanna_battle/model/AppealInfo.dart';
  4. import 'package:wanna_battle/redux/AppState.dart';
  5. import '../styles/colors.dart';
  6. import 'package:flutter/cupertino.dart';
  7. import 'dart:ui';
  8. import '../styles/totast.dart';
  9. import '../model/SystemNotice.dart';
  10. import '../net/HttpManager.dart';
  11. import '../net/Result.dart';
  12. import '../model/HouseInfo.dart';
  13. import '../model/GameInfo.dart';
  14. import '../pages/RoomInfoNew.dart';
  15. import '../widget/SuccessfulReception.dart';
  16. import 'Appeal.dart';
  17. class TipInfo extends StatefulWidget {
  18. TipInfo({Key key, this.notice}) : super(key: key);
  19. final SystemNotice notice;
  20. @override
  21. TipInfoState createState() => TipInfoState();
  22. }
  23. class TipInfoState extends State<TipInfo> {
  24. SystemNotice notice;
  25. HouseInfo houseInfo;
  26. bool canAppeal = false;
  27. int appealState = 0;
  28. Future<void> getInfo() async {
  29. HttpManager.get('systemNotice/getOne', data: {'id': widget.notice.id}).then((res) {
  30. if (res.success) {
  31. setState(() {
  32. notice = SystemNotice.fromJson(res.data);
  33. });
  34. }
  35. if (notice.statusFlag == 0 && notice.typeFlag != 2 && notice.typeFlag != 3) {
  36. HttpManager.post('systemNotice/update', data: {'id': notice.id, 'statusFlag': 1});
  37. }
  38. if (notice.typeFlag == 3) {
  39. return;
  40. }
  41. });
  42. HttpManager.get('houseInfo/getOne', data: {'id': notice.houseId}).then((res2) {
  43. if (res2.success) {
  44. setState(() {
  45. houseInfo = HouseInfo.fromJson(res2.data);
  46. });
  47. }
  48. });
  49. if (notice.playerInfo != null && (notice.playerInfo.ranking == null || notice.playerInfo.liveTime == null || notice.playerInfo.score == null)) {
  50. HttpManager.get('appealInfo/getOne', data: {
  51. 'userId': StoreProvider.of<AppState>(context).state.userInfo.id,
  52. 'playerInfoId': notice.playerInfo.id,
  53. }).then((res) {
  54. if (res.success && res.data != null) {
  55. setState(() {
  56. canAppeal = true;
  57. appealState = 1;
  58. });
  59. } else {
  60. setState(() {
  61. canAppeal = true;
  62. appealState = 0;
  63. });
  64. }
  65. });
  66. }
  67. }
  68. void showSuccess(money) {
  69. Navigator.of(context).push(
  70. PageRouteBuilder(
  71. opaque: false,
  72. transitionDuration: Duration(milliseconds: 300),
  73. transitionsBuilder: (BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation, Widget child) {
  74. return FadeTransition(
  75. opacity: CurvedAnimation(parent: animation, curve: Curves.linear),
  76. child: child,
  77. );
  78. },
  79. pageBuilder: (BuildContext context, _, __) {
  80. return SuccessfulReception(money: money);
  81. },
  82. ),
  83. );
  84. }
  85. @override
  86. void initState() {
  87. super.initState();
  88. notice = widget.notice;
  89. Future.delayed(Duration.zero, () => getInfo());
  90. }
  91. @override
  92. Widget build(BuildContext context) {
  93. int type = notice.typeFlag != null ? notice.typeFlag : 0;
  94. int status = notice.statusFlag ?? 0;
  95. GameInfo gameInfo;
  96. if (notice.gameInfo != null) {
  97. gameInfo = notice.gameInfo;
  98. }
  99. return WillPopScope(
  100. child: Scaffold(
  101. appBar: AppBar(
  102. title: Text('消息详情'),
  103. centerTitle: true,
  104. elevation: 0,
  105. ),
  106. body: Container(
  107. child: Column(
  108. children: <Widget>[
  109. Padding(
  110. padding: EdgeInsets.only(left: 15, right: 15),
  111. child: Column(
  112. crossAxisAlignment: CrossAxisAlignment.start,
  113. children: <Widget>[
  114. Padding(
  115. padding: EdgeInsets.symmetric(vertical: 12),
  116. child: Text(readTimestamp(notice.createTime, 'yyyy.MM.dd HH:mm:ss'), style: TextStyle(color: Colors.white24, fontSize: 13)),
  117. ),
  118. Container(
  119. height: 1,
  120. color: Colors.black26,
  121. ),
  122. Padding(
  123. padding: EdgeInsets.only(top: 10, bottom: 17),
  124. child: Text(
  125. notice.content,
  126. style: TextStyle(color: Colors.white, fontSize: 14),
  127. ),
  128. )
  129. ],
  130. ),
  131. ),
  132. // Builder(
  133. // builder: (context) {
  134. // String content = '';
  135. // if (notice.playerInfo.dataError || !notice.playerInfo.played) {
  136. // content = '造成此情况等原因可能是:\n'
  137. // '1、没有实际进行游戏比赛\n'
  138. // '2、使用作弊手段进行游戏';
  139. // } else if (notice.playerInfo.resultError) {
  140. // content = '造成此情况等原因可能是:\n'
  141. // '1、确认开始游戏后没有授权系统进行录屏\n'
  142. // '2、视频没有录制到最后的分数名次结算页面就回到APP点击完成比赛了\n'
  143. // '3、在游戏过程中,由于电量过低或系统安全性能策略问题导致本竞赛APP后台进程被退出\n'
  144. // '4、游戏结束后没有在规定时间内返回APP点击完成比赛按钮';
  145. // }
  146. // return Container(
  147. // margin: EdgeInsets.only(left: 15, right: 15, bottom: 20),
  148. // width: double.infinity,
  149. // child: Text(
  150. // content,
  151. // style: TextStyle(color: Color(0x99FFFFFF), fontSize: 13),
  152. // ),
  153. // );
  154. // },
  155. // ),
  156. houseInfo != null && type != 3 ? _houseWidget() : Container(),
  157. resultWidget(),
  158. Expanded(
  159. child: Container(),
  160. ),
  161. canAppeal
  162. ? SafeArea(
  163. child: Container(
  164. width: double.infinity,
  165. height: 48,
  166. margin: EdgeInsets.only(left: 15, right: 15, bottom: 10),
  167. child: FlatButton(
  168. color: PRIMARY_COLOR,
  169. child: Text(
  170. appealState == 0 ? '申诉结果' : '已提交申诉',
  171. style: TextStyle(color: Colors.white, fontSize: 16, fontWeight: FontWeight.bold),
  172. ),
  173. onPressed: () async {
  174. if (appealState == 0) {
  175. final success = await Navigator.push(context, CupertinoPageRoute(builder: (context) => Appeal(notice.playerInfo)));
  176. if (success != null && success) {
  177. Toast.show(context, '提交成功', 1500, 'success');
  178. setState(() {
  179. appealState = 1;
  180. });
  181. }
  182. }
  183. },
  184. ),
  185. ),
  186. )
  187. : Container(),
  188. // CustomPaint(
  189. // painter: CircleProgressBarPainter(
  190. // Color(0xFFDCA659), Color(0xFFAE4945), 0.0, 270.0, 360.0, 18.0),
  191. // size: Size(108.0, 108.0),
  192. // )
  193. ],
  194. ),
  195. )),
  196. onWillPop: () {
  197. Navigator.of(context).pop(true);
  198. Toast.hide();
  199. return Future.value(false);
  200. },
  201. );
  202. }
  203. Widget _houseWidget() {
  204. return GestureDetector(
  205. child: Container(
  206. padding: EdgeInsets.all(15),
  207. margin: EdgeInsets.only(left: 15, right: 15, bottom: 10),
  208. height: 78,
  209. color: SUB_COLOR,
  210. child: Material(
  211. color: Colors.transparent,
  212. child: Row(
  213. children: <Widget>[
  214. Image.network(
  215. notice.gameInfo.icon,
  216. width: 48,
  217. height: 48,
  218. ),
  219. Container(
  220. width: 10,
  221. ),
  222. Expanded(
  223. flex: 1,
  224. child: Column(
  225. crossAxisAlignment: CrossAxisAlignment.start,
  226. mainAxisAlignment: MainAxisAlignment.center,
  227. children: <Widget>[
  228. Row(
  229. children: <Widget>[
  230. Expanded(
  231. child: Text(
  232. notice.competitionInfo?.competitionName ?? '',
  233. style: TextStyle(color: Colors.white, fontSize: 14, fontWeight: FontWeight.bold),
  234. maxLines: 1,
  235. overflow: TextOverflow.ellipsis,
  236. ),
  237. ),
  238. Text(
  239. readTimestamp(notice.playerInfo.createTime, 'yyyy-MM-dd HH:mm:ss'),
  240. style: TextStyle(color: Color(0xff9BA0AE), fontSize: 12),
  241. )
  242. ],
  243. ),
  244. Container(
  245. margin: EdgeInsets.only(top: 4),
  246. child: Text(
  247. houseInfo.houseName,
  248. style: TextStyle(fontSize: 12, fontWeight: FontWeight.normal, color: Color(0xFF9BA0AE)),
  249. maxLines: 2,
  250. overflow: TextOverflow.ellipsis,
  251. ),
  252. )
  253. ],
  254. ),
  255. ),
  256. ],
  257. ),
  258. ),
  259. ),
  260. onTap: () {
  261. Navigator.push(
  262. context,
  263. CupertinoPageRoute(
  264. builder: (context) => RoomInfo(
  265. houseInfo,
  266. playerInfo: notice.playerInfo,
  267. )));
  268. },
  269. );
  270. }
  271. Widget resultWidget() {
  272. return Column(
  273. children: <Widget>[
  274. (notice.playerInfo != null && notice.playerInfo.ranking != null && notice.playerInfo.liveTime != null && notice.playerInfo.score != null)
  275. ? Container(
  276. margin: EdgeInsets.fromLTRB(15, 0, 15, 5),
  277. color: SUB_COLOR,
  278. padding: EdgeInsets.fromLTRB(15, 15, 0, 15),
  279. child: Column(
  280. mainAxisAlignment: MainAxisAlignment.center,
  281. crossAxisAlignment: CrossAxisAlignment.stretch,
  282. children: <Widget>[
  283. Text(
  284. '和平精英游戏结果',
  285. textAlign: TextAlign.left,
  286. style: TextStyle(color: Color(0x99FFFFFF)),
  287. ),
  288. Container(
  289. margin: EdgeInsets.only(top: 10),
  290. child: Row(
  291. children: <Widget>[
  292. Text(
  293. '名次',
  294. style: TextStyle(color: Colors.white, fontSize: 14),
  295. ),
  296. Expanded(
  297. child: Container(
  298. margin: EdgeInsets.only(left: 5),
  299. child: Text(
  300. notice.playerInfo?.ranking?.toString() ?? '',
  301. style: TextStyle(color: Colors.yellow, fontSize: 14, fontWeight: FontWeight.bold),
  302. ),
  303. ),
  304. ),
  305. Text(
  306. '时长',
  307. style: TextStyle(color: Colors.white, fontSize: 14),
  308. ),
  309. Expanded(
  310. child: Container(
  311. margin: EdgeInsets.only(left: 5),
  312. child: Text(
  313. (notice.playerInfo?.liveTime?.toString() ?? '') + '分钟',
  314. style: TextStyle(color: Colors.yellow, fontSize: 14, fontWeight: FontWeight.bold),
  315. ),
  316. ),
  317. ),
  318. Text(
  319. '评分',
  320. style: TextStyle(color: Colors.white, fontSize: 14),
  321. ),
  322. Expanded(
  323. child: Container(
  324. margin: EdgeInsets.only(left: 5),
  325. child: Text(
  326. notice.playerInfo?.score?.toString() ?? '',
  327. style: TextStyle(color: Colors.yellow, fontSize: 14, fontWeight: FontWeight.bold),
  328. ),
  329. ),
  330. ),
  331. ],
  332. ),
  333. ),
  334. ],
  335. ),
  336. )
  337. : Container(),
  338. Container(
  339. margin: EdgeInsets.fromLTRB(15, 0, 15, 20),
  340. color: SUB_COLOR,
  341. padding: EdgeInsets.all(15),
  342. child: Column(
  343. mainAxisAlignment: MainAxisAlignment.center,
  344. crossAxisAlignment: CrossAxisAlignment.stretch,
  345. children: <Widget>[
  346. Text(
  347. '比赛结果',
  348. textAlign: TextAlign.left,
  349. style: TextStyle(color: Color(0x99FFFFFF)),
  350. ),
  351. Container(
  352. margin: EdgeInsets.only(top: 10),
  353. child: Row(
  354. children: <Widget>[
  355. Expanded(
  356. child: Text(
  357. '参赛成员',
  358. style: TextStyle(color: Colors.white, fontSize: 14),
  359. textAlign: TextAlign.left,
  360. ),
  361. ),
  362. Text(
  363. houseInfo?.playerNumber?.toString() ?? '',
  364. style: TextStyle(color: Colors.yellow, fontWeight: FontWeight.bold),
  365. )
  366. ],
  367. ),
  368. ),
  369. Container(
  370. margin: EdgeInsets.only(top: 10),
  371. child: Row(
  372. children: <Widget>[
  373. Expanded(
  374. child: Text(
  375. '我的排名',
  376. style: TextStyle(color: Colors.white, fontSize: 14),
  377. textAlign: TextAlign.left,
  378. ),
  379. ),
  380. Text(
  381. notice.playerInfo?.houseRank?.toString() ?? '',
  382. style: TextStyle(color: Colors.yellow, fontWeight: FontWeight.bold),
  383. )
  384. ],
  385. ),
  386. ),
  387. Container(
  388. margin: EdgeInsets.only(top: 10),
  389. child: Row(
  390. children: <Widget>[
  391. Expanded(
  392. child: Text(
  393. '本场比赛获得积分',
  394. style: TextStyle(color: Colors.white, fontSize: 14),
  395. textAlign: TextAlign.left,
  396. ),
  397. ),
  398. Container(
  399. margin: EdgeInsets.only(right: 3),
  400. width: 20,
  401. child: Image.asset('images/icon_jifen_da.png'),
  402. ),
  403. Text(
  404. notice.playerInfo?.points?.toString() ?? '0',
  405. style: TextStyle(color: Colors.yellow, fontWeight: FontWeight.bold),
  406. )
  407. ],
  408. ),
  409. ),
  410. (notice.playerInfo?.ranking ?? 99) == 1
  411. ? Container(
  412. margin: EdgeInsets.only(top: 5),
  413. child: Text(
  414. '吃鸡额外获得10积分',
  415. style: TextStyle(color: PRIMARY_COLOR, fontSize: 12),
  416. ),
  417. )
  418. : Container()
  419. ],
  420. ),
  421. )
  422. ],
  423. );
  424. }
  425. }