import 'package:flutter/material.dart'; import 'package:flutter_redux/flutter_redux.dart'; import 'package:wanna_battle/model/AppealInfo.dart'; import 'package:wanna_battle/redux/AppState.dart'; import '../styles/colors.dart'; import 'package:flutter/cupertino.dart'; import 'dart:ui'; import '../styles/totast.dart'; import '../model/SystemNotice.dart'; import '../net/HttpManager.dart'; import '../net/Result.dart'; import '../model/HouseInfo.dart'; import '../model/GameInfo.dart'; import '../pages/RoomInfoNew.dart'; import '../widget/SuccessfulReception.dart'; import 'Appeal.dart'; class TipInfo extends StatefulWidget { TipInfo({Key key, this.notice}) : super(key: key); final SystemNotice notice; @override TipInfoState createState() => TipInfoState(); } class TipInfoState extends State { SystemNotice notice; HouseInfo houseInfo; bool canAppeal = false; int appealState = 0; Future getInfo() async { HttpManager.get('systemNotice/getOne', data: {'id': widget.notice.id}).then((res) { if (res.success) { setState(() { notice = SystemNotice.fromJson(res.data); }); } if (notice.statusFlag == 0 && notice.typeFlag != 2 && notice.typeFlag != 3) { HttpManager.post('systemNotice/update', data: {'id': notice.id, 'statusFlag': 1}); } if (notice.typeFlag == 3) { return; } }); HttpManager.get('houseInfo/getOne', data: {'id': notice.houseId}).then((res2) { if (res2.success) { setState(() { houseInfo = HouseInfo.fromJson(res2.data); }); } }); if (notice.playerInfo != null && (notice.playerInfo.ranking == null || notice.playerInfo.liveTime == null || notice.playerInfo.score == null)) { HttpManager.get('appealInfo/getOne', data: { 'userId': StoreProvider.of(context).state.userInfo.id, 'playerInfoId': notice.playerInfo.id, }).then((res) { if (res.success && res.data != null) { setState(() { canAppeal = true; appealState = 1; }); } else { setState(() { canAppeal = true; appealState = 0; }); } }); } } void showSuccess(money) { Navigator.of(context).push( PageRouteBuilder( opaque: false, transitionDuration: Duration(milliseconds: 300), transitionsBuilder: (BuildContext context, Animation animation, Animation secondaryAnimation, Widget child) { return FadeTransition( opacity: CurvedAnimation(parent: animation, curve: Curves.linear), child: child, ); }, pageBuilder: (BuildContext context, _, __) { return SuccessfulReception(money: money); }, ), ); } @override void initState() { super.initState(); notice = widget.notice; Future.delayed(Duration.zero, () => getInfo()); } @override Widget build(BuildContext context) { int type = notice.typeFlag != null ? notice.typeFlag : 0; int status = notice.statusFlag ?? 0; GameInfo gameInfo; if (notice.gameInfo != null) { gameInfo = notice.gameInfo; } return WillPopScope( child: Scaffold( appBar: AppBar( title: Text('消息详情'), centerTitle: true, elevation: 0, ), body: Container( child: Column( children: [ Padding( padding: EdgeInsets.only(left: 15, right: 15), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Padding( padding: EdgeInsets.symmetric(vertical: 12), child: Text(readTimestamp(notice.createTime, 'yyyy.MM.dd HH:mm:ss'), style: TextStyle(color: Colors.white24, fontSize: 13)), ), Container( height: 1, color: Colors.black26, ), Padding( padding: EdgeInsets.only(top: 10, bottom: 17), child: Text( notice.content, style: TextStyle(color: Colors.white, fontSize: 14), ), ) ], ), ), // Builder( // builder: (context) { // String content = ''; // if (notice.playerInfo.dataError || !notice.playerInfo.played) { // content = '造成此情况等原因可能是:\n' // '1、没有实际进行游戏比赛\n' // '2、使用作弊手段进行游戏'; // } else if (notice.playerInfo.resultError) { // content = '造成此情况等原因可能是:\n' // '1、确认开始游戏后没有授权系统进行录屏\n' // '2、视频没有录制到最后的分数名次结算页面就回到APP点击完成比赛了\n' // '3、在游戏过程中,由于电量过低或系统安全性能策略问题导致本竞赛APP后台进程被退出\n' // '4、游戏结束后没有在规定时间内返回APP点击完成比赛按钮'; // } // return Container( // margin: EdgeInsets.only(left: 15, right: 15, bottom: 20), // width: double.infinity, // child: Text( // content, // style: TextStyle(color: Color(0x99FFFFFF), fontSize: 13), // ), // ); // }, // ), houseInfo != null && type != 3 ? _houseWidget() : Container(), resultWidget(), Expanded( child: Container(), ), canAppeal ? SafeArea( child: Container( width: double.infinity, height: 48, margin: EdgeInsets.only(left: 15, right: 15, bottom: 10), child: FlatButton( color: PRIMARY_COLOR, child: Text( appealState == 0 ? '申诉结果' : '已提交申诉', style: TextStyle(color: Colors.white, fontSize: 16, fontWeight: FontWeight.bold), ), onPressed: () async { if (appealState == 0) { final success = await Navigator.push(context, CupertinoPageRoute(builder: (context) => Appeal(notice.playerInfo))); if (success != null && success) { Toast.show(context, '提交成功', 1500, 'success'); setState(() { appealState = 1; }); } } }, ), ), ) : Container(), // CustomPaint( // painter: CircleProgressBarPainter( // Color(0xFFDCA659), Color(0xFFAE4945), 0.0, 270.0, 360.0, 18.0), // size: Size(108.0, 108.0), // ) ], ), )), onWillPop: () { Navigator.of(context).pop(true); Toast.hide(); return Future.value(false); }, ); } Widget _houseWidget() { return GestureDetector( child: Container( padding: EdgeInsets.all(15), margin: EdgeInsets.only(left: 15, right: 15, bottom: 10), height: 78, color: SUB_COLOR, child: Material( color: Colors.transparent, child: Row( children: [ Image.network( notice.gameInfo.icon, width: 48, height: 48, ), Container( width: 10, ), Expanded( flex: 1, child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.center, children: [ Row( children: [ Expanded( child: Text( notice.competitionInfo?.competitionName ?? '', style: TextStyle(color: Colors.white, fontSize: 14, fontWeight: FontWeight.bold), maxLines: 1, overflow: TextOverflow.ellipsis, ), ), Text( readTimestamp(notice.playerInfo.createTime, 'yyyy-MM-dd HH:mm:ss'), style: TextStyle(color: Color(0xff9BA0AE), fontSize: 12), ) ], ), Container( margin: EdgeInsets.only(top: 4), child: Text( houseInfo.houseName, style: TextStyle(fontSize: 12, fontWeight: FontWeight.normal, color: Color(0xFF9BA0AE)), maxLines: 2, overflow: TextOverflow.ellipsis, ), ) ], ), ), ], ), ), ), onTap: () { Navigator.push( context, CupertinoPageRoute( builder: (context) => RoomInfo( houseInfo, playerInfo: notice.playerInfo, ))); }, ); } Widget resultWidget() { return Column( children: [ (notice.playerInfo != null && notice.playerInfo.ranking != null && notice.playerInfo.liveTime != null && notice.playerInfo.score != null) ? Container( margin: EdgeInsets.fromLTRB(15, 0, 15, 5), color: SUB_COLOR, padding: EdgeInsets.fromLTRB(15, 15, 0, 15), child: Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.stretch, children: [ Text( '和平精英游戏结果', textAlign: TextAlign.left, style: TextStyle(color: Color(0x99FFFFFF)), ), Container( margin: EdgeInsets.only(top: 10), child: Row( children: [ Text( '名次', style: TextStyle(color: Colors.white, fontSize: 14), ), Expanded( child: Container( margin: EdgeInsets.only(left: 5), child: Text( notice.playerInfo?.ranking?.toString() ?? '', style: TextStyle(color: Colors.yellow, fontSize: 14, fontWeight: FontWeight.bold), ), ), ), Text( '时长', style: TextStyle(color: Colors.white, fontSize: 14), ), Expanded( child: Container( margin: EdgeInsets.only(left: 5), child: Text( (notice.playerInfo?.liveTime?.toString() ?? '') + '分钟', style: TextStyle(color: Colors.yellow, fontSize: 14, fontWeight: FontWeight.bold), ), ), ), Text( '评分', style: TextStyle(color: Colors.white, fontSize: 14), ), Expanded( child: Container( margin: EdgeInsets.only(left: 5), child: Text( notice.playerInfo?.score?.toString() ?? '', style: TextStyle(color: Colors.yellow, fontSize: 14, fontWeight: FontWeight.bold), ), ), ), ], ), ), ], ), ) : Container(), Container( margin: EdgeInsets.fromLTRB(15, 0, 15, 20), color: SUB_COLOR, padding: EdgeInsets.all(15), child: Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.stretch, children: [ Text( '比赛结果', textAlign: TextAlign.left, style: TextStyle(color: Color(0x99FFFFFF)), ), Container( margin: EdgeInsets.only(top: 10), child: Row( children: [ Expanded( child: Text( '参赛成员', style: TextStyle(color: Colors.white, fontSize: 14), textAlign: TextAlign.left, ), ), Text( houseInfo?.playerNumber?.toString() ?? '', style: TextStyle(color: Colors.yellow, fontWeight: FontWeight.bold), ) ], ), ), Container( margin: EdgeInsets.only(top: 10), child: Row( children: [ Expanded( child: Text( '我的排名', style: TextStyle(color: Colors.white, fontSize: 14), textAlign: TextAlign.left, ), ), Text( notice.playerInfo?.houseRank?.toString() ?? '', style: TextStyle(color: Colors.yellow, fontWeight: FontWeight.bold), ) ], ), ), Container( margin: EdgeInsets.only(top: 10), child: Row( children: [ Expanded( child: Text( '本场比赛获得积分', style: TextStyle(color: Colors.white, fontSize: 14), textAlign: TextAlign.left, ), ), Container( margin: EdgeInsets.only(right: 3), width: 20, child: Image.asset('images/icon_jifen_da.png'), ), Text( notice.playerInfo?.points?.toString() ?? '0', style: TextStyle(color: Colors.yellow, fontWeight: FontWeight.bold), ) ], ), ), (notice.playerInfo?.ranking ?? 99) == 1 ? Container( margin: EdgeInsets.only(top: 5), child: Text( '吃鸡额外获得10积分', style: TextStyle(color: PRIMARY_COLOR, fontSize: 12), ), ) : Container() ], ), ) ], ); } }