x1ongzhu 6 лет назад
Родитель
Сommit
b7c3b2f8d2
50 измененных файлов с 2092 добавлено и 1244 удалено
  1. 4 1
      android/gradle.properties
  2. 4 0
      copyicon.js
  3. BIN
      images/2x/home_icon_vip.png
  4. BIN
      images/2x/icon_guanbi.png
  5. BIN
      images/2x/icon_jiangpin.png
  6. BIN
      images/2x/icon_paihangbang.png
  7. BIN
      images/2x/zhezhao_01.png
  8. BIN
      images/2x/zhezhao_02.png
  9. BIN
      images/2x/zhezhao_03.png
  10. BIN
      images/2x/zhezhao_04.png
  11. BIN
      images/3x/home_icon_vip.png
  12. BIN
      images/3x/icon_guanbi.png
  13. BIN
      images/3x/icon_jiangpin.png
  14. BIN
      images/3x/icon_paihangbang.png
  15. BIN
      images/3x/zhezhao_01.png
  16. BIN
      images/3x/zhezhao_02.png
  17. BIN
      images/3x/zhezhao_03.png
  18. BIN
      images/3x/zhezhao_04.png
  19. BIN
      images/home_icon_vip.png
  20. BIN
      images/icon_guanbi.png
  21. BIN
      images/icon_jiangpin.png
  22. BIN
      images/icon_paihangbang.png
  23. BIN
      images/zhezhao_01.png
  24. BIN
      images/zhezhao_02.png
  25. BIN
      images/zhezhao_03.png
  26. BIN
      images/zhezhao_04.png
  27. 4 2
      lib/main.dart
  28. 3 2
      lib/model/CompetitionInfo.dart
  29. 3 1
      lib/model/CompetitionInfo.g.dart
  30. 5 1
      lib/model/HouseInfo.dart
  31. 21 5
      lib/model/PlayerInfo.dart
  32. 7 2
      lib/model/PlayerInfo.g.dart
  33. 2 2
      lib/net/HttpManager.dart
  34. 179 0
      lib/pages/BonusDialog.dart
  35. 1 1
      lib/pages/CompetitionNotice.dart
  36. 0 9
      lib/pages/CompetitionRank.dart
  37. 156 44
      lib/pages/CompetitionRooms.dart
  38. 60 22
      lib/pages/Competitions.dart
  39. 159 33
      lib/pages/Home.dart
  40. 54 53
      lib/pages/RecordList.dart
  41. 833 104
      lib/pages/RoomInfo.dart
  42. 0 919
      lib/pages/RoomInfo1.dart
  43. 181 0
      lib/pages/RoomInfoNew.dart
  44. 20 9
      lib/pages/SecondRoomInfo.dart
  45. 7 1
      lib/pages/Shop.dart
  46. 33 8
      lib/pages/TipList.dart
  47. 54 14
      lib/pages/UserChange.dart
  48. 195 0
      lib/pages/UserGuid.dart
  49. 2 2
      lib/widget/CheckUpgrade.dart
  50. 105 9
      lib/widget/Competition.dart

+ 4 - 1
android/gradle.properties

@@ -1,3 +1,6 @@
 org.gradle.jvmargs=-Xmx1536M
 android.enableJetifier=true
-android.useAndroidX=true
+android.useAndroidX=true
+org.gradle.parallel=true
+org.gradle.daemon=true
+org.gradle.caching= true

+ 4 - 0
copyicon.js

@@ -1,6 +1,10 @@
 #!/usr/local/bin/node
 const fs = require('fs')
 const path = require('path')
+if (process.argv.length < 3) {
+    console.error('params error!')
+    return;
+}
 let baseDir = path.resolve(process.argv[2])
 var force = process.argv.indexOf('-f') > -1
 console.log("force:", force)

BIN
images/2x/home_icon_vip.png


BIN
images/2x/icon_guanbi.png


BIN
images/2x/icon_jiangpin.png


BIN
images/2x/icon_paihangbang.png


BIN
images/2x/zhezhao_01.png


BIN
images/2x/zhezhao_02.png


BIN
images/2x/zhezhao_03.png


BIN
images/2x/zhezhao_04.png


BIN
images/3x/home_icon_vip.png


BIN
images/3x/icon_guanbi.png


BIN
images/3x/icon_jiangpin.png


BIN
images/3x/icon_paihangbang.png


BIN
images/3x/zhezhao_01.png


BIN
images/3x/zhezhao_02.png


BIN
images/3x/zhezhao_03.png


BIN
images/3x/zhezhao_04.png


BIN
images/home_icon_vip.png


BIN
images/icon_guanbi.png


BIN
images/icon_jiangpin.png


BIN
images/icon_paihangbang.png


BIN
images/zhezhao_01.png


BIN
images/zhezhao_02.png


BIN
images/zhezhao_03.png


BIN
images/zhezhao_04.png


+ 4 - 2
lib/main.dart

@@ -49,7 +49,8 @@ class MobileCyberGamesApp extends StatelessWidget {
           buttonTheme: ButtonThemeData(
             buttonColor: PRIMARY_COLOR,
             splashColor: PRIMARY_COLOR,
-            shape: RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(0))),
+            shape: RoundedRectangleBorder(
+                borderRadius: BorderRadius.all(Radius.circular(0))),
           ),
         ),
         home: store.state.userInfo != null ? HomePage() : LoginFirst(),
@@ -71,7 +72,8 @@ Future<void> main() async {
     production: true,
     debug: true,
   );
-  jpush.applyPushAuthority(NotificationSettingsIOS(sound: true, alert: true, badge: true));
+  jpush.applyPushAuthority(
+      NotificationSettingsIOS(sound: true, alert: true, badge: true));
   final prefs = await SharedPreferences.getInstance();
   HttpManager.token = prefs.getString('token') ?? '';
 

+ 3 - 2
lib/model/CompetitionInfo.dart

