|
|
@@ -1,17 +1,29 @@
|
|
|
+import 'dart:async';
|
|
|
+
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
import 'package:flutter/material.dart';
|
|
|
-import 'package:wanna_battle/Constants.dart';
|
|
|
-import 'package:wanna_battle/styles/colors.dart';
|
|
|
-import 'package:wanna_battle/styles/totast.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}) : super(key: key);
|
|
|
+ RoomInfoDetail(this.houseInfo, {Key key, this.onStart}) : super(key: key);
|
|
|
|
|
|
final HouseInfo houseInfo;
|
|
|
+ final VoidCallback onStart;
|
|
|
_RoomInfoDetailState state;
|
|
|
|
|
|
void setHouseInfo(HouseInfo houseInfo) {
|
|
|
@@ -26,12 +38,14 @@ class RoomInfoDetail extends StatefulWidget {
|
|
|
}
|
|
|
|
|
|
class _RoomInfoDetailState extends State<RoomInfoDetail> {
|
|
|
- HouseInfo houseInfo;
|
|
|
+ HouseInfo mHouseInfo;
|
|
|
+ PlayerInfo mPlayerInfo;
|
|
|
+ int finishedPlayerNum;
|
|
|
|
|
|
@override
|
|
|
void initState() {
|
|
|
super.initState();
|
|
|
- houseInfo = widget.houseInfo;
|
|
|
+ mHouseInfo = widget.houseInfo;
|
|
|
}
|
|
|
|
|
|
@override
|
|
|
@@ -41,7 +55,7 @@ class _RoomInfoDetailState extends State<RoomInfoDetail> {
|
|
|
children: <Widget>[
|
|
|
ListView(
|
|
|
children: <Widget>[
|
|
|
- houseInfo != null ? VideoWidget(videoSrc: houseInfo.video) : Container(),
|
|
|
+ mHouseInfo != null ? VideoWidget(videoSrc: mHouseInfo.video) : Container(),
|
|
|
Container(
|
|
|
height: 60,
|
|
|
padding: EdgeInsets.fromLTRB(15, 0, 15, 0),
|
|
|
@@ -49,7 +63,7 @@ class _RoomInfoDetailState extends State<RoomInfoDetail> {
|
|
|
children: <Widget>[
|
|
|
Expanded(
|
|
|
child: Text(
|
|
|
- houseInfo.houseName,
|
|
|
+ mHouseInfo.houseName,
|
|
|
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold, color: Colors.white),
|
|
|
),
|
|
|
),
|
|
|
@@ -61,9 +75,7 @@ class _RoomInfoDetailState extends State<RoomInfoDetail> {
|
|
|
width: 20,
|
|
|
),
|
|
|
Text(
|
|
|
- (houseInfo != null ? (houseInfo.playerNumber ?? 0).toString() : '0') +
|
|
|
- '/' +
|
|
|
- (houseInfo != null ? houseInfo.maxNumber.toString() : '0'),
|
|
|
+ (mHouseInfo?.playerNumber ?? 0).toString() + '/' + (mHouseInfo?.maxNumber ?? 0).toString(),
|
|
|
style: TextStyle(fontSize: 14, fontWeight: FontWeight.bold, color: Color(0xFFB1B2C0)),
|
|
|
),
|
|
|
],
|
|
|
@@ -128,34 +140,168 @@ class _RoomInfoDetailState extends State<RoomInfoDetail> {
|
|
|
],
|
|
|
),
|
|
|
),
|
|
|
+ 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),
|
|
|
+ ),
|
|
|
+ )
|
|
|
],
|
|
|
),
|
|
|
Align(
|
|
|
alignment: Alignment.bottomCenter,
|
|
|
- child: SafeArea(
|
|
|
- child: Container(
|
|
|
- height: 48,
|
|
|
- margin: EdgeInsets.fromLTRB(15, 0, 15, 10),
|
|
|
- color: PRIMARY_COLOR,
|
|
|
- ),
|
|
|
- ),
|
|
|
+ child: SafeArea(child: roomBtn()),
|
|
|
)
|
|
|
],
|
|
|
),
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- Widget tip() {
|
|
|
- switch (houseInfo.statusFlag) {
|
|
|
+ TextSpan tipText() {
|
|
|
+ switch (mHouseInfo.statusFlag) {
|
|
|
case HouseStatus.WAIT:
|
|
|
case HouseStatus.READY:
|
|
|
+ return TextSpan(
|
|
|
+ text: '待倒计时结束或人数满员时会自动开启比赛,房主也可以手动开启比赛,请在此页面耐心等待其他人的加入,'
|
|
|
+ '加入房间后再次退出则视为自动放弃比赛,快快点击右上角分享给好友加入战局吧');
|
|
|
+
|
|
|
+ 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: ',你可以先去参加其他竞赛,稍后在“个人中心-我的战绩”中可以查看本次竞赛排名及积分详情')
|
|
|
+ ]);
|
|
|
+ break;
|
|
|
+
|
|
|
+ case HouseStatus.SETTLEMENT:
|
|
|
+ return TextSpan(text: '当前比赛已结束,可在参赛成员列表可查看当前比赛详细排名情况');
|
|
|
+ }
|
|
|
+ return TextSpan(text: '');
|
|
|
+ }
|
|
|
+
|
|
|
+ Widget roomBtn() {
|
|
|
+ switch (mHouseInfo.statusFlag) {
|
|
|
+ case HouseStatus.WAIT:
|
|
|
+ case HouseStatus.READY:
|
|
|
+ {
|
|
|
+ if (mHouseInfo.createUser == StoreProvider.of<AppState>(context).state.userInfo.id.toString()) {
|
|
|
+ return startBtn();
|
|
|
+ } else {
|
|
|
+ return countDownBtn();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case HouseStatus.START:
|
|
|
+ case HouseStatus.END:
|
|
|
+ {
|
|
|
+ final time = mHouseInfo.beginTime + 3600000 - DateTime.now().millisecondsSinceEpoch;
|
|
|
+ return statusBtn(time > 0 ? ('最迟在' + getCountDown(time) + '后结算') : '等待结算');
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case HouseStatus.SETTLEMENT:
|
|
|
+ return statusBtn('已结束');
|
|
|
+ break;
|
|
|
+ case HouseStatus.ANALYSIS:
|
|
|
+ return statusBtn('结算中...');
|
|
|
+ default:
|
|
|
+ return statusBtn('已结束', color: Color(0xFF4F5C87));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Widget startBtn() {
|
|
|
+ final time = mHouseInfo.createTime + 600000 - DateTime.now().millisecondsSinceEpoch;
|
|
|
+ return Container(
|
|
|
+ margin: EdgeInsets.fromLTRB(15, 0, 15, 10),
|
|
|
+ child: SizedBox(
|
|
|
+ height: 48,
|
|
|
+ width: double.infinity,
|
|
|
+ child: FlatButton(
|
|
|
+ color: PRIMARY_COLOR,
|
|
|
+ child: Text.rich(
|
|
|
+ TextSpan(children: [
|
|
|
+ TextSpan(
|
|
|
+ text: '开始比赛 ',
|
|
|
+ style: TextStyle(fontSize: 16),
|
|
|
+ ),
|
|
|
+ TextSpan(
|
|
|
+ text: '(${getCountDown(time)}后将自动开始)',
|
|
|
+ style: TextStyle(fontSize: 12, fontWeight: FontWeight.normal),
|
|
|
+ )
|
|
|
+ ]),
|
|
|
+ style: TextStyle(color: Colors.white, fontSize: 16, fontWeight: FontWeight.bold),
|
|
|
+ ),
|
|
|
+ onPressed: () {
|
|
|
+ if (widget.onStart != null) {
|
|
|
+ widget.onStart();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ Widget countDownBtn() {
|
|
|
+ final time = mHouseInfo.createTime + 600000 - DateTime.now().millisecondsSinceEpoch;
|
|
|
+ String text = '';
|
|
|
+ if (time >= 0) {
|
|
|
+ text = '预计${getCountDown(time)}后开始比赛';
|
|
|
+ } else {
|
|
|
+ text = '即将开始比赛';
|
|
|
}
|
|
|
- return Container();
|
|
|
+ return Container(
|
|
|
+ margin: EdgeInsets.fromLTRB(15, 0, 15, 10),
|
|
|
+ height: 48,
|
|
|
+ color: PRIMARY_COLOR,
|
|
|
+ child: Center(
|
|
|
+ child: Text(
|
|
|
+ text,
|
|
|
+ style: TextStyle(
|
|
|
+ color: Color(0xFF252532),
|
|
|
+ fontSize: 16,
|
|
|
+ fontWeight: FontWeight.bold,
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ Widget statusBtn(text, {Color color = PRIMARY_COLOR}) {
|
|
|
+ return Container(
|
|
|
+ margin: EdgeInsets.fromLTRB(15, 0, 15, 10),
|
|
|
+ height: 48,
|
|
|
+ color: color,
|
|
|
+ child: Center(
|
|
|
+ child: Text(
|
|
|
+ text,
|
|
|
+ style: TextStyle(
|
|
|
+ color: Color(0xFF252532),
|
|
|
+ fontSize: 16,
|
|
|
+ fontWeight: FontWeight.bold,
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
void setHouseInfo(HouseInfo houseInfo) {
|
|
|
setState(() {
|
|
|
- this.houseInfo = houseInfo;
|
|
|
+ mHouseInfo = houseInfo;
|
|
|
});
|
|
|
}
|
|
|
+
|
|
|
+ String getCountDown(int time) {
|
|
|
+ if (time == null) {
|
|
|
+ return '';
|
|
|
+ } else {
|
|
|
+ return ((time ~/ 1000 ~/ 60) % 60).toString() + '分' + (time ~/ 1000 % 60).toString() + '秒';
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|