|
|
@@ -13,6 +13,8 @@ import '../model/HouseInfo.dart';
|
|
|
import '../net/HttpManager.dart';
|
|
|
import '../net/Result.dart';
|
|
|
import '../styles/totast.dart';
|
|
|
+import 'StartWindow.dart';
|
|
|
+import '../model/PlayerInfo.dart';
|
|
|
|
|
|
class RoomInfo extends StatefulWidget {
|
|
|
RoomInfo({Key key, this.roomId}) : super(key: key);
|
|
|
@@ -25,29 +27,190 @@ class RoomInfo extends StatefulWidget {
|
|
|
class RoomInfoState extends State<RoomInfo>
|
|
|
with SingleTickerProviderStateMixin {
|
|
|
List<Map> tabList;
|
|
|
-
|
|
|
TabController mController;
|
|
|
- ScrollController _perController;
|
|
|
Map roomInfo;
|
|
|
HouseInfo houseInfo;
|
|
|
Map colorInfo;
|
|
|
- List joinList = [];
|
|
|
bool isJoin = true;
|
|
|
+ PlayerInfo playerInfo;
|
|
|
+
|
|
|
+//获取房间信息
|
|
|
+ void getRoomInfo() async {
|
|
|
+ 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);
|
|
|
+ });
|
|
|
+ if (houseInfo.statusFlag == 0) {
|
|
|
+ getNowStatus();
|
|
|
+ }
|
|
|
+ } else {}
|
|
|
+ }
|
|
|
+
|
|
|
+//隔一秒检查是否开始
|
|
|
+ getNowStatus() async {
|
|
|
+ await Future.delayed(const Duration(seconds: 1));
|
|
|
+ Result res = await HttpManager.get("houseInfo/getPlayerNum",
|
|
|
+ data: {"id": widget.roomId});
|
|
|
+ if (res.success) {
|
|
|
+ if (houseInfo.statusFlag == 0 && res.data["statusFlag"] == 2) {
|
|
|
+ showStart();
|
|
|
+ }
|
|
|
+ setState(() {
|
|
|
+ houseInfo.playerNumber = res.data["playerNumber"];
|
|
|
+ houseInfo.statusFlag = res.data["statusFlag"];
|
|
|
+ houseInfo.bonus = res.data["bonus"];
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (houseInfo.statusFlag == 0) {
|
|
|
+ getNowStatus();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+//开始比赛确认按钮
|
|
|
+ showStart() async {
|
|
|
+ final result = await 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 StartWindow();
|
|
|
+ }));
|
|
|
+
|
|
|
+ Toast.show(context, '加载中', -1, 'loading');
|
|
|
+ Map<String, dynamic> data = {"id": playerInfo.id};
|
|
|
+ if (result == null) {
|
|
|
+ data['statusFlag'] = 6;
|
|
|
+ } else {
|
|
|
+ data['statusFlag'] = 2;
|
|
|
+ }
|
|
|
+ Toast.hide();
|
|
|
+ Result res = await HttpManager.post("playerInfo/update", data: data);
|
|
|
+ if (res.success) {
|
|
|
+ if (data['statusFlag'] == 2) {
|
|
|
+ //加入比赛成功,开始录屏
|
|
|
+ Future.delayed(Duration(milliseconds: 100), () => showSucessInfo());
|
|
|
+ } else {
|
|
|
+ // showBackDialog();
|
|
|
+ Future.delayed(Duration(milliseconds: 100), () => showBackDialog());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+//开始录屏提示框
|
|
|
+ showSucessInfo() {
|
|
|
+ showDialog<Null>(
|
|
|
+ context: context,
|
|
|
+ barrierDismissible: false,
|
|
|
+ builder: (BuildContext context) {
|
|
|
+ return new AlertDialog(
|
|
|
+ content: Container(
|
|
|
+ height: 50,
|
|
|
+ child: Text(
|
|
|
+ '已经成功开启录屏,请保留当前页面,打开游戏开始比赛,祝您取得好成绩!',
|
|
|
+ style: TextStyle(color: Colors.black),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ actions: <Widget>[
|
|
|
+ new FlatButton(
|
|
|
+ child: new Text('完成比赛'),
|
|
|
+ onPressed: () {
|
|
|
+ HttpManager.post("playerInfo/update",
|
|
|
+ data: {'id': playerInfo.id, 'statusFlag': 3});
|
|
|
+ Navigator.of(context).pop();
|
|
|
+ },
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ );
|
|
|
+ },
|
|
|
+ ).then((val) {
|
|
|
+ Navigator.of(context).pop();
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+//未确认比赛弹窗
|
|
|
+ showBackDialog() {
|
|
|
+ showDialog<Null>(
|
|
|
+ context: context,
|
|
|
+ barrierDismissible: false,
|
|
|
+ builder: (BuildContext context) {
|
|
|
+ return new AlertDialog(
|
|
|
+ content: Container(
|
|
|
+ height: 50,
|
|
|
+ child: Text(
|
|
|
+ '您未在十秒内点击开始按钮,系统已经判定您放弃比赛,参赛奖金不予退还。',
|
|
|
+ style: TextStyle(color: Colors.black),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ actions: <Widget>[
|
|
|
+ new FlatButton(
|
|
|
+ child: new Text('确定'),
|
|
|
+ onPressed: () {
|
|
|
+ Navigator.of(context).pop();
|
|
|
+ },
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ );
|
|
|
+ },
|
|
|
+ ).then((val) {
|
|
|
+ print(val);
|
|
|
+ Navigator.of(context).pop();
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
+//检查加入信息
|
|
|
checkJoinInfo() async {
|
|
|
- Result res = await HttpManager.get("playerInfo/check", data: {
|
|
|
+ Result res = await HttpManager.get("playerInfo/getOne", data: {
|
|
|
"userId": StoreProvider.of<AppState>(context).state.userInfo.id,
|
|
|
"houseId": widget.roomId
|
|
|
});
|
|
|
- print(res.error);
|
|
|
if (res.success) {
|
|
|
- setState(() {
|
|
|
- isJoin = false;
|
|
|
- });
|
|
|
- } else if (res.error == '玩家已存在') {
|
|
|
+ print(res.data);
|
|
|
+ if (res.data == null) {
|
|
|
+ setState(() {
|
|
|
+ isJoin = false;
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ playerInfo = PlayerInfo.fromJson(res.data);
|
|
|
+ setState(() {
|
|
|
+ isJoin = true;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // if (res.success) {
|
|
|
+ //
|
|
|
+ // } else if (res.error == '玩家已存在') {
|
|
|
+ // setState(() {
|
|
|
+ // isJoin = true;
|
|
|
+ // });
|
|
|
+ // }
|
|
|
+ }
|
|
|
+
|
|
|
+//加入房间
|
|
|
+ joinRoom() 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) {
|
|
|
+ Toast.show(context, '加入成功', 1500, 'success');
|
|
|
setState(() {
|
|
|
isJoin = true;
|
|
|
});
|
|
|
+ } else {
|
|
|
+ Toast.show(context, res.error, 1500, 'info');
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -69,10 +232,10 @@ class RoomInfoState extends State<RoomInfo>
|
|
|
"白银": Color(0xFFAFCAD8),
|
|
|
"青铜": Color(0xFFE18D50),
|
|
|
};
|
|
|
- _perController = ScrollController();
|
|
|
getRoomInfo();
|
|
|
Future.delayed(Duration(milliseconds: 100), () {
|
|
|
checkJoinInfo();
|
|
|
+ // showBackDialog();
|
|
|
});
|
|
|
}
|
|
|
|
|
|
@@ -80,52 +243,64 @@ class RoomInfoState extends State<RoomInfo>
|
|
|
void dispose() {
|
|
|
super.dispose();
|
|
|
mController.dispose();
|
|
|
- _perController.dispose();
|
|
|
}
|
|
|
|
|
|
@override
|
|
|
Widget build(BuildContext context) {
|
|
|
ScreenUtil.instance = ScreenUtil(width: 375, height: 667)..init(context);
|
|
|
+ int status = 0;
|
|
|
+ if (houseInfo != null) {
|
|
|
+ status = houseInfo.statusFlag;
|
|
|
+ }
|
|
|
// TODO: implement build
|
|
|
- return new Scaffold(
|
|
|
- appBar: AppBar(
|
|
|
- backgroundColor: PRIMARY_COLOR,
|
|
|
- title: Container(
|
|
|
- child: TabBar(
|
|
|
- controller: mController,
|
|
|
- labelColor: Colors.white,
|
|
|
- unselectedLabelColor: Colors.white.withOpacity(0.5),
|
|
|
- labelStyle: TextStyle(fontSize: 16.0),
|
|
|
- indicatorColor: Colors.white,
|
|
|
- indicatorWeight: 3,
|
|
|
- indicatorSize: TabBarIndicatorSize.label,
|
|
|
- tabs: tabList.map((item) {
|
|
|
- return Tab(
|
|
|
- text: item['title'],
|
|
|
- );
|
|
|
- }).toList(),
|
|
|
+ return new WillPopScope(
|
|
|
+ child: Scaffold(
|
|
|
+ appBar: AppBar(
|
|
|
+ backgroundColor: PRIMARY_COLOR,
|
|
|
+ title: Container(
|
|
|
+ child: TabBar(
|
|
|
+ controller: mController,
|
|
|
+ labelColor: Colors.white,
|
|
|
+ unselectedLabelColor: Colors.white.withOpacity(0.5),
|
|
|
+ labelStyle: TextStyle(fontSize: 16.0),
|
|
|
+ indicatorColor: Colors.white,
|
|
|
+ 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: Image.asset(
|
|
|
+ 'images/icon_fenxiang.png',
|
|
|
+ width: 24,
|
|
|
+ ),
|
|
|
+ )
|
|
|
+ ],
|
|
|
),
|
|
|
- centerTitle: true,
|
|
|
- elevation: 0,
|
|
|
- actions: <Widget>[
|
|
|
- Container(
|
|
|
- padding: EdgeInsets.only(right: 30, left: 20),
|
|
|
- child: Image.asset(
|
|
|
- 'images/icon_fenxiang.png',
|
|
|
- width: 24,
|
|
|
- ),
|
|
|
- )
|
|
|
- ],
|
|
|
+ body: Container(
|
|
|
+ color: BG_SUB_COLOR,
|
|
|
+ child: TabBarView(
|
|
|
+ controller: mController,
|
|
|
+ children: [
|
|
|
+ _firstPage(),
|
|
|
+ SecondPage(roomId: widget.roomId, status: status)
|
|
|
+ ],
|
|
|
+ )),
|
|
|
+ floatingActionButton: _joinBtn(),
|
|
|
+ floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
|
|
|
),
|
|
|
- body: Container(
|
|
|
- color: BG_SUB_COLOR,
|
|
|
- child: TabBarView(
|
|
|
- controller: mController,
|
|
|
- children: [_firstPage(), _secondPage(context)],
|
|
|
- )),
|
|
|
- floatingActionButton: _joinBtn(),
|
|
|
- floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
|
|
|
+ onWillPop: () {
|
|
|
+ Toast.hide();
|
|
|
+ Navigator.of(context).pop();
|
|
|
+ },
|
|
|
);
|
|
|
}
|
|
|
|
|
|
@@ -141,6 +316,18 @@ class RoomInfoState extends State<RoomInfo>
|
|
|
? 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;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
return Container(
|
|
|
child: RefreshIndicator(
|
|
|
color: PRIMARY_COLOR,
|
|
|
@@ -154,9 +341,7 @@ class RoomInfoState extends State<RoomInfo>
|
|
|
child: Container(
|
|
|
child: Column(
|
|
|
children: <Widget>[
|
|
|
- Image.network(
|
|
|
- 'http://bpic.588ku.com/illus_pic/18/12/10/3678774e601145684677d48e17bb3486.jpg',
|
|
|
- width: double.infinity),
|
|
|
+ Image.network(topImg, width: double.infinity),
|
|
|
Container(
|
|
|
padding: EdgeInsets.only(top: 10),
|
|
|
child: Row(
|
|
|
@@ -205,9 +390,13 @@ class RoomInfoState extends State<RoomInfo>
|
|
|
width: 20,
|
|
|
),
|
|
|
Text(
|
|
|
- roomInfo['playerNumber'].toString() +
|
|
|
+ (houseInfo != null
|
|
|
+ ? houseInfo.playerNumber.toString()
|
|
|
+ : '0') +
|
|
|
'/' +
|
|
|
- roomInfo['maxNumber'].toString(),
|
|
|
+ (houseInfo != null
|
|
|
+ ? houseInfo.maxNumber.toString()
|
|
|
+ : '0'),
|
|
|
style: TextStyle(
|
|
|
fontSize: 14,
|
|
|
fontWeight: FontWeight.w500,
|
|
|
@@ -246,8 +435,8 @@ class RoomInfoState extends State<RoomInfo>
|
|
|
),
|
|
|
Text(
|
|
|
'X' +
|
|
|
- (houseLevelInfo.containsKey('entryCoin')
|
|
|
- ? houseLevelInfo['entryCoin'].toString()
|
|
|
+ (houseInfo != null
|
|
|
+ ? houseInfo.bonus.toString()
|
|
|
: '0'),
|
|
|
style: TextStyle(
|
|
|
color: PRIMARY_COLOR,
|
|
|
@@ -258,26 +447,30 @@ class RoomInfoState extends State<RoomInfo>
|
|
|
],
|
|
|
),
|
|
|
),
|
|
|
- Container(
|
|
|
- width: double.infinity,
|
|
|
- margin: EdgeInsets.only(top: 25, left: 15, right: 15),
|
|
|
- padding: EdgeInsets.only(
|
|
|
- top: 15, left: 15, right: 10, bottom: 15),
|
|
|
- decoration: BoxDecoration(
|
|
|
- borderRadius: BorderRadius.only(
|
|
|
- topLeft: Radius.circular(0),
|
|
|
- topRight: Radius.circular(8),
|
|
|
- bottomLeft: Radius.circular(8),
|
|
|
- bottomRight: Radius.circular(8)),
|
|
|
- gradient: LinearGradient(
|
|
|
- begin: Alignment.topRight,
|
|
|
- colors: [Color(0xFF464B6A), Color(0xFF35395E)],
|
|
|
- )),
|
|
|
- child: Text(
|
|
|
- '加入房间后,请在此页面耐心等待,竞赛即将开始时,玩家有10秒的时间进行确认,点击确认方可正式进入竞赛,若没有点击,则视为自动放弃此次竞赛,已支付金币概不退换',
|
|
|
- style: TextStyle(color: Colors.white, fontSize: 13),
|
|
|
- ),
|
|
|
- ),
|
|
|
+ statuFlag != 4
|
|
|
+ ? Container(
|
|
|
+ width: double.infinity,
|
|
|
+ margin: EdgeInsets.only(top: 25, left: 15, right: 15),
|
|
|
+ padding: EdgeInsets.only(
|
|
|
+ top: 15, left: 15, right: 10, bottom: 15),
|
|
|
+ decoration: BoxDecoration(
|
|
|
+ borderRadius: BorderRadius.only(
|
|
|
+ topLeft: Radius.circular(0),
|
|
|
+ topRight: Radius.circular(8),
|
|
|
+ bottomLeft: Radius.circular(8),
|
|
|
+ bottomRight: Radius.circular(8)),
|
|
|
+ gradient: LinearGradient(
|
|
|
+ begin: Alignment.topRight,
|
|
|
+ colors: [Color(0xFF464B6A), Color(0xFF35395E)],
|
|
|
+ )),
|
|
|
+ child: Text(
|
|
|
+ '加入房间后,请在此页面耐心等待,竞赛即将开始时,玩家有10秒的时间进行确认,点击确认方可正式进入竞赛,若没有点击,则视为自动放弃此次竞赛,已支付金币概不退换',
|
|
|
+ style: TextStyle(color: Colors.white, fontSize: 13),
|
|
|
+ ),
|
|
|
+ )
|
|
|
+ : RankContent(
|
|
|
+ roomId: widget.roomId,
|
|
|
+ ),
|
|
|
Container(
|
|
|
width: double.infinity,
|
|
|
height: 48 + ScreenUtil().setHeight(40),
|
|
|
@@ -290,12 +483,9 @@ class RoomInfoState extends State<RoomInfo>
|
|
|
}
|
|
|
|
|
|
Widget _joinBtn() {
|
|
|
- Map houseLevelInfo = roomInfo.isNotEmpty ? roomInfo["houseLevelInfo"] : {};
|
|
|
-
|
|
|
- int joinMoney = houseLevelInfo.containsKey('entryCoin')
|
|
|
- ? houseLevelInfo['entryCoin']
|
|
|
- : 0;
|
|
|
- if (!isJoin) {
|
|
|
+ int joinMoney = houseInfo != null ? houseInfo.houseLevel.entryCoin : 0;
|
|
|
+ int statusFlag = houseInfo != null ? houseInfo.statusFlag : 1;
|
|
|
+ if (!isJoin && statusFlag == 0) {
|
|
|
return Container(
|
|
|
width: ScreenUtil().setWidth(375),
|
|
|
height: 48 + ScreenUtil().setHeight(40),
|
|
|
@@ -305,39 +495,53 @@ class RoomInfoState extends State<RoomInfo>
|
|
|
left: 15,
|
|
|
right: 15),
|
|
|
child: RaisedButton(
|
|
|
- textColor: Colors.white,
|
|
|
- child: Row(
|
|
|
- mainAxisAlignment: MainAxisAlignment.center,
|
|
|
- children: <Widget>[
|
|
|
- Image.asset(
|
|
|
- 'images/icon_jinbi_da_bai.png',
|
|
|
- width: 20,
|
|
|
- ),
|
|
|
- Container(
|
|
|
- margin: EdgeInsets.only(left: 6),
|
|
|
- child: Text(
|
|
|
- 'X' + joinMoney.toString(),
|
|
|
- style: TextStyle(
|
|
|
- color: Colors.white,
|
|
|
- fontSize: 16,
|
|
|
- fontWeight: FontWeight.w500),
|
|
|
+ textColor: Colors.white,
|
|
|
+ child: Row(
|
|
|
+ mainAxisAlignment: MainAxisAlignment.center,
|
|
|
+ children: <Widget>[
|
|
|
+ Image.asset(
|
|
|
+ 'images/icon_jinbi_da_bai.png',
|
|
|
+ width: 20,
|
|
|
),
|
|
|
- ),
|
|
|
- Container(
|
|
|
- margin: EdgeInsets.only(left: 20),
|
|
|
+ Container(
|
|
|
+ margin: EdgeInsets.only(left: 6),
|
|
|
child: Text(
|
|
|
- '加入房间',
|
|
|
+ 'X' + joinMoney.toString(),
|
|
|
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),
|
|
|
+ ))
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ onPressed: () => joinRoom()),
|
|
|
+ );
|
|
|
+ } else if (isJoin && statusFlag == 0) {
|
|
|
+ return Container(
|
|
|
+ width: double.infinity,
|
|
|
+ padding: EdgeInsets.symmetric(horizontal: 15, vertical: 20),
|
|
|
+ height: 88,
|
|
|
+ child: RaisedButton(
|
|
|
+ disabledColor: Color(0xFF914244),
|
|
|
+ disabledTextColor: Color(0xFF252532),
|
|
|
+ child: Text(
|
|
|
+ '等待开始中',
|
|
|
+ style: TextStyle(fontSize: 16),
|
|
|
),
|
|
|
- onPressed: () => {},
|
|
|
+ onPressed: null,
|
|
|
),
|
|
|
);
|
|
|
- } else if (roomInfo['statusFlag'] == 0) {
|
|
|
+ } else if (isJoin && statusFlag == 3) {
|
|
|
return Container(
|
|
|
width: double.infinity,
|
|
|
padding: EdgeInsets.symmetric(horizontal: 15, vertical: 20),
|
|
|
@@ -346,7 +550,22 @@ class RoomInfoState extends State<RoomInfo>
|
|
|
disabledColor: Color(0xFF914244),
|
|
|
disabledTextColor: Color(0xFF252532),
|
|
|
child: Text(
|
|
|
- '等待开始中',
|
|
|
+ '正在结算中',
|
|
|
+ style: TextStyle(fontSize: 16),
|
|
|
+ ),
|
|
|
+ onPressed: null,
|
|
|
+ ),
|
|
|
+ );
|
|
|
+ } else if (isJoin && statusFlag == 4) {
|
|
|
+ return Container(
|
|
|
+ width: double.infinity,
|
|
|
+ padding: EdgeInsets.symmetric(horizontal: 15, vertical: 20),
|
|
|
+ height: 88,
|
|
|
+ child: RaisedButton(
|
|
|
+ disabledColor: Color(0xFF727785),
|
|
|
+ disabledTextColor: Color(0xFF15151D),
|
|
|
+ child: Text(
|
|
|
+ '已结束',
|
|
|
style: TextStyle(fontSize: 16),
|
|
|
),
|
|
|
onPressed: null,
|
|
|
@@ -356,26 +575,243 @@ class RoomInfoState extends State<RoomInfo>
|
|
|
return Container();
|
|
|
}
|
|
|
}
|
|
|
+}
|
|
|
+
|
|
|
+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 = [];
|
|
|
+ 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() {
|
|
|
+ // TODO: implement initState
|
|
|
+ super.initState();
|
|
|
+ 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();
|
|
|
+ }
|
|
|
+ List colorList = [
|
|
|
+ [Color(0xFFD48E00), Color(0xFFFECF01)],
|
|
|
+ [Color(0xFFC5C5C5), Color(0xFFE3E3E3)],
|
|
|
+ [Color(0xFFE77023), Color(0xFFF89E58)]
|
|
|
+ ];
|
|
|
+ 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>[
|
|
|
+ Positioned(
|
|
|
+ top: 0,
|
|
|
+ left: _num == 1 ? 19 : 14,
|
|
|
+ child: Center(
|
|
|
+ child: Image.asset(
|
|
|
+ 'images/icon_paihangbang_0' + '$_num.png',
|
|
|
+ width: 32,
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ Container(
|
|
|
+ margin: EdgeInsets.only(top: 27, 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,
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ 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('x' + (topList[_num - 1].bonus!=null?topList[_num - 1].bonus.toString():'0'),
|
|
|
+ style: TextStyle(color: PRIMARY_COLOR, fontSize: 12))
|
|
|
+ ],
|
|
|
+ )
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ );
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+class SecondPage extends StatefulWidget {
|
|
|
+ SecondPage({Key key, this.roomId, this.status}) : super(key: key);
|
|
|
+ final String roomId; // 用来储存传递过来的值
|
|
|
+ final int status;
|
|
|
+ @override
|
|
|
+ SecondPageState createState() => SecondPageState();
|
|
|
+}
|
|
|
+
|
|
|
+class SecondPageState extends State<SecondPage> {
|
|
|
+ List<PlayerInfo> joinList = [];
|
|
|
+ int currentPage = 1;
|
|
|
+ bool ismore = true;
|
|
|
+ ScrollController _perController;
|
|
|
+
|
|
|
+ //获取房间用户
|
|
|
+ getPlayerPage() async {
|
|
|
+ ismore = false;
|
|
|
+ Toast.show(context, '加载中', -1, 'loading');
|
|
|
+ Result res = await HttpManager.get("playerInfo/rankPage", data: {
|
|
|
+ "houseId": widget.roomId,
|
|
|
+ "currentPage": currentPage,
|
|
|
+ "pageNumber": 20
|
|
|
+ });
|
|
|
+ Toast.hide();
|
|
|
+ List<PlayerInfo> list = joinList;
|
|
|
+ if (currentPage == 1) {
|
|
|
+ list = [];
|
|
|
+ }
|
|
|
+ if (res.success) {
|
|
|
+ print(res.data['pp']);
|
|
|
+ for (var item in res.data['pp']) {
|
|
|
+ PlayerInfo jonPlayer = PlayerInfo.fromJson(item);
|
|
|
+ list.add(jonPlayer);
|
|
|
+ }
|
|
|
+ if (res.data['page']['currentPage'] < res.data['page']['totalPage']) {
|
|
|
+ ismore = true;
|
|
|
+ }
|
|
|
+ } else {}
|
|
|
+ setState(() {
|
|
|
+ joinList = list;
|
|
|
+ });
|
|
|
+ print(joinList);
|
|
|
+ }
|
|
|
+
|
|
|
+ @override
|
|
|
+ void initState() {
|
|
|
+ // TODO: implement initState
|
|
|
+ super.initState();
|
|
|
+ _perController = ScrollController();
|
|
|
+ currentPage = 1;
|
|
|
+ getPlayerPage();
|
|
|
+ _perController.addListener(() {
|
|
|
+ if (_perController.position.pixels ==
|
|
|
+ _perController.position.maxScrollExtent) {
|
|
|
+ if (ismore) {
|
|
|
+ currentPage++;
|
|
|
+ getPlayerPage();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
- Widget _secondPage(BuildContext context) {
|
|
|
+ @override
|
|
|
+ void dispose() {
|
|
|
+ // TODO: implement dispose
|
|
|
+ super.dispose();
|
|
|
+ _perController.dispose();
|
|
|
+ }
|
|
|
+
|
|
|
+ @override
|
|
|
+ Widget build(BuildContext context) {
|
|
|
return RefreshIndicator(
|
|
|
color: PRIMARY_COLOR,
|
|
|
backgroundColor: BG_SUB_COLOR,
|
|
|
displacement: 10,
|
|
|
onRefresh: () async {
|
|
|
await new Future.delayed(const Duration(seconds: 1));
|
|
|
+ currentPage = 1;
|
|
|
+ getPlayerPage();
|
|
|
},
|
|
|
child: ListView.builder(
|
|
|
physics: AlwaysScrollableScrollPhysics(),
|
|
|
controller: _perController,
|
|
|
- itemCount: 3,
|
|
|
+ itemCount: joinList.length + 1,
|
|
|
itemBuilder: (BuildContext context, int index) {
|
|
|
- return person_item({}, index);
|
|
|
+ if (index < joinList.length) {
|
|
|
+ return person_item(joinList[index], index);
|
|
|
+ } else {
|
|
|
+ return Container(
|
|
|
+ padding: EdgeInsets.all(15),
|
|
|
+ child: Text(
|
|
|
+ '其他人员正在火速赶来中...',
|
|
|
+ style: TextStyle(color: Colors.white30),
|
|
|
+ textAlign: TextAlign.center,
|
|
|
+ ),
|
|
|
+ );
|
|
|
+ }
|
|
|
}),
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- Widget person_item(Map info, int index) {
|
|
|
+ Widget person_item(PlayerInfo info, int index) {
|
|
|
return Container(
|
|
|
width: double.infinity,
|
|
|
height: 60,
|
|
|
@@ -395,13 +831,13 @@ class RoomInfoState extends State<RoomInfo>
|
|
|
height: 36,
|
|
|
child: CircleAvatar(
|
|
|
backgroundImage: NetworkImage(
|
|
|
- 'http://bpic.588ku.com/original_pic/19/01/10/c21f0c83a0029a820d47e4828559353f.jpg'),
|
|
|
+ info.userInfo != null ? info.userInfo.icon : ''),
|
|
|
),
|
|
|
),
|
|
|
Expanded(
|
|
|
flex: 1,
|
|
|
child: Text(
|
|
|
- '邱好好',
|
|
|
+ info.userInfo != null ? info.userInfo.nickname : '',
|
|
|
style: TextStyle(
|
|
|
color: Colors.white,
|
|
|
fontSize: 14,
|
|
|
@@ -409,25 +845,18 @@ class RoomInfoState extends State<RoomInfo>
|
|
|
maxLines: 1,
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
),
|
|
|
- )
|
|
|
+ ),
|
|
|
+ widget.status == 4 && index < 3
|
|
|
+ ? Image.asset(
|
|
|
+ 'images/icon_paihangbang_0' +
|
|
|
+ (index + 1).toString() +
|
|
|
+ '.png',
|
|
|
+ width: 32,
|
|
|
+ )
|
|
|
+ : Container()
|
|
|
],
|
|
|
),
|
|
|
),
|
|
|
);
|
|
|
}
|
|
|
-
|
|
|
- void getRoomInfo() async {
|
|
|
- Toast.show(context, '加载中', -1, 'loading');
|
|
|
- Result res =
|
|
|
- await HttpManager.get("houseInfo/getOne", data: {"id": widget.roomId});
|
|
|
- Toast.hide();
|
|
|
- if (res.success) {
|
|
|
- print(res.data);
|
|
|
- setState(() {
|
|
|
- roomInfo = res.data;
|
|
|
- houseInfo=HouseInfo.fromJson(res.data);
|
|
|
- });
|
|
|
- print(houseInfo);
|
|
|
- } else {}
|
|
|
- }
|
|
|
}
|