x1ongzhu 6 år sedan
förälder
incheckning
afe1c7974f

+ 1 - 1
android/app/build.gradle

@@ -39,7 +39,7 @@ android {
         versionName flutterVersionName
         testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
         ndk {
-            // abiFilters 'armeabi-v7a'
+            // abiFilters 'armeabi-v7a'  
         }
         manifestPlaceholders = [
             JPUSH_PKGNAME : applicationId,

+ 1 - 0
lib/main.dart

@@ -14,6 +14,7 @@ import 'pages/loginFirst.dart';
 import 'package:flutter_localizations/flutter_localizations.dart';
 import './Localizations.dart';
 
+
 class MobileCyberGamesApp extends StatelessWidget {
   final Store<AppState> store;
 

+ 2 - 1
lib/model/PlayerInfo.dart

@@ -8,7 +8,7 @@ part 'PlayerInfo.g.dart';
 @JsonSerializable()
 class PlayerInfo {
   PlayerInfo(
-      this.id, this.houseId, this.userId, this.statusFlag, this.userInfo,this.bonus,this.gameInfo,this.houseInfo,this.rank);
+      this.id, this.houseId, this.userId, this.statusFlag, this.userInfo,this.bonus,this.gameInfo,this.houseInfo,this.rank,this.houseRank);
   int id;
   int houseId; //房间id
   int userId; //用户id
@@ -18,6 +18,7 @@ class PlayerInfo {
   GameInfo gameInfo;
   HouseInfo houseInfo;
   int rank;//名次
+  int houseRank;//房间比赛名次
   
   factory PlayerInfo.fromJson(Map<String, dynamic> json) =>
       _$PlayerInfoFromJson(json);

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

@@ -16,7 +16,8 @@ PlayerInfo _$PlayerInfoFromJson(Map<String, dynamic> json) {
       json['bonus'] as int,
       json['gameInfo'] != null ? GameInfo.fromJson(json['gameInfo']) : null,
       json['houseInfo'] != null ? HouseInfo.fromJson(json['houseInfo']) : null,
-      json['rank']??null);
+      json['rank'] ?? null,
+      json['houseRank'] ?? null);
 }
 
 //  int id;
@@ -34,5 +35,6 @@ Map<String, dynamic> _$PlayerInfoToJson(PlayerInfo instance) =>
       'bonus': instance.bonus,
       'gameInfo': instance.gameInfo,
       'houseInfo': instance.houseInfo,
-      'rank':instance.rank
+      'rank': instance.rank,
+      'houseRank': instance.houseRank
     };

+ 6 - 4
lib/pages/HomePage.dart

@@ -1,10 +1,10 @@
 import 'package:flutter/material.dart';
 import '../widget/HomeDrawer.dart';
-import './Setting.dart';
-import './CreateRoom.dart';
-import 'RoomList.dart'; //房间列表
+import 'Setting.dart';
+import 'CreateRoom.dart';
+import 'RoomList.dart';
 import 'rankList.dart';
-import 'roomInfo.dart'; //房间信息
+import 'roomInfo.dart';
 import 'package:flutter/cupertino.dart';
 import 'package:flutter_swiper/flutter_swiper.dart';
 import '../model/CompetitionSeason.dart';
@@ -21,6 +21,7 @@ class HomePage extends StatefulWidget {
 class _HomePageState extends State<HomePage> {
   List<CompetitionSeason> seasonList = [];
   int nowIndex = 0;
+  PageController _pageController;
 
   void getSeasonInfo() async {
     Toast.show(context, '加载中', -1, 'loading');
@@ -80,6 +81,7 @@ class _HomePageState extends State<HomePage> {
   @override
   void initState() {
     super.initState();
+    _pageController = PageController(initialPage: 0);
     Future.delayed(Duration.zero, () {
       getSeasonInfo();
     });

+ 17 - 6
lib/pages/RecordList.dart

@@ -133,15 +133,23 @@ class houseItem extends StatelessWidget {
       'images/zhanji_icon_04.png'
     ];
     String imageSrc = '';
-     print('****');
-    print(playerInfo.rank);
-    if (playerInfo.rank != null && playerInfo.rank != 0) {
-      if (playerInfo.rank < 4) {
-        imageSrc = imageList[playerInfo.rank - 1];
+    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) {
+        tishiStr = '结算中';
+      } else if (playerInfo.statusFlag < 2) {
+        tishiStr = '准备中';
+      }
+    }
     if (roomInfo == null) {
       return Container();
     }
@@ -213,7 +221,10 @@ class houseItem extends StatelessWidget {
                     ],
                   ),
                 ),
-                // Image.asset(imageSrc,width:70)
+                imageSrc != ''
+                    ? Image.asset(imageSrc, width: 70)
+                    : Text(tishiStr,
+                        style: TextStyle(color: Colors.black38, fontSize: 14))
               ],
             ),
           ),

+ 3 - 0
lib/pages/StartWindow.dart

@@ -69,6 +69,9 @@ class StartWindowState extends State<StartWindow> {
                   Text('点击确认开始游戏', style: TextStyle(color: Color(0xFFFDC372), fontSize: 20, fontWeight: FontWeight.w600)),
                   _centerContent(),
                   Container(
+                    width: double.infinity,
+                    margin: EdgeInsets.symmetric(horizontal: 42),
+                    height: 44,
                     child: RaisedButton(
                       textTheme: ButtonTextTheme.primary,
                       child: Text('确认'),

+ 2 - 0
lib/pages/TipInfo.dart

@@ -44,6 +44,8 @@ class TipInfoState extends State<TipInfo> {
         houseInfo = HouseInfo.fromJson(res2.data);
       });
     }
+
+    
   }
 
   void updateHousInfo() {}

+ 193 - 53
lib/pages/roomInfo.dart

@@ -1,5 +1,6 @@
 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';
@@ -11,6 +12,7 @@ import '../model/HouseInfo.dart';
 import '../styles/totast.dart';
 import 'StartWindow.dart';
 import '../model/PlayerInfo.dart';
+import '../widget/VideoWidget.dart';
 
 class RoomInfo extends StatefulWidget {
   RoomInfo({Key key, this.roomId}) : super(key: key);
@@ -20,7 +22,8 @@ class RoomInfo extends StatefulWidget {
   RoomInfoState createState() => RoomInfoState();
 }
 
-class RoomInfoState extends State<RoomInfo> with SingleTickerProviderStateMixin {
+class RoomInfoState extends State<RoomInfo>
+    with SingleTickerProviderStateMixin {
   List<Map> tabList;
   TabController mController;
   Map roomInfo;
@@ -28,13 +31,18 @@ class RoomInfoState extends State<RoomInfo> with SingleTickerProviderStateMixin
   Map colorInfo;
   bool isJoin = true;
   PlayerInfo playerInfo;
+  bool isPop = false;
 
 //获取房间信息
   void getRoomInfo() async {
     Toast.show(context, '加载中', -1, 'loading');
-    Result res = await HttpManager.get("houseInfo/getOne", data: {"id": widget.roomId});
+    Result res =
+        await HttpManager.get("houseInfo/getOne", data: {"id": widget.roomId});
     Toast.hide();
     if (res.success) {
+      if (isPop) {
+        return;
+      }
       setState(() {
         roomInfo = res.data;
         houseInfo = HouseInfo.fromJson(res.data);
@@ -48,11 +56,15 @@ class RoomInfoState extends State<RoomInfo> with SingleTickerProviderStateMixin
 //隔一秒检查是否开始
   getNowStatus() async {
     await Future.delayed(const Duration(seconds: 1));
-    Result res = await HttpManager.get("houseInfo/getPlayerNum", data: {"id": widget.roomId});
+    Result res = await HttpManager.get("houseInfo/getPlayerNum",
+        data: {"id": widget.roomId});
     if (res.success) {
       if (houseInfo.statusFlag == 0 && res.data["statusFlag"] == 2) {
         showStart();
       }
+      if (isPop) {
+        return;
+      }
       setState(() {
         houseInfo.playerNumber = res.data["playerNumber"];
         houseInfo.statusFlag = res.data["statusFlag"];
@@ -70,7 +82,8 @@ class RoomInfoState extends State<RoomInfo> with SingleTickerProviderStateMixin
       PageRouteBuilder(
         opaque: false,
         transitionDuration: Duration(milliseconds: 300),
-        transitionsBuilder: (BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation, Widget child) {
+        transitionsBuilder: (BuildContext context, Animation<double> animation,
+            Animation<double> secondaryAnimation, Widget child) {
           return FadeTransition(
             opacity: CurvedAnimation(parent: animation, curve: Curves.linear),
             child: child,
@@ -81,26 +94,34 @@ class RoomInfoState extends State<RoomInfo> with SingleTickerProviderStateMixin
         },
       ),
     );
-
-    Toast.show(context, '加载中', -1, 'loading');
     Map<String, dynamic> data = {"id": playerInfo.id};
+    bool success=true;
     if (result) {
-      data['statusFlag'] = 2;
+      success = await ScreenStreamPlugin.start(
+          'rtmp://49.4.66.233:1935/myapp/' +
+              playerInfo.userId.toString() +
+              '?playerInfoId=' +
+              playerInfo.id.toString());
+      print('stream screen:' + success.toString());
+      if (success) {
+        data['statusFlag'] = 2;
+      } else {
+        data['statusFlag'] = 6;
+      }
     } else {
       data['statusFlag'] = 6;
     }
-    Toast.hide();
+    Toast.show(context, '加载中', -1, 'loading');
     Result res = await HttpManager.post("playerInfo/update", data: data);
+    Toast.hide();
     if (res.success) {
       if (data['statusFlag'] == 2) {
-        //加入比赛成功,开始录屏
-        bool success =
-            await ScreenStreamPlugin.start('rtmp://49.4.66.233:1935/myapp/' + playerInfo.userId.toString() + '?playerInfoId=' + playerInfo.id.toString());
-        print('stream screen:' + success.toString());
-        Future.delayed(Duration(milliseconds: 100), () => showSucessInfo());
+        await Future.delayed(Duration(milliseconds: 100));
+        showSucessInfo();
+        getTotast(10);
       } else {
         // showBackDialog();
-        Future.delayed(Duration(milliseconds: 100), () => showBackDialog());
+        Future.delayed(Duration(milliseconds: 100), () => showBackDialog(success?1:0));
       }
     }
   }
@@ -115,7 +136,7 @@ class RoomInfoState extends State<RoomInfo> with SingleTickerProviderStateMixin
           content: Container(
             height: 50,
             child: Text(
-              '已经成功开启录屏,请保留当前页面,打开游戏开始比赛,祝您取得好成绩!',
+              '已经成功开启录屏,请保留当前页面,10秒倒计时结束将自动打开游戏,如未自动打开请您手动打开,祝您取得好成绩!',
               style: TextStyle(color: Colors.black),
             ),
           ),
@@ -124,7 +145,8 @@ class RoomInfoState extends State<RoomInfo> with SingleTickerProviderStateMixin
               child: new Text('完成比赛'),
               onPressed: () async {
                 Toast.show(context, '加载中', -1, 'loading');
-                HttpManager.post("playerInfo/update", data: {'id': playerInfo.id, 'statusFlag': 3});
+                HttpManager.post("playerInfo/update",
+                    data: {'id': playerInfo.id, 'statusFlag': 3});
                 bool success = await ScreenStreamPlugin.stop();
                 print('stop stream screen:' + success.toString());
                 Toast.hide();
@@ -137,10 +159,32 @@ class RoomInfoState extends State<RoomInfo> with SingleTickerProviderStateMixin
     ).then((val) {
       Navigator.of(context).pop();
     });
+
+  }
+
+  getTotast(int index)async{
+    if(isPop){
+      return;
+    }
+    Toast.show(context, index.toString(), 500, 'num');
+    if(index==0){
+      Future.delayed(Duration(seconds: 1),()async{
+        const url = 'pubgmhd1106467070://';
+          if (await canLaunch(url)) {
+            await launch(url);
+          } else {
+            throw 'Could not launch $url';
+          }
+      });
+    }
+    else{
+       Future.delayed(Duration(seconds: 1),()=>getTotast(index-1));
+    }
+
   }
 
 //未确认比赛弹窗
-  showBackDialog() {
+  showBackDialog(type) {
     showDialog<Null>(
       context: context,
       barrierDismissible: false,
@@ -149,7 +193,7 @@ class RoomInfoState extends State<RoomInfo> with SingleTickerProviderStateMixin
           content: Container(
             height: 50,
             child: Text(
-              '您未在十秒内点击开始按钮,系统已经判定您放弃比赛,参赛奖金不予退还。',
+              (type==1?'您未在十秒内点击开始按钮':'您未允许录屏')+',系统已经判定您放弃比赛,参赛奖金不予退还。',
               style: TextStyle(color: Colors.black),
             ),
           ),
@@ -171,15 +215,24 @@ class RoomInfoState extends State<RoomInfo> with SingleTickerProviderStateMixin
 
 //检查加入信息
   checkJoinInfo() async {
-    Result res = await HttpManager.get("playerInfo/getOne", data: {"userId": StoreProvider.of<AppState>(context).state.userInfo.id, "houseId": widget.roomId});
+    Result res = await HttpManager.get("playerInfo/getOne", data: {
+      "userId": StoreProvider.of<AppState>(context).state.userInfo.id,
+      "houseId": widget.roomId
+    });
     if (res.success) {
       print(res.data);
       if (res.data == null) {
+        if (isPop) {
+          return;
+        }
         setState(() {
           isJoin = false;
         });
       } else {
         playerInfo = PlayerInfo.fromJson(res.data);
+        if (isPop) {
+          return;
+        }
         setState(() {
           isJoin = true;
         });
@@ -197,10 +250,16 @@ class RoomInfoState extends State<RoomInfo> with SingleTickerProviderStateMixin
 //加入房间
   joinRoom() async {
     Toast.show(context, '加载中', -1, 'loading');
-    Result res = await HttpManager.post("houseInfo/join", data: {"houseId": widget.roomId, "userId": StoreProvider.of<AppState>(context).state.userInfo.id});
+    Result res = await HttpManager.post("houseInfo/join", data: {
+      "houseId": widget.roomId,
+      "userId": StoreProvider.of<AppState>(context).state.userInfo.id
+    });
     Toast.hide();
     if (res.success) {
       Toast.show(context, '加入成功', 1500, 'success');
+      if (isPop) {
+        return;
+      }
       setState(() {
         isJoin = true;
       });
@@ -287,15 +346,24 @@ class RoomInfoState extends State<RoomInfo> with SingleTickerProviderStateMixin
             color: BG_SUB_COLOR,
             child: TabBarView(
               controller: mController,
-              children: [_firstPage(), SecondPage(roomId: widget.roomId, status: status)],
+              children: [
+                _firstPage(),
+                SecondPage(roomId: widget.roomId, status: status)
+              ],
             )),
         floatingActionButton: _joinBtn(),
         floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
       ),
       onWillPop: () {
-        Toast.hide();
-        Navigator.of(context).pop();
-        return Future.value(false);
+        if (houseInfo==null||(houseInfo.statusFlag!=0)) {
+          isPop = true;
+          Toast.hide();
+          Navigator.of(context).pop();
+          return Future.value(false);
+        }
+        else{
+          Toast.show(context, '比赛即将开始,暂不能离开房间', 1500, 'info');
+        }
       },
     );
   }
@@ -303,11 +371,17 @@ class RoomInfoState extends State<RoomInfo> with SingleTickerProviderStateMixin
   Widget _firstPage() {
     Map houseLevelInfo = roomInfo.isNotEmpty ? roomInfo["houseLevelInfo"] : {};
 
-    String levelName = houseLevelInfo.containsKey("levelName") ? houseLevelInfo["levelName"] : '黄金';
+    String levelName = houseLevelInfo.containsKey("levelName")
+        ? houseLevelInfo["levelName"]
+        : '黄金';
 
-    int joinMoney = houseLevelInfo.containsKey('feeRatio') && roomInfo.containsKey("bonus") ? houseLevelInfo["feeRatio"] * roomInfo["bonus"] : 0;
+    int joinMoney =
+        houseLevelInfo.containsKey('feeRatio') && roomInfo.containsKey("bonus")
+            ? houseLevelInfo["feeRatio"] * roomInfo["bonus"]
+            : 0;
 
-    String topImg = 'http://images.liqucn.com/img/h22/h70/img_localize_8e824debdd9ee29522690f36680e2d8e_600x337.png';
+    String topImg =
+        'http://images.liqucn.com/img/h22/h70/img_localize_8e824debdd9ee29522690f36680e2d8e_600x337.png';
     int statuFlag = 0;
     if (houseInfo != null) {
       if (houseInfo.video != null) {
@@ -331,7 +405,10 @@ class RoomInfoState extends State<RoomInfo> with SingleTickerProviderStateMixin
             child: Container(
               child: Column(
                 children: <Widget>[
-                  Image.network(topImg, width: double.infinity),
+                  houseInfo != null
+                      ? VideoWidget(videoSrc: houseInfo.video)
+                      : Container(),
+                  // Image.network(topImg, width: double.infinity),
                   Container(
                       padding: EdgeInsets.only(top: 10),
                       child: Row(
@@ -340,16 +417,25 @@ class RoomInfoState extends State<RoomInfo> with SingleTickerProviderStateMixin
                           Container(
                             margin: EdgeInsets.only(left: 30, right: 8),
                             child: Text(
-                              roomInfo.containsKey("houseName") ? roomInfo["houseName"] : '',
-                              style: TextStyle(color: Colors.white, fontSize: 16, fontWeight: FontWeight.w500),
+                              roomInfo.containsKey("houseName")
+                                  ? roomInfo["houseName"]
+                                  : '',
+                              style: TextStyle(
+                                  color: Colors.white,
+                                  fontSize: 16,
+                                  fontWeight: FontWeight.w500),
                             ),
                           ),
                           Image.network(
-                            houseLevelInfo.containsKey("icon") ? houseLevelInfo["icon"] : '',
+                            houseLevelInfo.containsKey("icon")
+                                ? houseLevelInfo["icon"]
+                                : '',
                             width: 14,
                           ),
                           Text(
-                            houseLevelInfo.containsKey("levelName") ? houseLevelInfo["levelName"] : '',
+                            houseLevelInfo.containsKey("levelName")
+                                ? houseLevelInfo["levelName"]
+                                : '',
                             style: TextStyle(color: colorInfo[levelName]),
                           )
                         ],
@@ -357,7 +443,9 @@ class RoomInfoState extends State<RoomInfo> with SingleTickerProviderStateMixin
                   Container(
                     margin: EdgeInsets.only(top: 6),
                     child: Text(
-                      roomInfo.containsKey('houseAbstract') ? roomInfo["houseAbstract"] : "",
+                      roomInfo.containsKey('houseAbstract')
+                          ? roomInfo["houseAbstract"]
+                          : "",
                       style: TextStyle(color: Color(0xFF9BA0AE), fontSize: 12),
                     ),
                   ),
@@ -369,8 +457,17 @@ class RoomInfoState extends State<RoomInfo> with SingleTickerProviderStateMixin
                         width: 20,
                       ),
                       Text(
-                        (houseInfo != null ? houseInfo.playerNumber.toString() : '0') + '/' + (houseInfo != null ? houseInfo.maxNumber.toString() : '0'),
-                        style: TextStyle(fontSize: 14, fontWeight: FontWeight.w500, color: Color(0xFFB1B2C0)),
+                        (houseInfo != null
+                                ? houseInfo.playerNumber.toString()
+                                : '0') +
+                            '/' +
+                            (houseInfo != null
+                                ? houseInfo.maxNumber.toString()
+                                : '0'),
+                        style: TextStyle(
+                            fontSize: 14,
+                            fontWeight: FontWeight.w500,
+                            color: Color(0xFFB1B2C0)),
                       )
                     ],
                   ),
@@ -379,7 +476,10 @@ class RoomInfoState extends State<RoomInfo> with SingleTickerProviderStateMixin
                     width: 200,
                     height: 40,
                     decoration: BoxDecoration(
-                      border: Border.all(width: 1, color: PRIMARY_COLOR, style: BorderStyle.solid),
+                      border: Border.all(
+                          width: 1,
+                          color: PRIMARY_COLOR,
+                          style: BorderStyle.solid),
                       borderRadius: BorderRadius.all(Radius.circular(2)),
                     ),
                     child: Row(
@@ -401,7 +501,10 @@ class RoomInfoState extends State<RoomInfo> with SingleTickerProviderStateMixin
                           ),
                         ),
                         Text(
-                          'X' + (houseInfo != null ? houseInfo.bonus.toString() : '0'),
+                          'X' +
+                              (houseInfo != null
+                                  ? houseInfo.bonus.toString()
+                                  : '0'),
                           style: TextStyle(
                             color: PRIMARY_COLOR,
                             fontSize: 22,
@@ -415,10 +518,14 @@ class RoomInfoState extends State<RoomInfo> with SingleTickerProviderStateMixin
                       ? Container(
                           width: double.infinity,
                           margin: EdgeInsets.only(top: 25, left: 15, right: 15),
-                          padding: EdgeInsets.only(top: 15, left: 15, right: 10, bottom: 15),
+                          padding: EdgeInsets.only(
+                              top: 15, left: 15, right: 10, bottom: 15),
                           decoration: BoxDecoration(
                               borderRadius: BorderRadius.only(
-                                  topLeft: Radius.circular(0), topRight: Radius.circular(8), bottomLeft: Radius.circular(8), bottomRight: Radius.circular(8)),
+                                  topLeft: Radius.circular(0),
+                                  topRight: Radius.circular(8),
+                                  bottomLeft: Radius.circular(8),
+                                  bottomRight: Radius.circular(8)),
                               gradient: LinearGradient(
                                 begin: Alignment.topRight,
                                 colors: [Color(0xFF464B6A), Color(0xFF35395E)],
@@ -450,7 +557,11 @@ class RoomInfoState extends State<RoomInfo> with SingleTickerProviderStateMixin
       return Container(
         width: ScreenUtil().setWidth(375),
         height: 48 + ScreenUtil().setHeight(40),
-        padding: EdgeInsets.only(top: ScreenUtil().setHeight(20), bottom: ScreenUtil().setHeight(20), left: 15, right: 15),
+        padding: EdgeInsets.only(
+            top: ScreenUtil().setHeight(20),
+            bottom: ScreenUtil().setHeight(20),
+            left: 15,
+            right: 15),
         child: RaisedButton(
             textColor: Colors.white,
             child: Row(
@@ -464,14 +575,20 @@ class RoomInfoState extends State<RoomInfo> with SingleTickerProviderStateMixin
                   margin: EdgeInsets.only(left: 6),
                   child: Text(
                     'X' + joinMoney.toString(),
-                    style: TextStyle(color: Colors.white, fontSize: 16, fontWeight: FontWeight.w500),
+                    style: TextStyle(
+                        color: Colors.white,
+                        fontSize: 16,
+                        fontWeight: FontWeight.w500),
                   ),
                 ),
                 Container(
                     margin: EdgeInsets.only(left: 20),
                     child: Text(
                       '加入房间',
-                      style: TextStyle(color: Colors.white, fontSize: 16, fontWeight: FontWeight.w500),
+                      style: TextStyle(
+                          color: Colors.white,
+                          fontSize: 16,
+                          fontWeight: FontWeight.w500),
                     ))
               ],
             ),
@@ -554,7 +671,8 @@ class RankContentState extends State<RankContent> {
   List<PlayerInfo> topList = [];
   getTopList() async {
     Toast.show(context, '加载中', -1, 'loading');
-    Result res = await HttpManager.get("playerInfo/rankPage", data: {"houseId": widget.roomId, "currentPage": 1, "pageNumber": 3});
+    Result res = await HttpManager.get("playerInfo/rankPage",
+        data: {"houseId": widget.roomId, "currentPage": 1, "pageNumber": 3});
     Toast.hide();
     List<PlayerInfo> list = [];
     if (res.success) {
@@ -623,14 +741,19 @@ class RankContentState extends State<RankContent> {
                   width: _num == 1 ? 70 : 60,
                   height: _num == 1 ? 70 : 60,
                   decoration: BoxDecoration(
-                    gradient: LinearGradient(colors: colorList[_num - 1], begin: Alignment.topLeft, end: Alignment.bottomRight),
+                    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)),
+                    child: CircleAvatar(
+                        backgroundImage:
+                            NetworkImage(topList[_num - 1].userInfo.icon)),
                   )),
                 ),
                 Positioned(
@@ -661,7 +784,12 @@ class RankContentState extends State<RankContent> {
             mainAxisAlignment: MainAxisAlignment.center,
             children: <Widget>[
               Image.asset('images/icon_jinbi_xiao_hong.png', width: 20),
-              Text('x' + (topList[_num - 1].bonus != null ? topList[_num - 1].bonus.toString() : '0'), style: TextStyle(color: PRIMARY_COLOR, fontSize: 12))
+              Text(
+                  'x' +
+                      (topList[_num - 1].bonus != null
+                          ? topList[_num - 1].bonus.toString()
+                          : '0'),
+                  style: TextStyle(color: PRIMARY_COLOR, fontSize: 12))
             ],
           )
         ],
@@ -688,7 +816,11 @@ class SecondPageState extends State<SecondPage> {
   getPlayerPage() async {
     ismore = false;
     Toast.show(context, '加载中', -1, 'loading');
-    Result res = await HttpManager.get("playerInfo/rankPage", data: {"houseId": widget.roomId, "currentPage": currentPage, "pageNumber": 20});
+    Result res = await HttpManager.get("playerInfo/rankPage", data: {
+      "houseId": widget.roomId,
+      "currentPage": currentPage,
+      "pageNumber": 20
+    });
     Toast.hide();
     List<PlayerInfo> list = joinList;
     if (currentPage == 1) {
@@ -718,7 +850,8 @@ class SecondPageState extends State<SecondPage> {
     Future.delayed(Duration.zero, () {
       getPlayerPage();
       _perController.addListener(() {
-        if (_perController.position.pixels == _perController.position.maxScrollExtent) {
+        if (_perController.position.pixels ==
+            _perController.position.maxScrollExtent) {
           if (ismore) {
             currentPage++;
             getPlayerPage();
@@ -774,16 +907,21 @@ class SecondPageState extends State<SecondPage> {
       margin: EdgeInsets.only(top: index == 0 ? 10 : 0),
       padding: EdgeInsets.only(left: 15, right: 15),
       child: Container(
-        decoration: BoxDecoration(border: Border(bottom: BorderSide(width: 1, color: BG_SUB_COLOR, style: BorderStyle.solid))),
+        decoration: BoxDecoration(
+            border: Border(
+                bottom: BorderSide(
+                    width: 1, color: BG_SUB_COLOR, style: BorderStyle.solid))),
         child: Row(
           children: <Widget>[
             Container(
               margin: EdgeInsets.only(right: 12),
               width: 36,
               height: 36,
-              child: CircleAvatar(
-                backgroundImage: NetworkImage(info.userInfo != null ? info.userInfo.icon : ''),
-              ),
+              child: info.userInfo != null
+                  ? CircleAvatar(
+                      backgroundImage: NetworkImage(info.userInfo.icon),
+                    )
+                  : Container(),
             ),
             Expanded(
               flex: 1,
@@ -799,7 +937,9 @@ class SecondPageState extends State<SecondPage> {
             ),
             widget.status == 4 && index < 3
                 ? Image.asset(
-                    'images/icon_paihangbang_0' + (index + 1).toString() + '.png',
+                    'images/icon_paihangbang_0' +
+                        (index + 1).toString() +
+                        '.png',
                     width: 32,
                   )
                 : Container()

+ 14 - 5
lib/styles/totast.dart

@@ -66,14 +66,16 @@ class Toast {
             child: Material(
                 color: Colors.white.withOpacity(0),
                 child: new Container(
+                  margin: EdgeInsets.only(top:toastType == 'num'?200:0),
                   padding: EdgeInsets.symmetric(
-                      horizontal: toastType == 'info' ? 15 : 36),
-                  height: toastType == 'info' ? 40 : 120,
+                      horizontal: toastType == 'info' ? 15 : (toastType == 'num'?0:36)),
+                  height: toastType == 'info' ? 40 : (toastType=='num'?60:100),
+                  width: toastType=='num'?60:null,
                   decoration: ShapeDecoration(
-                    color: Colors.black.withOpacity(0.4),
+                    color: Colors.black.withOpacity(toastType=='num'?0.8:0.4),
                     shape: RoundedRectangleBorder(
                       borderRadius: BorderRadius.all(
-                        Radius.circular(8.0),
+                        Radius.circular(toastType=='num'?60:8.0),
                       ),
                     ),
                   ),
@@ -119,7 +121,14 @@ List<Widget> _contentWidget(toastType, msg) {
         ),
       ),
     ];
-  } else {
+  } else if (toastType == 'num'){
+    widgetList = [
+      Text(
+        msg,
+        style: new TextStyle(fontSize: 24.0, color: Colors.white),
+      ),
+    ];
+  }else {
     widgetList = [
       Text(
         msg,

+ 139 - 0
lib/widget/VideoWidget.dart

@@ -0,0 +1,139 @@
+import 'package:video_player/video_player.dart';
+import 'package:flutter/material.dart';
+
+class VideoWidget extends StatefulWidget {
+  VideoWidget({Key key, this.videoSrc}) : super(key: key);
+  final String videoSrc; // 用来储存传递过来的值
+
+  @override
+  VideoWidgetState createState() => VideoWidgetState();
+}
+
+class VideoWidgetState extends State<VideoWidget> {
+  VideoPlayerController _controller;
+  String _defaultVideo =
+      'http://oss.izouma.com/shouyoudianjing/video/2019-03-01-11-19-41-ivqsgiy9.mp4';
+  bool isVideo = true;
+  bool showVideo = false;
+  bool isPlay = false;
+
+  @override
+  void initState() {
+    super.initState();
+    if (widget.videoSrc == null) {
+    } else {
+      if (widget.videoSrc.contains('.mp4')) {
+        _defaultVideo = widget.videoSrc;
+        isVideo = true;
+      } else {
+        isVideo = false;
+      }
+    }
+
+    print('**********');
+    print(isVideo);
+    print(_defaultVideo);
+    print(widget.videoSrc);
+    if (isVideo) {
+      _controller = VideoPlayerController.network(_defaultVideo)
+        ..initialize().then((_) {
+          // Ensure the first frame is shown after the video is initialized, even before the play button has been pressed.
+          setState(() {});
+        });
+        _controller.setLooping(true);
+      _controller.addListener(() {
+        setState(() {
+          isPlay = _controller.value.isPlaying;
+        });
+        // if(_controller.value.isLooping)
+      });
+    }
+  }
+
+  @override
+  void dispose() {
+    super.dispose();
+    _controller.dispose();
+  }
+
+  void playVideo() async {
+    if (!showVideo) {
+      setState(() {
+        showVideo = true;
+      });
+      await Future.delayed(Duration(milliseconds: 500));
+    }
+    _controller.value.isPlaying ? _controller.pause() : _controller.play();
+  }
+
+  @override
+  Widget build(BuildContext context) {
+    return Container(
+        child: Column(
+      children: <Widget>[
+        isVideo
+            ? _playContainer()
+            : Image.network(widget.videoSrc, width: double.infinity)
+      ],
+    ));
+  }
+
+  Widget _playContainer() {
+    return Container(
+      color: Colors.black,
+      height: 210,
+      width: double.infinity,
+      child: Center(
+        child: Stack(
+          children: <Widget>[
+            InkWell(
+                child: Center(
+                  child: showVideo
+                    ? AspectRatio(
+                        aspectRatio: _controller.value.aspectRatio,
+                        child: VideoPlayer(_controller),
+                      )
+                    : Image.network(
+                        'http://images.liqucn.com/img/h22/h70/img_localize_8e824debdd9ee29522690f36680e2d8e_600x337.png',
+                        width: double.infinity),
+                ),
+                onTap: () => playVideo()),
+            !isPlay
+                ? Positioned(
+                    left: 0,
+                    right: 0,
+                    top:83,
+                    child: Center(
+                      child: UnconstrainedBox(
+                        child: Container(
+                          width: 44,
+                          height: 44,
+                          child: RaisedButton(
+                            shape: RoundedRectangleBorder(
+                                borderRadius: BorderRadius.circular(44)),
+                            padding: EdgeInsets.all(0),
+                            color: Colors.black87,
+                            textColor: Colors.white,
+                            onPressed: () => playVideo(),
+                            child:
+                                Icon(isPlay ? Icons.pause : Icons.play_arrow),
+                          ),
+                        ),
+                      ),
+                    ))
+                : Container(),
+          ],
+        ),
+      ),
+    );
+    return InkWell(
+      child: AspectRatio(
+        aspectRatio: _controller.value.aspectRatio,
+        child: VideoPlayer(_controller),
+      ),
+      onTap: () {
+        _controller.value.isPlaying ? _controller.pause() : _controller.play();
+      },
+    );
+  }
+}