| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561 |
- import 'dart:async';
- import 'dart:io';
- import 'dart:ui';
- import 'package:flutter/material.dart';
- import 'package:flutter/painting.dart';
- import 'package:flutter_screenutil/flutter_screenutil.dart';
- import 'package:intl/intl.dart';
- import 'package:url_launcher/url_launcher.dart';
- import 'package:battery/battery.dart';
- import 'package:flutter_redux/flutter_redux.dart';
- import 'package:flutter/cupertino.dart';
- import '../styles/colors.dart';
- import 'package:screen_stream_plugin/screen_stream_plugin.dart';
- import '../net/HttpManager.dart';
- import '../net/Result.dart';
- import '../redux/AppState.dart';
- import '../model/HouseInfo.dart';
- import '../styles/totast.dart';
- import 'StartWindow.dart';
- import '../model/PlayerInfo.dart';
- import '../widget/VideoWidget.dart';
- import '../widget/Dialog.dart';
- import 'CompetitionInformation.dart';
- import 'SecondRoomInfo.dart';
- import 'VideoPlayer.dart';
- import '../model/UserInfo.dart';
- import '../widget/LinearButton.dart';
- import 'Appeal.dart';
- import 'ShoppingMall.dart';
- import '../redux/UserRedux.dart';
- class RoomInfo extends StatefulWidget {
- RoomInfo({Key key, this.roomId}) : super(key: key);
- final String roomId; // 用来储存传递过来的值
- @override
- RoomInfoState createState() => RoomInfoState();
- }
- class RoomInfoState extends State<RoomInfo> with SingleTickerProviderStateMixin {
- List<Map> tabList;
- TabController mController;
- Map roomInfo;
- HouseInfo houseInfo;
- Map colorInfo;
- bool isJoin = true;
- PlayerInfo playerInfo;
- bool isPop = false;
- bool showBack = false;
- Timer timer;
- List<List<Map>> roomTipsList = [];
- ScrollController _tipController;
- String _myUrl;
- int tabIndex = 0;
- UserInfo userInfo;
- int myRank = 0;
- String mymedal = '';
- bool canAppeal = false;
- int appealState = 0;
- bool showJiexie = false;
- bool showHelloWord = false;
- bool showWait = false;
- num race = 10;
- HttpServer server;
- //获取房间信息
- Future<void> getRoomInfo(type) async {
- print('现在时间:' + DateTime.now().millisecondsSinceEpoch.toString());
- Toast.show(context, '加载中', -1, 'loading');
- Result res = await HttpManager.get('houseInfo/getOne', data: {'id': widget.roomId});
- Toast.hide();
- if (res.success) {
- setState(() {
- roomInfo = res.data;
- houseInfo = HouseInfo.fromJson(res.data);
- });
- // showNotice();
- if (houseInfo.statusFlag == 0 && houseInfo.userId != StoreProvider.of<AppState>(context).state.userInfo.id) {
- showNotice();
- }
- if (houseInfo.statusFlag < 2 && type == 'first') {
- final battery = Battery();
- final batteryLevel = await battery.batteryLevel;
- await MyDialog.showDialog(context, (batteryLevel < 50 ? '系统检测到你的电量低于50%' : '') + ' 为了正常上传比赛结果,建议插上电源线保持电量充足', submitText: '知道了');
- }
- } else {}
- checkJoinInfo();
- }
- //开始比赛
- Future<void> startGame() async {
- Toast.show(context, '加载中', -1, 'loading');
- Result res = await HttpManager.post('houseInfo/handBegin', data: {'id': widget.roomId});
- Toast.hide();
- }
- //隔一秒检查是否开始
- Future<void> getNowStatus() async {
- print('检查执行');
- Result res = await HttpManager.get('houseInfo/getPlayerNum', data: {'id': widget.roomId});
- if (res.success) {
- if (houseInfo.statusFlag == 0 && res.data['statusFlag'] == 2) {
- showStart();
- // timer.cancel();
- }
- setState(() {
- houseInfo.playerNumber = res.data['playerNumber'];
- houseInfo.statusFlag = res.data['statusFlag'];
- houseInfo.bonus = res.data['bonus'];
- houseInfo.beginTime = res.data['beginTime'];
- });
- if (houseInfo.statusFlag == 4) {
- checkJoinInfo();
- } else if (!isJoin) {
- checkJoinInfo();
- }
- }
- }
- //开始比赛确认按钮
- Future<void> showStart() async {
- if (!isJoin) {
- return;
- }
- bool result = await Navigator.of(context).push<bool>(
- PageRouteBuilder(
- opaque: false,
- transitionDuration: Duration(milliseconds: 300),
- transitionsBuilder: (BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation, Widget child) {
- return FadeTransition(
- opacity: CurvedAnimation(parent: animation, curve: Curves.linear),
- child: child,
- );
- },
- pageBuilder: (BuildContext context, _, __) {
- return StartWindow();
- },
- ),
- );
- Map<String, dynamic> data = {'id': playerInfo.id};
- bool success = true;
- if (result) {
- success = await ScreenStreamPlugin.start(playerInfo.id.toString(), dialogMessage: '你是否已杀戮${playerInfo.needkill}人?');
- if (success) {
- data['beginTime'] = DateTime.now().millisecondsSinceEpoch;
- data['statusFlag'] = 2;
- data['played'] = true;
- } else {
- data['statusFlag'] = 6;
- data['played'] = false;
- }
- } else {
- data['statusFlag'] = 6;
- data['played'] = false;
- }
- Toast.show(context, '加载中', -1, 'loading');
- Result res = await HttpManager.post('playerInfo/update', data: data);
- Toast.hide();
- // MyDialog.showDialog(context, '自动启动游戏失败,请手动切换到游戏app开始竞赛', submitText: '知道了');
- // Timer(Duration(seconds: 10), () {
- // showSucessInfo();
- // });
- // return;
- if (res.success) {
- if (data['statusFlag'] == 2) {
- const url = 'pubgmhd1106467070://';
- if (await canLaunch(url)) {
- Timer(Duration(seconds: 1), () async {
- await launch(url);
- showSucessInfo(3);
- });
- } else {
- MyDialog.showDialog(context, '自动启动游戏失败,请手动切换到游戏app开始竞赛', submitText: '知道了');
- Timer(Duration(seconds: 10), () {
- showSucessInfo(3);
- });
- throw 'Could not launch $url';
- }
- } else {
- showBackDialog(success ? 1 : 0);
- }
- }
- }
- //开始录屏提示框
- void showSucessInfo(status) {
- MyDialog.showDialog(context, '',
- textList: [
- {"value": '您已经完成杀戮目标了吗?确定请点击', "isImportant": false},
- {"value": '“我已完成比赛”', "isImportant": true},
- {"value": '按钮。上传本次成绩,最后的名次稍后公布。祝您取得好成绩!', "isImportant": false}
- ],
- title: '完成比赛',
- submitText: '我已完成比赛', onsubmit: () async {
- HttpManager.post('playerInfo/gameOver', data: {'id': playerInfo.id, 'statusFlag': status, 'endTime': DateTime.now().millisecondsSinceEpoch});
- bool success = await ScreenStreamPlugin.stop();
- Timer(Duration(seconds: 1), () {
- getEndTips();
- });
- setState(() {
- playerInfo.statusFlag = 3;
- });
- });
- }
- Future<void> getEndTips() async {
- Result res = await HttpManager.get('playerInfo/endNum', data: {'houseId': widget.roomId});
- if (res.success) {
- int time = houseInfo.beginTime + 1 * 3600 * 1000 - DateTime.now().millisecondsSinceEpoch;
- var nowTime = (time ~/ 1000 ~/ 60) % 60;
- setState(() {
- showHelloWord = false;
- roomTipsList.add([
- {"value": '你已完成本次比赛,当前完成人数 ', "type": 0},
- {"value": res.data.toString(), "type": 1},
- {"value": '人,比赛需要等待其他人完成后方可结算奖励,你可以先去参加其他竞赛,稍后会有', "type": 0},
- {"value": '邮件', "type": 1},
- {"value": '提醒你本次竞赛结果以及领取奖励,请注意查看', "type": 0},
- {"value": '首页左上角邮件提醒', "type": 1},
- {"value": '哦', "type": 0}
- ]);
- showWait = true;
- changeScroll();
- });
- }
- }
- //未确认比赛弹窗
- void showBackDialog(type) {
- MyDialog.showDialog(context, (type == 1 ? '由于您未在十秒内点击开始按钮' : '由于您未授权录屏') + ',系统已经判定您放弃比赛,谢谢您的参与。', title: '很遗憾');
- }
- //检查加入信息
- Future<void> checkJoinInfo() async {
- Result res = await HttpManager.get('playerInfo/getOne', data: {'userId': StoreProvider.of<AppState>(context).state.userInfo.id, 'houseId': widget.roomId});
- if (res.success) {
- if (res.data == null) {
- setState(() {
- isJoin = false;
- });
- if (houseInfo.statusFlag == 0) {
- if (houseInfo.createUser == StoreProvider.of<AppState>(context).state.userInfo.id.toString()) {
- // roomTipsList.add([{
- // "value":'房间创建成功,待人数满员时会自动开启比赛,房主也可以手动开启比赛,同时,你也可以加入本次比赛',
- // "type":0
- // }]);
- changeScroll();
- }
- if (!showHelloWord) {
- setState(() {
- showHelloWord = true;
- });
- // if (isJoin) {
- // roomTipsList.add([{
- // "value":'亲爱的玩家:',
- // }]);
- // }
- changeScroll();
- }
- }
- } else {
- // if (houseInfo.statusFlag == 0) {
- // roomTipsList
- // .add(['待倒计时结束或人数满员时会自动开启比赛,请在此页面耐心等待其他人的加入,加入房间后再次退出则视为自动放弃比赛。', '由于部分手机在低电量情况下无法在后台正常运行竞赛APP,为了你比赛数据的正常获取,请保持手机电量在50%以上', '', '', '']);
- // }
- playerInfo = PlayerInfo.fromJson(res.data);
- if (playerInfo.medal != null) {
- mymedal = res.data['medal'];
- }
- if (houseInfo.statusFlag == 4) {
- _myUrl = await ScreenStreamPlugin.getVideo(playerInfo.id.toString());
- print('本地视频' + playerInfo.id.toString());
- print(_myUrl);
- Result rankRes = await HttpManager.get('playerInfo/userRank', data: {'id': playerInfo.id});
- if (rankRes.success) {
- myRank = rankRes.data + 1;
- }
- }
- setState(() {
- isJoin = true;
- });
- if (houseInfo.statusFlag == 0) {
- // if (houseInfo.createUser == StoreProvider.of<AppState>(context).state.userInfo.id.toString()) {
- // roomTipsList.add(['房间创建成功,待人数满员时会自动开启比赛,房主也可以手动开启比赛,请在此页面耐心等待其他人的加入,加入房间后再次退出则视为自动放弃比赛,已支付金币概不退换,快快点击右上角分享给好友加入战局吧']);
- // changeScroll();
- // } else {
- // roomTipsList.add([
- // '请在此页面耐心等待,竞赛即将开始,届时玩家有10秒的时间进行确认,点击确认方可正式进入竞赛,若没有点击,则视为自动放弃此次竞赛,已支付金币概不退换'
- // ]);
- // changeScroll();
- // }
- // Timer(Duration(seconds: 1), () {
- // roomTipsList.add([
- // '游戏开始后会有弹窗提示授权进行录屏的操作,',
- // '请一定点击“确定”或“允许”此操作',
- // ',系统会自动跳转打开游戏app,若长时间没有自动跳转,请手动打开游戏app进行比赛,在游戏比赛结束后,请',
- // '���定要点击查看游戏最后的��数名次结算页面',
- // ',返回游戏主页,最后再切换到我们竞赛app中,点击完成比赛,方可成功上传本次成绩。从游戏开始一小时之内必须返回全民App点击完成比赛,否则判定游戏失败,祝你取得好成绩。'
- // ]);
- // changeScroll();
- // });
- } else if (houseInfo.statusFlag != 4) {
- if (playerInfo.statusFlag == 3 || playerInfo.statusFlag == 8 || playerInfo.statusFlag == 9) {
- getEndTips();
- }
- }
- }
- }
- if (isJoin && houseInfo.statusFlag != 4 || houseInfo.statusFlag == 0) {
- print('检查1');
- if (timer != null) {
- timer.cancel();
- }
- timer = Timer.periodic(Duration(seconds: 1), (timer) {
- print('检查');
- if (houseInfo.statusFlag == 4) {
- timer.cancel();
- } else {
- getNowStatus();
- }
- });
- }
- if (isJoin && houseInfo.statusFlag == 4) {
- setState(() {
- showJiexie = true;
- });
- //申诉
- HttpManager.get('appealInfo/getOne', data: {
- 'userId': StoreProvider.of<AppState>(context).state.userInfo.id,
- 'playerInfoId': playerInfo.id,
- }).then((res) {
- if (res.success && res.data != null) {
- setState(() {
- canAppeal = true;
- appealState = 1;
- });
- } else {
- setState(() {
- canAppeal = true;
- appealState = 0;
- });
- }
- });
- }
- if (houseInfo.statusFlag == 2 && playerInfo.beginTime != null && playerInfo.endTime == null) {
- showSucessInfo(9);
- }
- }
- //加入房间
- Future<void> joinRoom() async {
- UserInfo myUser;
- Toast.show(context, '加载中', -1, 'loading');
- Result res2 = await HttpManager.get('userInfo/getUserInfo');
- if (res2.success) {
- StoreProvider.of<AppState>(context).dispatch(UpdateUserAction(UserInfo.fromJson(res2.data)));
- myUser = UserInfo.fromJson(res2.data);
- } else {}
- Toast.hide();
- if (myUser.moneyTicket < houseInfo.houseLevel.entryCoin) {
- MyDialog.showDialog(context, '门票不足不能加入', onsubmit: () async {
- Result res = await HttpManager.get('systemVariable/get', data: {'name': "iosPayHide"});
- if (Platform.isIOS && res.data != null && res.data == 'true') {
- MyDialog.showDialog(context, 'ios充值暂未开放');
- } else {
- Navigator.push(context, CupertinoPageRoute(builder: (context) => ShoppingMall()));
- }
- });
- return;
- }
- MyDialog.showDialog(context, '加入房间后再次退出则示为自动放弃比赛', submitText: '确认加入', isCancel: true, onsubmit: () async {
- Toast.show(context, '加载中', -1, 'loading');
- Result res = await HttpManager.post('houseInfo/join', data: {'houseId': widget.roomId, 'userId': StoreProvider.of<AppState>(context).state.userInfo.id});
- Toast.hide();
- if (res.success) {
- bool hasPermission = await ScreenStreamPlugin.checkPermission();
- if (!hasPermission) {
- showDialog(
- context: context,
- builder: (context) => AlertDialog(
- title: Text('需要悬浮窗权限'),
- contentTextStyle: TextStyle(color: Colors.black87),
- content: Text('请在点击确定后,勾选"允许显示在其他应用的上层"'),
- actions: <Widget>[
- FlatButton(
- child: Text('确定'),
- onPressed: () {
- Navigator.of(context).pop();
- ScreenStreamPlugin.requestPermission();
- },
- ),
- ],
- ),
- );
- return;
- } else {
- Toast.show(context, '加入成功', 1500, 'success');
- }
- } else {
- Toast.show(context, res.error, 1500, 'info');
- }
- });
- }
- //展示通知
- void showNotice() {
- Navigator.of(context).push(PageRouteBuilder(
- opaque: false,
- transitionDuration: Duration(milliseconds: 300),
- transitionsBuilder: (BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation, Widget child) {
- return FadeTransition(
- opacity: CurvedAnimation(parent: animation, curve: Curves.linear),
- child: child,
- );
- },
- pageBuilder: (BuildContext context, _, __) {
- return CompetitionInformation(houseInfo: houseInfo);
- }));
- }
- //改变滚动条
- void changeScroll() {
- Timer(Duration(seconds: 1), () {
- _tipController.animateTo(context.size.height, duration: Duration(milliseconds: 1500), curve: Curves.ease);
- });
- }
- //获取分秒
- String getSecondsMIn(int time) {
- if (time == null) {
- return '';
- } else {
- return ((time ~/ 1000 ~/ 60) % 60).toString() + '分' + (time ~/ 1000 % 60).toString() + '秒';
- }
- }
- @override
- void initState() {
- super.initState();
- tabList = [
- {'title': '房间信息', 'value': 1},
- {'title': '人员列表', 'value': 2}
- ];
- mController = TabController(
- length: tabList.length,
- vsync: this,
- );
- mController.addListener(() {
- setState(() {
- tabIndex = mController.index;
- });
- print(tabIndex);
- });
- _tipController = ScrollController();
- roomInfo = {};
- colorInfo = {
- '黄金': Color(0xFFF9D881),
- '白银': Color(0xFFAFCAD8),
- '青铜': Color(0xFFE18D50),
- };
- Future.delayed(Duration.zero, () async {
- Result res2 = await HttpManager.get('systemVariable/get', data: {'name': "ticketPrice"});
- if (res2.success) {
- print(res2.data);
- setState(() {
- race = double.parse(res2.data);
- });
- }
- // showSucessInfo(3);
- getRoomInfo('first');
- userInfo = StoreProvider.of<AppState>(context).state.userInfo;
- // showStart();
- });
- if (timer != null) {
- timer.cancel();
- }
- HttpServer.bind(InternetAddress.anyIPv4, 8899).then((s) {
- server = s;
- s.listen((HttpRequest request) {
- request.response.write('rtmp://202.79.174.56:1935/myapp/${playerInfo.id}?playerInfoId=${playerInfo.id}');
- request.response.close();
- });
- });
- }
- @override
- void dispose() {
- super.dispose();
- mController.dispose();
- if (timer != null) {
- timer.cancel();
- }
- if (server != null) {
- server.close(force: true);
- }
- }
- @override
- Widget build(BuildContext context) {
- ScreenUtil.instance = ScreenUtil(width: 375, height: 667)..init(context);
- int status = 0;
- if (houseInfo != null) {
- status = houseInfo.statusFlag;
- }
- return WillPopScope(
- child: Scaffold(
- appBar: AppBar(
- title: Container(
- child: TabBar(
- controller: mController,
- labelColor: Color(0xFFD4504B),
- unselectedLabelColor: Colors.white.withOpacity(0.5),
- labelStyle: TextStyle(fontSize: 16.0),
- indicatorColor: Color(0xFFC44D4B),
- indicatorWeight: 3,
- indicatorSize: TabBarIndicatorSize.label,
- tabs: tabList.map((item) {
- return Tab(
- text: item['title'],
- );
- }).toList(),
- ),
- ),
- centerTitle: true,
- elevation: 0,
- actions: <Widget>[
- Container(
- padding: EdgeInsets.only(right: 30, left: 20),
- child: Container(
- width: 24,
- ))
- ],
- ),
- body: Container(
- color: Color(0xFF2E3049),
- child: TabBarView(
- controller: mController,
- children: [_firstPage(), SecondPage(roomId: widget.roomId, status: status, houseInfo: houseInfo)],
- )),
- floatingActionButton: _joinBtn(),
- floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
- ),
- onWillPop: () {
- if (houseInfo == null || (houseInfo.statusFlag != 0) || !isJoin) {
- if (timer != null) {
- timer.cancel();
- }
- isPop = true;
- Toast.hide();
- Navigator.of(context).pop(true);
- return Future.value(false);
- } else {
- Toast.show(context, '比赛即将开始,暂不能离开房间', 1500, 'info');
- }
- return Future.value(false);
- },
- );
- }
- Widget _firstPage() {
- Map houseLevelInfo = roomInfo.isNotEmpty ? roomInfo['houseLevelInfo'] : {};
- String levelName = houseLevelInfo.containsKey('levelName') ? houseLevelInfo['levelName'] : '黄金';
- int joinMoney = houseLevelInfo.containsKey('feeRatio') && roomInfo.containsKey('bonus') ? houseLevelInfo['feeRatio'] * roomInfo['bonus'] : 0;
- String topImg = 'http://images.liqucn.com/img/h22/h70/img_localize_8e824debdd9ee29522690f36680e2d8e_600x337.png';
- int statuFlag = 0;
- if (houseInfo != null) {
- if (houseInfo.video != null) {
- topImg = houseInfo.video;
- }
- if (houseInfo.statusFlag != null) {
- statuFlag = houseInfo.statusFlag;
- }
- }
- String timeStr = '';
- int _time;
- if (houseInfo == null) {
- } else if (houseInfo.statusFlag == 0) {
- //房价未开始比赛
- _time = houseInfo.createTime + 600000 - DateTime.now().millisecondsSinceEpoch;
- timeStr = '最迟 ${getSecondsMIn(_time)} 后自动开始比赛';
- }
- // else if (isJoin && (houseInfo.statusFlag == 2 || houseInfo.statusFlag == 3)) {
- // _time = houseInfo.beginTime + 3600000 - DateTime.now().millisecondsSinceEpoch;
- // timeStr = '最迟 ${getSecondsMIn(_time)} 后结算';
- // }
- List jiangpaiImg = ['images/jiangpai_huangjin.png', 'images/jiangpai_baiyin.png', 'images/jiangpai_qingtong.png', 'images/jiangpai_bojin.png'];
- String img = '';
- if (playerInfo != null) {
- if (playerInfo.medal == 'platinum') {
- img = jiangpaiImg[3];
- } else if (playerInfo.medal == 'gold') {
- img = jiangpaiImg[0];
- } else if (playerInfo.medal == 'silver') {
- img = jiangpaiImg[1];
- } else if (playerInfo.medal == 'bronze') {
- img = jiangpaiImg[2];
- }
- }
- return LayoutBuilder(
- builder: (BuildContext context, BoxConstraints viewportConstraints) {
- return Container(
- child: RefreshIndicator(
- color: PRIMARY_COLOR,
- backgroundColor: Colors.white,
- displacement: 10,
- onRefresh: () async {
- await Future.delayed(const Duration(seconds: 1));
- },
- child: houseInfo != null
- ? SingleChildScrollView(
- controller: _tipController,
- physics: AlwaysScrollableScrollPhysics(),
- child: Column(
- children: <Widget>[
- houseInfo != null ? VideoWidget(videoSrc: houseInfo.video) : Container(),
- // Image.network(topImg, width: double.infinity),
- Container(
- padding: EdgeInsets.all(15),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: <Widget>[
- Container(
- child: Text(
- houseInfo != null ? houseInfo.houseName : '',
- style: TextStyle(color: Colors.white, fontSize: 20, fontWeight: FontWeight.w600),
- ),
- ),
- Container(
- width: 66,
- child: LinearButton(
- btntext: '竞赛须知',
- btnHeight: 28.0,
- textColor: Color(0xFF2E3049),
- textSize: 12.0,
- colorList: [Color(0xFFFFB726), Color(0xFFFFB726)],
- onTapHomeMenu: () {
- showNotice();
- },
- ),
- )
- // Container(
- // width: 5,
- // ),
- // houseInfo != null ? ScoreType(houseInfo.scoreType) : Container(),
- // Image.network(
- // houseLevelInfo.containsKey('icon')
- // ? houseLevelInfo['icon']
- // : '',
- // width: 14,
- // ),
- // Text(
- // houseLevelInfo.containsKey('levelName')
- // ? houseLevelInfo['levelName']
- // : '',
- // style:
- // TextStyle(color: colorInfo[levelName]),
- // )
- ],
- )),
- Container(
- padding: EdgeInsets.symmetric(horizontal: 15),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: <Widget>[
- Text(
- '本次任务:游戏中最短时间内杀戮${houseInfo.killnumber}人',
- style: TextStyle(fontSize: 14, fontWeight: FontWeight.w600, color: Color(0xFFFFB726)),
- ),
- Row(
- children: <Widget>[
- Image.asset(
- 'images/icon_renshu.png',
- ),
- Text(
- (houseInfo != null ? (houseInfo.playerNumber ?? 0).toString() : '0') +
- '/' +
- (houseInfo != null ? houseInfo.maxNumber.toString() : '0'),
- style: TextStyle(fontSize: 14, fontWeight: FontWeight.w500, color: Color(0xFFB1B2C0)),
- ),
- ],
- ),
- // Row(
- // children: <Widget>[
- // Image.asset(
- // 'images/house2.png',
- // ),
- // Text(
- // 'X${houseInfo.bonus}',
- // style: TextStyle(fontSize: 14, fontWeight: FontWeight.w500, color: Color(0xFFB1B2C0)),
- // ),
- // ],
- // ),
- // Container(
- // width: 30,
- // ),
- // Container(
- // width: 10,
- // ),
- ],
- ),
- ),
- Container(
- padding: EdgeInsets.symmetric(horizontal: 20, vertical: 10),
- margin: EdgeInsets.fromLTRB(15, 7, 15, 0),
- decoration: BoxDecoration(color: Color(0xFF23253C), borderRadius: BorderRadius.all(Radius.circular(4))),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: <Widget>[
- Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: <Widget>[
- Column(
- children: <Widget>[
- Row(
- children: <Widget>[
- Image.asset('images/icon_jifen.png'),
- Text(
- 'x${houseInfo.bonus * houseInfo.houseLevel.firstRatio / 100}/${houseInfo.maxNumber * race * houseInfo.houseLevel.entryCoin * houseInfo.houseLevel.firstRatio / 100}',
- style: TextStyle(color: Colors.white, fontSize: 14, fontWeight: FontWeight.w500),
- )
- ],
- ),
- Container(
- height: 3,
- ),
- Text('第一名', style: TextStyle(fontSize: 12, color: Color(0xFFB1B2C0)))
- ],
- ),
- Column(
- children: <Widget>[
- Row(
- children: <Widget>[
- Image.asset('images/icon_jifen.png'),
- Text(
- 'x${houseInfo.bonus * houseInfo.houseLevel.secondRatio / 100}/${houseInfo.maxNumber * race * houseInfo.houseLevel.entryCoin * houseInfo.houseLevel.secondRatio / 100}',
- style: TextStyle(color: Colors.white, fontSize: 14, fontWeight: FontWeight.w500),
- )
- ],
- ),
- Container(
- height: 3,
- ),
- Text('第二名', style: TextStyle(fontSize: 12, color: Color(0xFFB1B2C0)))
- ],
- ),
- Column(
- children: <Widget>[
- Row(
- children: <Widget>[
- Image.asset('images/icon_jifen.png'),
- Text(
- 'x${houseInfo.bonus * houseInfo.houseLevel.thirdRatio / 100}/${houseInfo.maxNumber * race * houseInfo.houseLevel.entryCoin * houseInfo.houseLevel.thirdRatio / 100}',
- style: TextStyle(color: Colors.white, fontSize: 14, fontWeight: FontWeight.w500),
- )
- ],
- ),
- Container(
- height: 3,
- ),
- Text('第三名', style: TextStyle(fontSize: 12, color: Color(0xFFB1B2C0)))
- ],
- )
- ],
- ),
- Container(
- height: 10,
- ),
- Text(
- '注:上方显示数值���前三名的“当前奖励/最高奖励”',
- style: TextStyle(color: Colors.white30, fontSize: 12),
- )
- ],
- )),
- timeStr != ''
- ? Container(
- decoration: BoxDecoration(
- color: Color(0xFF3E3348),
- borderRadius: BorderRadius.all(Radius.circular(4)),
- ),
- margin: EdgeInsets.fromLTRB(15, 15, 15, 0),
- padding: EdgeInsets.symmetric(vertical: 10),
- height: 40,
- width: double.infinity,
- child: Text(timeStr,
- textAlign: TextAlign.center, style: TextStyle(fontSize: 15, color: Color(0xFFD4504B), fontWeight: FontWeight.w500)),
- )
- : Container(),
- statuFlag != 4 && showWait
- ? Container(
- width: double.infinity,
- margin: EdgeInsets.fromLTRB(15, 10, 15, 0),
- padding: EdgeInsets.symmetric(vertical: 10),
- height: 40,
- decoration: BoxDecoration(color: Color(0xFF3E3348), borderRadius: BorderRadius.all(Radius.circular(4))),
- child: Text(
- '你已完成比赛,等待游戏解析中',
- style: TextStyle(
- color: Color(0xFFD4504B),
- fontSize: 15,
- ),
- textAlign: TextAlign.center,
- ))
- : Container(),
- statuFlag != 4 && showHelloWord
- ? Container(
- width: double.infinity,
- padding: EdgeInsets.all(15),
- margin: EdgeInsets.fromLTRB(15, 10, 15, 0),
- decoration: BoxDecoration(
- // gradient: LinearGradient(colors: [Color(0xFF464B6A), Color(0xFF35395E)], begin: Alignment.topCenter, end: Alignment.bottomCenter),
- color: Color(0xFF3A3E61),
- borderRadius:
- BorderRadius.only(topRight: Radius.circular(8), bottomLeft: Radius.circular(8), bottomRight: Radius.circular(8))),
- child: DefaultTextStyle(
- style: TextStyle(
- color: Colors.white,
- fontSize: 13.0,
- ),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: <Widget>[
- Text('亲爱的玩家:'),
- Text('欢迎来到有奖杀戮的世界!'),
- Text(
- '请保持手机电量在50%以上',
- style: TextStyle(fontWeight: FontWeight.w600, color: Color(0xFFFFB726)),
- ),
- Text.rich(TextSpan(children: [
- TextSpan(text: '倒计时结束或人数满员时会'),
- TextSpan(
- text: '自动',
- style: TextStyle(fontWeight: FontWeight.w600, color: Color(0xFFFFB726)),
- ),
- TextSpan(text: '开启比赛!请在此等候其他玩家加入')
- ])),
- Text.rich(TextSpan(children: [
- TextSpan(text: '完成本房间任务目标后,'),
- TextSpan(
- text: Platform.isIOS ? '切记立刻返回应用' : '切记立刻点击悬浮窗',
- style: TextStyle(fontWeight: FontWeight.w600, color: Color(0xFFFFB726)),
- ),
- TextSpan(text: '回到房间')
- ])),
- ],
- ),
- ))
- : Container(),
- statuFlag != 4
- ? TipsListContent(tipsList: roomTipsList, houseInfo: houseInfo)
- : Container(
- child: playerInfo != null && showJiexie
- ? Column(
- children: <Widget>[
- // ( playerInfo.statusFlag!=7&&playerInfo.statusFlag!=9&&!playerInfo.dataError)?
- Container(
- width: double.infinity,
- margin: EdgeInsets.symmetric(horizontal: 15, vertical: 10),
- padding: EdgeInsets.symmetric(vertical: 10),
- height: 40,
- decoration: BoxDecoration(color: Color(0xFF3E3348), borderRadius: BorderRadius.all(Radius.circular(4))),
- child: Text(
- playerInfo.statusFlag == 7 ||
- playerInfo.statusFlag == 9 ||
- playerInfo.dataError ||
- playerInfo.statusFlag == 6 ||
- playerInfo.killNumber < playerInfo.needkill
- ? (playerInfo.statusFlag == 6 ? '很遗憾您本次未参赛' : '很遗憾您本次任务失败,下次加油!')
- : (playerInfo.houseRank < 4 ? '恭喜您,您获得了第${playerInfo.houseRank}名!' : '很遗憾您未能进入前三名,下次加油!'),
- style: TextStyle(
- color: Color(0xFFD4504B),
- fontSize: 15,
- ),
- textAlign: TextAlign.center,
- ),
- ),
- (playerInfo.statusFlag != 7 &&
- playerInfo.statusFlag != 9 &&
- !playerInfo.dataError &&
- playerInfo.statusFlag != 6 &&
- playerInfo.killNumber >= playerInfo.needkill)
- ? Container(
- margin: EdgeInsets.symmetric(vertical: 10, horizontal: 15),
- padding: EdgeInsets.all(15),
- height: 140,
- decoration: BoxDecoration(
- color: Color(0xFF3A3E61),
- borderRadius: BorderRadius.only(
- topRight: Radius.circular(8), bottomLeft: Radius.circular(8), bottomRight: Radius.circular(8))),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: <Widget>[
- Text('比赛结果', style: TextStyle(color: Colors.white54, fontSize: 13)),
- Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: <Widget>[
- Text("参数成员 ", style: TextStyle(color: Colors.white, fontSize: 14)),
- Text("${houseInfo.playerNumber}人 ",
- style: TextStyle(color: Color(0xFFFFB726), fontWeight: FontWeight.w500, fontSize: 14))
- ],
- ),
- Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: <Widget>[
- Text("我的排名 ", style: TextStyle(color: Colors.white, fontSize: 14)),
- Text('${playerInfo.houseRank}',
- style: TextStyle(color: Color(0xFFFFB726), fontWeight: FontWeight.w500, fontSize: 14))
- ],
- ),
- Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: <Widget>[
- Text("获得积分 ", style: TextStyle(color: Colors.white, fontSize: 14)),
- Row(
- children: <Widget>[
- Image.asset('images/icon_jifen.png'),
- Text('x${playerInfo.bonus}',
- style: TextStyle(color: Color(0xFFFFB726), fontWeight: FontWeight.w500, fontSize: 14))
- ],
- )
- ],
- )
- ],
- ),
- )
- : playerInfo.statusFlag == 6
- ? Container(
- margin: EdgeInsets.symmetric(vertical: 10, horizontal: 15),
- padding: EdgeInsets.all(15),
- // height: 239,
- width: double.infinity,
- decoration: BoxDecoration(
- color: Color(0xFF3A3E61),
- borderRadius: BorderRadius.only(
- topRight: Radius.circular(8), bottomLeft: Radius.circular(8), bottomRight: Radius.circular(8))),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: <Widget>[
- Text(
- '造成此情况等原因可能是:',
- style: TextStyle(color: Colors.white54, fontSize: 13),
- ),
- Container(
- height: 10,
- ),
- Text(
- '1、倒计时结束内未点击开始',
- style: TextStyle(color: Colors.white, fontSize: 13),
- ),
- ],
- ),
- )
- : Container(
- margin: EdgeInsets.symmetric(vertical: 10, horizontal: 15),
- padding: EdgeInsets.all(15),
- // height: 239,
- width: double.infinity,
- decoration: BoxDecoration(
- color: Color(0xFF3A3E61),
- borderRadius: BorderRadius.only(
- topRight: Radius.circular(8), bottomLeft: Radius.circular(8), bottomRight: Radius.circular(8))),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: <Widget>[
- Text(
- '造成此情况等原因可能是:',
- style: TextStyle(color: Colors.white54, fontSize: 13),
- ),
- Container(
- height: 10,
- ),
- Text(
- '1、游戏中杀戮人数未到房间任务要求',
- style: TextStyle(color: Colors.white, fontSize: 13),
- ),
- Text(
- '2、没有实际进行游戏比赛 ',
- style: TextStyle(color: Colors.white, fontSize: 13),
- ),
- Text(
- '3、使用作弊手段进行游戏 ',
- style: TextStyle(color: Colors.white, fontSize: 13),
- ),
- Text(
- '4、手机性能或电量过低,在运行和平精英游戏时自动将我们平台APP从后台进程中退掉 ',
- style: TextStyle(color: Colors.white, fontSize: 13),
- ),
- Text(
- '5、游戏时间过长,没有在最大时间内返回平台APP点击结束游戏 ',
- style: TextStyle(color: Colors.white, fontSize: 13),
- ),
- ],
- ),
- )
- ],
- )
- : Container(),
- ),
- Container(
- width: double.infinity,
- height: 78,
- )
- ],
- ),
- )
- : Container()),
- );
- },
- );
- }
- Widget _joinBtn() {
- int joinMoney = houseInfo != null ? houseInfo.houseLevel.entryCoin : 0;
- int statusFlag = houseInfo != null ? houseInfo.statusFlag : 1;
- int playerStatus = playerInfo != null ? playerInfo.statusFlag : 0;
- List jiangpaiImg = ['金牌', '银牌', '铜牌', '铂金'];
- String img = '';
- if (mymedal != null) {
- if (mymedal == 'platinum') {
- img = jiangpaiImg[3];
- } else if (mymedal == 'gold') {
- img = jiangpaiImg[0];
- } else if (mymedal == 'silver') {
- img = jiangpaiImg[1];
- } else if (mymedal == 'bronze') {
- img = jiangpaiImg[2];
- }
- }
- int entryCoin = houseInfo != null ? houseInfo.houseLevel.entryCoin : 0;
- if (!isJoin && statusFlag == 0 && houseInfo.userId == StoreProvider.of<AppState>(context).state.userInfo.id) {
- return Container(
- padding: EdgeInsets.symmetric(vertical: 15, horizontal: 10),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: <Widget>[
- Container(
- width: 165,
- child: LinearButton(
- colorList: [Color(0xFF4F5386), Color(0xFF4F5386)],
- childWidget: Row(
- mainAxisAlignment: MainAxisAlignment.center,
- children: <Widget>[
- Image.asset(
- 'images/icon_menpiao.png',
- ),
- Container(
- margin: EdgeInsets.only(left: 6),
- child: Text(
- '×${entryCoin}',
- style: TextStyle(color: Colors.white, fontSize: 16, fontWeight: FontWeight.w500),
- ),
- ),
- Container(
- margin: EdgeInsets.only(left: 5),
- child: Text(
- '加入比赛',
- style: TextStyle(color: Colors.white, fontSize: 16, fontWeight: FontWeight.w500),
- ))
- ],
- ),
- onTapHomeMenu: () => joinRoom(),
- ),
- ),
- Container(
- width: 165,
- child: LinearButton(
- btntext: '开始竞赛',
- onTapHomeMenu: () {
- MyDialog.showDialog(context, '确认要开始比赛吗?', isCancel: true, onsubmit: () {
- print('开始');
- startGame();
- });
- },
- ),
- )
- ],
- ),
- );
- } else if (!isJoin && statusFlag == 0) {
- return Container(
- color: BG_SUB_COLOR,
- width: ScreenUtil().setWidth(375),
- height: 48 + ScreenUtil().setHeight(40),
- padding: EdgeInsets.only(top: ScreenUtil().setHeight(20), bottom: ScreenUtil().setHeight(20), left: 15, right: 15),
- child: LinearButton(
- childWidget: Row(
- mainAxisAlignment: MainAxisAlignment.center,
- children: <Widget>[
- Image.asset(
- 'images/icon_menpiao.png',
- width: 20,
- ),
- Container(
- margin: EdgeInsets.only(left: 6),
- child: Text(
- '×${entryCoin}',
- style: TextStyle(color: Colors.white, fontSize: 16, fontWeight: FontWeight.w500),
- ),
- ),
- Container(
- margin: EdgeInsets.only(left: 20),
- child: Text(
- '加入比赛',
- style: TextStyle(color: Colors.white, fontSize: 16, fontWeight: FontWeight.w500),
- ))
- ],
- ),
- onTapHomeMenu: () => joinRoom(),
- ),
- );
- } else if (!isJoin && statusFlag == 2) {
- return Container(
- width: double.infinity,
- padding: EdgeInsets.symmetric(horizontal: 15, vertical: 20),
- height: 88,
- child: LinearButton(btntext: '房间已经开始,加入通道关闭', colorList: [Color(0xFFB34A4A), Color(0xFFB34A4A)], textColor: Color(0xFF252532))
- // RaisedButton(
- // disabledColor: Color(0xFFD4504B),
- // disabledTextColor: Color(0xFF252532),
- // child: Text(
- // '房间已经开始,加入通道关闭',
- // style: TextStyle(fontSize: 16),
- // ),
- // onPressed: null,
- // ),
- );
- } else if (isJoin && statusFlag == 0) {
- int _time;
- if (houseInfo != null) {
- _time = houseInfo.createTime + 600000 - DateTime.now().millisecondsSinceEpoch;
- }
- if (houseInfo != null && houseInfo.createUser == StoreProvider.of<AppState>(context).state.userInfo.id.toString()) {
- return Container(
- width: double.infinity,
- padding: EdgeInsets.symmetric(horizontal: 15, vertical: 20),
- height: 88,
- child: LinearButton(
- childWidget: Center(
- child: Text.rich(TextSpan(children: [
- TextSpan(
- text: '开始比赛',
- style: TextStyle(fontSize: 16, color: Colors.white),
- ),
- // TextSpan(
- // text: '(${getSecondsMIn(_time)}秒后将自动开始)',
- // style: TextStyle(fontSize: 12),
- // )
- ])),
- ),
- onTapHomeMenu: () {
- MyDialog.showDialog(context, '确认要开始比赛吗?', isCancel: true, onsubmit: () {
- print('开始');
- startGame();
- });
- },
- )
- // RaisedButton(
- // child: Text.rich(TextSpan(children: [
- // TextSpan(
- // text: '开始比赛',
- // style: TextStyle(fontSize: 16),
- // ),
- // TextSpan(
- // text: '(${getSecondsMIn(_time)}秒后将自动开始)',
- // style: TextStyle(fontSize: 12),
- // )
- // ])),
- // onPressed: () {
- // MyDialog.showDialog(context, '确认要开始比赛吗?', isCancel: true,
- // onsubmit: () {
- // print('开始');
- // startGame();
- // });
- // },
- // ),
- );
- } else {
- return Container(
- width: double.infinity,
- padding: EdgeInsets.symmetric(horizontal: 15, vertical: 20),
- height: 88,
- child: LinearButton(btntext: '等待开始中', colorList: [Color(0xFFB34A4A), Color(0xFFB34A4A)], textColor: Color(0xFF252532)));
- }
- } else if (isJoin && statusFlag == 8) {
- return Container(
- width: double.infinity,
- padding: EdgeInsets.symmetric(horizontal: 15, vertical: 20),
- height: 88,
- child: LinearButton(btntext: '正在努力解析视频中', colorList: [Color(0xFFB34A4A), Color(0xFFB34A4A)], textColor: Color(0xFF252532))
- // RaisedButton(
- // disabledColor: Color(0xFFD4504B),
- // disabledTextColor: Color(0xFF252532),
- // child: Text(
- // '正在努力解析视频中',
- // style: TextStyle(fontSize: 16),
- // ),
- // onPressed: null,
- // ),
- );
- } else if (isJoin && (statusFlag == 2 || statusFlag == 3)) {
- int _time;
- if (houseInfo != null) {
- _time = houseInfo.beginTime + 1800000 - DateTime.now().millisecondsSinceEpoch;
- }
- return Container(
- width: double.infinity,
- padding: EdgeInsets.symmetric(horizontal: 15, vertical: 20),
- height: 88,
- child: LinearButton(btntext: '预计还有 ' + getSecondsMIn(_time) + ' 结算游戏', colorList: [Color(0xFFB34A4A), Color(0xFFB34A4A)], textColor: Color(0xFF252532)),
- );
- } else if (statusFlag == 4 && tabIndex == 0) {
- if (isJoin &&
- canAppeal &&
- appealState == 0 &&
- playerInfo != null &&
- (playerInfo.statusFlag == 9 ||
- playerInfo.statusFlag == 7 ||
- playerInfo.dataError ||
- playerInfo.statusFlag == 6 ||
- playerInfo.killNumber < playerInfo.needkill)) {
- return Container(
- width: double.infinity,
- padding: EdgeInsets.symmetric(horizontal: 15, vertical: 20),
- height: 88,
- child: LinearButton(
- btntext: '申诉结果',
- colorList: [Color(0xFFAF4946), Color(0xFFAF4946)],
- textColor: Colors.white,
- onTapHomeMenu: () async {
- final success = await Navigator.push(context, CupertinoPageRoute(builder: (context) => Appeal(playerInfo)));
- if (success != null && success) {
- Toast.show(context, '提交成功', 1500, 'success');
- setState(() {
- appealState = 1;
- });
- }
- },
- ));
- } else if (isJoin && canAppeal && appealState == 1) {
- return Container(
- width: double.infinity,
- padding: EdgeInsets.symmetric(horizontal: 15, vertical: 20),
- height: 88,
- child: LinearButton(btntext: '已提交申诉', colorList: [Color(0xFFB34A4A), Color(0xFFB34A4A)], textColor: Color(0xFF252532)));
- } else {
- return Container();
- }
- } else if (statusFlag == 4 && tabIndex == 1) {
- return Container(
- height: 48,
- child: LinearButton(
- childWidget: Padding(
- padding: EdgeInsets.symmetric(vertical: 9, horizontal: 20),
- child: Row(
- children: <Widget>[
- Container(
- width: 30,
- height: 30,
- margin: EdgeInsets.only(right: 10),
- child: CircleAvatar(
- backgroundImage: NetworkImage(userInfo.icon),
- ),
- ),
- Expanded(
- flex: 1,
- child: Text(
- userInfo.nickname,
- style: TextStyle(
- fontSize: 14,
- color: Color(0xFF252532),
- ),
- ),
- ),
- _myUrl != null
- ? Container(
- width: 68,
- height: 24,
- margin: EdgeInsets.only(right: 10),
- child: OutlineButton(
- textColor: BG_SUB_COLOR,
- borderSide: BorderSide(color: BG_SUB_COLOR),
- padding: EdgeInsets.all(0),
- highlightColor: PRIMARY_COLOR.withOpacity(0.8),
- highlightedBorderColor: BG_SUB_COLOR,
- child: Text(
- '查看回放',
- style: TextStyle(fontSize: 12),
- ),
- onPressed: () =>
- {Navigator.push(context, CupertinoPageRoute(builder: (context) => VideoPlayerPage(videoUrl: _myUrl, fileType: 'file')))},
- ),
- )
- : Container(),
- playerInfo != null
- ? Text(
- (playerInfo.statusFlag == 7 ||
- playerInfo.statusFlag == 9 ||
- playerInfo.dataError ||
- playerInfo.statusFlag == 6 ||
- playerInfo.killNumber < playerInfo.needkill)
- ? '任务失败'
- : '${playerInfo.houseRank}',
- style: TextStyle(fontSize: 14, color: Color(0xFF252532), fontWeight: FontWeight.w500),
- )
- : Container()
- ],
- ),
- ),
- ),
- );
- } else {
- return Container();
- }
- }
- }
- //房间的提示信息
- class TipsListContent extends StatelessWidget {
- TipsListContent({Key key, this.tipsList, this.houseInfo}) : super(key: key);
- final List<List<Map>> tipsList;
- final HouseInfo houseInfo;
- @override
- Widget build(BuildContext context) {
- return Container(
- // margin: EdgeInsets.only(top: 15),
- width: double.infinity,
- child: Column(
- children: _list(),
- ),
- );
- }
- List<Widget> _list() {
- List<Widget> myList = [];
- for (int i = 0; i < tipsList.length; i++) {
- myList.add(Tips(content: tipsList[i], showTongzhi: (tipsList[i].length == 1 && i == 0) ? true : false, houseInfo: houseInfo));
- }
- return myList;
- }
- }
- class Tips extends StatelessWidget {
- Tips({Key key, this.content, this.showTongzhi, this.houseInfo}) : super(key: key);
- final List<Map> content;
- final bool showTongzhi;
- final HouseInfo houseInfo;
- @override
- Widget build(BuildContext context) {
- return Container(
- padding: EdgeInsets.all(15),
- margin: EdgeInsets.fromLTRB(15, 10, 15, 0),
- decoration: BoxDecoration(
- // gradient: LinearGradient(colors: [Color(0xFF464B6A), Color(0xFF35395E)], begin: Alignment.topCenter, end: Alignment.bottomCenter),
- color: Color(0xFF3A3E61),
- borderRadius: BorderRadius.only(topRight: Radius.circular(8), bottomLeft: Radius.circular(8), bottomRight: Radius.circular(8))),
- child: Column(
- children: <Widget>[
- _textList(),
- ],
- ));
- }
- Widget _textList() {
- List<TextSpan> list = [];
- for (var item in content) {
- list.add(TextSpan(
- text: item['value'],
- style:
- item['type'] == 0 ? TextStyle(color: Colors.white, fontSize: 13) : TextStyle(fontWeight: FontWeight.w600, color: Color(0xFFFFB726), fontSize: 13),
- ));
- }
- return Text.rich(TextSpan(children: list));
- }
- }
- //比赛结束排名
- class RankContent extends StatefulWidget {
- RankContent({Key key, this.roomId}) : super(key: key);
- final String roomId; // 用来储存传递过来的值
- @override
- RankContentState createState() => RankContentState();
- }
- class RankContentState extends State<RankContent> {
- List<PlayerInfo> topList = [];
- Future<void> getTopList() async {
- Toast.show(context, '加载中', -1, 'loading');
- Result res = await HttpManager.get('playerInfo/rankPage', data: {'houseId': widget.roomId, 'currentPage': 1, 'pageNumber': 3});
- Toast.hide();
- List<PlayerInfo> list = [];
- if (res.success) {
- for (var item in res.data['pp']) {
- PlayerInfo jonPlayer = PlayerInfo.fromJson(item);
- list.add(jonPlayer);
- }
- } else {}
- setState(() {
- topList = list;
- });
- }
- @override
- void initState() {
- super.initState();
- Future.delayed(Duration.zero, () {
- getTopList();
- });
- }
- @override
- Widget build(BuildContext context) {
- return Container(
- width: double.infinity,
- height: 180,
- margin: EdgeInsets.only(top: 15),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.center,
- crossAxisAlignment: CrossAxisAlignment.end,
- children: <Widget>[_rankItem(2), _rankItem(1), _rankItem(3)],
- ),
- );
- }
- Widget _rankItem(int _num) {
- if (_num > topList.length) {
- return Container(
- width: 107,
- height: 60,
- );
- }
- List colorList = [
- [Color(0xFFD48E00), Color(0xFFFECF01)],
- [Color(0xFFC5C5C5), Color(0xFFE3E3E3)],
- [Color(0xFFE77023), Color(0xFFF89E58)]
- ];
- List imgList = ['images/jiangpai_huangjin.png', 'images/jiangpai_baiyin.png', 'images/jiangpai_qingtong.png', 'images/jiangpai_bojin.png'];
- String img = '';
- if (topList[_num - 1].medal == 'platinum') {
- img = imgList[3];
- } else if (topList[_num - 1].medal == 'gold') {
- img = imgList[0];
- } else if (topList[_num - 1].medal == 'silver') {
- img = imgList[1];
- } else if (topList[_num - 1].medal == 'bronze') {
- img = imgList[2];
- }
- return Container(
- padding: EdgeInsets.only(left: 15, right: 15, top: _num == 1 ? 0 : 15),
- width: 107,
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.center,
- children: <Widget>[
- Container(
- child: Stack(
- children: <Widget>[
- Container(
- margin: EdgeInsets.only(top: 17, bottom: 20),
- width: _num == 1 ? 70 : 60,
- height: _num == 1 ? 70 : 60,
- decoration: BoxDecoration(
- gradient: LinearGradient(colors: colorList[_num - 1], begin: Alignment.topLeft, end: Alignment.bottomRight),
- borderRadius: BorderRadius.all(Radius.circular(100)),
- ),
- child: Center(
- child: Container(
- width: _num == 1 ? 60 : 50,
- height: _num == 1 ? 60 : 50,
- child: CircleAvatar(backgroundImage: NetworkImage(topList[_num - 1].userInfo.icon)),
- )),
- ),
- Positioned(
- bottom: 0,
- child: Center(
- child: Image.asset(
- 'images/ph_yinpai_no' + '$_num.png',
- width: 67,
- ),
- ),
- ),
- Positioned(
- top: 0,
- left: 19,
- child: Center(
- child: img != ''
- ? Image.asset(
- img,
- )
- : Container(),
- ),
- )
- ],
- ),
- ),
- Text(
- topList[_num - 1].userInfo.nickname,
- style: TextStyle(
- color: Color(0xFFFDC372),
- fontSize: 12,
- ),
- overflow: TextOverflow.ellipsis,
- textAlign: TextAlign.center,
- ),
- // SizedBox(
- // height: 5,
- // ),
- // Row(
- // mainAxisAlignment: MainAxisAlignment.center,
- // children: <Widget>[
- // Image.asset('images/icon_jinbi_xiao_hong.png', width: 20),
- // Text('×' + (topList[_num - 1].bonus != null ? topList[_num - 1].bonus.toString() : '0'), style: TextStyle(color: PRIMARY_COLOR, fontSize: 12))
- // ],
- // )
- ],
- ),
- );
- }
- }
|