@@ -6,7 +6,7 @@ part 'CompetitionInfo.g.dart';
 class CompetitionInfo {
   CompetitionInfo.empty();
 
-  CompetitionInfo(this.id, this.competitionName, this.startTime, this.endTime, this.type, this.bonus, this.intro, this.participatingInfo);
+  CompetitionInfo(this.id, this.competitionName, this.startTime, this.endTime, this.type, this.bonus, this.intro, this.pic, this.participatingInfo);
 
   factory CompetitionInfo.fromJson(Map<String, dynamic> json) => _$CompetitionInfoFromJson(json);
 
@@ -15,8 +15,9 @@ class CompetitionInfo {
   int startTime;
   int endTime;
   int type;
-  int bonus;
+  String bonus;
   String intro;
+  String pic;
   ParticipatingInfo participatingInfo;
 
   Map<String, dynamic> toJson() => _$CompetitionInfoToJson(this);

+ 3 - 1
lib/model/CompetitionInfo.g.dart

@@ -13,8 +13,9 @@ CompetitionInfo _$CompetitionInfoFromJson(Map<String, dynamic> json) {
       json['startTime'] as int,
       json['endTime'] as int,
       json['type'] as int,
-      json['bonus'] as int,
+      json['bonus'] as String,
       json['intro'] as String,
+      json['pic'] as String,
       json['participatingInfo'] == null
           ? null
           : ParticipatingInfo.fromJson(
@@ -30,5 +31,6 @@ Map<String, dynamic> _$CompetitionInfoToJson(CompetitionInfo instance) =>
       'type': instance.type,
       'bonus': instance.bonus,
       'intro': instance.intro,
+      'pic': instance.pic,
       'participatingInfo': instance.participatingInfo
     };

+ 5 - 1
lib/model/HouseInfo.dart

@@ -27,6 +27,7 @@ class HouseInfo {
       this.beginTime,
       this.createTime,
       this.scoreType);
+
   int id;
   int gameId; //游戏ID
   int userId; //用户ID
@@ -48,11 +49,14 @@ class HouseInfo {
   int beginTime; //开始时间
   int createTime; //创建时间
   int scoreType; //评分类型
-  factory HouseInfo.fromJson(Map<String, dynamic> json) => _$HouseInfoFromJson(json);
+  factory HouseInfo.fromJson(Map<String, dynamic> json) =>
+      _$HouseInfoFromJson(json);
 
   Map<String, dynamic> toJson() => _$HouseInfoToJson(this);
+
   // 命名构造函数
   HouseInfo.empty();
+
   @override
   String toString() {
     return _$HouseInfoToJson(this).toString();

+ 21 - 5
lib/model/PlayerInfo.dart

@@ -2,13 +2,31 @@ import 'package:json_annotation/json_annotation.dart';
 import 'UserInfo.dart';
 import 'GameInfo.dart';
 import 'HouseInfo.dart';
+import 'CompetitionInfo.dart';
 
 part 'PlayerInfo.g.dart';
 
 @JsonSerializable()
 class PlayerInfo {
+  PlayerInfo.empty();
+
   PlayerInfo(
-      this.id, this.houseId, this.userId, this.statusFlag, this.userInfo, this.points, this.gameInfo, this.houseInfo, this.rank, this.houseRank, this.video);
+      this.id,
+      this.houseId,
+      this.userId,
+      this.statusFlag,
+      this.userInfo,
+      this.points,
+      this.gameInfo,
+      this.houseInfo,
+      this.rank,
+      this.houseRank,
+      this.video,
+      this.competitionInfo);
+
+  factory PlayerInfo.fromJson(Map<String, dynamic> json) =>
+      _$PlayerInfoFromJson(json);
+
   int id;
   int houseId; //房间id
   int userId; //用户id
@@ -20,12 +38,10 @@ class PlayerInfo {
   int rank; //名次
   int houseRank; //房间比赛名次
   String video; //视频地址
-
-  factory PlayerInfo.fromJson(Map<String, dynamic> json) => _$PlayerInfoFromJson(json);
+  CompetitionInfo competitionInfo;
 
   Map<String, dynamic> toJson() => _$PlayerInfoToJson(this);
-  // 命名构造函数
-  PlayerInfo.empty();
+
   @override
   String toString() {
     return _$PlayerInfoToJson(this).toString();

+ 7 - 2
lib/model/PlayerInfo.g.dart

@@ -24,7 +24,11 @@ PlayerInfo _$PlayerInfoFromJson(Map<String, dynamic> json) {
           : HouseInfo.fromJson(json['houseInfo'] as Map<String, dynamic>),
       json['rank'] as int,
       json['houseRank'] as int,
-      json['video'] as String);
+      json['video'] as String,
+      json['competitionInfo'] == null
+          ? null
+          : CompetitionInfo.fromJson(
+              json['competitionInfo'] as Map<String, dynamic>));
 }
 
 Map<String, dynamic> _$PlayerInfoToJson(PlayerInfo instance) =>
@@ -39,5 +43,6 @@ Map<String, dynamic> _$PlayerInfoToJson(PlayerInfo instance) =>
       'houseInfo': instance.houseInfo,
       'rank': instance.rank,
       'houseRank': instance.houseRank,
-      'video': instance.video
+      'video': instance.video,
+      'competitionInfo': instance.competitionInfo
     };

+ 2 - 2
lib/net/HttpManager.dart

@@ -3,8 +3,8 @@ import 'Result.dart';
 import 'package:intl/intl.dart';
 
 class HttpManager {
-  // static String baseUrl = 'http://47.96.141.102:8203/';
-  static String baseUrl = 'http://192.168.50.132:8080/';
+   static String baseUrl = 'http://47.96.141.102:8203/';
+//  static String baseUrl = 'http://192.168.50.132:8080/';
   static String token;
   static bool debug;
 

+ 179 - 0
lib/pages/BonusDialog.dart

@@ -0,0 +1,179 @@
+import 'package:flutter/cupertino.dart';
+import 'package:flutter/material.dart';
+import '../styles/colors.dart';
+import '../model/CompetitionInfo.dart';
+import '../Constants.dart';
+import 'CompetitionRooms.dart';
+
+class BonusDialog extends StatefulWidget {
+  final List<CompetitionInfo> competitions;
+
+  const BonusDialog({Key key, this.competitions}) : super(key: key);
+
+  @override
+  State<StatefulWidget> createState() {
+    return BonusDialogState();
+  }
+}
+
+class BonusDialogState extends State<BonusDialog> {
+  final Color primaryColor = Color(0xFF1990F8);
+  final Color bgColor = Color(0xE6293559);
+
+  @override
+  Widget build(BuildContext context) {
+    return Column(
+      mainAxisAlignment: MainAxisAlignment.center,
+      mainAxisSize: MainAxisSize.min,
+      children: <Widget>[
+        Container(
+          width: 320,
+          height: 330,
+          padding: EdgeInsets.all(0),
+          decoration: BoxDecoration(
+              color: bgColor,
+              border: Border.all(width: 1, color: primaryColor)),
+          child: Builder(builder: (context) {
+            List<Widget> list = [
+              Container(
+                padding: EdgeInsets.fromLTRB(20, 0, 20, 0),
+                height: 75,
+                child: Row(
+                  crossAxisAlignment: CrossAxisAlignment.center,
+                  children: <Widget>[
+                    Expanded(
+                      child: Container(
+                        height: 2,
+                        color: Colors.white.withAlpha(72),
+                      ),
+                    ),
+                    Container(
+                      margin: EdgeInsets.only(left: 10, right: 10),
+                      child: Text(
+                        '奖品',
+                        style: TextStyle(
+                            color: Colors.white,
+                            fontSize: 18,
+                            fontWeight: FontWeight.bold),
+                      ),
+                    ),
+                    Expanded(
+                      child: Container(
+                        height: 2,
+                        color: Colors.white.withAlpha(72),
+                      ),
+                    ),
+                  ],
+                ),
+              )
+            ];
+            for (CompetitionInfo competitionInfo in widget.competitions) {
+              list.add(bonusItem(competitionInfo));
+              list.add(bonusItem(competitionInfo));
+              list.add(bonusItem(competitionInfo));
+            }
+            return ListView(
+              children: list,
+              padding: EdgeInsets.all(0),
+            );
+          }),
+        ),
+        Container(
+          margin: EdgeInsets.only(top: 20),
+          child: GestureDetector(
+            child: Image.asset('images/icon_guanbi.png'),
+            onTap: () {
+              Navigator.of(context).pop();
+            },
+          ),
+        )
+      ],
+    );
+  }
+
+  Widget bonusItem(CompetitionInfo competitionInfo) {
+    return GestureDetector(
+      child: Container(
+        padding: EdgeInsets.only(left: 20, right: 20),
+        margin: EdgeInsets.only(bottom: 30),
+        child: Column(
+          crossAxisAlignment: CrossAxisAlignment.stretch,
+          children: <Widget>[
+            Row(
+              children: <Widget>[
+                Container(
+                  width: 21,
+                  height: 18,
+                  child: competitionInfo.type == 2
+                      ? Image.asset('images/home_icon_vip.png')
+                      : Container(),
+                ),
+                Expanded(
+                  child: Container(
+                    margin: EdgeInsets.only(left: 10),
+                    child: Text(
+                      competitionInfo.competitionName,
+                      style: TextStyle(
+                          color: Colors.white,
+                          fontSize: 13,
+                          fontWeight: FontWeight.bold),
+                      overflow: TextOverflow.ellipsis,
+                    ),
+                  ),
+                ),
+                Container(
+                  width: 46,
+                  height: 20,
+                  color: PRIMARY_COLOR,
+                  child: Center(
+                    child: Text(
+                      '进入',
+                      style: TextStyle(color: Colors.white, fontSize: 12),
+                    ),
+                  ),
+                ),
+              ],
+            ),
+            Container(
+              color: Colors.white.withAlpha(30),
+              margin: EdgeInsets.only(left: 31, top: 7),
+              height: 1,
+            ),
+            Container(
+              margin: EdgeInsets.only(left: 31, top: 6),
+              child: Text(
+                competitionInfo.bonus ?? '',
+                style: TextStyle(color: Colors.yellow, fontSize: 12),
+              ),
+            )
+          ],
+        ),
+      ),
+      onTap: () {
+        Navigator.push(
+            context,
+            CupertinoPageRoute(
+                builder: (context) => CompetitionRooms(competitionInfo)));
+      },
+    );
+  }
+}
+
+Future showBonusDialog(context, List<CompetitionInfo> competitions) async {
+  return await showGeneralDialog(
+    context: context,
+    barrierDismissible: true,
+    pageBuilder: (BuildContext buildContext, Animation<double> animation,
+        Animation<double> secondaryAnimation) {
+      return Center(
+        child: Material(
+          color: Colors.transparent,
+          child: BonusDialog(competitions: competitions),
+        ),
+      );
+    },
+    barrierLabel: MaterialLocalizations.of(context).modalBarrierDismissLabel,
+    barrierColor: Colors.black26,
+    transitionDuration: const Duration(milliseconds: 300),
+  );
+}

+ 1 - 1
lib/pages/CompetitionNotice.dart

@@ -192,7 +192,7 @@ class CompetitionNoticeState extends State<CompetitionNotice> {
                           child: Text.rich(
                               TextSpan(text: '在游戏比赛结束后,', children: [
                               TextSpan(text: '请一定要点击查看游戏最后的分数名次结算页面', style: TextStyle(color: Colors.yellow)),
-                              TextSpan(text: ',返回游戏主页,最后再切换到我们竞赛app中,点击完成比赛,方可成功传本次成绩,赢取积分'),
+                              TextSpan(text: ',返回游戏主页,最后再切换到我们竞赛app中,点击完成比赛,方可成功传本次成绩,赢取积分'),
                             ]),
                             textAlign: TextAlign.center,
                             style: TextStyle(

+ 0 - 9
lib/pages/CompetitionRank.dart

@@ -57,15 +57,6 @@ class CompetitionRankState extends State<CompetitionRank> {
         centerTitle: true,
         elevation: 0,
         title: Text('排行榜'),
-        actions: <Widget>[
-          CupertinoButton(
-            child: Text(
-              '奖金规则',
-              style: TextStyle(fontSize: 13, color: Color(0x80FFFFFF)),
-            ),
-            onPressed: () {},
-          )
-        ],
       ),
       body: Stack(
         children: <Widget>[

+ 156 - 44
lib/pages/CompetitionRooms.dart

@@ -6,7 +6,6 @@ import 'package:wanna_battle/model/UserPlayTimes.dart';
 import 'package:wanna_battle/styles/totast.dart';
 import '../model/CompetitionInfo.dart';
 import '../styles/colors.dart';
-import 'package:gradient_text/gradient_text.dart';
 import '../model/HouseInfo.dart';
 import '../net/HttpManager.dart';
 import '../net/Result.dart';
@@ -14,6 +13,9 @@ import './RoomInfo.dart';
 import '../redux/AppState.dart';
 import '../plugins/ScreenStramPlugin.dart';
 import './CompetitionRank.dart';
+import '../Constants.dart';
+import './CompetitionRank.dart';
+import 'CompetitionNotice.dart';
 
 class CompetitionRooms extends StatefulWidget {
   CompetitionRooms(this.competitionInfo);
@@ -34,6 +36,7 @@ class _CompetitionRoomsState extends State<CompetitionRooms> {
   void initState() {
     super.initState();
     Future.delayed(Duration.zero, () {
+      showNotice(context);
       _getRooms();
       _getPlayTimes();
     });
@@ -46,46 +49,26 @@ class _CompetitionRoomsState extends State<CompetitionRooms> {
         title: Text(widget.competitionInfo.competitionName),
         centerTitle: true,
         elevation: 0,
-        actions: <Widget>[
-          GestureDetector(
-            onTap: () {
-              Navigator.push(context, CupertinoPageRoute(builder: (context) => CompetitionRank(competitionId: widget.competitionInfo.id)));
-            },
-            child: Image.asset('images/icon_paihangbang.png'),
-          )
-        ],
       ),
       body: Column(
+        crossAxisAlignment: CrossAxisAlignment.stretch,
         children: <Widget>[
           Container(
             color: SUB_COLOR,
-            height: 116,
+            padding: EdgeInsets.only(left: 15, right: 15, bottom: 10),
             child: Column(
               mainAxisAlignment: MainAxisAlignment.center,
               crossAxisAlignment: CrossAxisAlignment.center,
               children: <Widget>[
-                Row(
-                  mainAxisAlignment: MainAxisAlignment.center,
-                  crossAxisAlignment: CrossAxisAlignment.baseline,
-                  textBaseline: TextBaseline.alphabetic,
-                  children: <Widget>[
-                    GradientText('¥',
-                        gradient: LinearGradient(
-                          colors: [Color(0xFFFFC84B), Color(0xFFA26A23)],
-                          begin: Alignment.topCenter,
-                          end: Alignment.bottomCenter,
-                        ),
-                        style: TextStyle(fontSize: 17),
-                        textAlign: TextAlign.center),
-                    GradientText(widget.competitionInfo.bonus.toString().replaceAllMapped(RegExp(r'(\d{1,3})(?=(\d{3})+(?!\d))'), (Match m) => '${m[1]},'),
-                        gradient: LinearGradient(
-                          colors: [Color(0xFFFFC84B), Color(0xFFA26A23)],
-                          begin: Alignment.topCenter,
-                          end: Alignment.bottomCenter,
-                        ),
-                        style: TextStyle(fontSize: 27),
-                        textAlign: TextAlign.center),
-                  ],
+                Container(
+                  margin: EdgeInsets.only(top: 10),
+                  child: Text(
+                    widget.competitionInfo.intro ?? '',
+                    style: TextStyle(
+                      color: Color(0xADFFFFFF),
+                      fontSize: 13,
+                    ),
+                  ),
                 ),
                 Container(
                   color: Colors.yellow,
@@ -100,13 +83,72 @@ class _CompetitionRoomsState extends State<CompetitionRooms> {
                   ),
                 ),
                 Container(
-                  margin: EdgeInsets.only(top: 10),
-                  child: Text(
-                    widget.competitionInfo.intro ?? '',
-                    style: TextStyle(
-                      color: Color(0xADFFFFFF),
-                      fontSize: 13,
-                    ),
+                  margin: EdgeInsets.only(top: 15),
+                  child: Row(
+                    children: <Widget>[
+                      Expanded(
+                        child: MaterialButton(
+                          color: Color(0xFFE56B45),
+                          elevation: 0,
+                          highlightElevation: 0,
+                          child: Row(
+                            mainAxisAlignment: MainAxisAlignment.center,
+                            crossAxisAlignment: CrossAxisAlignment.center,
+                            children: <Widget>[
+                              Image.asset(
+                                'images/icon_jiangpin.png',
+                                width: 19,
+                              ),
+                              Container(
+                                margin: EdgeInsets.only(left: 15),
+                                child: Text(
+                                  '奖品规则',
+                                  style: TextStyle(
+                                      color: Colors.white, fontSize: 14),
+                                ),
+                              )
+                            ],
+                          ),
+                          onPressed: () {
+                            showBonus();
+                          },
+                        ),
+                      ),
+                      Container(width: 15),
+                      Expanded(
+                        child: MaterialButton(
+                          color: PRIMARY_COLOR,
+                          elevation: 0,
+                          highlightElevation: 0,
+                          child: Row(
+                            mainAxisAlignment: MainAxisAlignment.center,
+                            crossAxisAlignment: CrossAxisAlignment.center,
+                            children: <Widget>[
+                              Image.asset(
+                                'images/icon_paihangbang.png',
+                                width: 19,
+                              ),
+                              Container(
+                                margin: EdgeInsets.only(left: 15),
+                                child: Text(
+                                  '排行榜',
+                                  style: TextStyle(
+                                      color: Colors.white, fontSize: 14),
+                                ),
+                              )
+                            ],
+                          ),
+                          onPressed: () {
+                            Navigator.push(
+                                context,
+                                CupertinoPageRoute(
+                                    builder: (context) => CompetitionRank(
+                                        competitionId:
+                                            widget.competitionInfo.id)));
+                          },
+                        ),
+                      )
+                    ],
                   ),
                 )
               ],
@@ -129,7 +171,11 @@ class _CompetitionRoomsState extends State<CompetitionRooms> {
   }
 
   Future<void> _getRooms() async {
-    final Result res = await HttpManager.get('houseInfo/all', data: {'competitionId': widget.competitionInfo.id});
+    final Result res = await HttpManager.get('houseInfo/all', data: {
+      'competitionId': widget.competitionInfo.id,
+      'advancedQuery':
+          ' AND_,status_flag_,!=_,' + HouseStatus.SETTLEMENT.toString(),
+    });
     final List<HouseInfo> list = [];
     if (res.success && res.data != null) {
       for (var item in res.data) {
@@ -161,11 +207,71 @@ class _CompetitionRoomsState extends State<CompetitionRooms> {
     }
     print(res);
   }
+
+  void showBonus() {
+    showGeneralDialog(
+      context: context,
+      barrierDismissible: true,
+      pageBuilder: (BuildContext buildContext, Animation<double> animation,
+          Animation<double> secondaryAnimation) {
+        return Center(
+          child: Material(
+            color: Colors.transparent,
+            child: Container(
+              width: 270,
+              padding: EdgeInsets.all(0),
+              decoration: BoxDecoration(
+                  color: Color(0xE6293559),
+                  border: Border.all(width: 1, color: Color(0xFF1990F8))),
+              child: Column(
+                mainAxisSize: MainAxisSize.min,
+                crossAxisAlignment: CrossAxisAlignment.stretch,
+                children: <Widget>[
+                  Container(
+                    margin: EdgeInsets.only(top: 25),
+                    child: Text(
+                      '奖品规则',
+                      style: TextStyle(
+                          color: Colors.white,
+                          fontSize: 18,
+                          fontWeight: FontWeight.bold),
+                      textAlign: TextAlign.center,
+                    ),
+                  ),
+                  Container(
+                    margin: EdgeInsets.only(top: 20),
+                    child: Text(
+                      '按照比赛周期内\n各个玩家累计积分排名发放奖金',
+                      style: TextStyle(color: Colors.yellow, fontSize: 14),
+                      textAlign: TextAlign.center,
+                    ),
+                  ),
+                  Container(
+                    margin: EdgeInsets.only(top: 10, bottom: 40),
+                    padding: EdgeInsets.only(left: 38, right: 38),
+                    child: Text(
+                      widget.competitionInfo.bonus ?? '',
+                      style: TextStyle(color: Colors.yellow, fontSize: 14),
+                    ),
+                  )
+                ],
+              ),
+            ),
+          ),
+        );
+      },
+      barrierLabel: MaterialLocalizations.of(context).modalBarrierDismissLabel,
+      barrierColor: Colors.black26,
+      transitionDuration: const Duration(milliseconds: 300),
+    );
+  }
 }
 
 class _Room extends StatelessWidget {
   _Room(this.houseInfo);
+
   final HouseInfo houseInfo;
+
   @override
   Widget build(BuildContext context) {
     var status;
@@ -222,7 +328,9 @@ class _Room extends StatelessWidget {
                   style: TextStyle(color: Colors.white, fontSize: 11),
                   children: <TextSpan>[
                     TextSpan(text: '参赛人数:'),
-                    TextSpan(text: (houseInfo.playerNumber ?? 0).toString(), style: TextStyle(color: Color(0xFF38A968))),
+                    TextSpan(
+                        text: (houseInfo.playerNumber ?? 0).toString(),
+                        style: TextStyle(color: Color(0xFF38A968))),
                     TextSpan(text: '/${houseInfo.maxNumber}'),
                   ],
                 ),
@@ -261,7 +369,7 @@ class _Room extends StatelessWidget {
         builder: (context) => AlertDialog(
               title: Text('需要悬浮窗权限'),
               contentTextStyle: TextStyle(color: Colors.black87),
-              content: Text('请在点击确定后勾选"允许显示在其他应用的上层"'),
+              content: Text('请在点击确定后勾选"允许显示在其他应用的上层"'),
               actions: <Widget>[
                 FlatButton(
                   child: Text('确定'),
@@ -276,11 +384,15 @@ class _Room extends StatelessWidget {
       return;
     }
     Toast.show(context, '加载中', -1, 'loading');
-    Result res = await HttpManager.post('houseInfo/join', data: {'houseId': houseId, 'userId': StoreProvider.of<AppState>(context).state.userInfo.id});
+    Result res = await HttpManager.post('houseInfo/join', data: {
+      'houseId': houseId,
+      'userId': StoreProvider.of<AppState>(context).state.userInfo.id
+    });
     Toast.hide();
     if (res.success) {
       Toast.show(context, '加入成功', 1500, 'success');
-      Navigator.push(context, CupertinoPageRoute(builder: (context) => RoomInfo(houseInfo)));
+      Navigator.push(context,
+          CupertinoPageRoute(builder: (context) => RoomInfo(houseInfo)));
     } else {
       Toast.show(context, res.error, 1500, 'info');
     }

+ 60 - 22
lib/pages/Competitions.dart

@@ -10,17 +10,26 @@ import '../net/HttpManager.dart';
 import '../model/CompetitionInfo.dart';
 import '../widget/Competition.dart';
 import '../widget/CheckinDialog.dart';
+import './BonusDialog.dart';
 
 class Competitions extends StatefulWidget {
+  Competitions({Key key}) : super(key: key);
+
   @override
   State<StatefulWidget> createState() => _CompetitionState();
 }
 
 class _CompetitionState extends State<Competitions> {
   List<CompetitionInfo> competitionInfoList = [];
+
   @override
   void initState() {
     super.initState();
+    setState(() {
+      competitionInfoList = PageStorage.of(context)
+              .readState(context, identifier: ValueKey('page1')) ??
+          [];
+    });
     Future.delayed(Duration.zero, () {
       _getCompetitions();
     });
@@ -59,7 +68,8 @@ class _CompetitionState extends State<Competitions> {
                                                 height: 42,
                                               ),
                                               onTap: () {
-                                                Scaffold.of(context).openDrawer();
+                                                Scaffold.of(context)
+                                                    .openDrawer();
                                               },
                                             ),
                                           );
@@ -73,7 +83,8 @@ class _CompetitionState extends State<Competitions> {
                                       height: 42,
                                       margin: EdgeInsets.only(left: 8),
                                       child: Column(
-                                        crossAxisAlignment: CrossAxisAlignment.start,
+                                        crossAxisAlignment:
+                                            CrossAxisAlignment.start,
                                         children: <Widget>[
                                           Text(
                                             userInfo.username,
@@ -85,25 +96,32 @@ class _CompetitionState extends State<Competitions> {
                                           ),
                                           Row(
                                             children: <Widget>[
-                                              Text(
-                                                '最强王者',
-                                                style: TextStyle(
-                                                  color: Color(0xFFFC9A3B),
-                                                  fontSize: 13,
-                                                  fontWeight: FontWeight.bold,
-                                                ),
-                                              ),
+                                              // Text(
+                                              //   '最强王者',
+                                              //   style: TextStyle(
+                                              //     color: Color(0xFFFC9A3B),
+                                              //     fontSize: 13,
+                                              //     fontWeight: FontWeight.bold,
+                                              //   ),
+                                              // ),
                                               Container(
-                                                margin: EdgeInsets.only(left: 23),
-                                                child: Image.asset('images/icon_jinbi.png'),
+                                                margin:
+                                                    EdgeInsets.only(left: 0),
+                                                child: Image.asset(
+                                                    'images/icon_jinbi.png'),
                                               ),
                                               Container(
-                                                margin: EdgeInsets.only(left: 2),
+                                                margin:
+                                                    EdgeInsets.only(left: 2),
                                                 child: Text(
                                                   userInfo.moneyCoin
                                                       .floor()
                                                       .toString()
-                                                      .replaceAllMapped(RegExp(r'(\d{1,3})(?=(\d{3})+(?!\d))'), (Match m) => '${m[1]},'),
+                                                      .replaceAllMapped(
+                                                          RegExp(
+                                                              r'(\d{1,3})(?=(\d{3})+(?!\d))'),
+                                                          (Match m) =>
+                                                              '${m[1]},'),
                                                   style: TextStyle(
                                                     color: Colors.white,
                                                     fontWeight: FontWeight.bold,
@@ -129,7 +147,7 @@ class _CompetitionState extends State<Competitions> {
                                             Container(
                                               margin: EdgeInsets.only(left: 6),
                                               child: Image.asset(
-                                                'images/icon_qiandao.png',
+                                                'images/icon_jiangpin.png',
                                                 width: 20,
                                                 height: 20,
                                               ),
@@ -137,7 +155,7 @@ class _CompetitionState extends State<Competitions> {
                                             Container(
                                               margin: EdgeInsets.only(left: 2),
                                               child: Text(
-                                                '签到',
+                                                '奖品',
                                                 style: TextStyle(
                                                   fontSize: 14,
                                                   color: Colors.white,
@@ -148,7 +166,8 @@ class _CompetitionState extends State<Competitions> {
                                         ),
                                       ),
                                       onTap: () async {
-                                        showCheckinDialog(context);
+                                        showBonusDialog(
+                                            context, competitionInfoList);
                                       },
                                     ),
                                   ),
@@ -181,11 +200,28 @@ class _CompetitionState extends State<Competitions> {
 
   List<Widget> buidChildren() {
     List<Widget> list = [];
-    list.add(Padding(
-      padding: EdgeInsets.fromLTRB(15, 10, 15, 7),
-      child: Image.asset(
-        'images/text_saishiliebiao.png',
-        fit: BoxFit.contain,
+    list.add(Container(
+      height: 56,
+      padding: EdgeInsets.only(left: 15, right: 15),
+      child: Row(
+        children: <Widget>[
+          Expanded(
+            child: Container(height: 2, color: Color(0xFF293354)),
+          ),
+          Container(
+            margin: EdgeInsets.only(left: 10, right: 10),
+            child: Text(
+              '赛事列表',
+              style: TextStyle(
+                  color: Colors.white,
+                  fontSize: 16,
+                  fontWeight: FontWeight.bold),
+            ),
+          ),
+          Expanded(
+            child: Container(height: 2, color: Color(0xFF293354)),
+          )
+        ],
       ),
     ));
     for (CompetitionInfo competitionInfo in competitionInfoList) {
@@ -203,6 +239,8 @@ class _CompetitionState extends State<Competitions> {
       }
       setState(() {
         competitionInfoList = list;
+        PageStorage.of(context).writeState(context, competitionInfoList,
+            identifier: ValueKey('page1'));
       });
     }
   }

+ 159 - 33
lib/pages/Home.dart

@@ -1,18 +1,26 @@
+import 'package:cached_network_image/cached_network_image.dart';
 import 'package:flutter/material.dart';
 import 'package:flutter/cupertino.dart';
+import 'package:shared_preferences/shared_preferences.dart';
+import 'package:wanna_battle/styles/totast.dart';
 import './Competitions.dart';
 import '../widget/HomeDrawer.dart';
 import './TipList.dart';
 import './Shop.dart';
 import '../widget/CheckUpgrade.dart';
+import '../styles/colors.dart';
+import '../net/HttpManager.dart';
+import 'UserGuid.dart';
 
 class HomePage extends StatefulWidget {
   const HomePage({Key key}) : super(key: key);
+
   @override
   _HomePageState createState() => _HomePageState();
 }
 
-class _HomePageState extends State<HomePage> with SingleTickerProviderStateMixin {
+class _HomePageState extends State<HomePage>
+    with SingleTickerProviderStateMixin {
   final List<Tab> myTabs = <Tab>[
     Tab(text: 'LEFT'),
     Tab(text: 'RIGHT'),
@@ -20,12 +28,30 @@ class _HomePageState extends State<HomePage> with SingleTickerProviderStateMixin
 
   final GlobalKey<UpgradeDialogState> _dialogKey = GlobalKey();
   TabController _tabController;
-  
+
+  int _selectedIndex = 0;
+
+  final List<Widget> _widgetOptions = [
+    Competitions(key: PageStorageKey('page1')),
+    TipList(key: PageStorageKey('page2')),
+    Shop(key: PageStorageKey('page3'))
+  ];
+
+  final PageStorageBucket bucket = PageStorageBucket();
+
   @override
   void initState() {
     super.initState();
     _tabController = TabController(vsync: this, length: myTabs.length);
-    Future.delayed(Duration.zero, () {
+    Future.delayed(Duration.zero, () async {
+      final prefs = await SharedPreferences.getInstance();
+      bool isFirstOpen = prefs.getBool('firstOpen') ?? true;
+      if (isFirstOpen) {
+        await showUserGuide(context);
+        await prefs.setBool('firstOpen', false);
+      }
+      getAppNotice();
+
       checkUpgrade(context, _dialogKey);
     });
   }
@@ -40,41 +66,141 @@ class _HomePageState extends State<HomePage> with SingleTickerProviderStateMixin
   Widget build(BuildContext context) {
     return Scaffold(
       drawer: HomeDrawer(),
-      body: CupertinoTabScaffold(
-        tabBar: CupertinoTabBar(
-          items: <BottomNavigationBarItem>[
-            BottomNavigationBarItem(
-              icon: Image.asset('images/tabbar_icon_01.png'),
-              activeIcon: Image.asset('images/tabbar_icon_01_pre.png'),
-              title: Text('赛事'),
+      bottomNavigationBar: BottomNavigationBar(
+        unselectedItemColor: Colors.white70,
+        backgroundColor: Color(0xFF424767),
+        currentIndex: _selectedIndex,
+        items: const <BottomNavigationBarItem>[
+          BottomNavigationBarItem(
+            icon: ImageIcon(AssetImage('images/tabbar_icon_01.png'), size: 28),
+            title: Text(
+              '赛事',
+              style: TextStyle(fontSize: 11),
+            ),
+          ),
+          BottomNavigationBarItem(
+            icon: ImageIcon(AssetImage('images/tabbar_icon_02.png'), size: 28),
+            title: Text(
+              '邮件',
+              style: TextStyle(fontSize: 11),
             ),
-            BottomNavigationBarItem(
-              icon: Image.asset('images/tabbar_icon_02.png'),
-              activeIcon: Image.asset('images/tabbar_icon_02_pre.png'),
-              title: Text('邮件'),
+          ),
+          BottomNavigationBarItem(
+            icon: ImageIcon(AssetImage('images/tabbar_icon_03.png'), size: 28),
+            title: Text(
+              '商城',
+              style: TextStyle(fontSize: 11),
             ),
-            BottomNavigationBarItem(
-              icon: Image.asset('images/tabbar_icon_03.png'),
-              activeIcon: Image.asset('images/tabbar_icon_03_pre.png'),
-              title: Text('商城'),
-            )
-          ],
-          backgroundColor: Color(0xff424767),
-          activeColor: Color(0xff1990F8),
-        ),
-        tabBuilder: (BuildContext context, int index) {
-          switch (index) {
-            case 0:
-              return Competitions();
-            case 1:
-              return TipList();
-            case 2:
-              return Shop();
-            default:
-              return Competitions();
+          ),
+        ],
+        onTap: (int index) {
+          if (index == 2) {
+            Toast.show(context, '即将开放,敬请期待', 1500, 'info');
+            return;
           }
+          setState(() {
+            _selectedIndex = index;
+          });
         },
       ),
+      body: PageStorage(
+          bucket: bucket, child: _widgetOptions.elementAt(_selectedIndex)),
+//      body: CupertinoTabScaffold(
+//        tabBar: CupertinoTabBar(
+//          currentIndex: _selectedIndex,
+//          items: <BottomNavigationBarItem>[
+//            BottomNavigationBarItem(
+//              icon: Image.asset('images/tabbar_icon_01.png'),
+//              activeIcon: Image.asset('images/tabbar_icon_01_pre.png'),
+//              title: Text('赛事'),
+//            ),
+//            BottomNavigationBarItem(
+//              icon: Image.asset('images/tabbar_icon_02.png'),
+//              activeIcon: Image.asset('images/tabbar_icon_02_pre.png'),
+//              title: Text('邮件'),
+//            ),
+//            BottomNavigationBarItem(
+//              icon: Image.asset('images/tabbar_icon_03.png'),
+//              activeIcon: Image.asset('images/tabbar_icon_03_pre.png'),
+//              title: Text('商城'),
+//            )
+//          ],
+//          backgroundColor: Color(0xff424767),
+//          activeColor: Color(0xff1990F8),
+//          onTap: (tabIndex) {
+//            setState(() {
+//              _selectedIndex = 1;
+//            });
+//          },
+//        ),
+//        tabBuilder: (BuildContext context, int index) {
+//          switch (index) {
+//            case 0:
+//              return Competitions();
+//            case 1:
+//              return TipList();
+//            case 2:
+//              return Shop();
+//            default:
+//              return Competitions();
+//          }
+//        },
+//      ),
     );
   }
+
+  Future<void> getAppNotice() async {
+    final res = await HttpManager.get('systemVariable/getOne', data: {
+      'variableName': 'appNotice',
+    });
+    if (res.success) {
+      final String imageUrl = (res.data ?? {})['variableValue'] ?? '';
+      if (imageUrl.isNotEmpty) {
+        showGeneralDialog(
+          context: context,
+          barrierDismissible: true,
+          pageBuilder: (BuildContext buildContext, Animation<double> animation,
+              Animation<double> secondaryAnimation) {
+            return Center(
+              child: Material(
+                color: Colors.transparent,
+                child: Container(
+                  child: Column(
+                    mainAxisSize: MainAxisSize.min,
+                    children: <Widget>[
+                      Container(
+                          width: 320,
+                          height: 375,
+                          padding: EdgeInsets.all(0),
+                          decoration: BoxDecoration(
+                              color: Color(0xE6293559),
+                              border: Border.all(
+                                  width: 1, color: Color(0xFF1990F8))),
+                          child: CachedNetworkImage(
+                            imageUrl: imageUrl,
+                            fit: BoxFit.cover,
+                          )),
+                      Container(
+                        margin: EdgeInsets.only(top: 20),
+                        child: GestureDetector(
+                          child: Image.asset('images/icon_guanbi.png'),
+                          onTap: () {
+                            Navigator.of(context).pop();
+                          },
+                        ),
+                      )
+                    ],
+                  ),
+                ),
+              ),
+            );
+          },
+          barrierLabel:
+              MaterialLocalizations.of(context).modalBarrierDismissLabel,
+          barrierColor: Colors.black26,
+          transitionDuration: const Duration(milliseconds: 300),
+        );
+      }
+    }
+  }
 }

+ 54 - 53
lib/pages/RecordList.dart

@@ -1,4 +1,5 @@
 import 'dart:ui';
+import 'package:cached_network_image/cached_network_image.dart';
 import 'package:flutter/material.dart';
 import '../styles/colors.dart';
 import 'package:flutter/cupertino.dart';
@@ -27,8 +28,11 @@ class RecordListState extends State<RecordList> {
   Future<void> getListPage() async {
     isMore = false;
     Toast.show(context, '加载中', -1, 'loading');
-    Result res = await HttpManager.get('playerInfo/page',
-        data: {'userId': StoreProvider.of<AppState>(context).state.userInfo.id, 'currentPage': currentPage, 'pageNumber': 20});
+    Result res = await HttpManager.get('playerInfo/page', data: {
+      'userId': StoreProvider.of<AppState>(context).state.userInfo.id,
+      'currentPage': currentPage,
+      'pageNumber': 20
+    });
     Toast.hide();
     List<PlayerInfo> list = playerList;
     if (currentPage == 1) {
@@ -74,7 +78,6 @@ class RecordListState extends State<RecordList> {
   Widget build(BuildContext context) {
     return Scaffold(
         appBar: AppBar(
-          backgroundColor: PRIMARY_COLOR,
           title: Text('我的战绩'),
           centerTitle: true,
           elevation: 0,
@@ -90,6 +93,7 @@ class RecordListState extends State<RecordList> {
                 getListPage();
               },
               child: ListView.builder(
+                  padding: EdgeInsets.only(top: 10),
                   physics: AlwaysScrollableScrollPhysics(),
                   controller: _mControll,
                   itemCount: playerList.isNotEmpty ? playerList.length : 1,
@@ -97,54 +101,35 @@ class RecordListState extends State<RecordList> {
                     if (playerList.isEmpty) {
                       return Text(
                         '还没有战绩快去比赛吧...',
-                        style: TextStyle(color: Colors.white30, fontSize: 13, height: 2),
+                        style: TextStyle(
+                            color: Colors.white30, fontSize: 13, height: 2),
                         textAlign: TextAlign.center,
                       );
                     }
-                    return houseItem(roomInfo: playerList[index].houseInfo, gameInfo: playerList[index].gameInfo, playerInfo: playerList[index]);
+                    return houseItem(
+                        roomInfo: playerList[index].houseInfo,
+                        gameInfo: playerList[index].gameInfo,
+                        playerInfo: playerList[index]);
                   })),
         ));
   }
 }
 
 class houseItem extends StatelessWidget {
-  houseItem({Key key, this.roomInfo, this.gameInfo, this.playerInfo}) : super(key: key);
+  houseItem({Key key, this.roomInfo, this.gameInfo, this.playerInfo})
+      : super(key: key);
   final HouseInfo roomInfo;
   final GameInfo gameInfo;
   final PlayerInfo playerInfo;
 
   @override
   Widget build(BuildContext context) {
-    List imageList = ['images/zhanji_icon_01.png', 'images/zhanji_icon_02.png', 'images/zhanji_icon_03.png', 'images/zhanji_icon_04.png'];
-    String imageSrc = '';
-    if (playerInfo.houseRank != null) {
-      if (playerInfo.houseRank < 4) {
-        imageSrc = imageList[playerInfo.houseRank - 1];
-      } else {
-        imageSrc = imageList[3];
-      }
-    }
-    String tishiStr = '';
-    if (playerInfo.statusFlag != null) {
-      if (playerInfo.statusFlag == 6) {
-        tishiStr = '未参加';
-      } else if (playerInfo.statusFlag < 4 || (roomInfo.statusFlag >= 2 && roomInfo.statusFlag < 4)) {
-        tishiStr = '结算中';
-      } else if (playerInfo.statusFlag < 2) {
-        tishiStr = '准备中';
-      }
-    }
     if (roomInfo == null) {
       return Container();
     }
     return Container(
-      decoration: BoxDecoration(
-          gradient: LinearGradient(
-            colors: [Color(0xFF3F4261), Color(0xFF323456)],
-            begin: Alignment.topCenter,
-            end: Alignment.bottomCenter,
-          ),
-          border: Border(bottom: BorderSide(color: Colors.black, width: 1))),
+      margin: EdgeInsets.only(bottom: 1),
+      color: SUB_COLOR,
       child: Material(
         color: Colors.transparent,
         child: InkWell(
@@ -152,8 +137,8 @@ class houseItem extends StatelessWidget {
             padding: EdgeInsets.all(15),
             child: Row(
               children: <Widget>[
-                Image.network(
-                  gameInfo.icon,
+                CachedNetworkImage(
+                  imageUrl: gameInfo?.icon ?? '',
                   width: 48,
                   height: 48,
                 ),
@@ -170,39 +155,55 @@ class houseItem extends StatelessWidget {
                           LimitedBox(
                             maxWidth: 170,
                             child: Text(
-                              roomInfo.houseName,
-                              style: TextStyle(color: Colors.white, fontSize: 14, fontWeight: FontWeight.bold),
+                              playerInfo.competitionInfo?.competitionName ?? '',
+                              style: TextStyle(
+                                  color: Colors.white,
+                                  fontSize: 14,
+                                  fontWeight: FontWeight.bold),
                               maxLines: 1,
                               overflow: TextOverflow.ellipsis,
                             ),
                           ),
-                          Container(
-                            margin: EdgeInsets.only(left: 6),
-                            child: Image.network(roomInfo.houseLevel.icon, width: 14),
-                          ),
-                          Container(
-                              margin: EdgeInsets.only(left: 1),
-                              child: Text(
-                                roomInfo.houseLevel.levelName,
-                                style: TextStyle(color: Color(0xFFF9D881), fontSize: 9),
-                              )),
                         ],
                       ),
-                      Text(
-                        roomInfo.houseAbstract ?? '',
-                        style: TextStyle(fontSize: 12, fontWeight:  FontWeight.normal, color: Color(0xFF9BA0AE)),
-                        maxLines: 2,
-                        overflow: TextOverflow.ellipsis,
+                      Container(
+                        margin: EdgeInsets.only(top: 8),
+                        child: Text(
+                          roomInfo.houseName,
+                          style: TextStyle(
+                              fontSize: 12,
+                              fontWeight: FontWeight.normal,
+                              color: Color(0xFF9BA0AE)),
+                          maxLines: 2,
+                          overflow: TextOverflow.ellipsis,
+                        ),
                       )
                     ],
                   ),
                 ),
-                imageSrc != '' ? Image.asset(imageSrc, width: 70) : Text(tishiStr, style: TextStyle(color: Colors.black38, fontSize: 14))
+                playerInfo.points == null
+                    ? Container()
+                    : Container(
+                        width: 60,
+                        child: Row(
+                          children: <Widget>[
+                            Image.asset('images/icon_jifen_da.png', width: 20),
+                            Text(
+                              playerInfo.points.toString(),
+                              style: TextStyle(
+                                  color: Colors.yellow,
+                                  fontSize: 14,
+                                  fontWeight: FontWeight.bold),
+                            )
+                          ],
+                        ),
+                      )
               ],
             ),
           ),
           onTap: () {
-            Navigator.push(context, CupertinoPageRoute(builder: (context) => RoomInfo(roomInfo)));
+            Navigator.push(context,
+                CupertinoPageRoute(builder: (context) => RoomInfo(roomInfo)));
           },
         ),
       ),

+ 833 - 104
lib/pages/RoomInfo.dart

@@ -1,111 +1,88 @@
-import 'dart:async';
-
 import 'package:flutter/material.dart';
+import 'package:flutter_screenutil/flutter_screenutil.dart';
 import 'package:url_launcher/url_launcher.dart';
-import 'package:wanna_battle/model/PlayerInfo.dart';
-import 'package:wanna_battle/pages/RoomInfoDetail.dart';
-import '../model/HouseInfo.dart';
-import '../Constants.dart';
 import '../styles/colors.dart';
+import 'dart:ui';
+import '../plugins/ScreenStramPlugin.dart';
 import '../net/HttpManager.dart';
 import '../net/Result.dart';
-import '../plugins/ScreenStramPlugin.dart';
-import './StartWindow.dart';
+import 'package:flutter_redux/flutter_redux.dart';
+import '../redux/AppState.dart';
+import '../model/HouseInfo.dart';
+import '../styles/totast.dart';
+import 'StartWindow.dart';
+import '../model/PlayerInfo.dart';
+import '../widget/VideoWidget.dart';
+import 'dart:async';
 import '../widget/Dialog.dart';
+import 'SecondRoomInfo.dart';
+import 'package:flutter/cupertino.dart';
+import 'VideoPlayer.dart';
+import './CompetitionNotice.dart';
 
 class RoomInfo extends StatefulWidget {
-  final HouseInfo houseInfo;
   RoomInfo(this.houseInfo, {Key key}) : super(key: key);
+  final HouseInfo houseInfo; // 用来储存传递过来的值
+
   @override
-  State<StatefulWidget> createState() {
-    return _RoomInfoState();
-  }
+  RoomInfoState createState() => RoomInfoState();
 }
 
-class _RoomInfoState extends State<RoomInfo> with SingleTickerProviderStateMixin {
-  HouseInfo mHouseInfo;
-  PlayerInfo mPlayerInfo;
-  TabController tabController;
-  RoomInfoDetail roomInfoDetail;
+class RoomInfoState extends State<RoomInfo> with SingleTickerProviderStateMixin {
+  TabController mController;
+  Map roomInfo;
+  HouseInfo houseInfo;
+  bool isJoin = true;
+  PlayerInfo playerInfo;
+  bool isPop = false;
+  bool showBack = false;
+  Timer timer;
+  List<List<String>> roomTipsList = [];
+  ScrollController _tipController;
+  String _myUrl;
+  int tabIndex = 0;
+  int myRank = 0;
+  int myPoints = 0;
 
-  @override
-  void initState() {
-    super.initState();
-    mHouseInfo = widget.houseInfo;
-    tabController = TabController(
-      length: 2,
-      vsync: this,
-    );
+  //获取房间信息
+  Future<void> getRoomInfo() async {
+    Result res = await HttpManager.get('houseInfo/getOne', data: {'id': houseInfo.id});
+    if (res.success) {
+      setState(() {
+        roomInfo = res.data;
+        houseInfo = HouseInfo.fromJson(res.data);
+      });
+    } else {}
+    checkJoinInfo();
   }
 
-  @override
-  void dispose() {
-    super.dispose();
-    tabController.dispose();
+  //开始比赛
+  Future<void> startGame() async {
+    Toast.show(context, '加载中', -1, 'loading');
+    Result res = await HttpManager.post('houseInfo/handBegin', data: {'id': houseInfo.id});
+    Toast.hide();
   }
 
-  @override
-  Widget build(BuildContext context) {
-    return WillPopScope(
-      child: Scaffold(
-        appBar: AppBar(
-          title: Container(
-            child: TabBar(
-              controller: tabController,
-              labelColor: PRIMARY_COLOR,
-              unselectedLabelColor: Color(0xCCFFFFFF),
-              labelStyle: TextStyle(fontSize: 16.0),
-              indicatorColor: PRIMARY_COLOR,
-              indicatorWeight: 3,
-              indicatorSize: TabBarIndicatorSize.label,
-              tabs: <Widget>[
-                Tab(text: '房间信息'),
-                Tab(text: '参赛成员'),
-              ],
-            ),
-          ),
-          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(
-          child: TabBarView(
-            controller: tabController,
-            children: [
-              Builder(
-                builder: (context) {
-                  roomInfoDetail = RoomInfoDetail(
-                    mHouseInfo,
-                    onStart: () {
-                      showStart();
-                    },
-                  );
-                  return roomInfoDetail;
-                },
-              ),
-              Container()
-            ],
-          ),
-        ),
-      ),
-      onWillPop: () {
-        return Future.value(true);
-      },
-    );
+  //隔一秒检查是否开始
+  Future<void> getNowStatus() async {
+    Result res = await HttpManager.get('houseInfo/getPlayerNum', data: {'id': houseInfo.id});
+    if (res.success) {
+      if (houseInfo.statusFlag == 0 && res.data['statusFlag'] == 2) {
+        showStart();
+        // timer.cancel();
+      }
+      setState(() {
+        houseInfo.playerNumber = res.data['playerNumber'];
+        houseInfo.statusFlag = res.data['statusFlag'];
+        houseInfo.bonus = res.data['bonus'];
+        houseInfo.beginTime = res.data['beginTime'];
+      });
+    }
   }
 
-  Future<void> refreshData() async {}
-
+//开始比赛确认按钮
   Future<void> showStart() async {
-    if (mPlayerInfo == null) {
+    if (!isJoin) {
       return;
     }
     bool result = await Navigator.of(context).push<bool>(
@@ -123,10 +100,10 @@ class _RoomInfoState extends State<RoomInfo> with SingleTickerProviderStateMixin
         },
       ),
     );
-    final Map<String, dynamic> data = {'id': mPlayerInfo.id};
+    Map<String, dynamic> data = {'id': playerInfo.id};
     bool success = true;
     if (result) {
-      success = await ScreenStreamPlugin.start(mPlayerInfo.id.toString());
+      success = await ScreenStreamPlugin.start(playerInfo.id.toString());
       if (success) {
         data['statusFlag'] = 2;
       } else {
@@ -135,7 +112,13 @@ class _RoomInfoState extends State<RoomInfo> with SingleTickerProviderStateMixin
     } else {
       data['statusFlag'] = 6;
     }
-    final Result res = await HttpManager.post('playerInfo/update', data: data);
+    Result res = await HttpManager.post('playerInfo/update', data: data);
+
+    // MyDialog.showDialog(context, '自动启动游戏失败,请手动切换到游戏app开始竞赛', submitText: '知道了');
+    // Timer(Duration(seconds: 10), () {
+    //   showSucessInfo();
+    // });
+    // return;
     if (res.success) {
       if (data['statusFlag'] == 2) {
         const url = 'pubgmhd1106467070://';
@@ -153,29 +136,775 @@ class _RoomInfoState extends State<RoomInfo> with SingleTickerProviderStateMixin
           throw 'Could not launch $url';
         }
       } else {
-        showStartFailDialog(success ? 1 : 0);
+        showBackDialog(success ? 1 : 0);
       }
     }
   }
 
+//开始录屏提示框
   void showSucessInfo() {
-    showCustomDialog(
-      context,
-      '您已经完成比赛了吗,确认完成,那就点击下方完成竞赛按钮,上传本次成绩,祝您赢取大奖',
-      title: '完成比赛',
-      submitText: '我已完成比赛',
-      onsubmit: () async {
-        HttpManager.post('playerInfo/update', data: {'id': mPlayerInfo.id, 'statusFlag': 3});
-        bool success = await ScreenStreamPlugin.stop();
+    showCustomDialog(context, '您已经完成比赛了吗,确认完成,那就点击下方完成竞赛按钮,上传本次成绩,祝您赢取大奖', title: '完成比赛', submitText: '我已完成比赛', onsubmit: () async {
+      HttpManager.post('playerInfo/update', data: {'id': playerInfo.id, 'statusFlag': 3});
+      bool success = await ScreenStreamPlugin.stop();
+
+      Timer(Duration(seconds: 1), () {
+        getEndTips();
+      });
+
+      setState(() {
+        playerInfo.statusFlag = 3;
+      });
+    });
+  }
+
+  Future<void> getEndTips() async {
+    Result res = await HttpManager.get('playerInfo/endNum', data: {'houseId': houseInfo.id});
+
+    if (res.success) {
+      int time = houseInfo.beginTime + 1 * 3600 * 1000 - DateTime.now().millisecondsSinceEpoch;
+      var nowTime = (time ~/ 1000 ~/ 60) % 60;
+      setState(() {
+        roomTipsList.add(['你已完成本次比赛,当前完成人数 ', res.data.toString(), '人,比赛需要等待所有人完成后方可结算奖励', '', ',你可以先去参加其他竞赛,稍后在“个人中心-我的战绩”中可以查看本次竞赛排名及领取奖励']);
+      });
+    }
+  }
+
+//未确认比赛弹窗
+  void showBackDialog(type) {
+    showCustomDialog(context, (type == 1 ? '由于您未在十秒内点击开始按钮' : '由于您未授权录屏') + ',系统已经判定您放弃比赛,谢谢您的参与。', title: '很遗憾');
+  }
+
+//检查加入信息
+  Future<void> checkJoinInfo() async {
+    Result res = await HttpManager.get('playerInfo/getOne', data: {'userId': StoreProvider.of<AppState>(context).state.userInfo.id, 'houseId': houseInfo.id});
+    if (res.success) {
+      if (res.data == null) {
+        setState(() {
+          isJoin = false;
+        });
+        if (houseInfo.statusFlag == 0) {
+          if (houseInfo.scoreType == 0) {
+            roomTipsList.add([
+              '上方奖金为当前本次竞赛的总奖金,根据当前人数的增加,奖金也就越多,竞赛的第一名获得${houseInfo.houseLevel.firstRatio}%,第二名获得${houseInfo.houseLevel.secondRatio}%,第三名获得${houseInfo.houseLevel.thirdRatio}%,其他名次算作失败没有奖励,祝你取得好成绩。注:奖金池的${houseInfo.houseLevel.feeRatio}%为平台方运营服务费, 奖金池的${houseInfo.houseLevel.poolRatio}%流入赛季总奖金。'
+            ]);
+          } else {
+            roomTipsList.add([
+              '同房间内的玩家进行竞赛,所有吃上鸡的玩家均可获得奖金,即平分总奖金池的${houseInfo.houseLevel.avgRatio}%。注:奖金池的${houseInfo.houseLevel.feeRatio}%为平台方运营服务费, 奖金池的${houseInfo.houseLevel.poolRatio}%流入赛季总奖金。'
+            ]);
+          }
+        }
+      } else {
+        playerInfo = PlayerInfo.fromJson(res.data);
+        myPoints = playerInfo.points;
+        if (houseInfo.statusFlag == 4) {
+          _myUrl = await ScreenStreamPlugin.getVideo(playerInfo.id.toString());
+          print('本地视频' + playerInfo.id.toString());
+          print(_myUrl);
+
+          Result rankRes = await HttpManager.get('playerInfo/userRank', data: {'id': playerInfo.id});
+          if (rankRes.success) {
+            myRank = rankRes.data;
+          }
+        }
+
         setState(() {
-          mPlayerInfo.statusFlag = 3;
+          isJoin = true;
         });
-        refreshData();
+        if (houseInfo.statusFlag == 0) {
+          if (houseInfo.createUser == StoreProvider.of<AppState>(context).state.userInfo.id.toString()) {
+            roomTipsList.add(['房间创建成功,待人数满员时会自动开启比赛,请在此页面耐心等待其他人的加入,退出房间则视为自动放弃比赛,已支付金币概不退换,快快点击右上角分享给好友加入战局吧']);
+          } else {
+            // roomTipsList.add([
+            //   '请在此页面耐心等待,竞赛即将开始,届时玩家有10秒的时间进行确认,点击确认方可正式进入竞赛,若没有点击,则视为自动放弃此次竞赛,已支付金币概不退换'
+            // ]);
+          }
+          // Timer(Duration(seconds: 1), () {
+          //   roomTipsList.add([
+          //     '游戏开始后会有弹窗提示授权进行录屏的操作,',
+          //     '请一定点击“确定”或“允许”此操作',
+          //     ',系统会自动跳转打开游戏app,若长时间没有自动跳转,请手动打开游戏app进行比赛,在游戏比赛结束后,请',
+          //     '一定要点击查看游戏最后的��数名次结算页面',
+          //     ',返回游戏主页,最后再切换到我们竞赛app中,点击完成比赛,方可成功上传本次成绩。从游戏开始一小时之内必须返回全民App点击完成比赛,否则判定游戏失败,祝你取得好成绩。'
+          //   ]);
+          //   changeScroll();
+          // });
+        } else if (houseInfo.statusFlag != 4) {
+          if (playerInfo.statusFlag == 3 || playerInfo.statusFlag == 8 || playerInfo.statusFlag == 9) {
+            getEndTips();
+          }
+        }
+      }
+    }
+
+    if (isJoin && houseInfo.statusFlag != 4) {
+      timer = Timer.periodic(Duration(seconds: 1), (timer) {
+        getNowStatus();
+      });
+    }
+  }
+
+//加入房间
+  Future<void> joinRoom() async {
+    Toast.show(context, '加载中', -1, 'loading');
+    Result res = await HttpManager.post('houseInfo/join', data: {'houseId': houseInfo.id, 'userId': StoreProvider.of<AppState>(context).state.userInfo.id});
+    Toast.hide();
+    if (res.success) {
+      Toast.show(context, '加入成功', 1500, 'success');
+      checkJoinInfo();
+    } else {
+      Toast.show(context, res.error, 1500, 'info');
+    }
+  }
+
+  //获取分秒
+  String getSecondsMIn(int time) {
+    if (time == null) {
+      return '';
+    } else {
+      return ((time ~/ 1000 ~/ 60) % 60).toString() + '分' + (time ~/ 1000 % 60).toString() + '秒';
+    }
+  }
+
+  @override
+  void initState() {
+    super.initState();
+    houseInfo = widget.houseInfo;
+    mController = TabController(
+      length: 2,
+      vsync: this,
+    );
+
+    mController.addListener(() {
+      setState(() {
+        tabIndex = mController.index;
+      });
+      print(tabIndex);
+    });
+    _tipController = ScrollController();
+    roomInfo = {};
+
+    Future.delayed(Duration.zero, () {
+      getRoomInfo();
+    });
+  }
+
+  @override
+  void dispose() {
+    super.dispose();
+    mController.dispose();
+    if (timer != null) {
+      timer.cancel();
+    }
+  }
+
+  @override
+  Widget build(BuildContext context) {
+    ScreenUtil.instance = ScreenUtil(width: 375, height: 667)..init(context);
+    int status = 0;
+    if (houseInfo != null) {
+      status = houseInfo.statusFlag;
+    }
+    return WillPopScope(
+      child: Scaffold(
+        appBar: AppBar(
+          title: Container(
+            child: TabBar(
+              controller: mController,
+              labelColor: PRIMARY_COLOR,
+              unselectedLabelColor: Color(0xCCFFFFFF),
+              labelStyle: TextStyle(fontSize: 16.0),
+              indicatorColor: PRIMARY_COLOR,
+              indicatorWeight: 3,
+              indicatorSize: TabBarIndicatorSize.label,
+              tabs: <Widget>[
+                Tab(text: '房间信息'),
+                Tab(text: '参赛成员'),
+              ],
+            ),
+          ),
+          centerTitle: true,
+          elevation: 0,
+        ),
+        body: Container(
+            color: BG_SUB_COLOR,
+            child: TabBarView(
+              controller: mController,
+              children: [_firstPage(), SecondPage(houseInfo)],
+            )),
+        floatingActionButton: _joinBtn(),
+        floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
+      ),
+      onWillPop: () {
+        if (houseInfo == null || (houseInfo.statusFlag != 0) || !isJoin) {
+          if (timer != null) {
+            timer.cancel();
+          }
+          isPop = true;
+          Toast.hide();
+          Navigator.of(context).pop();
+          return Future.value(false);
+        } else {
+          Toast.show(context, '比赛即将开始,暂不能离开房间', 1500, 'info');
+        }
+        return Future.value(false);
+      },
+    );
+  }
+
+  Widget _firstPage() {
+    int statuFlag = 0;
+    if (houseInfo != null) {
+      if (houseInfo.statusFlag != null) {
+        statuFlag = houseInfo.statusFlag;
+      }
+    }
+
+    return LayoutBuilder(
+      builder: (BuildContext context, BoxConstraints viewportConstraints) {
+        return Container(
+          child: RefreshIndicator(
+              color: PRIMARY_COLOR,
+              backgroundColor: Colors.white,
+              displacement: 10,
+              onRefresh: () async {
+                await Future.delayed(const Duration(seconds: 1));
+              },
+              child: SingleChildScrollView(
+                  controller: _tipController,
+                  physics: AlwaysScrollableScrollPhysics(),
+                  child: Column(
+                    children: <Widget>[
+                      houseInfo != null ? VideoWidget(videoSrc: houseInfo.video) : Container(),
+                      // Image.network(topImg, width: double.infinity),
+                      Container(
+                        height: 60,
+                        padding: EdgeInsets.fromLTRB(15, 0, 15, 0),
+                        child: Row(
+                          children: <Widget>[
+                            Expanded(
+                              child: Text(
+                                houseInfo.houseName,
+                                style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold, color: Colors.white),
+                              ),
+                            ),
+                            Row(
+                              mainAxisAlignment: MainAxisAlignment.center,
+                              children: <Widget>[
+                                Image.asset(
+                                  'images/icon_renshu.png',
+                                  width: 20,
+                                ),
+                                Text(
+                                  (houseInfo != null ? (houseInfo.playerNumber ?? 0).toString() : '0') +
+                                      '/' +
+                                      (houseInfo != null ? houseInfo.maxNumber.toString() : '0'),
+                                  style: TextStyle(fontSize: 14, fontWeight: FontWeight.bold, color: Color(0xFFB1B2C0)),
+                                ),
+                              ],
+                            )
+                          ],
+                        ),
+                      ),
+                      Container(
+                        height: 40,
+                        margin: EdgeInsets.fromLTRB(15, 0, 15, 0),
+                        color: Color(0x1A1990F8),
+                        child: Row(
+                          children: <Widget>[
+                            Expanded(
+                              flex: 1,
+                              child: CupertinoButton(
+                                padding: EdgeInsets.all(0),
+                                onPressed: () {
+                                  if (houseInfo == null || (houseInfo.statusFlag != 0) || !isJoin) {
+                                    if (timer != null) {
+                                      timer.cancel();
+                                    }
+                                    isPop = true;
+                                    Toast.hide();
+                                    Navigator.of(context).pop();
+                                    return Future.value(false);
+                                  } else {
+                                    Toast.show(context, '比赛即将开始,暂不能离开房间', 1500, 'info');
+                                  }
+                                },
+                                child: Text(
+                                  '返回锦标赛',
+                                  style: TextStyle(color: PRIMARY_COLOR, fontSize: 14, fontWeight: FontWeight.bold),
+                                ),
+                              ),
+                            ),
+                            Container(
+                              width: 1,
+                              height: 12,
+                              color: PRIMARY_COLOR,
+                            ),
+                            Expanded(
+                              flex: 1,
+                              child: CupertinoButton(
+                                padding: EdgeInsets.all(0),
+                                onPressed: () {
+                                  showNotice(context);
+                                },
+                                child: Text(
+                                  '竞赛须知',
+                                  style: TextStyle(color: PRIMARY_COLOR, fontSize: 14, fontWeight: FontWeight.bold),
+                                ),
+                              ),
+                            ),
+                          ],
+                        ),
+                      ),
+                      // 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)),
+                      //     ],
+                      //   ),
+                      // ),
+                      statuFlag != 4
+                          ? TipsListContent(tipsList: roomTipsList, houseInfo: houseInfo)
+                          : RankContent(
+                              roomId: houseInfo.id.toString(),
+                            ),
+                      Container(
+                        width: double.infinity,
+                        height: 78,
+                      )
+                    ],
+                  ))),
+        );
       },
     );
   }
 
-  void showStartFailDialog(type) {
-    showCustomDialog(context, type == 1 ? '由于您未在十秒内点击开始按钮' : '由于您未授权录屏' ',系统已经判定您放弃比赛,谢谢您的参与。', title: '很遗憾');
+  Widget _joinBtn() {
+    int joinMoney = 0;
+    int statusFlag = houseInfo != null ? houseInfo.statusFlag : 1;
+    int playerStatus = playerInfo != null ? playerInfo.statusFlag : 0;
+    if (!isJoin && statusFlag == 0) {
+      return Container(
+        color: BG_SUB_COLOR,
+        width: ScreenUtil().setWidth(375),
+        height: 48 + ScreenUtil().setHeight(40),
+        padding: EdgeInsets.only(top: ScreenUtil().setHeight(20), bottom: ScreenUtil().setHeight(20), left: 15, right: 15),
+        child: RaisedButton(
+            textColor: Colors.white,
+            child: Row(
+              mainAxisAlignment: MainAxisAlignment.center,
+              children: <Widget>[
+                Container(
+                    margin: EdgeInsets.only(left: 20),
+                    child: Text(
+                      '加入房间',
+                      style: TextStyle(color: Colors.white, fontSize: 16, fontWeight: FontWeight.bold),
+                    ))
+              ],
+            ),
+            onPressed: () => joinRoom()),
+      );
+    } else if (!isJoin && statusFlag == 2) {
+      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: null,
+        ),
+      );
+    } else if (isJoin && statusFlag == 0) {
+      int _time;
+      if (houseInfo != null) {
+        _time = houseInfo.createTime + 600000 - DateTime.now().millisecondsSinceEpoch;
+      }
+      if (houseInfo != null && houseInfo.createUser == StoreProvider.of<AppState>(context).state.userInfo.id.toString()) {
+        return Container(
+          width: double.infinity,
+          padding: EdgeInsets.symmetric(horizontal: 15, vertical: 20),
+          height: 88,
+          child: RaisedButton(
+            child: Text.rich(TextSpan(children: [
+              TextSpan(
+                text: '开始比赛',
+                style: TextStyle(fontSize: 16),
+              ),
+              TextSpan(
+                text: '(${getSecondsMIn(_time)}秒后将自动开始)',
+                style: TextStyle(fontSize: 12),
+              )
+            ])),
+            onPressed: () {
+              showCustomDialog(context, '确认要开始比赛吗?', isCancel: true, onsubmit: () {
+                print('开始');
+                startGame();
+              });
+            },
+          ),
+        );
+      } else {
+        return Container(
+          width: double.infinity,
+          padding: EdgeInsets.symmetric(horizontal: 15, vertical: 20),
+          height: 88,
+          child: RaisedButton(
+            disabledColor: Color(0xFF1990F8),
+            disabledTextColor: Color(0xFF252532),
+            child: Text(
+              '预计' + getSecondsMIn(_time) + '后开始',
+              style: TextStyle(fontSize: 16),
+            ),
+            onPressed: null,
+          ),
+        );
+      }
+    } else if (isJoin && statusFlag == 8) {
+      return Container(
+        width: double.infinity,
+        padding: EdgeInsets.symmetric(horizontal: 15, vertical: 20),
+        height: 88,
+        child: RaisedButton(
+          disabledColor: Color(0xFF1990F8),
+          disabledTextColor: Color(0xFF252532),
+          child: Text(
+            '正在努力解析视频中',
+            style: TextStyle(fontSize: 16),
+          ),
+          onPressed: null,
+        ),
+      );
+    } else if (isJoin && (statusFlag == 2 || statusFlag == 3)) {
+      int _time;
+      if (houseInfo != null) {
+        _time = houseInfo.beginTime + 3600000 - DateTime.now().millisecondsSinceEpoch;
+      }
+      return Container(
+        width: double.infinity,
+        padding: EdgeInsets.symmetric(horizontal: 15, vertical: 20),
+        height: 88,
+        child: RaisedButton(
+          disabledColor: Color(0xFF1990F8),
+          disabledTextColor: Color(0xFF252532),
+          child: Text(
+            '最迟在' + getSecondsMIn(_time) + '后结算',
+            style: TextStyle(fontSize: 16),
+          ),
+          onPressed: null,
+        ),
+      );
+    } else if (statusFlag == 4 && tabIndex == 0) {
+      return Container(
+        width: double.infinity,
+        padding: EdgeInsets.symmetric(horizontal: 15, vertical: 20),
+        height: 88,
+        child: RaisedButton(
+          disabledColor: Color(0xFF1990F8),
+          disabledTextColor: Color(0xFF15151D),
+          child: Text(
+            '已结束',
+            style: TextStyle(fontSize: 16),
+          ),
+          onPressed: null,
+        ),
+      );
+    } else if (statusFlag == 4 && tabIndex == 1) {
+      return Builder(
+        builder: (context) {
+          return Container(
+            height: 48,
+            color: SUB_COLOR,
+            child: Row(
+              children: <Widget>[
+                Container(
+                    width: 57,
+                    child: Center(
+                      child: Container(
+                          width: 22,
+                          height: 22,
+                          color: PRIMARY_COLOR,
+                          child: Center(
+                            child: Text(
+                              myRank.toString(),
+                              style: TextStyle(fontSize: 12, color: Colors.white),
+                            ),
+                          )),
+                    )),
+                Container(
+                  width: 30,
+                  height: 30,
+                  margin: EdgeInsets.only(right: 10),
+                  child: CircleAvatar(
+                    backgroundImage: NetworkImage(StoreProvider.of<AppState>(context).state.userInfo.icon),
+                  ),
+                ),
+                Expanded(
+                  flex: 1,
+                  child: Text(
+                    StoreProvider.of<AppState>(context).state.userInfo.nickname,
+                    style: TextStyle(
+                      fontSize: 14,
+                      color: Colors.white,
+                    ),
+                  ),
+                ),
+                _myUrl != null
+                    ? Container(
+                        width: 68,
+                        height: 24,
+                        margin: EdgeInsets.only(right: 10),
+                        child: OutlineButton(
+                          textColor: BG_SUB_COLOR,
+                          borderSide: BorderSide(color: BG_SUB_COLOR),
+                          padding: EdgeInsets.all(0),
+                          highlightColor: PRIMARY_COLOR.withOpacity(0.8),
+                          highlightedBorderColor: BG_SUB_COLOR,
+                          child: Text(
+                            '查看回放',
+                            style: TextStyle(fontSize: 12),
+                          ),
+                          onPressed: () {
+                            Navigator.push(context, CupertinoPageRoute(builder: (context) => VideoPlayerPage(videoUrl: _myUrl, fileType: 'file')));
+                          },
+                        ),
+                      )
+                    : Container()
+              ],
+            ),
+          );
+        },
+      );
+    } else {
+      return Container();
+    }
+  }
+}
+
+//房间的提示信息
+class TipsListContent extends StatelessWidget {
+  TipsListContent({Key key, this.tipsList, this.houseInfo}) : super(key: key);
+  final List<List<String>> tipsList;
+  final HouseInfo houseInfo;
+
+  @override
+  Widget build(BuildContext context) {
+    return Container(
+      margin: EdgeInsets.only(top: 15),
+      width: double.infinity,
+      child: Column(
+        children: _list(),
+      ),
+    );
+  }
+
+  List<Widget> _list() {
+    List<Widget> myList = [];
+    for (int i = 0; i < tipsList.length; i++) {
+      myList.add(Tips(content: tipsList[i], showTongzhi: (tipsList[i].length == 1 && i == 0) ? true : false, houseInfo: houseInfo));
+    }
+
+    return myList;
+  }
+}
+
+class Tips extends StatelessWidget {
+  Tips({Key key, this.content, this.showTongzhi, this.houseInfo}) : super(key: key);
+  final List<String> content;
+  final bool showTongzhi;
+  final HouseInfo houseInfo;
+  @override
+  Widget build(BuildContext context) {
+    return Container(
+        padding: EdgeInsets.all(15),
+        margin: EdgeInsets.fromLTRB(15, 10, 15, 0),
+        color: Color(0xFF293354),
+        child: Column(
+          children: <Widget>[
+            content.length == 1
+                ? Text(
+                    content[0],
+                    style: TextStyle(color: Colors.white, fontSize: 13),
+                  )
+                : _textList(),
+            showTongzhi
+                ? FlatButton(
+                    padding: EdgeInsets.all(0),
+                    textColor: PRIMARY_COLOR,
+                    highlightColor: Colors.transparent,
+                    splashColor: Colors.transparent,
+                    child: Text(
+                      '查看竞赛须知',
+                      style: TextStyle(
+                        decoration: TextDecoration.underline,
+                      ),
+                    ),
+                    onPressed: () {
+                      showNotice(context);
+                    },
+                  )
+                : Container()
+          ],
+        ));
+  }
+
+  Widget _textList() {
+    return Text.rich(TextSpan(
+      style: TextStyle(color: Colors.white, fontSize: 13),
+      children: [
+        TextSpan(text: content[0]),
+        TextSpan(
+          text: content[1],
+          style: TextStyle(color: PRIMARY_COLOR, fontSize: 13, fontWeight: FontWeight.bold),
+        ),
+        TextSpan(text: content[2]),
+        TextSpan(text: content[3]),
+        TextSpan(text: content[4])
+      ],
+    ));
+  }
+}
+
+//比赛结束排名
+class RankContent extends StatefulWidget {
+  RankContent({Key key, this.roomId}) : super(key: key);
+  final String roomId; // 用来储存传递过来的值
+  @override
+  RankContentState createState() => RankContentState();
+}
+
+class RankContentState extends State<RankContent> {
+  List<PlayerInfo> topList = [];
+  Future<void> getTopList() async {
+    Toast.show(context, '加载中', -1, 'loading');
+    Result res = await HttpManager.get('playerInfo/rankPage', data: {'houseId': widget.roomId, 'currentPage': 1, 'pageNumber': 3});
+    Toast.hide();
+    List<PlayerInfo> list = [];
+    if (res.success) {
+      for (var item in res.data['pp']) {
+        PlayerInfo jonPlayer = PlayerInfo.fromJson(item);
+        list.add(jonPlayer);
+      }
+    } else {}
+    setState(() {
+      topList = list;
+    });
+  }
+
+  @override
+  void initState() {
+    super.initState();
+    Future.delayed(Duration.zero, () {
+      getTopList();
+    });
+  }
+
+  @override
+  Widget build(BuildContext context) {
+    return Container(
+      width: double.infinity,
+      height: 180,
+      margin: EdgeInsets.only(top: 15),
+      child: Row(
+        mainAxisAlignment: MainAxisAlignment.center,
+        crossAxisAlignment: CrossAxisAlignment.end,
+        children: <Widget>[_rankItem(2), _rankItem(1), _rankItem(3)],
+      ),
+    );
+  }
+
+  Widget _rankItem(int _num) {
+    if (_num > topList.length) {
+      return Container(
+        width: 107,
+        height: 60,
+      );
+    }
+    List colorList = [
+      [Color(0xFFD48E00), Color(0xFFFECF01)],
+      [Color(0xFFC5C5C5), Color(0xFFE3E3E3)],
+      [Color(0xFFE77023), Color(0xFFF89E58)]
+    ];
+    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_jifen.png', width: 20),
+              Text('×' + (topList[_num - 1].points != null ? topList[_num - 1].points.toString() : '0'), style: TextStyle(color: PRIMARY_COLOR, fontSize: 12))
+            ],
+          )
+        ],
+      ),
+    );
   }
 }

+ 0 - 919
lib/pages/RoomInfo1.dart

@@ -1,919 +0,0 @@
-import 'package:flutter/material.dart';
-import 'package:flutter_screenutil/flutter_screenutil.dart';
-import 'package:url_launcher/url_launcher.dart';
-import '../styles/colors.dart';
-import 'dart:ui';
-import '../plugins/ScreenStramPlugin.dart';
-import '../net/HttpManager.dart';
-import '../net/Result.dart';
-import 'package:flutter_redux/flutter_redux.dart';
-import '../redux/AppState.dart';
-import '../model/HouseInfo.dart';
-import '../styles/totast.dart';
-import 'StartWindow.dart';
-import '../model/PlayerInfo.dart';
-import '../widget/VideoWidget.dart';
-import 'dart:async';
-import '../widget/Dialog.dart';
-import 'SecondRoomInfo.dart';
-import 'package:flutter/cupertino.dart';
-import 'VideoPlayer.dart';
-import './CompetitionNotice.dart';
-
-class RoomInfo extends StatefulWidget {
-  RoomInfo(this.houseInfo, {Key key}) : super(key: key);
-  final HouseInfo houseInfo; // 用来储存传递过来的值
-
-  @override
-  RoomInfoState createState() => RoomInfoState();
-}
-
-class RoomInfoState extends State<RoomInfo> with SingleTickerProviderStateMixin {
-  TabController mController;
-  Map roomInfo;
-  HouseInfo houseInfo;
-  bool isJoin = true;
-  PlayerInfo playerInfo;
-  bool isPop = false;
-  bool showBack = false;
-  Timer timer;
-  List<List<String>> roomTipsList = [];
-  ScrollController _tipController;
-  String _myUrl;
-  int tabIndex = 0;
-  int myRank = 0;
-  int myPoints = 0;
-
-  //获取房间信息
-  Future<void> getRoomInfo() async {
-    Result res = await HttpManager.get('houseInfo/getOne', data: {'id': houseInfo.id});
-    if (res.success) {
-      setState(() {
-        roomInfo = res.data;
-        houseInfo = HouseInfo.fromJson(res.data);
-      });
-    } else {}
-    checkJoinInfo();
-  }
-
-  //开始比赛
-  Future<void> startGame() async {
-    Toast.show(context, '加载中', -1, 'loading');
-    Result res = await HttpManager.post('houseInfo/handBegin', data: {'id': houseInfo.id});
-    Toast.hide();
-  }
-
-  //隔一秒检查是否开始
-  Future<void> getNowStatus() async {
-    Result res = await HttpManager.get('houseInfo/getPlayerNum', data: {'id': houseInfo.id});
-    if (res.success) {
-      if (houseInfo.statusFlag == 0 && res.data['statusFlag'] == 2) {
-        showStart();
-        // timer.cancel();
-      }
-      setState(() {
-        houseInfo.playerNumber = res.data['playerNumber'];
-        houseInfo.statusFlag = res.data['statusFlag'];
-        houseInfo.bonus = res.data['bonus'];
-        houseInfo.beginTime = res.data['beginTime'];
-      });
-    }
-  }
-
-//开始比赛确认按钮
-  Future<void> showStart() async {
-    if (!isJoin) {
-      return;
-    }
-    bool result = await Navigator.of(context).push<bool>(
-      PageRouteBuilder(
-        opaque: false,
-        transitionDuration: Duration(milliseconds: 300),
-        transitionsBuilder: (BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation, Widget child) {
-          return FadeTransition(
-            opacity: CurvedAnimation(parent: animation, curve: Curves.linear),
-            child: child,
-          );
-        },
-        pageBuilder: (BuildContext context, _, __) {
-          return StartWindow();
-        },
-      ),
-    );
-    Map<String, dynamic> data = {'id': playerInfo.id};
-    bool success = true;
-    if (result) {
-      success = await ScreenStreamPlugin.start(playerInfo.id.toString());
-      if (success) {
-        data['statusFlag'] = 2;
-      } else {
-        data['statusFlag'] = 6;
-      }
-    } else {
-      data['statusFlag'] = 6;
-    }
-    Result res = await HttpManager.post('playerInfo/update', data: data);
-
-    // MyDialog.showDialog(context, '自动启动游戏失败,请手动切换到游戏app开始竞赛', submitText: '知道了');
-    // Timer(Duration(seconds: 10), () {
-    //   showSucessInfo();
-    // });
-    // return;
-    if (res.success) {
-      if (data['statusFlag'] == 2) {
-        const url = 'pubgmhd1106467070://';
-        if (await canLaunch(url)) {
-          Timer(Duration(seconds: 1), () async {
-            await launch(url);
-            showSucessInfo();
-          });
-        } else {
-          showCustomDialog(context, '自动启动游戏失败,请手动切换到游戏app开始竞赛', submitText: '知道了');
-          Timer(Duration(seconds: 10), () {
-            showSucessInfo();
-          });
-
-          throw 'Could not launch $url';
-        }
-      } else {
-        showBackDialog(success ? 1 : 0);
-      }
-    }
-  }
-
-//开始录屏提示框
-  void showSucessInfo() {
-    showCustomDialog(context, '您已经完成比赛了吗,确认完成,那就点击下方完成竞赛按钮,上传本次成绩,祝您赢取大奖', title: '完成比赛', submitText: '我已完成比赛', onsubmit: () async {
-      HttpManager.post('playerInfo/update', data: {'id': playerInfo.id, 'statusFlag': 3});
-      bool success = await ScreenStreamPlugin.stop();
-
-      Timer(Duration(seconds: 1), () {
-        getEndTips();
-      });
-
-      setState(() {
-        playerInfo.statusFlag = 3;
-      });
-    });
-  }
-
-  Future<void> getEndTips() async {
-    Result res = await HttpManager.get('playerInfo/endNum', data: {'houseId': houseInfo.id});
-
-    if (res.success) {
-      int time = houseInfo.beginTime + 1 * 3600 * 1000 - DateTime.now().millisecondsSinceEpoch;
-      var nowTime = (time ~/ 1000 ~/ 60) % 60;
-      setState(() {
-        roomTipsList.add(['你已完成本次比赛,当前完成人数 ', res.data.toString(), '人,比赛需要等待所有人完成后方可结算奖励', '', ',你可以先去参加其他竞赛,稍后在“个人中心-我的战绩”中可以查看本次竞赛排名及领取奖励']);
-      });
-    }
-  }
-
-//未确认比赛弹窗
-  void showBackDialog(type) {
-    showCustomDialog(context, (type == 1 ? '由于您未在十秒内点击开始按钮' : '由于您未授权录屏') + ',系统已经判定您放弃比赛,谢谢您的参与。', title: '很遗憾');
-  }
-
-//检查加入信息
-  Future<void> checkJoinInfo() async {
-    Result res = await HttpManager.get('playerInfo/getOne', data: {'userId': StoreProvider.of<AppState>(context).state.userInfo.id, 'houseId': houseInfo.id});
-    if (res.success) {
-      if (res.data == null) {
-        setState(() {
-          isJoin = false;
-        });
-        if (houseInfo.statusFlag == 0) {
-          if (houseInfo.scoreType == 0) {
-            roomTipsList.add([
-              '上方奖金为当前本次竞赛的总奖金,根据当前人数的增加,奖金也就越多,竞赛的第一名获得${houseInfo.houseLevel.firstRatio}%,第二名获得${houseInfo.houseLevel.secondRatio}%,第三名获得${houseInfo.houseLevel.thirdRatio}%,其他名次算作失败没有奖励,祝你取得好成绩。注:奖金池的${houseInfo.houseLevel.feeRatio}%为平台方运营服务费, 奖金池的${houseInfo.houseLevel.poolRatio}%流入赛季总奖金。'
-            ]);
-          } else {
-            roomTipsList.add([
-              '同房间内的玩家进行竞赛,所有吃上鸡的玩家均可获得奖金,即平分总奖金池的${houseInfo.houseLevel.avgRatio}%。注:奖金池的${houseInfo.houseLevel.feeRatio}%为平台方运营服务费, 奖金池的${houseInfo.houseLevel.poolRatio}%流入赛季总奖金。'
-            ]);
-          }
-        }
-      } else {
-        playerInfo = PlayerInfo.fromJson(res.data);
-        myPoints = playerInfo.points;
-        if (houseInfo.statusFlag == 4) {
-          _myUrl = await ScreenStreamPlugin.getVideo(playerInfo.id.toString());
-          print('本地视频' + playerInfo.id.toString());
-          print(_myUrl);
-
-          Result rankRes = await HttpManager.get('playerInfo/userRank', data: {'id': playerInfo.id});
-          if (rankRes.success) {
-            myRank = rankRes.data + 1;
-          }
-        }
-
-        setState(() {
-          isJoin = true;
-        });
-        if (houseInfo.statusFlag == 0) {
-          if (houseInfo.createUser == StoreProvider.of<AppState>(context).state.userInfo.id.toString()) {
-            roomTipsList.add(['房间创建成功,待人数满员时会自动开启比赛,请在此页面耐心等待其他人的加入,退出房间则视为自动放弃比赛,已支付金币概不退换,快快点击右上角分享给好友加入战局吧']);
-          } else {
-            // roomTipsList.add([
-            //   '请在此页面耐心等待,竞赛即将开始,届时玩家有10秒的时间进行确认,点击确认方可正式进入竞赛,若没有点击,则视为自动放弃此次竞赛,已支付金币概不退换'
-            // ]);
-          }
-          // Timer(Duration(seconds: 1), () {
-          //   roomTipsList.add([
-          //     '游戏开始后会有弹窗提示授权进行录屏的操作,',
-          //     '请一定点击“确定”或“允许”此操作',
-          //     ',系统会自动跳转打开游戏app,若长时间没有自动跳转,请手动打开游戏app进行比赛,在游戏比赛结束后,请',
-          //     '一定要点击查看游戏最后的��数名次结算页面',
-          //     ',返回游戏主页,最后再切换到我们竞赛app中,点击完成比赛,方可成功上传本次成绩。从游戏开始一小时之内必须返回全民App点击完成比赛,否则判定游戏失败,祝你取得好成绩。'
-          //   ]);
-          //   changeScroll();
-          // });
-        } else if (houseInfo.statusFlag != 4) {
-          if (playerInfo.statusFlag == 3 || playerInfo.statusFlag == 8 || playerInfo.statusFlag == 9) {
-            getEndTips();
-          }
-        }
-      }
-    }
-
-    if (isJoin && houseInfo.statusFlag != 4) {
-      timer = Timer.periodic(Duration(seconds: 1), (timer) {
-        getNowStatus();
-      });
-    }
-  }
-
-//加入房间
-  Future<void> joinRoom() async {
-    Toast.show(context, '加载中', -1, 'loading');
-    Result res = await HttpManager.post('houseInfo/join', data: {'houseId': houseInfo.id, 'userId': StoreProvider.of<AppState>(context).state.userInfo.id});
-    Toast.hide();
-    if (res.success) {
-      Toast.show(context, '加入成功', 1500, 'success');
-      checkJoinInfo();
-    } else {
-      Toast.show(context, res.error, 1500, 'info');
-    }
-  }
-
-  //获取分秒
-  String getSecondsMIn(int time) {
-    if (time == null) {
-      return '';
-    } else {
-      return ((time ~/ 1000 ~/ 60) % 60).toString() + '分' + (time ~/ 1000 % 60).toString() + '秒';
-    }
-  }
-
-  @override
-  void initState() {
-    super.initState();
-    houseInfo = widget.houseInfo;
-    mController = TabController(
-      length: 2,
-      vsync: this,
-    );
-
-    mController.addListener(() {
-      setState(() {
-        tabIndex = mController.index;
-      });
-      print(tabIndex);
-    });
-    _tipController = ScrollController();
-    roomInfo = {};
-
-    Future.delayed(Duration.zero, () {
-      getRoomInfo();
-    });
-  }
-
-  @override
-  void dispose() {
-    super.dispose();
-    mController.dispose();
-    if (timer != null) {
-      timer.cancel();
-    }
-  }
-
-  @override
-  Widget build(BuildContext context) {
-    ScreenUtil.instance = ScreenUtil(width: 375, height: 667)..init(context);
-    int status = 0;
-    if (houseInfo != null) {
-      status = houseInfo.statusFlag;
-    }
-    return WillPopScope(
-      child: Scaffold(
-        appBar: AppBar(
-          title: Container(
-            child: TabBar(
-              controller: mController,
-              labelColor: PRIMARY_COLOR,
-              unselectedLabelColor: Color(0xCCFFFFFF),
-              labelStyle: TextStyle(fontSize: 16.0),
-              indicatorColor: PRIMARY_COLOR,
-              indicatorWeight: 3,
-              indicatorSize: TabBarIndicatorSize.label,
-              tabs: <Widget>[
-                Tab(text: '房间信息'),
-                Tab(text: '参赛成员'),
-              ],
-            ),
-          ),
-          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(houseInfo)],
-            )),
-        floatingActionButton: _joinBtn(),
-        floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
-      ),
-      onWillPop: () {
-        if (houseInfo == null || (houseInfo.statusFlag != 0) || !isJoin) {
-          if (timer != null) {
-            timer.cancel();
-          }
-          isPop = true;
-          Toast.hide();
-          Navigator.of(context).pop();
-          return Future.value(false);
-        } else {
-          Toast.show(context, '比赛即将开始,暂不能离开房间', 1500, 'info');
-        }
-        return Future.value(false);
-      },
-    );
-  }
-
-  Widget _firstPage() {
-    int statuFlag = 0;
-    if (houseInfo != null) {
-      if (houseInfo.statusFlag != null) {
-        statuFlag = houseInfo.statusFlag;
-      }
-    }
-
-    return LayoutBuilder(
-      builder: (BuildContext context, BoxConstraints viewportConstraints) {
-        return Container(
-          child: RefreshIndicator(
-              color: PRIMARY_COLOR,
-              backgroundColor: Colors.white,
-              displacement: 10,
-              onRefresh: () async {
-                await Future.delayed(const Duration(seconds: 1));
-              },
-              child: SingleChildScrollView(
-                  controller: _tipController,
-                  physics: AlwaysScrollableScrollPhysics(),
-                  child: Column(
-                    children: <Widget>[
-                      houseInfo != null ? VideoWidget(videoSrc: houseInfo.video) : Container(),
-                      // Image.network(topImg, width: double.infinity),
-                      Container(
-                        height: 60,
-                        padding: EdgeInsets.fromLTRB(15, 0, 15, 0),
-                        child: Row(
-                          children: <Widget>[
-                            Expanded(
-                              child: Text(
-                                houseInfo.houseName,
-                                style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold, color: Colors.white),
-                              ),
-                            ),
-                            Row(
-                              mainAxisAlignment: MainAxisAlignment.center,
-                              children: <Widget>[
-                                Image.asset(
-                                  'images/icon_renshu.png',
-                                  width: 20,
-                                ),
-                                Text(
-                                  (houseInfo != null ? (houseInfo.playerNumber ?? 0).toString() : '0') +
-                                      '/' +
-                                      (houseInfo != null ? houseInfo.maxNumber.toString() : '0'),
-                                  style: TextStyle(fontSize: 14, fontWeight: FontWeight.bold, color: Color(0xFFB1B2C0)),
-                                ),
-                              ],
-                            )
-                          ],
-                        ),
-                      ),
-                      Container(
-                        height: 40,
-                        margin: EdgeInsets.fromLTRB(15, 0, 15, 0),
-                        color: Color(0x1A1990F8),
-                        child: Row(
-                          children: <Widget>[
-                            Expanded(
-                              flex: 1,
-                              child: CupertinoButton(
-                                padding: EdgeInsets.all(0),
-                                onPressed: () {
-                                  if (houseInfo == null || (houseInfo.statusFlag != 0) || !isJoin) {
-                                    if (timer != null) {
-                                      timer.cancel();
-                                    }
-                                    isPop = true;
-                                    Toast.hide();
-                                    Navigator.of(context).pop();
-                                    return Future.value(false);
-                                  } else {
-                                    Toast.show(context, '比赛即将开始,暂不能离开房间', 1500, 'info');
-                                  }
-                                },
-                                child: Text(
-                                  '返回锦标赛',
-                                  style: TextStyle(color: PRIMARY_COLOR, fontSize: 14, fontWeight: FontWeight.bold),
-                                ),
-                              ),
-                            ),
-                            Container(
-                              width: 1,
-                              height: 12,
-                              color: PRIMARY_COLOR,
-                            ),
-                            Expanded(
-                              flex: 1,
-                              child: CupertinoButton(
-                                padding: EdgeInsets.all(0),
-                                onPressed: () {
-                                  showNotice(context);
-                                },
-                                child: Text(
-                                  '竞赛须知',
-                                  style: TextStyle(color: PRIMARY_COLOR, fontSize: 14, fontWeight: FontWeight.bold),
-                                ),
-                              ),
-                            ),
-                          ],
-                        ),
-                      ),
-                      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)),
-                          ],
-                        ),
-                      ),
-                      statuFlag != 4
-                          ? TipsListContent(tipsList: roomTipsList, houseInfo: houseInfo)
-                          : RankContent(
-                              roomId: houseInfo.id.toString(),
-                            ),
-                      Container(
-                        width: double.infinity,
-                        height: 78,
-                      )
-                    ],
-                  ))),
-        );
-      },
-    );
-  }
-
-  Widget _joinBtn() {
-    int joinMoney = 0;
-    int statusFlag = houseInfo != null ? houseInfo.statusFlag : 1;
-    int playerStatus = playerInfo != null ? playerInfo.statusFlag : 0;
-    if (!isJoin && statusFlag == 0) {
-      return Container(
-        color: BG_SUB_COLOR,
-        width: ScreenUtil().setWidth(375),
-        height: 48 + ScreenUtil().setHeight(40),
-        padding: EdgeInsets.only(top: ScreenUtil().setHeight(20), bottom: ScreenUtil().setHeight(20), left: 15, right: 15),
-        child: RaisedButton(
-            textColor: Colors.white,
-            child: Row(
-              mainAxisAlignment: MainAxisAlignment.center,
-              children: <Widget>[
-                Container(
-                    margin: EdgeInsets.only(left: 20),
-                    child: Text(
-                      '加入房间',
-                      style: TextStyle(color: Colors.white, fontSize: 16, fontWeight: FontWeight.bold),
-                    ))
-              ],
-            ),
-            onPressed: () => joinRoom()),
-      );
-    } else if (!isJoin && statusFlag == 2) {
-      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: null,
-        ),
-      );
-    } else if (isJoin && statusFlag == 0) {
-      int _time;
-      if (houseInfo != null) {
-        _time = houseInfo.createTime + 600000 - DateTime.now().millisecondsSinceEpoch;
-      }
-      if (houseInfo != null && houseInfo.createUser == StoreProvider.of<AppState>(context).state.userInfo.id.toString()) {
-        return Container(
-          width: double.infinity,
-          padding: EdgeInsets.symmetric(horizontal: 15, vertical: 20),
-          height: 88,
-          child: RaisedButton(
-            child: Text.rich(TextSpan(children: [
-              TextSpan(
-                text: '开始比赛',
-                style: TextStyle(fontSize: 16),
-              ),
-              TextSpan(
-                text: '(${getSecondsMIn(_time)}秒后将自动开始)',
-                style: TextStyle(fontSize: 12),
-              )
-            ])),
-            onPressed: () {
-              showCustomDialog(context, '确认要开始比赛吗?', isCancel: true, onsubmit: () {
-                print('开始');
-                startGame();
-              });
-            },
-          ),
-        );
-      } else {
-        return Container(
-          width: double.infinity,
-          padding: EdgeInsets.symmetric(horizontal: 15, vertical: 20),
-          height: 88,
-          child: RaisedButton(
-            disabledColor: Color(0xFF1990F8),
-            disabledTextColor: Color(0xFF252532),
-            child: Text(
-              '预计' + getSecondsMIn(_time) + '后开始',
-              style: TextStyle(fontSize: 16),
-            ),
-            onPressed: null,
-          ),
-        );
-      }
-    } else if (isJoin && statusFlag == 8) {
-      return Container(
-        width: double.infinity,
-        padding: EdgeInsets.symmetric(horizontal: 15, vertical: 20),
-        height: 88,
-        child: RaisedButton(
-          disabledColor: Color(0xFF1990F8),
-          disabledTextColor: Color(0xFF252532),
-          child: Text(
-            '正在努力解析视频中',
-            style: TextStyle(fontSize: 16),
-          ),
-          onPressed: null,
-        ),
-      );
-    } else if (isJoin && (statusFlag == 2 || statusFlag == 3)) {
-      int _time;
-      if (houseInfo != null) {
-        _time = houseInfo.beginTime + 3600000 - DateTime.now().millisecondsSinceEpoch;
-      }
-      return Container(
-        width: double.infinity,
-        padding: EdgeInsets.symmetric(horizontal: 15, vertical: 20),
-        height: 88,
-        child: RaisedButton(
-          disabledColor: Color(0xFF1990F8),
-          disabledTextColor: Color(0xFF252532),
-          child: Text(
-            '最迟在' + getSecondsMIn(_time) + '后结算',
-            style: TextStyle(fontSize: 16),
-          ),
-          onPressed: null,
-        ),
-      );
-    } else if (statusFlag == 4 && tabIndex == 0) {
-      return Container(
-        width: double.infinity,
-        padding: EdgeInsets.symmetric(horizontal: 15, vertical: 20),
-        height: 88,
-        child: RaisedButton(
-          disabledColor: Color(0xFF1990F8),
-          disabledTextColor: Color(0xFF15151D),
-          child: Text(
-            '已结束',
-            style: TextStyle(fontSize: 16),
-          ),
-          onPressed: null,
-        ),
-      );
-    } else if (statusFlag == 4 && tabIndex == 1) {
-      return Builder(
-        builder: (context) {
-          return Container(
-            height: 48,
-            color: SUB_COLOR,
-            child: Row(
-              children: <Widget>[
-                Container(
-                    width: 57,
-                    child: Center(
-                      child: Container(
-                          width: 22,
-                          height: 22,
-                          color: PRIMARY_COLOR,
-                          child: Center(
-                            child: Text(
-                              myRank.toString(),
-                              style: TextStyle(fontSize: 12, color: Colors.white),
-                            ),
-                          )),
-                    )),
-                Container(
-                  width: 30,
-                  height: 30,
-                  margin: EdgeInsets.only(right: 10),
-                  child: CircleAvatar(
-                    backgroundImage: NetworkImage(StoreProvider.of<AppState>(context).state.userInfo.icon),
-                  ),
-                ),
-                Expanded(
-                  flex: 1,
-                  child: Text(
-                    StoreProvider.of<AppState>(context).state.userInfo.nickname,
-                    style: TextStyle(
-                      fontSize: 14,
-                      color: Colors.white,
-                    ),
-                  ),
-                ),
-                _myUrl != null
-                    ? Container(
-                        width: 68,
-                        height: 24,
-                        margin: EdgeInsets.only(right: 10),
-                        child: OutlineButton(
-                          textColor: BG_SUB_COLOR,
-                          borderSide: BorderSide(color: BG_SUB_COLOR),
-                          padding: EdgeInsets.all(0),
-                          highlightColor: PRIMARY_COLOR.withOpacity(0.8),
-                          highlightedBorderColor: BG_SUB_COLOR,
-                          child: Text(
-                            '查看回放',
-                            style: TextStyle(fontSize: 12),
-                          ),
-                          onPressed: () {
-                            Navigator.push(context, CupertinoPageRoute(builder: (context) => VideoPlayerPage(videoUrl: _myUrl, fileType: 'file')));
-                          },
-                        ),
-                      )
-                    : Container()
-              ],
-            ),
-          );
-        },
-      );
-    } else {
-      return Container();
-    }
-  }
-}
-
-//房间的提示信息
-class TipsListContent extends StatelessWidget {
-  TipsListContent({Key key, this.tipsList, this.houseInfo}) : super(key: key);
-  final List<List<String>> tipsList;
-  final HouseInfo houseInfo;
-
-  @override
-  Widget build(BuildContext context) {
-    return Container(
-      margin: EdgeInsets.only(top: 15),
-      width: double.infinity,
-      child: Column(
-        children: _list(),
-      ),
-    );
-  }
-
-  List<Widget> _list() {
-    List<Widget> myList = [];
-    for (int i = 0; i < tipsList.length; i++) {
-      myList.add(Tips(content: tipsList[i], showTongzhi: (tipsList[i].length == 1 && i == 0) ? true : false, houseInfo: houseInfo));
-    }
-
-    return myList;
-  }
-}
-
-class Tips extends StatelessWidget {
-  Tips({Key key, this.content, this.showTongzhi, this.houseInfo}) : super(key: key);
-  final List<String> content;
-  final bool showTongzhi;
-  final HouseInfo houseInfo;
-  @override
-  Widget build(BuildContext context) {
-    return Container(
-        padding: EdgeInsets.all(15),
-        margin: EdgeInsets.fromLTRB(15, 10, 15, 0),
-        color: Color(0xFF293354),
-        child: Column(
-          children: <Widget>[
-            content.length == 1
-                ? Text(
-                    content[0],
-                    style: TextStyle(color: Colors.white, fontSize: 13),
-                  )
-                : _textList(),
-            showTongzhi
-                ? FlatButton(
-                    padding: EdgeInsets.all(0),
-                    textColor: PRIMARY_COLOR,
-                    highlightColor: Colors.transparent,
-                    splashColor: Colors.transparent,
-                    child: Text(
-                      '查看竞赛须知',
-                      style: TextStyle(
-                        decoration: TextDecoration.underline,
-                      ),
-                    ),
-                    onPressed: () {
-                      showNotice(context);
-                    },
-                  )
-                : Container()
-          ],
-        ));
-  }
-
-  Widget _textList() {
-    return Text.rich(TextSpan(
-      style: TextStyle(color: Colors.white, fontSize: 13),
-      children: [
-        TextSpan(text: content[0]),
-        TextSpan(
-          text: content[1],
-          style: TextStyle(color: PRIMARY_COLOR, fontSize: 13, fontWeight: FontWeight.bold),
-        ),
-        TextSpan(text: content[2]),
-        TextSpan(text: content[3]),
-        TextSpan(text: content[4])
-      ],
-    ));
-  }
-}
-
-//比赛结束排名
-class RankContent extends StatefulWidget {
-  RankContent({Key key, this.roomId}) : super(key: key);
-  final String roomId; // 用来储存传递过来的值
-  @override
-  RankContentState createState() => RankContentState();
-}
-
-class RankContentState extends State<RankContent> {
-  List<PlayerInfo> topList = [];
-  Future<void> getTopList() async {
-    Toast.show(context, '加载中', -1, 'loading');
-    Result res = await HttpManager.get('playerInfo/rankPage', data: {'houseId': widget.roomId, 'currentPage': 1, 'pageNumber': 3});
-    Toast.hide();
-    List<PlayerInfo> list = [];
-    if (res.success) {
-      for (var item in res.data['pp']) {
-        PlayerInfo jonPlayer = PlayerInfo.fromJson(item);
-        list.add(jonPlayer);
-      }
-    } else {}
-    setState(() {
-      topList = list;
-    });
-  }
-
-  @override
-  void initState() {
-    super.initState();
-    Future.delayed(Duration.zero, () {
-      getTopList();
-    });
-  }
-
-  @override
-  Widget build(BuildContext context) {
-    return Container(
-      width: double.infinity,
-      height: 180,
-      margin: EdgeInsets.only(top: 15),
-      child: Row(
-        mainAxisAlignment: MainAxisAlignment.center,
-        crossAxisAlignment: CrossAxisAlignment.end,
-        children: <Widget>[_rankItem(2), _rankItem(1), _rankItem(3)],
-      ),
-    );
-  }
-
-  Widget _rankItem(int _num) {
-    if (_num > topList.length) {
-      return Container(
-        width: 107,
-        height: 60,
-      );
-    }
-    List colorList = [
-      [Color(0xFFD48E00), Color(0xFFFECF01)],
-      [Color(0xFFC5C5C5), Color(0xFFE3E3E3)],
-      [Color(0xFFE77023), Color(0xFFF89E58)]
-    ];
-    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_jifen.png', width: 20),
-              Text('×' + (topList[_num - 1].points != null ? topList[_num - 1].points.toString() : '0'), style: TextStyle(color: PRIMARY_COLOR, fontSize: 12))
-            ],
-          )
-        ],
-      ),
-    );
-  }
-}

+ 181 - 0
lib/pages/RoomInfoNew.dart

@@ -0,0 +1,181 @@
+import 'dart:async';
+
+import 'package:flutter/material.dart';
+import 'package:url_launcher/url_launcher.dart';
+import 'package:wanna_battle/model/PlayerInfo.dart';
+import 'package:wanna_battle/pages/RoomInfoDetail.dart';
+import '../model/HouseInfo.dart';
+import '../Constants.dart';
+import '../styles/colors.dart';
+import '../net/HttpManager.dart';
+import '../net/Result.dart';
+import '../plugins/ScreenStramPlugin.dart';
+import './StartWindow.dart';
+import '../widget/Dialog.dart';
+
+class RoomInfo extends StatefulWidget {
+  final HouseInfo houseInfo;
+  RoomInfo(this.houseInfo, {Key key}) : super(key: key);
+  @override
+  State<StatefulWidget> createState() {
+    return _RoomInfoState();
+  }
+}
+
+class _RoomInfoState extends State<RoomInfo> with SingleTickerProviderStateMixin {
+  HouseInfo mHouseInfo;
+  PlayerInfo mPlayerInfo;
+  TabController tabController;
+  RoomInfoDetail roomInfoDetail;
+
+  @override
+  void initState() {
+    super.initState();
+    mHouseInfo = widget.houseInfo;
+    tabController = TabController(
+      length: 2,
+      vsync: this,
+    );
+  }
+
+  @override
+  void dispose() {
+    super.dispose();
+    tabController.dispose();
+  }
+
+  @override
+  Widget build(BuildContext context) {
+    return WillPopScope(
+      child: Scaffold(
+        appBar: AppBar(
+          title: Container(
+            child: TabBar(
+              controller: tabController,
+              labelColor: PRIMARY_COLOR,
+              unselectedLabelColor: Color(0xCCFFFFFF),
+              labelStyle: TextStyle(fontSize: 16.0),
+              indicatorColor: PRIMARY_COLOR,
+              indicatorWeight: 3,
+              indicatorSize: TabBarIndicatorSize.label,
+              tabs: <Widget>[
+                Tab(text: '房间信息'),
+                Tab(text: '参赛成员'),
+              ],
+            ),
+          ),
+          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(
+          child: TabBarView(
+            controller: tabController,
+            children: [
+              Builder(
+                builder: (context) {
+                  roomInfoDetail = RoomInfoDetail(
+                    mHouseInfo,
+                    onStart: () {
+                      showStart();
+                    },
+                  );
+                  return roomInfoDetail;
+                },
+              ),
+              Container()
+            ],
+          ),
+        ),
+      ),
+      onWillPop: () {
+        return Future.value(true);
+      },
+    );
+  }
+
+  Future<void> refreshData() async {}
+
+  Future<void> showStart() async {
+    if (mPlayerInfo == null) {
+      return;
+    }
+    bool result = await Navigator.of(context).push<bool>(
+      PageRouteBuilder(
+        opaque: false,
+        transitionDuration: Duration(milliseconds: 300),
+        transitionsBuilder: (BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation, Widget child) {
+          return FadeTransition(
+            opacity: CurvedAnimation(parent: animation, curve: Curves.linear),
+            child: child,
+          );
+        },
+        pageBuilder: (BuildContext context, _, __) {
+          return StartWindow();
+        },
+      ),
+    );
+    final Map<String, dynamic> data = {'id': mPlayerInfo.id};
+    bool success = true;
+    if (result) {
+      success = await ScreenStreamPlugin.start(mPlayerInfo.id.toString());
+      if (success) {
+        data['statusFlag'] = 2;
+      } else {
+        data['statusFlag'] = 6;
+      }
+    } else {
+      data['statusFlag'] = 6;
+    }
+    final Result res = await HttpManager.post('playerInfo/update', data: data);
+    if (res.success) {
+      if (data['statusFlag'] == 2) {
+        const url = 'pubgmhd1106467070://';
+        if (await canLaunch(url)) {
+          Timer(Duration(seconds: 1), () async {
+            await launch(url);
+            showSucessInfo();
+          });
+        } else {
+          showCustomDialog(context, '自动启动游戏失败,请手动切换到游戏app开始竞赛', submitText: '知道了');
+          Timer(Duration(seconds: 10), () {
+            showSucessInfo();
+          });
+
+          throw 'Could not launch $url';
+        }
+      } else {
+        showStartFailDialog(success ? 1 : 0);
+      }
+    }
+  }
+
+  void showSucessInfo() {
+    showCustomDialog(
+      context,
+      '您已经完成比赛了吗,确认完成,那就点击下方完成竞赛按钮,上传本次成绩,祝您赢取大奖',
+      title: '完成比赛',
+      submitText: '我已完成比赛',
+      onsubmit: () async {
+        HttpManager.post('playerInfo/update', data: {'id': mPlayerInfo.id, 'statusFlag': 3});
+        bool success = await ScreenStreamPlugin.stop();
+        setState(() {
+          mPlayerInfo.statusFlag = 3;
+        });
+        refreshData();
+      },
+    );
+  }
+
+  void showStartFailDialog(type) {
+    showCustomDialog(context, type == 1 ? '由于您未在十秒内点击开始按钮' : '由于您未授权录屏' ',系统已经判定您放弃比赛,谢谢您的参与。', title: '很遗憾');
+  }
+}

+ 20 - 9
lib/pages/SecondRoomInfo.dart

@@ -1,3 +1,4 @@
+import 'package:cached_network_image/cached_network_image.dart';
 import 'package:flutter/material.dart';
 import 'package:wanna_battle/model/HouseInfo.dart';
 import '../model/PlayerInfo.dart';
@@ -126,23 +127,33 @@ class SecondPageState extends State<SecondPage> {
                         'images/icon_paihangbang_0' + (index + 1).toString() + '.png',
                         width: 32,
                       )
-                    : Container(),
+                    : Container(
+                        width: 22,
+                        height: 22,
+                        color: Color(0x33FFFFFF),
+                        child: Center(
+                          child: Text(
+                            (index + 1).toString(),
+                            style: TextStyle(color: Colors.white, fontSize: 12),
+                          ),
+                        ),
+                      ),
               ),
             ),
             Container(
               margin: EdgeInsets.only(right: 12),
-              width: 36,
-              height: 36,
-              child: info.userInfo != null
-                  ? CircleAvatar(
-                      backgroundImage: NetworkImage(info.userInfo.icon),
-                    )
-                  : Container(),
+              child: ClipOval(
+                child: CachedNetworkImage(
+                  width: 36,
+                  height: 36,
+                  imageUrl: info?.userInfo?.icon ?? '',
+                ),
+              ),
             ),
             Expanded(
               flex: 1,
               child: Text(
-                info.userInfo != null ? info.userInfo.nickname : '',
+                info?.userInfo?.nickname ?? '',
                 style: TextStyle(
                   color: Colors.white,
                   fontSize: 14,

+ 7 - 1
lib/pages/Shop.dart

@@ -6,6 +6,8 @@ class Shop extends StatefulWidget {
   State<StatefulWidget> createState() {
     return _ShopState();
   }
+
+  Shop({Key key}) : super(key: key);
 }
 
 class _ShopState extends State<Shop> {
@@ -102,7 +104,11 @@ class _ShopState extends State<Shop> {
     );
   }
 
-  Widget shopItem({@required String icon, @required String text, @required int money, @required Color color}) {
+  Widget shopItem(
+      {@required String icon,
+      @required String text,
+      @required int money,
+      @required Color color}) {
     return GestureDetector(
       child: Container(
         padding: EdgeInsets.all(7.5),

+ 33 - 8
lib/pages/TipList.dart

@@ -13,6 +13,8 @@ import 'TipInfo.dart';
 class TipList extends StatefulWidget {
   @override
   TipListState createState() => TipListState();
+
+  TipList({Key key}) : super(key: key);
 }
 
 class TipListState extends State<TipList> {
@@ -33,10 +35,10 @@ class TipListState extends State<TipList> {
     });
     Toast.hide();
     List<SystemNotice> list = tipList;
-    if (currentPage == 1) {
-      list = [];
-    }
     if (res.success) {
+      if (currentPage == 1) {
+        list = [];
+      }
       for (var item in res.data['pp']) {
         SystemNotice tip = SystemNotice.fromJson(item);
         list.add(tip);
@@ -47,6 +49,8 @@ class TipListState extends State<TipList> {
     } else {}
     setState(() {
       tipList = list;
+      PageStorage.of(context)
+          .writeState(context, tipList, identifier: ValueKey('tipList'));
     });
   }
 
@@ -54,6 +58,9 @@ class TipListState extends State<TipList> {
   void initState() {
     super.initState();
     _mControll = ScrollController();
+    tipList = PageStorage.of(context)
+            .readState(context, identifier: ValueKey('tipList')) ??
+        [];
     Future.delayed(Duration.zero, () => getListPage());
     _mControll.addListener(() {
       if (_mControll.position.pixels == _mControll.position.maxScrollExtent) {
@@ -95,14 +102,19 @@ class TipListState extends State<TipList> {
                 if (tipList.isEmpty) {
                   return Text(
                     '数据正在火速加载中...',
-                    style: TextStyle(color: Colors.white30, fontSize: 13, height: 2),
+                    style: TextStyle(
+                        color: Colors.white30, fontSize: 13, height: 2),
                     textAlign: TextAlign.center,
                   );
                 }
                 return TipItem(
                     tipInfo: tipList[index],
                     tapInfo: () async {
-                      bool res = await Navigator.push(context, CupertinoPageRoute(builder: (context) => TipInfo(notice: tipList[index])));
+                      bool res = await Navigator.push(
+                          context,
+                          CupertinoPageRoute(
+                              builder: (context) =>
+                                  TipInfo(notice: tipList[index])));
                       if (res != null) {
                         setState(() {
                           tipList = [];
@@ -124,6 +136,7 @@ class TipItem extends StatelessWidget {
   TipItem({Key key, this.tipInfo, this.tapInfo}) : super(key: key);
   final SystemNotice tipInfo; // 用来储存传递过来的值
   final OnTapHomeMenu tapInfo;
+
   @override
   Widget build(BuildContext context) {
     return Container(
@@ -144,10 +157,22 @@ class TipItem extends StatelessWidget {
                   child: Row(
                     mainAxisAlignment: MainAxisAlignment.spaceBetween,
                     children: <Widget>[
-                      Text(readTimestamp(tipInfo.createTime, 'yyyy.MM.dd HH:mm:ss'), style: TextStyle(color: Color(0xFF9BA0AE), fontSize: 13)),
+                      Text(
+                          readTimestamp(
+                              tipInfo.createTime, 'yyyy.MM.dd HH:mm:ss'),
+                          style: TextStyle(
+                              color: Color(0xFF9BA0AE), fontSize: 13)),
                       tipInfo.statusFlag == 0
-                          ? Text('未读', style: TextStyle(color: PRIMARY_COLOR, fontSize: 13, fontWeight: FontWeight.bold))
-                          : Text('已读', style: TextStyle(color: Colors.black, fontSize: 13, fontWeight: FontWeight.bold))
+                          ? Text('未读',
+                              style: TextStyle(
+                                  color: PRIMARY_COLOR,
+                                  fontSize: 13,
+                                  fontWeight: FontWeight.bold))
+                          : Text('已读',
+                              style: TextStyle(
+                                  color: Colors.black,
+                                  fontSize: 13,
+                                  fontWeight: FontWeight.bold))
                     ],
                   ),
                 ),

+ 54 - 14
lib/pages/UserChange.dart

@@ -7,6 +7,7 @@ import 'package:intl/intl.dart';
 import 'package:jpush_flutter/jpush_flutter.dart';
 import 'package:package_info/package_info.dart';
 import 'package:shared_preferences/shared_preferences.dart';
+import 'package:flutter_bugly/flutter_bugly.dart';
 import './loginFirst.dart';
 import '../styles/colors.dart';
 import 'dart:io';
@@ -22,6 +23,7 @@ import '../net/HttpManager.dart';
 import '../net/Result.dart';
 import '../redux/UserRedux.dart';
 import 'package:image_cropper/image_cropper.dart';
+import '../widget/CheckUpgrade.dart';
 
 class UserChange extends StatefulWidget {
   @override
@@ -31,13 +33,14 @@ class UserChange extends StatefulWidget {
 class UserChangeState extends State<UserChange> {
   String version = '';
   bool receiveMsg = false;
+  final GlobalKey<UpgradeDialogState> _dialogKey = GlobalKey();
 
   @override
   void initState() {
     super.initState();
     PackageInfo.fromPlatform().then((packageInfo) {
       setState(() {
-        version = packageInfo.version;
+        version = '当前版本:' + packageInfo.version;
       });
     });
   }
@@ -76,7 +79,8 @@ class UserChangeState extends State<UserChange> {
                                 _cell(
                                   '头像',
                                   ClipOval(
-                                    child: Image.network(userInfo.icon, width: 36, height: 36),
+                                    child: Image.network(userInfo.icon,
+                                        width: 36, height: 36),
                                   ),
                                   onTap: () {
                                     _chooseImage();
@@ -87,7 +91,13 @@ class UserChangeState extends State<UserChange> {
                                   userInfo.nickname,
                                   placeholder: '请填写昵称',
                                   onTap: () {
-                                    Navigator.push(context, CupertinoPageRoute(builder: (context) => ChangeUserInfo(title: '昵称', val: userInfo.nickname)));
+                                    Navigator.push(
+                                        context,
+                                        CupertinoPageRoute(
+                                            builder: (context) =>
+                                                ChangeUserInfo(
+                                                    title: '昵称',
+                                                    val: userInfo.nickname)));
                                   },
                                 ),
                                 _cell(
@@ -101,15 +111,34 @@ class UserChangeState extends State<UserChange> {
                                 _cell(
                                   '生日',
                                   DateFormat('yyyy-MM-dd').format(
-                                    DateTime.fromMillisecondsSinceEpoch(userInfo.birthday),
+                                    DateTime.fromMillisecondsSinceEpoch(
+                                        userInfo.birthday),
                                   ),
                                   placeholder: '选择生日',
                                   onTap: () {
                                     _chooseBirthday(context);
                                   },
                                 ),
-                                _cell('手机', userInfo.phone, showBorder: false, onTap: () {
-                                  Navigator.push(context, CupertinoPageRoute(builder: (context) => ChangeUserInfo(title: '手机号', val: userInfo.phone)));
+                                _cell('手机', userInfo.phone, onTap: () {
+                                  Navigator.push(
+                                      context,
+                                      CupertinoPageRoute(
+                                          builder: (context) => ChangeUserInfo(
+                                              title: '手机号',
+                                              val: userInfo.phone)));
+                                }),
+                                _cell('检查更新', version, showBorder: false,
+                                    onTap: () async {
+                                  Toast.show(context, '检查更新中', -1, 'loading');
+                                  final upgradeInfo =
+                                      await FlutterBugly.getUpgradeInfo();
+                                  Toast.hide();
+                                  if (upgradeInfo != null) {
+                                    showUpgradeDialog(
+                                        context, upgradeInfo, _dialogKey);
+                                  } else {
+                                    Toast.show(context, '已是最新版本', 1500, 'info');
+                                  }
                                 })
                               ]),
                             ],
@@ -128,11 +157,15 @@ class UserChangeState extends State<UserChange> {
                           highlightColor: Color(0xFF763434),
                           child: Text(
                             '退出登录',
-                            style: TextStyle(fontSize: 16, fontWeight: FontWeight.normal),
+                            style: TextStyle(
+                                fontSize: 16, fontWeight: FontWeight.normal),
                           ),
                           onPressed: () async {
                             Toast.show(context, '退出成功', 1500, 'success');
-                            Navigator.push(context, MaterialPageRoute(builder: (context) => LoginFirst()));
+                            Navigator.push(
+                                context,
+                                MaterialPageRoute(
+                                    builder: (context) => LoginFirst()));
                             final prefs = await SharedPreferences.getInstance();
                             prefs.remove('token');
                             JPush jpush = JPush();
@@ -157,7 +190,8 @@ class UserChangeState extends State<UserChange> {
     if (Toast.preToast == null) {
       Toast.show(context, '加载中', -1, 'loading');
     }
-    final Result res = await HttpManager.post('userInfo/update', data: {'id': userInfo.id, key: value});
+    final Result res = await HttpManager.post('userInfo/update',
+        data: {'id': userInfo.id, key: value});
     Toast.hide();
     if (res.success) {
       Toast.show(context, '修改成功', 1500, 'success');
@@ -170,7 +204,8 @@ class UserChangeState extends State<UserChange> {
   Future<void> getUserInfo() async {
     Result res = await HttpManager.get('userInfo/getUserInfo');
     if (res.success) {
-      StoreProvider.of<AppState>(context).dispatch(UpdateUserAction(UserInfo.fromJson(res.data)));
+      StoreProvider.of<AppState>(context)
+          .dispatch(UpdateUserAction(UserInfo.fromJson(res.data)));
     } else {}
   }
 
@@ -203,13 +238,16 @@ class UserChangeState extends State<UserChange> {
           );
         });
     if (sex != null) {
-      updateUserInfo(StoreProvider.of<AppState>(context).state.userInfo, sex, 'sex');
+      updateUserInfo(
+          StoreProvider.of<AppState>(context).state.userInfo, sex, 'sex');
     }
   }
 
   Future<void> _chooseBirthday(BuildContext context) async {
     UserInfo userInfo = StoreProvider.of<AppState>(context).state.userInfo;
-    DateTime date = userInfo.birthday > 0 ? DateTime.fromMillisecondsSinceEpoch(userInfo.birthday) : DateTime.now();
+    DateTime date = userInfo.birthday > 0
+        ? DateTime.fromMillisecondsSinceEpoch(userInfo.birthday)
+        : DateTime.now();
     DateTime res = await showCupertinoModalPopup<DateTime>(
       context: context,
       builder: (BuildContext context) {
@@ -310,7 +348,8 @@ class UserChangeState extends State<UserChange> {
     });
     Toast.hide();
     if (res.success) {
-      updateUserInfo(StoreProvider.of<AppState>(context).state.userInfo, res.data[0], 'icon');
+      updateUserInfo(StoreProvider.of<AppState>(context).state.userInfo,
+          res.data[0], 'icon');
     }
   }
 
@@ -327,7 +366,8 @@ class UserChangeState extends State<UserChange> {
     );
   }
 
-  Widget _cell(String title, dynamic child, {String placeholder, void Function() onTap, bool showBorder = true}) {
+  Widget _cell(String title, dynamic child,
+      {String placeholder, void Function() onTap, bool showBorder = true}) {
     Widget secondChild;
     if (child == null || (child is String && child.isEmpty)) {
       secondChild = Text(

+ 195 - 0
lib/pages/UserGuid.dart

@@ -0,0 +1,195 @@
+import 'package:flutter/material.dart';
+import 'package:flutter/cupertino.dart';
+import '../styles/colors.dart';
+import 'dart:math';
+
+Future showUserGuide(BuildContext context) {
+  return 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 UserGuide();
+      },
+    ),
+  );
+}
+
+class UserGuide extends StatefulWidget {
+  @override
+  State<StatefulWidget> createState() {
+    return UserGuideState();
+  }
+}
+
+class UserGuideState extends State<UserGuide> {
+  final pageController = PageController(initialPage: 0);
+
+  @override
+  Widget build(BuildContext context) {
+    return WillPopScope(
+      onWillPop: () {
+        return Future.value(true);
+      },
+      child: Scaffold(
+        backgroundColor: Color(0xb3000000),
+        body: Stack(
+          children: <Widget>[
+            PageView(
+              controller: pageController,
+              children: <Widget>[
+                _page(context, children: [
+                  Align(
+                    alignment: Alignment.topLeft,
+                    child: Container(
+                      margin: EdgeInsets.only(top: 23, left: 40),
+                      child: Image.asset('images/zhezhao_01.png'),
+                    ),
+                  ),
+                  Align(
+                    alignment: Alignment.topCenter,
+                    child: Container(
+                      margin: EdgeInsets.only(top: 177),
+                      child: Text(
+                        '01、此处是您拥有金币的数量',
+                        style: TextStyle(color: Colors.white, fontSize: 15),
+                      ),
+                    ),
+                  )
+                ]),
+                _page(context, children: [
+                  Align(
+                    alignment: Alignment.topLeft,
+                    child: Container(
+                      margin: EdgeInsets.only(top: 128),
+                      child: Image.asset('images/zhezhao_02.png'),
+                    ),
+                  ),
+                  Align(
+                    alignment: Alignment.topLeft,
+                    child: Container(
+                      margin: EdgeInsets.only(top: 159, left: 106),
+                      child: Text(
+                        '02、带此标示的为VIP赛事\n        相对于普通赛事奖励更为丰厚',
+                        style: TextStyle(color: Colors.white, fontSize: 15),
+                      ),
+                    ),
+                  )
+                ]),
+                _page(context, children: [
+                  Align(
+                    alignment: Alignment.topRight,
+                    child: Container(
+                      margin: EdgeInsets.only(top: 126),
+                      child: Image.asset('images/zhezhao_03.png'),
+                    ),
+                  ),
+                  Align(
+                    alignment: Alignment.topLeft,
+                    child: Container(
+                      margin: EdgeInsets.only(top: 175, left: 30),
+                      child: Text(
+                        '03、这是您在此赛事中的排名情况',
+                        style: TextStyle(color: Colors.white, fontSize: 15),
+                      ),
+                    ),
+                  )
+                ]),
+                _page(context, isLast: true, children: [
+                  Align(
+                    alignment: Alignment.topCenter,
+                    child: Container(
+                      margin: EdgeInsets.only(
+                          top: (MediaQuery.of(context).size.width - 30) *
+                                  150 /
+                                  345 +
+                              133),
+                      child: Image.asset('images/zhezhao_04.png'),
+                    ),
+                  ),
+                  Align(
+                    alignment: Alignment.topCenter,
+                    child: Container(
+                      margin: EdgeInsets.only(
+                        top: (MediaQuery.of(context).size.width - 30) *
+                                150 /
+                                345 +
+                            285,
+                      ),
+                      child: Text(
+                        '04、点击进入,开始您的比赛吧',
+                        style: TextStyle(color: Colors.white, fontSize: 15),
+                      ),
+                    ),
+                  )
+                ]),
+              ],
+            ),
+          ],
+        ),
+      ),
+    );
+  }
+
+  Widget _page(BuildContext context,
+      {@required List<Widget> children, bool isLast = false}) {
+    List<Widget> list = [
+      Align(
+        alignment: Alignment.bottomCenter,
+        child: Container(
+          margin: EdgeInsets.only(bottom: 92),
+          child: SizedBox(
+            width: 220,
+            height: 36,
+            child: OutlineButton(
+              borderSide: BorderSide(color: PRIMARY_COLOR),
+              highlightColor: Colors.transparent,
+              color: PRIMARY_COLOR,
+              onPressed: () {
+                if (isLast) {
+                  Navigator.of(context).pop();
+                  return;
+                }
+                pageController.nextPage(
+                    duration: Duration(milliseconds: 300),
+                    curve: Curves.linearToEaseOut);
+              },
+              child: Text(
+                isLast ? '知道了' : '下一步',
+                style: TextStyle(color: PRIMARY_COLOR, fontSize: 14),
+              ),
+            ),
+          ),
+        ),
+      ),
+      Align(
+        alignment: Alignment.bottomCenter,
+        child: Container(
+          margin: EdgeInsets.only(bottom: 50),
+          child: CupertinoButton(
+              padding: EdgeInsets.all(0),
+              child: Text(
+                '关闭',
+                style: TextStyle(color: Color(0xFF4F5C87), fontSize: 14),
+              ),
+              onPressed: () {
+                Navigator.of(context).pop();
+              }),
+        ),
+      )
+    ];
+    for (Widget widget in children) {
+      list.add(widget);
+    }
+    return Stack(
+      children: list,
+    );
+  }
+}

+ 2 - 2
lib/widget/CheckUpgrade.dart

@@ -14,10 +14,10 @@ Future checkUpgrade(context, key) async {
   if (upgradeInfo == null) {
     return false;
   }
-  return await showUpgradeDailog(context, upgradeInfo, key);
+  return await showUpgradeDialog(context, upgradeInfo, key);
 }
 
-Future showUpgradeDailog(context, upgradeInfo, key) async {
+Future showUpgradeDialog(context, upgradeInfo, key) async {
   return await showGeneralDialog(
     context: context,
     barrierDismissible: false,

+ 105 - 9
lib/widget/Competition.dart

@@ -1,19 +1,115 @@
+import 'package:intl/intl.dart';
 import 'package:flutter/material.dart';
 import 'package:flutter/cupertino.dart';
+import 'package:cached_network_image/cached_network_image.dart';
+import 'package:gradient_text/gradient_text.dart';
+import 'package:wanna_battle/styles/colors.dart';
+import '../pages/CompetitionRank.dart';
 import '../model/CompetitionInfo.dart';
-import 'package:intl/intl.dart';
-import '../pages/RoomList.dart';
 import '../pages/CompetitionRooms.dart';
-import 'package:gradient_text/gradient_text.dart';
 
 class Competition extends StatelessWidget {
   final CompetitionInfo competitionInfo;
-  Competition(this.competitionInfo);
-  final Shader linearGradient = LinearGradient(
-    begin: Alignment.topCenter,
-    end: Alignment.bottomCenter,
-    colors: <Color>[Color(0xFFFFC84B), Color(0xFFA26A23)],
-  ).createShader(Rect.fromLTWH(0.0, 0.0, 200, 70));
+
+  const Competition(this.competitionInfo, {Key key}) : super(key: key);
+
+  @override
+  Widget build(BuildContext context) {
+    return GestureDetector(
+      child: Container(
+        margin: EdgeInsets.fromLTRB(15, 7, 15, 7),
+        child: Column(
+          crossAxisAlignment: CrossAxisAlignment.stretch,
+          children: <Widget>[
+            Stack(
+              overflow: Overflow.visible,
+              children: <Widget>[
+                AspectRatio(
+                  aspectRatio: 345 / 150,
+                  child: CachedNetworkImage(
+                    imageUrl: competitionInfo.pic,
+                    fit: BoxFit.cover,
+                  ),
+                ),
+                Align(
+                  alignment: Alignment.topLeft,
+                  child: Image.asset('images/home_icon_vip.png'),
+                ),
+                Positioned(
+                  right: 10,
+                  top: -2,
+                  width: 52,
+                  height: 35,
+                  child: GestureDetector(
+                    child: Container(
+                      transform: Matrix4.translationValues(0.0, -2.0, 0.0),
+                      child: Builder(
+                        builder: (context) {
+                          var src = 'images/icon_paimingno.png';
+                          if (competitionInfo.participatingInfo != null && competitionInfo.participatingInfo.rank > 0) {
+                            if (competitionInfo.participatingInfo.rank == 1) {
+                              src = 'images/icon_paiming01.png';
+                            } else if (competitionInfo.participatingInfo.rank == 2) {
+                              src = 'images/icon_paiming02.png';
+                            } else if (competitionInfo.participatingInfo.rank == 3) {
+                              src = 'images/icon_paiming03.png';
+                            } else {
+                              return Stack(
+                                children: <Widget>[
+                                  Image.asset('images/icon_paiming0000.png'),
+                                  Align(
+                                    alignment: Alignment.topCenter,
+                                    child: Container(
+                                      margin: EdgeInsets.only(top: 10),
+                                      child: Text(
+                                        competitionInfo.participatingInfo.rank.toString(),
+                                        style: TextStyle(
+                                          fontSize: 16,
+                                          fontWeight: FontWeight.bold,
+                                          color: Colors.white,
+                                        ),
+                                      ),
+                                    ),
+                                  ),
+                                ],
+                              );
+                            }
+                          }
+                          return Image.asset(src);
+                        },
+                      ),
+                    ),
+                    onTap: () {
+                      Navigator.push(context, CupertinoPageRoute(builder: (context) => CompetitionRank(competitionId: competitionInfo.id)));
+                    },
+                  ),
+                ),
+              ],
+            ),
+            Container(
+              height: 36,
+              color: PRIMARY_COLOR,
+              child: Center(
+                child: Text(
+                  '进入',
+                  style: TextStyle(color: Colors.white, fontSize: 14),
+                ),
+              ),
+            )
+          ],
+        ),
+      ),
+      onTap: () {
+        Navigator.push(context, CupertinoPageRoute(builder: (context) => CompetitionRooms(competitionInfo)));
+      },
+    );
+  }
+}
+
+class CompetitionOld extends StatelessWidget {
+  final CompetitionInfo competitionInfo;
+  CompetitionOld(this.competitionInfo);
+
   @override
   Widget build(BuildContext context) {
     return GestureDetector(