RoomInfo.dart 53 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287
  1. import 'dart:async';
  2. import 'dart:ui';
  3. import 'package:flutter/cupertino.dart' as prefix0;
  4. import 'package:flutter/material.dart';
  5. import 'package:flutter/material.dart' as prefix1;
  6. import 'package:flutter_screenutil/flutter_screenutil.dart';
  7. import 'package:url_launcher/url_launcher.dart';
  8. import 'package:battery/battery.dart';
  9. import 'package:flutter_redux/flutter_redux.dart';
  10. import 'package:flutter/cupertino.dart';
  11. import '../styles/colors.dart';
  12. import '../plugins/ScreenStramPlugin.dart';
  13. import '../net/HttpManager.dart';
  14. import '../net/Result.dart';
  15. import '../redux/AppState.dart';
  16. import '../model/HouseInfo.dart';
  17. import '../styles/totast.dart';
  18. import 'StartWindow.dart';
  19. import '../model/PlayerInfo.dart';
  20. import '../widget/VideoWidget.dart';
  21. import '../widget/Dialog.dart';
  22. import 'CompetitionInformation.dart';
  23. import 'SecondRoomInfo.dart';
  24. import 'VideoPlayer.dart';
  25. import '../model/UserInfo.dart';
  26. import '../widget/LinearButton.dart';
  27. import 'Appeal.dart';
  28. class RoomInfo extends StatefulWidget {
  29. RoomInfo({Key key, this.roomId}) : super(key: key);
  30. final String roomId; // 用来储存传递过来的值
  31. @override
  32. RoomInfoState createState() => RoomInfoState();
  33. }
  34. class RoomInfoState extends State<RoomInfo> with SingleTickerProviderStateMixin {
  35. List<Map> tabList;
  36. TabController mController;
  37. Map roomInfo;
  38. HouseInfo houseInfo;
  39. Map colorInfo;
  40. bool isJoin = true;
  41. PlayerInfo playerInfo;
  42. bool isPop = false;
  43. bool showBack = false;
  44. Timer timer;
  45. List<List<String>> roomTipsList = [];
  46. ScrollController _tipController;
  47. String _myUrl;
  48. int tabIndex = 0;
  49. UserInfo userInfo;
  50. int myRank = 0;
  51. String mymedal = '';
  52. bool canAppeal = false;
  53. int appealState = 0;
  54. //获取房间信息
  55. Future<void> getRoomInfo(type) async {
  56. print('现在时间:' + DateTime.now().millisecondsSinceEpoch.toString());
  57. Toast.show(context, '加载中', -1, 'loading');
  58. Result res = await HttpManager.get('houseInfo/getOne', data: {'id': widget.roomId});
  59. Toast.hide();
  60. if (res.success) {
  61. setState(() {
  62. roomInfo = res.data;
  63. houseInfo = HouseInfo.fromJson(res.data);
  64. });
  65. // showNotice();
  66. if (houseInfo.statusFlag == 0 && houseInfo.userId != StoreProvider.of<AppState>(context).state.userInfo.id) {
  67. showNotice();
  68. }
  69. if (houseInfo.statusFlag < 2 && type == 'first') {
  70. final battery = Battery();
  71. final batteryLevel = await battery.batteryLevel;
  72. await MyDialog.showDialog(context, (batteryLevel < 50 ? '系统检测到你的电量低于50%' : '') + ' 为了正常上传比赛结果,建议插上电源线保持电量充足', submitText: '知道了');
  73. }
  74. } else {}
  75. checkJoinInfo();
  76. }
  77. //开始比赛
  78. Future<void> startGame() async {
  79. Toast.show(context, '加载中', -1, 'loading');
  80. Result res = await HttpManager.post('houseInfo/handBegin', data: {'id': widget.roomId});
  81. Toast.hide();
  82. }
  83. //隔一秒检查是否开始
  84. Future<void> getNowStatus() async {
  85. Result res = await HttpManager.get('houseInfo/getPlayerNum', data: {'id': widget.roomId});
  86. if (res.success) {
  87. if (houseInfo.statusFlag == 0 && res.data['statusFlag'] == 2) {
  88. showStart();
  89. // timer.cancel();
  90. }
  91. setState(() {
  92. houseInfo.playerNumber = res.data['playerNumber'];
  93. houseInfo.statusFlag = res.data['statusFlag'];
  94. houseInfo.bonus = res.data['bonus'];
  95. houseInfo.beginTime = res.data['beginTime'];
  96. });
  97. }
  98. }
  99. //开始比赛确认按钮
  100. Future<void> showStart() async {
  101. if (!isJoin) {
  102. return;
  103. }
  104. bool result = await Navigator.of(context).push<bool>(
  105. PageRouteBuilder(
  106. opaque: false,
  107. transitionDuration: Duration(milliseconds: 300),
  108. transitionsBuilder: (BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation, Widget child) {
  109. return FadeTransition(
  110. opacity: CurvedAnimation(parent: animation, curve: Curves.linear),
  111. child: child,
  112. );
  113. },
  114. pageBuilder: (BuildContext context, _, __) {
  115. return StartWindow();
  116. },
  117. ),
  118. );
  119. Map<String, dynamic> data = {'id': playerInfo.id};
  120. bool success = true;
  121. if (result) {
  122. success = await ScreenStreamPlugin.start(playerInfo.id.toString());
  123. if (success) {
  124. data['beginTime'] = DateTime.now().millisecondsSinceEpoch;
  125. data['statusFlag'] = 2;
  126. data['played'] = true;
  127. } else {
  128. data['statusFlag'] = 6;
  129. data['played'] = false;
  130. }
  131. } else {
  132. data['statusFlag'] = 6;
  133. data['played'] = false;
  134. }
  135. Toast.show(context, '加载中', -1, 'loading');
  136. Result res = await HttpManager.post('playerInfo/update', data: data);
  137. Toast.hide();
  138. // MyDialog.showDialog(context, '自动启动游戏失败,请手动切换到游戏app开始竞赛', submitText: '知道了');
  139. // Timer(Duration(seconds: 10), () {
  140. // showSucessInfo();
  141. // });
  142. // return;
  143. if (res.success) {
  144. if (data['statusFlag'] == 2) {
  145. const url = 'pubgmhd1106467070://';
  146. if (await canLaunch(url)) {
  147. Timer(Duration(seconds: 1), () async {
  148. await launch(url);
  149. showSucessInfo(3);
  150. });
  151. } else {
  152. MyDialog.showDialog(context, '自动启动游戏失败,请手动切换到游戏app开始竞赛', submitText: '知道了');
  153. Timer(Duration(seconds: 10), () {
  154. showSucessInfo(3);
  155. });
  156. throw 'Could not launch $url';
  157. }
  158. } else {
  159. showBackDialog(success ? 1 : 0);
  160. }
  161. }
  162. }
  163. //开始录屏提示框
  164. void showSucessInfo(status) {
  165. MyDialog.showDialog(context, '您已经完成比赛了吗,确认完成,那就点击下方完成竞赛按钮,上传本次成绩,祝您赢取大奖', title: '完成比赛', submitText: '我已完成比赛', onsubmit: () async {
  166. HttpManager.post('playerInfo/update', data: {'id': playerInfo.id, 'statusFlag': status, 'endTime': DateTime.now().millisecondsSinceEpoch});
  167. bool success = await ScreenStreamPlugin.stop();
  168. Timer(Duration(seconds: 1), () {
  169. getEndTips();
  170. });
  171. setState(() {
  172. playerInfo.statusFlag = 3;
  173. });
  174. });
  175. }
  176. Future<void> getEndTips() async {
  177. Result res = await HttpManager.get('playerInfo/endNum', data: {'houseId': widget.roomId});
  178. if (res.success) {
  179. int time = houseInfo.beginTime + 1 * 3600 * 1000 - DateTime.now().millisecondsSinceEpoch;
  180. var nowTime = (time ~/ 1000 ~/ 60) % 60;
  181. setState(() {
  182. roomTipsList.add(['你已完成本次比赛,当前完成人数 ', res.data.toString(), '人,比赛需要等待所有人完成后方可结算奖励', '', ',你可以先去参加其他竞赛,稍后在“个人中心-我的战绩”中可以查看本次竞赛排名及领取奖励']);
  183. changeScroll();
  184. });
  185. }
  186. }
  187. //未确认比赛弹窗
  188. void showBackDialog(type) {
  189. MyDialog.showDialog(context, (type == 1 ? '由于您未在十秒内点击开始按钮' : '由于您未授权录屏') + ',系统已经判定您放弃比赛,谢谢您的参与。', title: '很遗憾');
  190. }
  191. //检查加入信息
  192. Future<void> checkJoinInfo() async {
  193. Result res = await HttpManager.get('playerInfo/getOne', data: {'userId': StoreProvider.of<AppState>(context).state.userInfo.id, 'houseId': widget.roomId});
  194. if (res.success) {
  195. if (res.data == null) {
  196. setState(() {
  197. isJoin = false;
  198. });
  199. if (houseInfo.statusFlag == 0) {
  200. if (houseInfo.createUser == StoreProvider.of<AppState>(context).state.userInfo.id.toString()) {
  201. roomTipsList.add(['房间创建成功,待人数满员时会自动开启比赛,房主也可以手动开启比赛,同时,你也可以加入本次比赛']);
  202. changeScroll();
  203. }
  204. if (isJoin) {
  205. roomTipsList
  206. .add(['待人数满员时会自动开启比赛,房主也可以手动开启比赛,请在此页面耐心等待其他人的加入,加入房间后再次退出则视为自动放弃比赛。', '由于部分手机在低电量情况下无法在后台正常运行竞赛APP,为了你比赛数据的正常获取,请保持手机电量在50%以上', '', '', '']);
  207. }
  208. changeScroll();
  209. }
  210. } else {
  211. if (houseInfo.statusFlag == 0) {
  212. roomTipsList
  213. .add(['待人数满员时会自动开启比赛,房主也可以手动开启比赛,请在此页面耐心等待其他人的加入,加入房间后再次退出则视为自动放弃比赛。', '由于部分手机在低电量情况下无法在后台正常运行竞赛APP,为了你比赛数据的正常获取,请保持手机电量在50%以上', '', '', '']);
  214. }
  215. playerInfo = PlayerInfo.fromJson(res.data);
  216. if (playerInfo.medal != null) {
  217. mymedal = res.data['medal'];
  218. }
  219. if (houseInfo.statusFlag == 4) {
  220. _myUrl = await ScreenStreamPlugin.getVideo(playerInfo.id.toString());
  221. print('本地视频' + playerInfo.id.toString());
  222. print(_myUrl);
  223. Result rankRes = await HttpManager.get('playerInfo/userRank', data: {'id': playerInfo.id});
  224. if (rankRes.success) {
  225. myRank = rankRes.data + 1;
  226. }
  227. }
  228. setState(() {
  229. isJoin = true;
  230. });
  231. if (houseInfo.statusFlag == 0) {
  232. // if (houseInfo.createUser == StoreProvider.of<AppState>(context).state.userInfo.id.toString()) {
  233. // roomTipsList.add(['房间创建成功,待人数满员时会自动开启比赛,房主也可以手动开启比赛,请在此页面耐心等待其他人的加入,加入房间后再次退出则视为自动放弃比赛,已支付金币概不退换,快快点击右上角分享给好友加入战局吧']);
  234. // changeScroll();
  235. // } else {
  236. // roomTipsList.add([
  237. // '请在此页面耐心等待,竞赛即将开始,届时玩家有10秒的时间进行确认,点击确认方可正式进入竞赛,若没有点击,则视为自动放弃此次竞赛,已支付金币概不退换'
  238. // ]);
  239. // changeScroll();
  240. // }
  241. // Timer(Duration(seconds: 1), () {
  242. // roomTipsList.add([
  243. // '游戏开始后会有弹窗提示授权进行录屏的操作,',
  244. // '请一定点击“确定”或“允许”此操作',
  245. // ',系统会自动跳转打开游戏app,若长时间没有自动跳转,请手动打开游戏app进行比赛,在游戏比赛结束后,请',
  246. // '���定要点击查看游戏最后的��数名次结算页面',
  247. // ',返回游戏主页,最后再切换到我们竞赛app中,点击完成比赛,方可成功上传本次成绩。从游戏开始一小时之内必须返回全民App点击完成比赛,否则判定游戏失败,祝你取得好成绩。'
  248. // ]);
  249. // changeScroll();
  250. // });
  251. } else if (houseInfo.statusFlag != 4) {
  252. if (playerInfo.statusFlag == 3 || playerInfo.statusFlag == 8 || playerInfo.statusFlag == 9) {
  253. getEndTips();
  254. }
  255. }
  256. }
  257. }
  258. if (isJoin && houseInfo.statusFlag != 4 || houseInfo.statusFlag == 0) {
  259. timer = Timer.periodic(Duration(seconds: 1), (timer) {
  260. print('检查');
  261. getNowStatus();
  262. });
  263. }
  264. if (isJoin && houseInfo.statusFlag == 4) {
  265. HttpManager.get('appealInfo/getOne', data: {
  266. 'userId': StoreProvider.of<AppState>(context).state.userInfo.id,
  267. 'playerInfoId': playerInfo.id,
  268. }).then((res) {
  269. if (res.success && res.data != null) {
  270. setState(() {
  271. canAppeal = true;
  272. appealState = 1;
  273. });
  274. } else {
  275. setState(() {
  276. canAppeal = true;
  277. appealState = 0;
  278. });
  279. }
  280. });
  281. }
  282. if (houseInfo.statusFlag == 2 && playerInfo.beginTime != null && playerInfo.endTime == null) {
  283. showSucessInfo(9);
  284. }
  285. }
  286. //加入房间
  287. Future<void> joinRoom() async {
  288. print(StoreProvider.of<AppState>(context).state.userInfo.moneyTicket);
  289. if (StoreProvider.of<AppState>(context).state.userInfo.moneyTicket < 1) {
  290. MyDialog.showDialog(context, '门票不足不能加入');
  291. return;
  292. }
  293. bool hasPermission = await ScreenStreamPlugin.checkPermission();
  294. if (!hasPermission) {
  295. showDialog(
  296. context: context,
  297. builder: (context) => AlertDialog(
  298. title: Text('需要悬浮窗权限'),
  299. contentTextStyle: TextStyle(color: Colors.black87),
  300. content: Text('请在点击确定后,勾选"允许显示在其他应用的上层"'),
  301. actions: <Widget>[
  302. FlatButton(
  303. child: Text('确定'),
  304. onPressed: () {
  305. Navigator.of(context).pop();
  306. ScreenStreamPlugin.requestPermission();
  307. },
  308. ),
  309. ],
  310. ),
  311. );
  312. return;
  313. }
  314. Toast.show(context, '加载中', -1, 'loading');
  315. Result res = await HttpManager.post('houseInfo/join', data: {'houseId': widget.roomId, 'userId': StoreProvider.of<AppState>(context).state.userInfo.id});
  316. Toast.hide();
  317. if (res.success) {
  318. Toast.show(context, '加入成功', 1500, 'success');
  319. checkJoinInfo();
  320. } else {
  321. Toast.show(context, res.error, 1500, 'info');
  322. }
  323. }
  324. //展示通知
  325. void showNotice() {
  326. Navigator.of(context).push(PageRouteBuilder(
  327. opaque: false,
  328. transitionDuration: Duration(milliseconds: 300),
  329. transitionsBuilder: (BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation, Widget child) {
  330. return FadeTransition(
  331. opacity: CurvedAnimation(parent: animation, curve: Curves.linear),
  332. child: child,
  333. );
  334. },
  335. pageBuilder: (BuildContext context, _, __) {
  336. return CompetitionInformation(houseInfo);
  337. }));
  338. }
  339. //改变滚动条
  340. void changeScroll() {
  341. Timer(Duration(seconds: 1), () {
  342. _tipController.animateTo(context.size.height, duration: Duration(milliseconds: 1500), curve: Curves.ease);
  343. });
  344. }
  345. //获取分秒
  346. String getSecondsMIn(int time) {
  347. if (time == null) {
  348. return '';
  349. } else {
  350. return ((time ~/ 1000 ~/ 60) % 60).toString() + '分' + (time ~/ 1000 % 60).toString() + '秒';
  351. }
  352. }
  353. @override
  354. void initState() {
  355. super.initState();
  356. tabList = [
  357. {'title': '房间信息', 'value': 1},
  358. {'title': '人员列表', 'value': 2}
  359. ];
  360. mController = TabController(
  361. length: tabList.length,
  362. vsync: this,
  363. );
  364. mController.addListener(() {
  365. setState(() {
  366. tabIndex = mController.index;
  367. });
  368. print(tabIndex);
  369. });
  370. _tipController = ScrollController();
  371. roomInfo = {};
  372. colorInfo = {
  373. '黄金': Color(0xFFF9D881),
  374. '白银': Color(0xFFAFCAD8),
  375. '青铜': Color(0xFFE18D50),
  376. };
  377. Future.delayed(Duration.zero, () async {
  378. getRoomInfo('first');
  379. userInfo = StoreProvider.of<AppState>(context).state.userInfo;
  380. // showStart();
  381. });
  382. }
  383. @override
  384. void dispose() {
  385. super.dispose();
  386. mController.dispose();
  387. if (timer != null) {
  388. timer.cancel();
  389. }
  390. }
  391. @override
  392. Widget build(BuildContext context) {
  393. ScreenUtil.instance = ScreenUtil(width: 375, height: 667)..init(context);
  394. int status = 0;
  395. if (houseInfo != null) {
  396. status = houseInfo.statusFlag;
  397. }
  398. return WillPopScope(
  399. child: Scaffold(
  400. appBar: AppBar(
  401. title: Container(
  402. child: TabBar(
  403. controller: mController,
  404. labelColor: Color(0xFFD4504B),
  405. unselectedLabelColor: Colors.white.withOpacity(0.5),
  406. labelStyle: TextStyle(fontSize: 16.0),
  407. indicatorColor: Color(0xFFC44D4B),
  408. indicatorWeight: 3,
  409. indicatorSize: TabBarIndicatorSize.label,
  410. tabs: tabList.map((item) {
  411. return Tab(
  412. text: item['title'],
  413. );
  414. }).toList(),
  415. ),
  416. ),
  417. centerTitle: true,
  418. elevation: 0,
  419. actions: <Widget>[
  420. Container(
  421. padding: EdgeInsets.only(right: 30, left: 20),
  422. child: Image.asset(
  423. 'images/icon_fenxiang.png',
  424. width: 24,
  425. ),
  426. )
  427. ],
  428. ),
  429. body: Container(
  430. color: BG_SUB_COLOR,
  431. child: TabBarView(
  432. controller: mController,
  433. children: [_firstPage(), SecondPage(roomId: widget.roomId, status: status)],
  434. )),
  435. floatingActionButton: _joinBtn(),
  436. floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
  437. ),
  438. onWillPop: () {
  439. if (houseInfo == null || (houseInfo.statusFlag != 0) || !isJoin) {
  440. if (timer != null) {
  441. timer.cancel();
  442. }
  443. isPop = true;
  444. Toast.hide();
  445. Navigator.of(context).pop();
  446. return Future.value(false);
  447. } else {
  448. Toast.show(context, '比赛即将开始,暂不能离开房间', 1500, 'info');
  449. }
  450. return Future.value(false);
  451. },
  452. );
  453. }
  454. Widget _firstPage() {
  455. Map houseLevelInfo = roomInfo.isNotEmpty ? roomInfo['houseLevelInfo'] : {};
  456. String levelName = houseLevelInfo.containsKey('levelName') ? houseLevelInfo['levelName'] : '黄金';
  457. int joinMoney = houseLevelInfo.containsKey('feeRatio') && roomInfo.containsKey('bonus') ? houseLevelInfo['feeRatio'] * roomInfo['bonus'] : 0;
  458. String topImg = 'http://images.liqucn.com/img/h22/h70/img_localize_8e824debdd9ee29522690f36680e2d8e_600x337.png';
  459. int statuFlag = 0;
  460. if (houseInfo != null) {
  461. if (houseInfo.video != null) {
  462. topImg = houseInfo.video;
  463. }
  464. if (houseInfo.statusFlag != null) {
  465. statuFlag = houseInfo.statusFlag;
  466. }
  467. }
  468. String timeStr = '';
  469. int _time;
  470. if (houseInfo == null) {
  471. } else if (houseInfo.statusFlag == 0) {
  472. //房价未开始比赛
  473. _time = houseInfo.createTime + 600000 - DateTime.now().millisecondsSinceEpoch;
  474. timeStr = '最迟 ${getSecondsMIn(_time)} 后自动开始比赛';
  475. }
  476. // else if (isJoin && (houseInfo.statusFlag == 2 || houseInfo.statusFlag == 3)) {
  477. // _time = houseInfo.beginTime + 3600000 - DateTime.now().millisecondsSinceEpoch;
  478. // timeStr = '最迟 ${getSecondsMIn(_time)} 后结算';
  479. // }
  480. List jiangpaiImg = ['images/jiangpai_huangjin.png', 'images/jiangpai_baiyin.png', 'images/jiangpai_qingtong.png', 'images/jiangpai_bojin.png'];
  481. String img = '';
  482. if (playerInfo != null) {
  483. if (playerInfo.medal == 'platinum') {
  484. img = jiangpaiImg[3];
  485. } else if (playerInfo.medal == 'gold') {
  486. img = jiangpaiImg[0];
  487. } else if (playerInfo.medal == 'silver') {
  488. img = jiangpaiImg[1];
  489. } else if (playerInfo.medal == 'bronze') {
  490. img = jiangpaiImg[2];
  491. }
  492. }
  493. return LayoutBuilder(
  494. builder: (BuildContext context, BoxConstraints viewportConstraints) {
  495. return Container(
  496. child: RefreshIndicator(
  497. color: PRIMARY_COLOR,
  498. backgroundColor: Colors.white,
  499. displacement: 10,
  500. onRefresh: () async {
  501. await Future.delayed(const Duration(seconds: 1));
  502. },
  503. child: houseInfo != null
  504. ? SingleChildScrollView(
  505. controller: _tipController,
  506. physics: AlwaysScrollableScrollPhysics(),
  507. child: Column(
  508. children: <Widget>[
  509. houseInfo != null ? VideoWidget(videoSrc: houseInfo.video) : Container(),
  510. // Image.network(topImg, width: double.infinity),
  511. Container(
  512. padding: EdgeInsets.all(15),
  513. child: Row(
  514. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  515. children: <Widget>[
  516. Container(
  517. child: Text(
  518. houseInfo != null ? houseInfo.houseName : '',
  519. style: TextStyle(color: Colors.white, fontSize: 16, fontWeight: FontWeight.w500),
  520. ),
  521. ),
  522. Container(
  523. width: 66,
  524. child: LinearButton(
  525. btntext: '竞赛须知',
  526. btnHeight: 28.0,
  527. textColor: Color(0xFF2E3049),
  528. textSize: 12.0,
  529. colorList: [Color(0xFFFFB726), Color(0xFFFFB726)],
  530. onTapHomeMenu: () {
  531. Navigator.of(context).push(PageRouteBuilder(
  532. opaque: false,
  533. transitionDuration: Duration(milliseconds: 300),
  534. transitionsBuilder:
  535. (BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation, Widget child) {
  536. return FadeTransition(
  537. opacity: CurvedAnimation(parent: animation, curve: Curves.linear),
  538. child: child,
  539. );
  540. },
  541. pageBuilder: (BuildContext context, _, __) {
  542. return CompetitionInformation(houseInfo);
  543. }));
  544. },
  545. ),
  546. )
  547. // Container(
  548. // width: 5,
  549. // ),
  550. // houseInfo != null ? ScoreType(houseInfo.scoreType) : Container(),
  551. // Image.network(
  552. // houseLevelInfo.containsKey('icon')
  553. // ? houseLevelInfo['icon']
  554. // : '',
  555. // width: 14,
  556. // ),
  557. // Text(
  558. // houseLevelInfo.containsKey('levelName')
  559. // ? houseLevelInfo['levelName']
  560. // : '',
  561. // style:
  562. // TextStyle(color: colorInfo[levelName]),
  563. // )
  564. ],
  565. )),
  566. Container(
  567. padding: EdgeInsets.symmetric(horizontal: 15),
  568. child: Row(
  569. // mainAxisAlignment: MainAxisAlignment.center,
  570. children: <Widget>[
  571. Image.asset(
  572. 'images/icon_renshu.png',
  573. width: 20,
  574. ),
  575. Text(
  576. (houseInfo != null ? (houseInfo.playerNumber ?? 0).toString() : '0') +
  577. '/' +
  578. (houseInfo != null ? houseInfo.maxNumber.toString() : '0'),
  579. style: TextStyle(fontSize: 14, fontWeight: FontWeight.w500, color: Color(0xFFB1B2C0)),
  580. ),
  581. Container(
  582. width: 30,
  583. ),
  584. Text.rich(TextSpan(children: [
  585. TextSpan(text: "模式 ", style: TextStyle(color: Colors.white30, fontSize: 14)),
  586. TextSpan(text: houseInfo.houseType == 0 ? '评分模式' : '吃鸡模式', style: TextStyle(color: Colors.white70, fontSize: 14)),
  587. ])),
  588. Container(
  589. width: 30,
  590. ),
  591. Text.rich(TextSpan(children: [
  592. TextSpan(text: "房间ID ", style: TextStyle(color: Colors.white30, fontSize: 14)),
  593. TextSpan(text: houseInfo.houseCode != null ? houseInfo.houseCode : '', style: TextStyle(color: Colors.white70, fontSize: 14)),
  594. ])),
  595. ],
  596. ),
  597. ),
  598. timeStr != ''
  599. ? Container(
  600. decoration: BoxDecoration(
  601. color: Color.fromARGB(10, 212, 80, 75),
  602. borderRadius: BorderRadius.all(Radius.circular(4)),
  603. ),
  604. margin: EdgeInsets.fromLTRB(15, 15, 15, 0),
  605. padding: EdgeInsets.symmetric(vertical: 10),
  606. height: 40,
  607. width: double.infinity,
  608. child: Text(timeStr,
  609. textAlign: TextAlign.center, style: TextStyle(fontSize: 15, color: Color(0xFFD4504B), fontWeight: FontWeight.w500)),
  610. )
  611. : Container(),
  612. statuFlag != 4
  613. ? TipsListContent(tipsList: roomTipsList, houseInfo: houseInfo)
  614. : Container(
  615. child: playerInfo != null
  616. ? Column(
  617. children: <Widget>[
  618. ( playerInfo.statusFlag!=7&&playerInfo.statusFlag!=9&&!playerInfo.dataError)? Container(
  619. margin: EdgeInsets.symmetric(vertical: 10, horizontal: 15),
  620. padding: EdgeInsets.all(15),
  621. height: 80,
  622. decoration: BoxDecoration(
  623. color: Color(0xFF3A3E61),
  624. borderRadius: BorderRadius.only(
  625. topRight: Radius.circular(8), bottomLeft: Radius.circular(8), bottomRight: Radius.circular(8))),
  626. child: Column(
  627. crossAxisAlignment: CrossAxisAlignment.start,
  628. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  629. children: <Widget>[
  630. Text('和平精英游戏结果', style: TextStyle(color: Colors.white54, fontSize: 13)),
  631. Row(
  632. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  633. children: <Widget>[
  634. Text.rich(TextSpan(children: [
  635. TextSpan(text: "名次 ", style: TextStyle(color: Colors.white, fontSize: 14)),
  636. TextSpan(
  637. text: '${myRank}',
  638. style: TextStyle(color: Color(0xFFFFB726), fontWeight: FontWeight.w500, fontSize: 14)),
  639. ])),
  640. Text.rich(TextSpan(children: [
  641. TextSpan(text: "时长 ", style: TextStyle(color: Colors.white, fontSize: 14)),
  642. TextSpan(
  643. text: playerInfo.liveTime != null ? '${playerInfo.liveTime}' : '0',
  644. style: TextStyle(color: Color(0xFFFFB726), fontWeight: FontWeight.w500, fontSize: 14)),
  645. ])),
  646. Text.rich(TextSpan(children: [
  647. TextSpan(text: "评分 ", style: TextStyle(color: Colors.white, fontSize: 14)),
  648. TextSpan(
  649. text: '${playerInfo.score}',
  650. style: TextStyle(color: Color(0xFFFFB726), fontWeight: FontWeight.w500, fontSize: 14)),
  651. ])),
  652. ],
  653. )
  654. ],
  655. ),
  656. ):Container(),
  657. Container(
  658. margin: EdgeInsets.symmetric(vertical: 10, horizontal: 15),
  659. padding: EdgeInsets.all(15),
  660. height: 140,
  661. decoration: BoxDecoration(
  662. color: Color(0xFF3A3E61),
  663. borderRadius: BorderRadius.only(
  664. topRight: Radius.circular(8), bottomLeft: Radius.circular(8), bottomRight: Radius.circular(8))),
  665. child: Column(
  666. crossAxisAlignment: CrossAxisAlignment.start,
  667. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  668. children: <Widget>[
  669. Text('比赛结果', style: TextStyle(color: Colors.white54, fontSize: 13)),
  670. Row(
  671. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  672. children: <Widget>[
  673. Text("参数成员 ", style: TextStyle(color: Colors.white, fontSize: 14)),
  674. Text("${houseInfo.playerNumber}人 ",
  675. style: TextStyle(color: Color(0xFFFFB726), fontWeight: FontWeight.w500, fontSize: 14))
  676. ],
  677. ),
  678. Row(
  679. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  680. children: <Widget>[
  681. Text("是否吃鸡 ", style: TextStyle(color: Colors.white, fontSize: 14)),
  682. Text(playerInfo.ranking == 1 ? '是' : '否',
  683. style: TextStyle(color: Color(0xFFFFB726), fontWeight: FontWeight.w500, fontSize: 14))
  684. ],
  685. ),
  686. Row(
  687. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  688. children: <Widget>[
  689. Text("获得奖牌 ", style: TextStyle(color: Colors.white, fontSize: 14)),
  690. img != ''
  691. ? Row(
  692. children: <Widget>[
  693. prefix1.Image.asset(
  694. img,
  695. width: 20,
  696. ),
  697. Text("+1",
  698. style: TextStyle(color: Color(0xFFFFB726), fontWeight: FontWeight.w500, fontSize: 14))
  699. ],
  700. )
  701. : Text("无", style: TextStyle(color: Color(0xFFFFB726), fontWeight: FontWeight.w500, fontSize: 14))
  702. ],
  703. )
  704. ],
  705. ),
  706. )
  707. ],
  708. )
  709. : Container(),
  710. ),
  711. Container(
  712. width: double.infinity,
  713. height: 78,
  714. )
  715. ],
  716. ),
  717. )
  718. : Container()),
  719. );
  720. },
  721. );
  722. }
  723. Widget _joinBtn() {
  724. int joinMoney = houseInfo != null ? houseInfo.houseLevel.entryCoin : 0;
  725. int statusFlag = houseInfo != null ? houseInfo.statusFlag : 1;
  726. int playerStatus = playerInfo != null ? playerInfo.statusFlag : 0;
  727. List jiangpaiImg = ['金牌', '银牌', '铜牌', '铂金'];
  728. String img = '';
  729. if (mymedal != null) {
  730. if (mymedal == 'platinum') {
  731. img = jiangpaiImg[3];
  732. } else if (mymedal == 'gold') {
  733. img = jiangpaiImg[0];
  734. } else if (mymedal == 'silver') {
  735. img = jiangpaiImg[1];
  736. } else if (mymedal == 'bronze') {
  737. img = jiangpaiImg[2];
  738. }
  739. }
  740. if (!isJoin && statusFlag == 0 && houseInfo.userId == StoreProvider.of<AppState>(context).state.userInfo.id) {
  741. return Container(
  742. padding: EdgeInsets.symmetric(vertical: 15, horizontal: 10),
  743. child: Row(
  744. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  745. children: <Widget>[
  746. Container(
  747. width: 165,
  748. child: LinearButton(
  749. colorList: [Color(0xFF4F5386), Color(0xFF4F5386)],
  750. childWidget: Row(
  751. mainAxisAlignment: MainAxisAlignment.center,
  752. children: <Widget>[
  753. Image.asset(
  754. 'images/icon_menpiao.png',
  755. ),
  756. Container(
  757. margin: EdgeInsets.only(left: 6),
  758. child: Text(
  759. '×1',
  760. style: TextStyle(color: Colors.white, fontSize: 16, fontWeight: FontWeight.w500),
  761. ),
  762. ),
  763. Container(
  764. margin: EdgeInsets.only(left: 5),
  765. child: Text(
  766. '加入比赛',
  767. style: TextStyle(color: Colors.white, fontSize: 16, fontWeight: FontWeight.w500),
  768. ))
  769. ],
  770. ),
  771. onTapHomeMenu: () => joinRoom(),
  772. ),
  773. ),
  774. Container(
  775. width: 165,
  776. child: LinearButton(
  777. btntext: '开始竞赛',
  778. onTapHomeMenu: () {
  779. MyDialog.showDialog(context, '确认要开始比赛吗?', isCancel: true, onsubmit: () {
  780. print('开始');
  781. startGame();
  782. });
  783. },
  784. ),
  785. )
  786. ],
  787. ),
  788. );
  789. } else if (!isJoin && statusFlag == 0) {
  790. return Container(
  791. color: BG_SUB_COLOR,
  792. width: ScreenUtil().setWidth(375),
  793. height: 48 + ScreenUtil().setHeight(40),
  794. padding: EdgeInsets.only(top: ScreenUtil().setHeight(20), bottom: ScreenUtil().setHeight(20), left: 15, right: 15),
  795. child: LinearButton(
  796. childWidget: Row(
  797. mainAxisAlignment: MainAxisAlignment.center,
  798. children: <Widget>[
  799. Image.asset(
  800. 'images/icon_menpiao.png',
  801. width: 20,
  802. ),
  803. Container(
  804. margin: EdgeInsets.only(left: 6),
  805. child: Text(
  806. '×1',
  807. style: TextStyle(color: Colors.white, fontSize: 16, fontWeight: FontWeight.w500),
  808. ),
  809. ),
  810. Container(
  811. margin: EdgeInsets.only(left: 20),
  812. child: Text(
  813. '加入比赛',
  814. style: TextStyle(color: Colors.white, fontSize: 16, fontWeight: FontWeight.w500),
  815. ))
  816. ],
  817. ),
  818. onTapHomeMenu: () => joinRoom(),
  819. ),
  820. );
  821. } else if (!isJoin && statusFlag == 2) {
  822. return Container(
  823. width: double.infinity,
  824. padding: EdgeInsets.symmetric(horizontal: 15, vertical: 20),
  825. height: 88,
  826. child: LinearButton(btntext: '房间已经开始,加入通道关闭', colorList: [Color(0xFFC99C09), Color(0xFFC7873E)], textColor: Color(0xFF252532))
  827. // RaisedButton(
  828. // disabledColor: Color(0xFFC2524D),
  829. // disabledTextColor: Color(0xFF252532),
  830. // child: Text(
  831. // '房间已经开始,加入通道关闭',
  832. // style: TextStyle(fontSize: 16),
  833. // ),
  834. // onPressed: null,
  835. // ),
  836. );
  837. } else if (isJoin && statusFlag == 0) {
  838. int _time;
  839. if (houseInfo != null) {
  840. _time = houseInfo.createTime + 600000 - DateTime.now().millisecondsSinceEpoch;
  841. }
  842. if (houseInfo != null && houseInfo.createUser == StoreProvider.of<AppState>(context).state.userInfo.id.toString()) {
  843. return Container(
  844. width: double.infinity,
  845. padding: EdgeInsets.symmetric(horizontal: 15, vertical: 20),
  846. height: 88,
  847. child: LinearButton(
  848. childWidget: Center(
  849. child: Text.rich(TextSpan(children: [
  850. TextSpan(
  851. text: '开始比赛',
  852. style: TextStyle(fontSize: 16, color: Colors.white),
  853. ),
  854. // TextSpan(
  855. // text: '(${getSecondsMIn(_time)}秒后将自动开始)',
  856. // style: TextStyle(fontSize: 12),
  857. // )
  858. ])),
  859. ),
  860. onTapHomeMenu: () {
  861. MyDialog.showDialog(context, '确认要开始比赛吗?', isCancel: true, onsubmit: () {
  862. print('开始');
  863. startGame();
  864. });
  865. },
  866. )
  867. // RaisedButton(
  868. // child: Text.rich(TextSpan(children: [
  869. // TextSpan(
  870. // text: '开始比赛',
  871. // style: TextStyle(fontSize: 16),
  872. // ),
  873. // TextSpan(
  874. // text: '(${getSecondsMIn(_time)}秒后将自动开始)',
  875. // style: TextStyle(fontSize: 12),
  876. // )
  877. // ])),
  878. // onPressed: () {
  879. // MyDialog.showDialog(context, '确认要开始比赛吗?', isCancel: true,
  880. // onsubmit: () {
  881. // print('开始');
  882. // startGame();
  883. // });
  884. // },
  885. // ),
  886. );
  887. } else {
  888. return Container(
  889. width: double.infinity,
  890. padding: EdgeInsets.symmetric(horizontal: 15, vertical: 20),
  891. height: 88,
  892. child: LinearButton(btntext: '等待开始中', colorList: [Color(0xFFAF4946), Color(0xFFAF4946)], textColor: Color(0xFF252532)));
  893. }
  894. } else if (isJoin && statusFlag == 8) {
  895. return Container(
  896. width: double.infinity,
  897. padding: EdgeInsets.symmetric(horizontal: 15, vertical: 20),
  898. height: 88,
  899. child: LinearButton(btntext: '正在努力解析视频中', colorList: [Color(0xFFAF4946), Color(0xFFAF4946)], textColor: Color(0xFF252532))
  900. // RaisedButton(
  901. // disabledColor: Color(0xFFC2524D),
  902. // disabledTextColor: Color(0xFF252532),
  903. // child: Text(
  904. // '正在努力解析视频中',
  905. // style: TextStyle(fontSize: 16),
  906. // ),
  907. // onPressed: null,
  908. // ),
  909. );
  910. } else if (isJoin && (statusFlag == 2 || statusFlag == 3)) {
  911. int _time;
  912. if (houseInfo != null) {
  913. _time = houseInfo.beginTime + 3600000 - DateTime.now().millisecondsSinceEpoch;
  914. }
  915. return Container(
  916. width: double.infinity,
  917. padding: EdgeInsets.symmetric(horizontal: 15, vertical: 20),
  918. height: 88,
  919. child: LinearButton(btntext: '预计还有 ' + getSecondsMIn(_time) + ' 结算', colorList: [Color(0xFFAF4946), Color(0xFFAF4946)], textColor: Color(0xFF252532)),
  920. );
  921. } else if (statusFlag == 4 && tabIndex == 0) {
  922. if (isJoin && canAppeal && appealState == 0 &&playerInfo!=null&&(playerInfo.statusFlag==9||playerInfo.statusFlag==7||playerInfo.dataError)) {
  923. return Container(
  924. width: double.infinity,
  925. padding: EdgeInsets.symmetric(horizontal: 15, vertical: 20),
  926. height: 88,
  927. child: LinearButton(
  928. btntext: '申诉结果',
  929. colorList: [Color(0xFFAF4946), Color(0xFFAF4946)],
  930. textColor: Colors.white,
  931. onTapHomeMenu: () async {
  932. final success = await Navigator.push(context, CupertinoPageRoute(builder: (context) => Appeal(playerInfo)));
  933. if (success != null && success) {
  934. Toast.show(context, '提交成功', 1500, 'success');
  935. setState(() {
  936. appealState = 1;
  937. });
  938. }
  939. },
  940. ));
  941. } else if (isJoin && canAppeal && appealState == 1) {
  942. return Container(
  943. width: double.infinity,
  944. padding: EdgeInsets.symmetric(horizontal: 15, vertical: 20),
  945. height: 88,
  946. child: LinearButton(btntext: '已提交申诉', colorList: [Color(0xFFAF4946), Color(0xFFAF4946)], textColor: Color(0xFF252532)));
  947. } else {
  948. return Container();
  949. }
  950. } else if (statusFlag == 4 && tabIndex == 1) {
  951. return Container(
  952. height: 48,
  953. child: LinearButton(
  954. childWidget: Padding(
  955. padding: EdgeInsets.symmetric(vertical: 9, horizontal: 20),
  956. child: Row(
  957. children: <Widget>[
  958. Container(
  959. width: 30,
  960. height: 30,
  961. margin: EdgeInsets.only(right: 10),
  962. child: CircleAvatar(
  963. backgroundImage: NetworkImage(userInfo.icon),
  964. ),
  965. ),
  966. Expanded(
  967. flex: 1,
  968. child: Text(
  969. userInfo.nickname,
  970. style: TextStyle(
  971. fontSize: 14,
  972. color: Color(0xFF252532),
  973. ),
  974. ),
  975. ),
  976. _myUrl != null
  977. ? Container(
  978. width: 68,
  979. height: 24,
  980. margin: EdgeInsets.only(right: 10),
  981. child: OutlineButton(
  982. textColor: BG_SUB_COLOR,
  983. borderSide: BorderSide(color: BG_SUB_COLOR),
  984. padding: EdgeInsets.all(0),
  985. highlightColor: PRIMARY_COLOR.withOpacity(0.8),
  986. highlightedBorderColor: BG_SUB_COLOR,
  987. child: Text(
  988. '查看回放',
  989. style: TextStyle(fontSize: 12),
  990. ),
  991. onPressed: () =>
  992. {Navigator.push(context, CupertinoPageRoute(builder: (context) => VideoPlayerPage(videoUrl: _myUrl, fileType: 'file')))},
  993. ),
  994. )
  995. : Container(),
  996. myRank != 0 && myRank < 4
  997. ? Text(
  998. img,
  999. style: TextStyle(fontSize: 14, color: Color(0xFF252532), fontWeight: FontWeight.w500),
  1000. )
  1001. : Text(
  1002. '未上榜',
  1003. style: TextStyle(fontSize: 14, color: Color(0xFF252532), fontWeight: FontWeight.w500),
  1004. )
  1005. ],
  1006. ),
  1007. ),
  1008. ),
  1009. );
  1010. } else {
  1011. return Container();
  1012. }
  1013. }
  1014. }
  1015. //房间的提示信息
  1016. class TipsListContent extends StatelessWidget {
  1017. TipsListContent({Key key, this.tipsList, this.houseInfo}) : super(key: key);
  1018. final List<List<String>> tipsList;
  1019. final HouseInfo houseInfo;
  1020. @override
  1021. Widget build(BuildContext context) {
  1022. return Container(
  1023. margin: EdgeInsets.only(top: 15),
  1024. width: double.infinity,
  1025. child: Column(
  1026. children: _list(),
  1027. ),
  1028. );
  1029. }
  1030. List<Widget> _list() {
  1031. List<Widget> myList = [];
  1032. for (int i = 0; i < tipsList.length; i++) {
  1033. myList.add(Tips(content: tipsList[i], showTongzhi: (tipsList[i].length == 1 && i == 0) ? true : false, houseInfo: houseInfo));
  1034. }
  1035. return myList;
  1036. }
  1037. }
  1038. class Tips extends StatelessWidget {
  1039. Tips({Key key, this.content, this.showTongzhi, this.houseInfo}) : super(key: key);
  1040. final List<String> content;
  1041. final bool showTongzhi;
  1042. final HouseInfo houseInfo;
  1043. @override
  1044. Widget build(BuildContext context) {
  1045. return Container(
  1046. padding: EdgeInsets.all(15),
  1047. margin: EdgeInsets.fromLTRB(15, 10, 15, 0),
  1048. decoration: BoxDecoration(
  1049. // gradient: LinearGradient(colors: [Color(0xFF464B6A), Color(0xFF35395E)], begin: Alignment.topCenter, end: Alignment.bottomCenter),
  1050. color: Color(0xFF3A3E61),
  1051. borderRadius: BorderRadius.only(topRight: Radius.circular(8), bottomLeft: Radius.circular(8), bottomRight: Radius.circular(8))),
  1052. child: Column(
  1053. children: <Widget>[
  1054. content.length == 1
  1055. ? Text(
  1056. content[0],
  1057. style: TextStyle(color: Colors.white, fontSize: 13),
  1058. )
  1059. : _textList(),
  1060. ],
  1061. ));
  1062. }
  1063. Widget _textList() {
  1064. return Text.rich(TextSpan(children: [
  1065. TextSpan(
  1066. text: content[0],
  1067. style: TextStyle(color: Colors.white, fontSize: 13),
  1068. ),
  1069. TextSpan(
  1070. text: content[1],
  1071. style: TextStyle(color: Color(0xFFFFB726), fontSize: 13, fontWeight: FontWeight.w500),
  1072. ),
  1073. TextSpan(
  1074. text: content[2],
  1075. style: TextStyle(color: Colors.white, fontSize: 13),
  1076. ),
  1077. TextSpan(
  1078. text: content[3],
  1079. style: TextStyle(color: Color(0xFFFFB726), fontSize: 13, fontWeight: FontWeight.w500),
  1080. ),
  1081. TextSpan(
  1082. text: content[4],
  1083. style: TextStyle(color: Colors.white, fontSize: 13),
  1084. )
  1085. ]));
  1086. }
  1087. }
  1088. //比赛结束排名
  1089. class RankContent extends StatefulWidget {
  1090. RankContent({Key key, this.roomId}) : super(key: key);
  1091. final String roomId; // 用来储存传递过来的值
  1092. @override
  1093. RankContentState createState() => RankContentState();
  1094. }
  1095. class RankContentState extends State<RankContent> {
  1096. List<PlayerInfo> topList = [];
  1097. Future<void> getTopList() async {
  1098. Toast.show(context, '加载中', -1, 'loading');
  1099. Result res = await HttpManager.get('playerInfo/rankPage', data: {'houseId': widget.roomId, 'currentPage': 1, 'pageNumber': 3});
  1100. Toast.hide();
  1101. List<PlayerInfo> list = [];
  1102. if (res.success) {
  1103. for (var item in res.data['pp']) {
  1104. PlayerInfo jonPlayer = PlayerInfo.fromJson(item);
  1105. list.add(jonPlayer);
  1106. }
  1107. } else {}
  1108. setState(() {
  1109. topList = list;
  1110. });
  1111. }
  1112. @override
  1113. void initState() {
  1114. super.initState();
  1115. Future.delayed(Duration.zero, () {
  1116. getTopList();
  1117. });
  1118. }
  1119. @override
  1120. Widget build(BuildContext context) {
  1121. return Container(
  1122. width: double.infinity,
  1123. height: 180,
  1124. margin: EdgeInsets.only(top: 15),
  1125. child: Row(
  1126. mainAxisAlignment: MainAxisAlignment.center,
  1127. crossAxisAlignment: CrossAxisAlignment.end,
  1128. children: <Widget>[_rankItem(2), _rankItem(1), _rankItem(3)],
  1129. ),
  1130. );
  1131. }
  1132. Widget _rankItem(int _num) {
  1133. if (_num > topList.length) {
  1134. return Container(
  1135. width: 107,
  1136. height: 60,
  1137. );
  1138. }
  1139. List colorList = [
  1140. [Color(0xFFD48E00), Color(0xFFFECF01)],
  1141. [Color(0xFFC5C5C5), Color(0xFFE3E3E3)],
  1142. [Color(0xFFE77023), Color(0xFFF89E58)]
  1143. ];
  1144. List imgList = ['images/jiangpai_huangjin.png', 'images/jiangpai_baiyin.png', 'images/jiangpai_qingtong.png', 'images/jiangpai_bojin.png'];
  1145. String img = '';
  1146. if (topList[_num - 1].medal == 'platinum') {
  1147. img = imgList[3];
  1148. } else if (topList[_num - 1].medal == 'gold') {
  1149. img = imgList[0];
  1150. } else if (topList[_num - 1].medal == 'silver') {
  1151. img = imgList[1];
  1152. } else if (topList[_num - 1].medal == 'bronze') {
  1153. img = imgList[2];
  1154. }
  1155. return Container(
  1156. padding: EdgeInsets.only(left: 15, right: 15, top: _num == 1 ? 0 : 15),
  1157. width: 107,
  1158. child: Column(
  1159. crossAxisAlignment: CrossAxisAlignment.center,
  1160. children: <Widget>[
  1161. Container(
  1162. child: Stack(
  1163. children: <Widget>[
  1164. Container(
  1165. margin: EdgeInsets.only(top: 17, bottom: 20),
  1166. width: _num == 1 ? 70 : 60,
  1167. height: _num == 1 ? 70 : 60,
  1168. decoration: BoxDecoration(
  1169. gradient: LinearGradient(colors: colorList[_num - 1], begin: Alignment.topLeft, end: Alignment.bottomRight),
  1170. borderRadius: BorderRadius.all(Radius.circular(100)),
  1171. ),
  1172. child: Center(
  1173. child: Container(
  1174. width: _num == 1 ? 60 : 50,
  1175. height: _num == 1 ? 60 : 50,
  1176. child: CircleAvatar(backgroundImage: NetworkImage(topList[_num - 1].userInfo.icon)),
  1177. )),
  1178. ),
  1179. Positioned(
  1180. bottom: 0,
  1181. child: Center(
  1182. child: Image.asset(
  1183. 'images/ph_yinpai_no' + '$_num.png',
  1184. width: 67,
  1185. ),
  1186. ),
  1187. ),
  1188. Positioned(
  1189. top: 0,
  1190. left: 19,
  1191. child: Center(
  1192. child: img != ''
  1193. ? Image.asset(
  1194. img,
  1195. )
  1196. : Container(),
  1197. ),
  1198. )
  1199. ],
  1200. ),
  1201. ),
  1202. Text(
  1203. topList[_num - 1].userInfo.nickname,
  1204. style: TextStyle(
  1205. color: Color(0xFFFDC372),
  1206. fontSize: 12,
  1207. ),
  1208. overflow: TextOverflow.ellipsis,
  1209. textAlign: TextAlign.center,
  1210. ),
  1211. // SizedBox(
  1212. // height: 5,
  1213. // ),
  1214. // Row(
  1215. // mainAxisAlignment: MainAxisAlignment.center,
  1216. // children: <Widget>[
  1217. // Image.asset('images/icon_jinbi_xiao_hong.png', width: 20),
  1218. // Text('×' + (topList[_num - 1].bonus != null ? topList[_num - 1].bonus.toString() : '0'), style: TextStyle(color: PRIMARY_COLOR, fontSize: 12))
  1219. // ],
  1220. // )
  1221. ],
  1222. ),
  1223. );
  1224. }
  1225. }