|
|
@@ -1,51 +1,33 @@
|
|
|
-import 'dart:async';
|
|
|
-
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
import 'package:flutter/material.dart';
|
|
|
-import 'package:flutter_html/flutter_html.dart';
|
|
|
import 'package:flutter_redux/flutter_redux.dart';
|
|
|
-import 'package:url_launcher/url_launcher.dart';
|
|
|
import 'package:wanna_battle/redux/AppState.dart';
|
|
|
import '../Constants.dart';
|
|
|
import '../styles/colors.dart';
|
|
|
-import '../styles/totast.dart';
|
|
|
import '../widget/VideoWidget.dart';
|
|
|
import '../model/HouseInfo.dart';
|
|
|
import '../widget/Dialog.dart';
|
|
|
import './CompetitionNotice.dart';
|
|
|
import '../model/PlayerInfo.dart';
|
|
|
-import 'StartWindow.dart';
|
|
|
-import '../net/Result.dart';
|
|
|
-import '../net/HttpManager.dart';
|
|
|
-import '../plugins/ScreenStramPlugin.dart';
|
|
|
|
|
|
class RoomInfoDetail extends StatefulWidget {
|
|
|
- RoomInfoDetail(this.houseInfo, {Key key, this.onStart}) : super(key: key);
|
|
|
+ RoomInfoDetail(this.houseInfo, this.playerInfo, {Key key, this.onStart, this.finishedPlayerNum = 0}) : super(key: key);
|
|
|
|
|
|
final HouseInfo houseInfo;
|
|
|
+ final PlayerInfo playerInfo;
|
|
|
final VoidCallback onStart;
|
|
|
- _RoomInfoDetailState state;
|
|
|
-
|
|
|
- void setHouseInfo(HouseInfo houseInfo) {
|
|
|
- state.setHouseInfo(houseInfo);
|
|
|
- }
|
|
|
+ final int finishedPlayerNum;
|
|
|
|
|
|
@override
|
|
|
State<StatefulWidget> createState() {
|
|
|
- state = _RoomInfoDetailState();
|
|
|
- return state;
|
|
|
+ return RoomInfoDetailState();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-class _RoomInfoDetailState extends State<RoomInfoDetail> {
|
|
|
- HouseInfo mHouseInfo;
|
|
|
- PlayerInfo mPlayerInfo;
|
|
|
- int finishedPlayerNum;
|
|
|
-
|
|
|
+class RoomInfoDetailState extends State<RoomInfoDetail> {
|
|
|
@override
|
|
|
void initState() {
|
|
|
super.initState();
|
|
|
- mHouseInfo = widget.houseInfo;
|
|
|
}
|
|
|
|
|
|
@override
|
|
|
@@ -55,7 +37,7 @@ class _RoomInfoDetailState extends State<RoomInfoDetail> {
|
|
|
children: <Widget>[
|
|
|
ListView(
|
|
|
children: <Widget>[
|
|
|
- mHouseInfo != null ? VideoWidget(videoSrc: mHouseInfo.video) : Container(),
|
|
|
+ widget.houseInfo != null ? VideoWidget(videoSrc: widget.houseInfo.video) : Container(),
|
|
|
Container(
|
|
|
height: 60,
|
|
|
padding: EdgeInsets.fromLTRB(15, 0, 15, 0),
|
|
|
@@ -63,7 +45,7 @@ class _RoomInfoDetailState extends State<RoomInfoDetail> {
|
|
|
children: <Widget>[
|
|
|
Expanded(
|
|
|
child: Text(
|
|
|
- mHouseInfo.houseName,
|
|
|
+ widget.houseInfo.houseName,
|
|
|
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold, color: Colors.white),
|
|
|
),
|
|
|
),
|
|
|
@@ -75,7 +57,7 @@ class _RoomInfoDetailState extends State<RoomInfoDetail> {
|
|
|
width: 20,
|
|
|
),
|
|
|
Text(
|
|
|
- (mHouseInfo?.playerNumber ?? 0).toString() + '/' + (mHouseInfo?.maxNumber ?? 0).toString(),
|
|
|
+ (widget.houseInfo?.playerNumber ?? 0).toString() + '/' + (widget.houseInfo?.maxNumber ?? 0).toString(),
|
|
|
style: TextStyle(fontSize: 14, fontWeight: FontWeight.bold, color: Color(0xFFB1B2C0)),
|
|
|
),
|
|
|
],
|
|
|
@@ -94,7 +76,13 @@ class _RoomInfoDetailState extends State<RoomInfoDetail> {
|
|
|
child: CupertinoButton(
|
|
|
padding: EdgeInsets.all(0),
|
|
|
onPressed: () {
|
|
|
- Toast.show(context, '比赛即将开始,暂不能离开房间', 1500, 'info');
|
|
|
+ if (widget.houseInfo.statusFlag == 0) {
|
|
|
+ showCustomDialog(context, '比赛即将开始,确定离开房间?', isCancel: true, onsubmit: () {
|
|
|
+ Navigator.of(context).pop();
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ Navigator.of(context).pop();
|
|
|
+ }
|
|
|
},
|
|
|
child: Text(
|
|
|
'返回锦标赛',
|
|
|
@@ -123,32 +111,24 @@ class _RoomInfoDetailState extends State<RoomInfoDetail> {
|
|
|
],
|
|
|
),
|
|
|
),
|
|
|
- Container(
|
|
|
- height: 40,
|
|
|
- margin: EdgeInsets.fromLTRB(15, 10, 15, 0),
|
|
|
- decoration: BoxDecoration(
|
|
|
- color: Color(0x1AFFFF00),
|
|
|
- border: Border.all(
|
|
|
- width: 1,
|
|
|
- color: Colors.yellow,
|
|
|
- )),
|
|
|
- child: Row(
|
|
|
- mainAxisAlignment: MainAxisAlignment.spaceAround,
|
|
|
- children: <Widget>[
|
|
|
- Text('积分 加成+0%', style: TextStyle(color: Colors.yellow, fontSize: 12)),
|
|
|
- Text('保底 0积分', style: TextStyle(color: Colors.yellow, fontSize: 12)),
|
|
|
- ],
|
|
|
- ),
|
|
|
- ),
|
|
|
- Container(
|
|
|
- margin: EdgeInsets.fromLTRB(15, 20, 15, 0),
|
|
|
- color: SUB_COLOR,
|
|
|
- padding: EdgeInsets.all(15),
|
|
|
- child: Text.rich(
|
|
|
- tipText(),
|
|
|
- style: TextStyle(color: Colors.white, fontSize: 13),
|
|
|
- ),
|
|
|
- )
|
|
|
+ // Container(
|
|
|
+ // height: 40,
|
|
|
+ // margin: EdgeInsets.fromLTRB(15, 10, 15, 0),
|
|
|
+ // decoration: BoxDecoration(
|
|
|
+ // color: Color(0x1AFFFF00),
|
|
|
+ // border: Border.all(
|
|
|
+ // width: 1,
|
|
|
+ // color: Colors.yellow,
|
|
|
+ // )),
|
|
|
+ // child: Row(
|
|
|
+ // mainAxisAlignment: MainAxisAlignment.spaceAround,
|
|
|
+ // children: <Widget>[
|
|
|
+ // Text('积分 加成+0%', style: TextStyle(color: Colors.yellow, fontSize: 12)),
|
|
|
+ // Text('保底 0积分', style: TextStyle(color: Colors.yellow, fontSize: 12)),
|
|
|
+ // ],
|
|
|
+ // ),
|
|
|
+ // ),
|
|
|
+ tipText()
|
|
|
],
|
|
|
),
|
|
|
Align(
|
|
|
@@ -160,39 +140,200 @@ class _RoomInfoDetailState extends State<RoomInfoDetail> {
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- TextSpan tipText() {
|
|
|
- switch (mHouseInfo.statusFlag) {
|
|
|
+ Widget tipText() {
|
|
|
+ switch (widget.houseInfo.statusFlag) {
|
|
|
case HouseStatus.WAIT:
|
|
|
case HouseStatus.READY:
|
|
|
- return TextSpan(
|
|
|
- text: '待倒计时结束或人数满员时会自动开启比赛,房主也可以手动开启比赛,请在此页面耐心等待其他人的加入,'
|
|
|
- '加入房间后再次退出则视为自动放弃比赛,快快点击右上角分享给好友加入战局吧');
|
|
|
-
|
|
|
+ return Container(
|
|
|
+ margin: EdgeInsets.fromLTRB(15, 20, 15, 0),
|
|
|
+ color: SUB_COLOR,
|
|
|
+ padding: EdgeInsets.all(15),
|
|
|
+ child: Text.rich(
|
|
|
+ TextSpan(
|
|
|
+ text: '待倒计时结束或人数满员时会自动开启比赛,请在此页面耐心等待其他人的加入,'
|
|
|
+ '祝您取得好成绩'),
|
|
|
+ style: TextStyle(color: Colors.white, fontSize: 13),
|
|
|
+ ),
|
|
|
+ );
|
|
|
case HouseStatus.START:
|
|
|
case HouseStatus.END:
|
|
|
case HouseStatus.ANALYSIS:
|
|
|
- final time = mHouseInfo.beginTime + 3600000 - DateTime.now().millisecondsSinceEpoch;
|
|
|
- return TextSpan(children: <TextSpan>[
|
|
|
- TextSpan(text: (mPlayerInfo?.statusFlag ?? 0 == PlayerStatus.END) ? '你已完成本次比赛,当前完成人数' : '当前完成人数'),
|
|
|
- TextSpan(text: '${finishedPlayerNum ?? 0}'),
|
|
|
- TextSpan(text: '比赛需要等待所有人完成后方可结算积分<br>最迟结算时间还剩'),
|
|
|
- TextSpan(text: '${getCountDown(time)}'),
|
|
|
- TextSpan(text: ',你可以先去参加其他竞赛,稍后在“个人中心-我的战绩”中可以查看本次竞赛排名及积分详情')
|
|
|
- ]);
|
|
|
+ final time = widget.houseInfo.beginTime + 3600000 - DateTime.now().millisecondsSinceEpoch;
|
|
|
+ return Container(
|
|
|
+ margin: EdgeInsets.fromLTRB(15, 20, 15, 0),
|
|
|
+ color: SUB_COLOR,
|
|
|
+ padding: EdgeInsets.all(15),
|
|
|
+ child: Text.rich(
|
|
|
+ TextSpan(children: <TextSpan>[
|
|
|
+ TextSpan(text: ((widget.playerInfo?.statusFlag ?? 0) == PlayerStatus.END) ? '你已完成本次比赛,当前完成人数' : '当前完成人数'),
|
|
|
+ TextSpan(text: ' ${widget.finishedPlayerNum ?? 0} ', style: TextStyle(color: Colors.yellow, fontWeight: FontWeight.bold)),
|
|
|
+ TextSpan(text: '比赛需要等待所有人完成后方可结算积分最迟结算时间还剩'),
|
|
|
+ TextSpan(text: ' ${getCountDown(time)} ', style: TextStyle(color: Colors.yellow, fontWeight: FontWeight.bold)),
|
|
|
+ TextSpan(text: ',你可以先去参加其他竞赛,稍后在“个人中心-我的战绩”中可以查看本次竞赛排名及积分详情'),
|
|
|
+ ]),
|
|
|
+ style: TextStyle(color: Colors.white, fontSize: 13),
|
|
|
+ ),
|
|
|
+ );
|
|
|
break;
|
|
|
-
|
|
|
case HouseStatus.SETTLEMENT:
|
|
|
- return TextSpan(text: '当前比赛已结束,可在参赛成员列表可查看当前比赛详细排名情况');
|
|
|
+ return Column(
|
|
|
+ children: <Widget>[
|
|
|
+ Container(
|
|
|
+ margin: EdgeInsets.fromLTRB(15, 20, 15, 0),
|
|
|
+ color: SUB_COLOR,
|
|
|
+ padding: EdgeInsets.fromLTRB(15, 15, 0, 15),
|
|
|
+ child: Column(
|
|
|
+ mainAxisAlignment: MainAxisAlignment.center,
|
|
|
+ crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
|
+ children: <Widget>[
|
|
|
+ Text(
|
|
|
+ '游戏结果',
|
|
|
+ textAlign: TextAlign.left,
|
|
|
+ style: TextStyle(color: Color(0x99FFFFFF)),
|
|
|
+ ),
|
|
|
+ Container(
|
|
|
+ margin: EdgeInsets.only(top: 10),
|
|
|
+ child: Row(
|
|
|
+ children: <Widget>[
|
|
|
+ Text(
|
|
|
+ '名次',
|
|
|
+ style: TextStyle(color: Colors.white, fontSize: 14),
|
|
|
+ ),
|
|
|
+ Expanded(
|
|
|
+ child: Container(
|
|
|
+ margin: EdgeInsets.only(left: 5),
|
|
|
+ child: Text(
|
|
|
+ widget.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(
|
|
|
+ (widget.playerInfo?.liveTime ?? '') + '分钟',
|
|
|
+ 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(
|
|
|
+ widget.playerInfo?.score?.toString() ?? '',
|
|
|
+ style: TextStyle(color: Colors.yellow, fontSize: 14, fontWeight: FontWeight.bold),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ Container(
|
|
|
+ margin: EdgeInsets.fromLTRB(15, 5, 15, 20),
|
|
|
+ color: SUB_COLOR,
|
|
|
+ padding: EdgeInsets.all(15),
|
|
|
+ child: Column(
|
|
|
+ mainAxisAlignment: MainAxisAlignment.center,
|
|
|
+ crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
|
+ children: <Widget>[
|
|
|
+ Text(
|
|
|
+ '比赛结果',
|
|
|
+ textAlign: TextAlign.left,
|
|
|
+ style: TextStyle(color: Color(0x99FFFFFF)),
|
|
|
+ ),
|
|
|
+ Container(
|
|
|
+ margin: EdgeInsets.only(top: 10),
|
|
|
+ child: Row(
|
|
|
+ children: <Widget>[
|
|
|
+ Expanded(
|
|
|
+ child: Text(
|
|
|
+ '参赛成员',
|
|
|
+ style: TextStyle(color: Colors.white, fontSize: 14),
|
|
|
+ textAlign: TextAlign.left,
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ Text(
|
|
|
+ widget.houseInfo?.playerNumber?.toString() ?? '',
|
|
|
+ style: TextStyle(color: Colors.yellow, fontWeight: FontWeight.bold),
|
|
|
+ )
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ Container(
|
|
|
+ margin: EdgeInsets.only(top: 10),
|
|
|
+ child: Row(
|
|
|
+ children: <Widget>[
|
|
|
+ Expanded(
|
|
|
+ child: Text(
|
|
|
+ '我的排名',
|
|
|
+ style: TextStyle(color: Colors.white, fontSize: 14),
|
|
|
+ textAlign: TextAlign.left,
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ Text(
|
|
|
+ widget.playerInfo?.houseRank?.toString() ?? '',
|
|
|
+ style: TextStyle(color: Colors.yellow, fontWeight: FontWeight.bold),
|
|
|
+ )
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ Container(
|
|
|
+ margin: EdgeInsets.only(top: 10),
|
|
|
+ child: Row(
|
|
|
+ children: <Widget>[
|
|
|
+ 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(
|
|
|
+ widget.playerInfo?.points?.toString() ?? '0',
|
|
|
+ style: TextStyle(color: Colors.yellow, fontWeight: FontWeight.bold),
|
|
|
+ )
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ Container(
|
|
|
+ margin: EdgeInsets.only(top: 5),
|
|
|
+ child: Text(
|
|
|
+ '吃鸡可额外获得10积分',
|
|
|
+ style: TextStyle(color: PRIMARY_COLOR, fontSize: 12),
|
|
|
+ ),
|
|
|
+ )
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ )
|
|
|
+ ],
|
|
|
+ );
|
|
|
}
|
|
|
- return TextSpan(text: '');
|
|
|
+ return Container();
|
|
|
}
|
|
|
|
|
|
Widget roomBtn() {
|
|
|
- switch (mHouseInfo.statusFlag) {
|
|
|
+ switch (widget.houseInfo.statusFlag) {
|
|
|
case HouseStatus.WAIT:
|
|
|
case HouseStatus.READY:
|
|
|
{
|
|
|
- if (mHouseInfo.createUser == StoreProvider.of<AppState>(context).state.userInfo.id.toString()) {
|
|
|
+ if (widget.houseInfo.createUser == StoreProvider.of<AppState>(context).state.userInfo.id.toString()) {
|
|
|
return startBtn();
|
|
|
} else {
|
|
|
return countDownBtn();
|
|
|
@@ -202,7 +343,7 @@ class _RoomInfoDetailState extends State<RoomInfoDetail> {
|
|
|
case HouseStatus.START:
|
|
|
case HouseStatus.END:
|
|
|
{
|
|
|
- final time = mHouseInfo.beginTime + 3600000 - DateTime.now().millisecondsSinceEpoch;
|
|
|
+ final time = widget.houseInfo.beginTime + 3600000 - DateTime.now().millisecondsSinceEpoch;
|
|
|
return statusBtn(time > 0 ? ('最迟在' + getCountDown(time) + '后结算') : '等待结算');
|
|
|
}
|
|
|
break;
|
|
|
@@ -217,7 +358,7 @@ class _RoomInfoDetailState extends State<RoomInfoDetail> {
|
|
|
}
|
|
|
|
|
|
Widget startBtn() {
|
|
|
- final time = mHouseInfo.createTime + 600000 - DateTime.now().millisecondsSinceEpoch;
|
|
|
+ final time = widget.houseInfo.createTime + 600000 - DateTime.now().millisecondsSinceEpoch;
|
|
|
return Container(
|
|
|
margin: EdgeInsets.fromLTRB(15, 0, 15, 10),
|
|
|
child: SizedBox(
|
|
|
@@ -249,7 +390,7 @@ class _RoomInfoDetailState extends State<RoomInfoDetail> {
|
|
|
}
|
|
|
|
|
|
Widget countDownBtn() {
|
|
|
- final time = mHouseInfo.createTime + 600000 - DateTime.now().millisecondsSinceEpoch;
|
|
|
+ final time = widget.houseInfo.createTime + 600000 - DateTime.now().millisecondsSinceEpoch;
|
|
|
String text = '';
|
|
|
if (time >= 0) {
|
|
|
text = '预计${getCountDown(time)}后开始比赛';
|
|
|
@@ -291,12 +432,6 @@ class _RoomInfoDetailState extends State<RoomInfoDetail> {
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- void setHouseInfo(HouseInfo houseInfo) {
|
|
|
- setState(() {
|
|
|
- mHouseInfo = houseInfo;
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
String getCountDown(int time) {
|
|
|
if (time == null) {
|
|
|
return '';
|