panhui 6 years ago
parent
commit
92976b6c01

+ 1 - 1
android/app/src/main/AndroidManifest.xml

@@ -9,7 +9,7 @@
     <application
         android:name="com.izouma.screen_stream_plugin.MyApplication"
         android:icon="@mipmap/ic_launcher"
-        android:label="战神竞"
+        android:label="EMMC战神竞技场"
         android:networkSecurityConfig="@xml/network_security_config"
         android:usesCleartextTraffic="true">
         <activity

BIN
images/2x/tabbar_icon_02.png


BIN
images/3x/tabbar_icon_02.png


BIN
images/tabbar_icon_02.png


+ 2 - 0
lib/pages/BindGame.dart

@@ -1,4 +1,5 @@
 import 'package:flutter/material.dart';
+import 'package:cached_network_image/cached_network_image.dart';
 import '../styles/colors.dart';
 import 'dart:ui';
 import '../styles/totast.dart';
@@ -9,6 +10,7 @@ import '../net/Result.dart';
 import '../model/BindGameInfo.dart';
 import '../widget/LinearButton.dart';
 
+
 class BindGame extends StatefulWidget {
   @override
   BindGameState createState() => BindGameState();

+ 8 - 11
lib/pages/HomePage.dart

@@ -1,15 +1,8 @@
 import 'package:flutter/material.dart';
 import 'package:flutter/cupertino.dart';
-import 'package:flutter_swiper/flutter_swiper.dart';
-import '../widget/HomeDrawer.dart';
-import '../widget/LinearButton.dart';
-import '../net/HttpManager.dart';
-import 'package:flutter_redux/flutter_redux.dart';
-import '../redux/AppState.dart';
 import 'GuidePage.dart';
-import 'TipList.dart';
-import '../net/Result.dart';
 import 'MatchPage.dart';
+import 'RankList.dart';
 import '../widget/BottomTabs.dart';
 import 'UserPage.dart';
 
@@ -24,7 +17,7 @@ class _HomePageState extends State<HomePage> with SingleTickerProviderStateMixin
   @override
   void initState() {
     super.initState();
-    controller = new TabController(length: 2, vsync: this);
+    controller = new TabController(length: 3, vsync: this);
     Future.delayed(Duration.zero, () {
       ;
       //引导页
@@ -46,7 +39,7 @@ class _HomePageState extends State<HomePage> with SingleTickerProviderStateMixin
             color: Color(0xFF2E3049),
             child: new MyTabBarView(
               controller: controller,
-              children: <Widget>[MatchPage(), UserPage()],
+              children: <Widget>[MatchPage(),RankList(), UserPage()],
             ),
           ),
           onWillPop: () {
@@ -68,6 +61,10 @@ class _HomePageState extends State<HomePage> with SingleTickerProviderStateMixin
                 text: "赛事",
                 icon: ImageIcon(AssetImage('images/tabbar_icon_01_pre.png'), size: 28),
               ),
+              MyTab(
+                text: "排行",
+                icon: ImageIcon(AssetImage('images/tabbar_icon_02.png'), size: 28),
+              ),
               new MyTab(
                 text: "我的",
                 icon: ImageIcon(AssetImage('images/tabbar_icon_03.png'), size: 28),
@@ -94,4 +91,4 @@ class _HomePageState extends State<HomePage> with SingleTickerProviderStateMixin
           return GuidePage();
         }));
   }
-}
+}

+ 218 - 156
lib/pages/MatchPage.dart

@@ -1,5 +1,6 @@
 import 'package:flutter/material.dart';
 import 'package:flutter_swiper/flutter_swiper.dart';
+import 'package:cached_network_image/cached_network_image.dart';
 import 'package:flutter/cupertino.dart';
 import '../styles/totast.dart';
 import '../net/HttpManager.dart';
@@ -18,6 +19,7 @@ import '../model/GameInfo.dart';
 import 'dart:async';
 import 'dart:convert';
 import 'dart:ui';
+import 'dart:math';
 
 class MatchPage extends StatefulWidget {
   @override
@@ -35,6 +37,7 @@ class _MatchPageState extends State<MatchPage> with WidgetsBindingObserver {
   ScrollController _controller;
   List<GameInfo> gameList = [];
   String gameName = '全部游戏';
+  bool isFirst = true;
 
   void showPicker(BuildContext context) {
     List<String> _list = [];
@@ -88,6 +91,7 @@ class _MatchPageState extends State<MatchPage> with WidgetsBindingObserver {
   }
 
   Future<void> getRoomInfo() async {
+    print('获取房间');
     Map<String, dynamic> data = {'currentPage': currentPage, 'pageNumber': 20, 'myUserId': StoreProvider.of<AppState>(context).state.userInfo.id};
 
     data['advancedQuery'] = '';
@@ -130,16 +134,18 @@ class _MatchPageState extends State<MatchPage> with WidgetsBindingObserver {
   }
 
   Future<void> getBannerInfo() async {
+    List<BannerInfo> _bannerList = [];
     Toast.show(context, '加载中', -1, 'loading');
     Result res = await HttpManager.get('bannerInfo/all');
     Toast.hide();
     if (res.success && res.data != null) {
       for (var item in res.data) {
         BannerInfo banner = BannerInfo.fromJson(item);
-        setState(() {
-          bannerList.add(banner);
-        });
+        _bannerList.add(banner);
       }
+      setState(() {
+        bannerList = _bannerList;
+      });
     }
   }
 
@@ -161,176 +167,204 @@ class _MatchPageState extends State<MatchPage> with WidgetsBindingObserver {
       }
     });
     Future.delayed(Duration.zero, () {
-      getRoomInfo();
       getBannerInfo();
       getGame();
+      getRoomInfo();
     });
   }
 
   @override
   Widget build(BuildContext context) {
-    return Scaffold(
-      appBar: AppBar(
-        title: Text('赛事'),
-        centerTitle: true,
-        leading: Material(
-          color: Colors.transparent,
-          child: Builder(
-            builder: (context) => InkWell(
-                  onTap: () async {
-                    bool result = await Navigator.push(context, CupertinoPageRoute(builder: (context) => TipList()));
-                    if (result) {
-                      getUnreadMsg();
-                    }
-                  },
-                  child: Image.asset('images/home_icon_xiaoxi.png'),
+    return WillPopScope(
+      child: Scaffold(
+          appBar: AppBar(
+            title: Text('赛事'),
+            centerTitle: true,
+            leading: Material(
+              color: Colors.transparent,
+              child: Builder(
+                builder: (context) => InkWell(
+                      onTap: () async {
+                        bool result = await Navigator.push(context, CupertinoPageRoute(builder: (context) => TipList()));
+                        if (result) {
+                          getUnreadMsg();
+                        }
+                      },
+                      child: Image.asset('images/home_icon_xiaoxi.png'),
+                    ),
+              ),
+            ),
+            actions: <Widget>[
+              Container(
+                width: 102,
+                padding: EdgeInsets.all(15),
+                child: LinearButton(
+                  btntext: '发起比赛',
+                  textColor: Color(0xFFA2423E),
+                  btnHeight: 26.0,
+                  colorList: [Color(0xFFFFE77C), Color(0xFFFFE77C)],
+                  textSize: 12.0,
+                  onTapHomeMenu: () => {Navigator.push(context, CupertinoPageRoute(builder: (context) => OpenRoom(roomFlag: '0')))},
                 ),
+              )
+            ],
           ),
-        ),
-        actions: <Widget>[
-          Container(
-            width: 102,
-            padding: EdgeInsets.all(15),
-            child: LinearButton(
-              btntext: '发起比赛',
-              textColor: Color(0xFFA2423E),
-              btnHeight: 26.0,
-              colorList: [Color(0xFFFFE77C), Color(0xFFFFE77C)],
-              textSize: 12.0,
-              onTapHomeMenu: () => {Navigator.push(context, CupertinoPageRoute(builder: (context) => OpenRoom(roomFlag: '0')))},
-            ),
-          )
-        ],
-      ),
-      body: Container(
-        color: Color(0xFF2E3049),
-        height: double.infinity,
-        width: double.infinity,
-        child: CustomScrollView(
-          controller: _controller,
-          slivers: <Widget>[
-            SliverToBoxAdapter(
-              child: Column(
-                children: <Widget>[
-                  Container(
-                    width: double.infinity,
-                    height: 200,
-                    child: new Swiper(
-                        itemBuilder: (BuildContext context, int index) {
-                          return Image.network(
-                            bannerList[index].imageUrl,
-                            fit: BoxFit.fill,
-                          );
-                        },
-                        itemCount: bannerList.length,
-                        loop: false,
-                        autoplay: true,
-                        autoplayDelay: 5000,
-                        pagination: new SwiperPagination()),
-                  ),
-                  Container(
-                    height: 60,
-                    padding: EdgeInsets.symmetric(vertical: 10, horizontal: 15),
+          body: Container(
+            color: Color(0xFF2E3049),
+            height: double.infinity,
+            width: double.infinity,
+            child: RefreshIndicator(
+              color: Theme.of(context).primaryColor,
+              backgroundColor: Colors.white,
+              displacement: 10,
+              onRefresh: () async {
+                await Future.delayed(const Duration(seconds: 1));
+                gameId = 0;
+                currentPage = 1;
+                searchKey = '';
+                getRoomInfo();
+                // getBannerInfo();
+                getGame();
+              },
+              child: CustomScrollView(
+                physics: AlwaysScrollableScrollPhysics(),
+                controller: _controller,
+                slivers: <Widget>[
+                  SliverToBoxAdapter(
                     child: Container(
-                      decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.all(Radius.circular(4))),
-                      child: Row(
-                        children: <Widget>[
-                          Container(
-                            width: 10,
-                          ),
-                          ImageIcon(
-                            AssetImage('images/home_icon_sousuo.png'),
-                            color: Color(0xFF727785),
-                          ),
-                          Expanded(
-                            flex: 1,
-                            child: Container(
-                              height: 34,
-                              decoration: BoxDecoration(
-                                color: Colors.white,
-                                borderRadius: BorderRadius.all(Radius.circular(100)),
-                              ),
-                              child: ITextField(
-                                  hintText: '搜索竞赛房间',
-                                  inputBorder: InputBorder.none,
-                                  hintStyle: TextStyle(
-                                    fontSize: 18,
-                                    color: Color(0xFFB1B5C0),
+                      width: double.infinity,
+                      height: 200,
+                      child: new Swiper(
+                          itemBuilder: (BuildContext context, int index) {
+                            return Image.network(
+                              bannerList[index].imageUrl,
+                              fit: BoxFit.fill,
+                            );
+                          },
+                          itemCount: bannerList.length,
+                          loop: false,
+                          autoplay: true,
+                          autoplayDelay: 5000,
+                          pagination: SwiperPagination()),
+                    ),
+                  ),
+                  SliverPersistentHeader(
+                    pinned: true, //是否固定在顶部
+                    floating: true,
+                    delegate: _SliverAppBarDelegate(
+                        minHeight: 60, //收起的高度
+                        maxHeight: 60, //展开的最大高度
+                        child: Container(
+                          color: Color(0xFF2E3049),
+                          height: 60,
+                          padding: EdgeInsets.symmetric(vertical: 10, horizontal: 15),
+                          child: Container(
+                            decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.all(Radius.circular(4))),
+                            child: Row(
+                              children: <Widget>[
+                                Container(
+                                  width: 10,
+                                ),
+                                ImageIcon(
+                                  AssetImage('images/home_icon_sousuo.png'),
+                                  color: Color(0xFF727785),
+                                ),
+                                Expanded(
+                                  flex: 1,
+                                  child: Container(
+                                    height: 34,
+                                    decoration: BoxDecoration(
+                                      color: Colors.white,
+                                      borderRadius: BorderRadius.all(Radius.circular(100)),
+                                    ),
+                                    child: ITextField(
+                                        hintText: '搜索竞赛房间',
+                                        inputBorder: InputBorder.none,
+                                        hintStyle: TextStyle(
+                                          fontSize: 18,
+                                          color: Color(0xFFB1B5C0),
+                                        ),
+                                        textStyle: TextStyle(color: Colors.black),
+                                        contentPadding: EdgeInsets.symmetric(vertical: 4, horizontal: 4),
+                                        fieldCallBack: (content) {
+                                          search(content);
+                                        },
+                                        counterStyle: TextStyle(color: Color(0xFF9BA0AE), fontSize: 0),
+                                        textInputAction: TextInputAction.search),
                                   ),
-                                  textStyle: TextStyle(color: Colors.black),
-                                  contentPadding: EdgeInsets.symmetric(vertical: 4, horizontal: 4),
-                                  fieldCallBack: (content) {
-                                    search(content);
-                                  },
-                                  counterStyle: TextStyle(color: Color(0xFF9BA0AE), fontSize: 0),
-                                  textInputAction: TextInputAction.search),
+                                ),
+                                Container(
+                                  width: 1,
+                                  height: 10,
+                                  color: Color(0xFFB1B5C0),
+                                ),
+                                Container(
+                                    width: 99,
+                                    child: InkWell(
+                                        onTap: () {
+                                          showPicker(context);
+                                        },
+                                        child: Row(
+                                          mainAxisAlignment: MainAxisAlignment.center,
+                                          children: <Widget>[
+                                            Expanded(
+                                              flex: 1,
+                                              child: Container(
+                                                padding: EdgeInsets.only(left: 5),
+                                                alignment: Alignment.center,
+                                                child: Text(
+                                                  gameName,
+                                                  style: TextStyle(color: Color(0xFFB1B5C0)),
+                                                  overflow: TextOverflow.ellipsis,
+                                                ),
+                                              ),
+                                            ),
+                                            Image.asset('images/icon_zhankai_huise.png'),
+                                            Container(
+                                              width: 5,
+                                            )
+                                          ],
+                                        )))
+                              ],
                             ),
                           ),
-                          Container(
-                            width: 1,
-                            height: 10,
-                            color: Color(0xFFB1B5C0),
-                          ),
-                          Container(
-                              width: 99,
-                              child: InkWell(
-                                  onTap: () {
-                                    showPicker(context);
-                                  },
-                                  child: Row(
-                                    mainAxisAlignment: MainAxisAlignment.center,
-                                    children: <Widget>[
-                                      Expanded(
-                                        flex: 1,
-                                        child: Container(
-                                          padding: EdgeInsets.only(left: 5),
-                                          alignment: Alignment.center,
-                                          child: Text(
-                                            gameName,
-                                            style: TextStyle(color: Color(0xFFB1B5C0)),
-                                            overflow: TextOverflow.ellipsis,
-                                          ),
-                                        ),
-                                      ),
-                                      Image.asset('images/icon_zhankai_huise.png'),
-                                      Container(width: 5,)
-                                    ],
-                                  )))
-                        ],
-                      ),
-                    ),
+                        )),
                   ),
-                  // Padding(
-                  //   padding: EdgeInsets.symmetric(horizontal: 15),
-                  //   child: Column(
-                  //     children: _houseList(houseList),
-                  //   ),
-                  // )
+                  SliverFixedExtentList(
+                    itemExtent: houseList.isEmpty ? 300 : 90,
+                    delegate: SliverChildBuilderDelegate((BuildContext context, int index) {
+                      if (houseList.isEmpty) {
+                        return Container(
+                          padding: EdgeInsets.only(top: 105),
+                          child: Column(
+                            children: <Widget>[
+                              Image.asset('images/icon_kong.png'),
+                              Text('暂时没有此房间哦~', style: TextStyle(fontSize: 14, color: Theme.of(context).primaryColor.withOpacity(0.3)))
+                            ],
+                          ),
+                        );
+                      } else if (index == houseList.length) {
+                        return Text('更多房间敬请期待...', style: TextStyle(color: Colors.grey, fontSize: 13, height: 3), textAlign: TextAlign.center);
+                      }
+                      return HouseItem(houseList[index], houseList[index].gameInfo);
+                    }, childCount: houseList.length + 1),
+                  )
                 ],
               ),
             ),
-            SliverFixedExtentList(
-              itemExtent: houseList.isEmpty ? 300 : 80,
-              delegate: SliverChildBuilderDelegate((BuildContext context, int index) {
-                if (houseList.isEmpty) {
-                  return Container(
-                    padding: EdgeInsets.only(top: 105),
-                    child: Column(
-                      children: <Widget>[
-                        Image.asset('images/icon_kong.png'),
-                        Text('暂时没有此房间哦~', style: TextStyle(fontSize: 14, color: Theme.of(context).primaryColor.withOpacity(0.3)))
-                      ],
-                    ),
-                  );
-                } else if (index == houseList.length) {
-                  return Text('更多房间敬请期待...', style: TextStyle(color: Colors.grey, fontSize: 13, height: 3), textAlign: TextAlign.center);
-                }
-                return HouseItem(houseList[index], houseList[index].gameInfo);
-              }, childCount: houseList.length + 1),
-            )
-          ],
-        ),
-      ),
+          )),
+      onWillPop: () {
+        if (isFirst) {
+          isFirst = false;
+          Toast.show(context, '再次点击退出程序', 1500, 'info');
+          Timer(Duration(seconds: 2), () {
+            isFirst = true;
+          });
+          return Future.value(false);
+        } else {
+          return Future.value(true);
+        }
+      },
     );
   }
 
@@ -343,3 +377,31 @@ class _MatchPageState extends State<MatchPage> with WidgetsBindingObserver {
     return list;
   }
 }
+
+class _SliverAppBarDelegate extends SliverPersistentHeaderDelegate {
+  _SliverAppBarDelegate({
+    @required this.minHeight,
+    @required this.maxHeight,
+    @required this.child,
+  });
+
+  final double minHeight;
+  final double maxHeight;
+  final Widget child;
+
+  @override
+  double get minExtent => minHeight;
+
+  @override
+  double get maxExtent => max(maxHeight, minHeight);
+
+  @override
+  Widget build(BuildContext context, double shrinkOffset, bool overlapsContent) {
+    return new SizedBox.expand(child: child);
+  }
+
+  @override
+  bool shouldRebuild(_SliverAppBarDelegate oldDelegate) {
+    return maxHeight != oldDelegate.maxHeight || minHeight != oldDelegate.minHeight || child != oldDelegate.child;
+  }
+}

+ 240 - 316
lib/pages/OpenRoom.dart

@@ -1,5 +1,6 @@
 import 'package:flutter/material.dart';
 import 'package:flutter_picker/flutter_picker.dart';
+import 'package:cached_network_image/cached_network_image.dart';
 import 'package:flutter/cupertino.dart';
 import 'package:file_picker/file_picker.dart';
 import '../styles/colors.dart';
@@ -29,15 +30,9 @@ class OpenRoom extends StatefulWidget {
 
 class OpenRoomState extends State<OpenRoom> {
   TextStyle titleStyle = TextStyle(color: Colors.white, fontSize: 14);
-  TextStyle valStyle =
-      TextStyle(color: Colors.white, fontSize: 15, fontWeight: FontWeight.w500);
+  TextStyle valStyle = TextStyle(color: Colors.white, fontSize: 15, fontWeight: FontWeight.w500);
 
-  Map<String, dynamic> editRoomInfo = {
-    'gameId': 1,
-    'houseLevel': 1,
-    'maxNumber': 5,
-    'scoreType': 0
-  };
+  Map<String, dynamic> editRoomInfo = {'gameId': 1, 'houseLevel': 1, 'maxNumber': 5, 'scoreType': 0};
   List<GameInfo> gameList = [];
   List<HouseLevel> levelList = [];
 
@@ -85,15 +80,11 @@ class OpenRoomState extends State<OpenRoom> {
     //   Toast.show(context, '请选择房间等级', 1500, 'info');
     //   return;
     // }
-    if (editRoomInfo['houseType'] == '1' &&
-        (editRoomInfo['gameHouseId'] == null ||
-            editRoomInfo['gameHouseId'] == '')) {
+    if (editRoomInfo['houseType'] == '1' && (editRoomInfo['gameHouseId'] == null || editRoomInfo['gameHouseId'] == '')) {
       Toast.show(context, '请录入游戏房间号', 1500, 'info');
       return;
     }
-    if (editRoomInfo['houseType'] == '1' &&
-        (editRoomInfo['gameHousePassword'] == null ||
-            editRoomInfo['gameHousePassword'] == '')) {
+    if (editRoomInfo['houseType'] == '1' && (editRoomInfo['gameHousePassword'] == null || editRoomInfo['gameHousePassword'] == '')) {
       Toast.show(context, '请录入游戏房间密码', 1500, 'info');
       return;
     }
@@ -104,8 +95,7 @@ class OpenRoomState extends State<OpenRoom> {
           chooseLevelInfo = item;
         }
       }
-      if (StoreProvider.of<AppState>(context).state.userInfo.moneyCoin <
-          chooseLevelInfo.entryCoin) {
+      if (StoreProvider.of<AppState>(context).state.userInfo.moneyCoin < chooseLevelInfo.entryCoin) {
         return;
       }
     } else {
@@ -133,10 +123,8 @@ class OpenRoomState extends State<OpenRoom> {
       );
       return;
     }
-    editRoomInfo['createUser'] =
-        StoreProvider.of<AppState>(context).state.userInfo.id;
-    editRoomInfo['userId'] =
-        StoreProvider.of<AppState>(context).state.userInfo.id;
+    editRoomInfo['createUser'] = StoreProvider.of<AppState>(context).state.userInfo.id;
+    editRoomInfo['userId'] = StoreProvider.of<AppState>(context).state.userInfo.id;
     Toast.show(context, '加载中', -1, 'loading');
     Result res = await HttpManager.post('houseInfo/save', data: editRoomInfo);
     Toast.hide();
@@ -147,10 +135,7 @@ class OpenRoomState extends State<OpenRoom> {
       // });
       Toast.show(context, '创建成功', 1500, 'success');
       Future.delayed(Duration(milliseconds: 1500), () {
-        Navigator.pushReplacement(
-            context,
-            CupertinoPageRoute(
-                builder: (context) => RoomInfo(roomId: res.data.toString())));
+        Navigator.pushReplacement(context, CupertinoPageRoute(builder: (context) => RoomInfo(roomId: res.data.toString())));
       });
     } else {
       Toast.show(context, res.error, 1500, 'info');
@@ -169,11 +154,8 @@ class OpenRoomState extends State<OpenRoom> {
         gameList = _list;
         if (res.data.length > 0) {
           editRoomInfo['gameId'] = res.data[0]['id'];
-          editRoomInfo['houseName'] =
-              StoreProvider.of<AppState>(context).state.userInfo.nickname +
-                  '的' +
-                  res.data[0]['shortName'] +
-                  '房间';
+          String name = StoreProvider.of<AppState>(context).state.userInfo.nickname;
+          editRoomInfo['houseName'] = (name.length > 5 ? name.substring(0, 5) : name) + '的' + res.data[0]['shortName'] + '房间';
           editRoomInfo['houseAbstract'] = res.data[0]['profile'] ?? '';
         }
       });
@@ -223,238 +205,223 @@ class OpenRoomState extends State<OpenRoom> {
 
     return WillPopScope(
       child: Scaffold(
-          appBar: AppBar(
-            title: Text('发起' + (widget.roomFlag == '0' ? '普通' : '官方') + '赛事'),
-            centerTitle: true,
-            elevation: 0,
-            // actions: <Widget>[
-            //   Container(
-            //     width: 60,
-            //     child: FlatButton(
-            //       highlightColor: PRIMARY_COLOR,
-            //       padding: EdgeInsets.only(right: 0),
-            //       child: Text('规则',
-            //           style: TextStyle(color: Colors.white, fontSize: 13)),
-            //       onPressed: () {},
-            //     ),
-            //   )
-            // ],
-          ),
-          body: Container(
-            color: BG_COLOR,
-            width: double.infinity,
-            height: double.infinity,
-            child: SingleChildScrollView(
-              child: Container(
-                color: BG_COLOR,
-                child: Column(
-                  children: <Widget>[
-                    ChooseContent(
-                      title: '选择游戏',
-                      val: chooseGameInfo.gameName,
-                      onTapHomeMenu: () {
-                        showPicker(context);
-                      },
-                    ),
-                    Container(
-                      width: double.infinity,
-                      color: BG_SUB_COLOR,
-                      height: 210,
-                      child: Column(
-                        mainAxisAlignment: MainAxisAlignment.center,
-                        children: <Widget>[
-                          FlatButton(
-                            padding: EdgeInsets.all(0),
-                            color: Color(0xFF464B6A),
-                            highlightColor: Color(0xFF333557),
-                            child: Container(
-                              height: 38,
-                              width: 160,
-                              decoration: BoxDecoration(
-                                  gradient: LinearGradient(
-                                begin: Alignment.topRight,
-                                colors: [Colors.black12, Colors.black38],
-                              )),
-                              child: Row(
-                                mainAxisAlignment: MainAxisAlignment.center,
-                                children: <Widget>[
-                                  Padding(
-                                      padding: EdgeInsets.only(right: 8),
-                                      child: Image.asset(
-                                        'images/icon_shipin.png',
-                                        width: 20,
-                                      )),
-                                  Text('上传图片或视频', style: titleStyle)
-                                ],
-                              ),
+        appBar: AppBar(
+          title: Text('发起' + (widget.roomFlag == '0' ? '普通' : '官方') + '赛事'),
+          centerTitle: true,
+          elevation: 0,
+          // actions: <Widget>[
+          //   Container(
+          //     width: 60,
+          //     child: FlatButton(
+          //       highlightColor: PRIMARY_COLOR,
+          //       padding: EdgeInsets.only(right: 0),
+          //       child: Text('规则',
+          //           style: TextStyle(color: Colors.white, fontSize: 13)),
+          //       onPressed: () {},
+          //     ),
+          //   )
+          // ],
+        ),
+        body: Container(
+          color: Color(0xFF2E3049),
+          width: double.infinity,
+          height: double.infinity,
+          child: SingleChildScrollView(
+            child: Container(
+              child: Column(
+                children: <Widget>[
+                  Container(
+                    width: double.infinity,
+                    color: Color(0xFF1D1E2E),
+                    height: 210,
+                    child: Column(
+                      mainAxisAlignment: MainAxisAlignment.center,
+                      children: <Widget>[
+                        Container(
+                          width: 160,
+                          height: 38,
+                          child: LinearButton(
+                            radius:38.0,
+                            colorList: [Color(0xFF3A3E61),Color(0xFF3A3E61)],
+                            childWidget: Row(
+                              mainAxisAlignment: MainAxisAlignment.center,
+                              children: <Widget>[
+                                Padding(
+                                    padding: EdgeInsets.only(right: 8),
+                                    child: Image.asset(
+                                      'images/icon_shipin.png',
+                                      width: 20,
+                                    )),
+                                Text('上传图片或视频', style: titleStyle)
+                              ],
                             ),
-                            onPressed: () {
+                            onTapHomeMenu: () {
                               getFilePath();
                             },
                           ),
-                          Padding(
-                            padding: EdgeInsets.only(top: 12),
-                            child: Text(
-                              editRoomInfo.containsKey('video')
-                                  ? '已选择'
-                                  : '不上传则自动使用官方默认视频',
-                              style: TextStyle(
-                                  color: Color(0xFF9BA0AE), fontSize: 13),
-                            ),
-                          )
-                        ],
-                      ),
-                    ),
-                    //房间标题
-                    // Container(
-                    //   height: 60,
-                    //   color: BG_COLOR,
-                    //   padding:
-                    //       EdgeInsets.symmetric(horizontal: 15, vertical: 8),
-                    //   child: TextField(
-                    //     textAlign: TextAlign.end,
-                    //     style: valStyle,
-                    //     maxLength: 10,
-                    //     decoration: InputDecoration(
-                    //         hintText: '请输入房间标题',
-                    //         hintStyle: TextStyle(
-                    //             color: Color(0xFF727785), fontSize: 13),
-                    //         prefixIcon: Padding(
-                    //           padding: EdgeInsets.symmetric(vertical: 12),
-                    //           child: Text('房间标题', style: titleStyle),
-                    //         ),
-                    //         border: InputBorder.none,
-                    //         counterStyle: TextStyle(fontSize: 0)),
-                    //     onChanged: (value) {
-                    //       editRoomInfo['houseName'] = value;
-                    //     },
-                    //   ),
-                    // ),
-                    InputContent(
-                        title: '房间标题',
-                        value: editRoomInfo['houseName'],
-                        onTextChange: (value) {
-                          editRoomInfo['houseName'] = value;
-                        }),
-                    Container(
-                      margin: EdgeInsets.symmetric(horizontal: 15),
-                      height: 1,
-                      color: BG_SUB_COLOR,
-                    ),
-                    //房间简介
-                    InputContent(
-                        title: '房间简介',
-                        value: editRoomInfo['houseAbstract'],
-                        onTextChange: (value) {
-                          editRoomInfo['houseAbstract'] = value;
-                        }),
-                    // Container(
-                    //   height: 60,
-                    //   color: BG_COLOR,
-                    //   padding:
-                    //       EdgeInsets.symmetric(horizontal: 15, vertical: 8),
-                    //   child: TextField(
-                    //     textAlign: TextAlign.end,
-                    //     style: valStyle,
-                    //     maxLength: 15,
-                    //     decoration: InputDecoration(
-                    //         hintText: '请输入房间简介',
-                    //         hintStyle: TextStyle(
-                    //             color: Color(0xFF727785), fontSize: 13),
-                    //         prefixIcon: Padding(
-                    //           padding: EdgeInsets.symmetric(vertical: 12),
-                    //           child: Text('房间简介', style: titleStyle),
-                    //         ),
-                    //         border: InputBorder.none,
-                    //         counterStyle: TextStyle(fontSize: 0)),
-                    //     onChanged: (value) {
-                    //       editRoomInfo['houseAbstract'] = value;
-                    //     },
-                    //   ),
-                    // ),
-                     Container(
-                      margin: EdgeInsets.symmetric(horizontal: 15),
-                      height: 1,
-                      color: BG_SUB_COLOR,
-                    ),
-                    //房间等级
-                    // ChooseContent(
-                    //   title: '房间等级',
-                    //   chooseLevelInfo: chooseLevelInfo,
-                    //   isLevel: true,
-                    //   onTapHomeMenu: () {
-                    //     showLevelPicker(context);
-                    //   },
-                    // ),
-                     Container(
-                      margin: EdgeInsets.symmetric(horizontal: 15),
-                      height: 1,
-                      color: BG_SUB_COLOR,
-                    ),
-                    //房间人数
-                    ChooseContent(
-                      title: '房卡人数',
-                      val: editRoomInfo['maxNumber'].toString() + '人次房卡',
-                      icon: Image.asset('images/icon_yiwen.png'),
-                      onTapHomeMenu: () {
-                        showNumPicker(context);
-                      },
-                    ),
-                     Container(
-                      margin: EdgeInsets.symmetric(horizontal: 15),
-                      height: 1,
-                      color: BG_SUB_COLOR,
-                    ),
-                    //房间人数
-                    ChooseContent(
-                      title: '胜利条件',
-                      val: editRoomInfo['scoreType'] == 0 ? '评分' : '吃鸡',
-                      onTapHomeMenu: () {
-                        showScoreType(context);
-                      },
+                        ),
+                        Padding(
+                          padding: EdgeInsets.only(top: 12),
+                          child: Text(
+                            editRoomInfo.containsKey('video') ? '已选择' : '不上传则自动使用官方默认视频',
+                            style: TextStyle(color: Color(0xFF9BA0AE), fontSize: 13),
+                          ),
+                        )
+                      ],
                     ),
-                    _bottomWidget(),
-                   
-                  ],
-                ),
+                  ),
+                  //房间标题
+                  // Container(
+                  //   height: 60,
+                  //   color: BG_COLOR,
+                  //   padding:
+                  //       EdgeInsets.symmetric(horizontal: 15, vertical: 8),
+                  //   child: TextField(
+                  //     textAlign: TextAlign.end,
+                  //     style: valStyle,
+                  //     maxLength: 10,
+                  //     decoration: InputDecoration(
+                  //         hintText: '请输入房间标题',
+                  //         hintStyle: TextStyle(
+                  //             color: Color(0xFF727785), fontSize: 13),
+                  //         prefixIcon: Padding(
+                  //           padding: EdgeInsets.symmetric(vertical: 12),
+                  //           child: Text('房间标题', style: titleStyle),
+                  //         ),
+                  //         border: InputBorder.none,
+                  //         counterStyle: TextStyle(fontSize: 0)),
+                  //     onChanged: (value) {
+                  //       editRoomInfo['houseName'] = value;
+                  //     },
+                  //   ),
+                  // ),
+                  ChooseContent(
+                    title: '选择游戏',
+                    val: chooseGameInfo.gameName,
+                    onTapHomeMenu: () {
+                      showPicker(context);
+                    },
+                  ),
+                  Container(
+                    margin: EdgeInsets.symmetric(horizontal: 15),
+                    height: 1,
+                    color: BG_SUB_COLOR,
+                  ),
+                  InputContent(
+                      title: '房间标题',
+                      value: editRoomInfo['houseName'],
+                      onTextChange: (value) {
+                        editRoomInfo['houseName'] = value;
+                      }),
+                  Container(
+                    margin: EdgeInsets.symmetric(horizontal: 15),
+                    height: 1,
+                    color: BG_SUB_COLOR,
+                  ),
+                  // //房间简介
+                  // InputContent(
+                  //     title: '房间简介',
+                  //     value: editRoomInfo['houseAbstract'],
+                  //     onTextChange: (value) {
+                  //       editRoomInfo['houseAbstract'] = value;
+                  //     }),
+                  // Container(
+                  //   height: 60,
+                  //   color: BG_COLOR,
+                  //   padding:
+                  //       EdgeInsets.symmetric(horizontal: 15, vertical: 8),
+                  //   child: TextField(
+                  //     textAlign: TextAlign.end,
+                  //     style: valStyle,
+                  //     maxLength: 15,
+                  //     decoration: InputDecoration(
+                  //         hintText: '请输入房间简介',
+                  //         hintStyle: TextStyle(
+                  //             color: Color(0xFF727785), fontSize: 13),
+                  //         prefixIcon: Padding(
+                  //           padding: EdgeInsets.symmetric(vertical: 12),
+                  //           child: Text('房间简介', style: titleStyle),
+                  //         ),
+                  //         border: InputBorder.none,
+                  //         counterStyle: TextStyle(fontSize: 0)),
+                  //     onChanged: (value) {
+                  //       editRoomInfo['houseAbstract'] = value;
+                  //     },
+                  //   ),
+                  // ),
+
+                  //房间等级
+                  // ChooseContent(
+                  //   title: '房间等级',
+                  //   chooseLevelInfo: chooseLevelInfo,
+                  //   isLevel: true,
+                  //   onTapHomeMenu: () {
+                  //     showLevelPicker(context);
+                  //   },
+                  // ),
+                  Container(
+                    margin: EdgeInsets.symmetric(horizontal: 15),
+                    height: 1,
+                    color: BG_SUB_COLOR,
+                  ),
+                  //房间人数
+                  ChooseContent(
+                    title: '房卡人数',
+                    val: editRoomInfo['maxNumber'].toString() + '人次房卡',
+                    icon: Image.asset('images/icon_yiwen.png'),
+                    onTapHomeMenu: () {
+                      showNumPicker(context);
+                    },
+                  ),
+                  Container(
+                    margin: EdgeInsets.symmetric(horizontal: 15),
+                    height: 1,
+                    color: BG_SUB_COLOR,
+                  ),
+                  //房间人数
+                  ChooseContent(
+                    title: '胜利条件',
+                    val: editRoomInfo['scoreType'] == 0 ? '评分' : '吃鸡',
+                    onTapHomeMenu: () {
+                      showScoreType(context);
+                    },
+                  ),
+                  _bottomWidget(),
+                ],
               ),
             ),
           ),
-          floatingActionButton:  Padding(
-                      padding: EdgeInsets.fromLTRB(15, 39, 15, 10),
-                      child: LinearButton(
-                        onTapHomeMenu: () {
-                          saveInfo();
-                        },
-                        childWidget: Row(
-                          mainAxisAlignment: MainAxisAlignment.center,
-                          children: <Widget>[
-                            Padding(
-                              padding: EdgeInsets.only(right: 6),
-                              child: Image.asset('images/icon_renci.png'),
-                            ),
-                            Text(
-                              '×${editRoomInfo["maxNumber"]}' ,
-                              style: TextStyle(
-                                  color: Colors.white,
-                                  fontSize: 16,
-                                  fontWeight: FontWeight.w500),
-                            ),
-                            Padding(
-                              padding: EdgeInsets.only(left: 20),
-                              child: Text(
-                                '创建房间',
-                                style: TextStyle(
-                                    color: Colors.white,
-                                    fontSize: 16,
-                                    fontWeight: FontWeight.w500),
-                              ),
-                            )
-                          ],
-                        ),
-                      ),
-                    ),
-                    floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,),
+        ),
+        floatingActionButton: Padding(
+          padding: EdgeInsets.fromLTRB(15, 39, 15, 10),
+          child: LinearButton(
+            onTapHomeMenu: () {
+              saveInfo();
+            },
+            childWidget: Row(
+              mainAxisAlignment: MainAxisAlignment.center,
+              children: <Widget>[
+                Padding(
+                  padding: EdgeInsets.only(right: 6),
+                  child: Image.asset('images/icon_renci.png'),
+                ),
+                Text(
+                  '×${editRoomInfo["maxNumber"]}',
+                  style: TextStyle(color: Colors.white, fontSize: 16, fontWeight: FontWeight.w500),
+                ),
+                Padding(
+                  padding: EdgeInsets.only(left: 20),
+                  child: Text(
+                    '创建房间',
+                    style: TextStyle(color: Colors.white, fontSize: 16, fontWeight: FontWeight.w500),
+                  ),
+                )
+              ],
+            ),
+          ),
+        ),
+        floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
+      ),
       onWillPop: () {
         Toast.hide();
         Navigator.pop(context);
@@ -537,19 +504,14 @@ class OpenRoomState extends State<OpenRoom> {
     Picker(
         confirmText: '确定',
         cancelText: '取消',
-        adapter: PickerDataAdapter<String>(
-            pickerdata: JsonDecoder().convert(PickerData)),
+        adapter: PickerDataAdapter<String>(pickerdata: JsonDecoder().convert(PickerData)),
         changeToFirst: true,
         textAlign: TextAlign.left,
         columnPadding: const EdgeInsets.all(8.0),
         onConfirm: (Picker picker, List value) {
           setState(() {
             editRoomInfo['gameId'] = gameList[value[0]].id;
-            editRoomInfo['houseName'] =
-                StoreProvider.of<AppState>(context).state.userInfo.nickname +
-                    '的' +
-                    gameList[value[0]].shortName +
-                    '房间';
+            editRoomInfo['houseName'] = StoreProvider.of<AppState>(context).state.userInfo.nickname + '的' + gameList[value[0]].shortName + '房间';
             editRoomInfo['houseAbstract'] = gameList[value[0]].profile ?? '';
           });
         }).showModal(this.context);
@@ -558,7 +520,7 @@ class OpenRoomState extends State<OpenRoom> {
   void showNumPicker(BuildContext context) {
     List _list = [];
     List _listName = [];
-    List _member=[5,10,15,20,25,50,100];
+    List _member = [5, 10, 15, 20, 25, 50, 100];
     for (var item in _member) {
       _list.add(item);
       _listName.add(item.toString() + '人次房卡');
@@ -568,8 +530,7 @@ class OpenRoomState extends State<OpenRoom> {
     Picker(
         confirmText: '确定',
         cancelText: '取消',
-        adapter: PickerDataAdapter<String>(
-            pickerdata: JsonDecoder().convert(pickerData)),
+        adapter: PickerDataAdapter<String>(pickerdata: JsonDecoder().convert(pickerData)),
         changeToFirst: true,
         textAlign: TextAlign.left,
         columnPadding: const EdgeInsets.all(8.0),
@@ -586,8 +547,7 @@ class OpenRoomState extends State<OpenRoom> {
     Picker(
         confirmText: '确定',
         cancelText: '取消',
-        adapter: PickerDataAdapter<String>(
-            pickerdata: JsonDecoder().convert(PickerData)),
+        adapter: PickerDataAdapter<String>(pickerdata: JsonDecoder().convert(PickerData)),
         changeToFirst: true,
         textAlign: TextAlign.left,
         columnPadding: const EdgeInsets.all(8.0),
@@ -607,8 +567,7 @@ class OpenRoomState extends State<OpenRoom> {
     Picker(
         confirmText: '确定',
         cancelText: '取消',
-        adapter: PickerDataAdapter<String>(
-            pickerdata: JsonDecoder().convert(PickerData)),
+        adapter: PickerDataAdapter<String>(pickerdata: JsonDecoder().convert(PickerData)),
         changeToFirst: true,
         textAlign: TextAlign.left,
         columnPadding: const EdgeInsets.all(8.0),
@@ -624,15 +583,7 @@ typedef void OnTapHomeMenu();
 typedef ValueChanged<T> = void Function(T value);
 
 class ChooseContent extends StatelessWidget {
-  ChooseContent(
-      {Key key,
-      this.title,
-      this.val,
-      this.chooseLevelInfo,
-      this.isLevel = false,
-      this.icon,
-      this.onTapHomeMenu})
-      : super(key: key);
+  ChooseContent({Key key, this.title, this.val, this.chooseLevelInfo, this.isLevel = false, this.icon, this.onTapHomeMenu}) : super(key: key);
   final String title;
   final String val;
   final OnTapHomeMenu onTapHomeMenu;
@@ -655,32 +606,23 @@ class ChooseContent extends StatelessWidget {
                 ? InkWell(
                     onTap: () {
                       //弹出
-                      RenderBox renderBox =
-                          anchorKey.currentContext.findRenderObject();
+                      RenderBox renderBox = anchorKey.currentContext.findRenderObject();
                       var offset = renderBox.localToGlobal(Offset.zero);
                       print(offset.dx.toString() + ',' + offset.dy.toString());
                       Navigator.of(context).push(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),
+                              opacity: CurvedAnimation(parent: animation, curve: Curves.linear),
                               child: child,
                             );
                           },
                           pageBuilder: (BuildContext context, _, __) {
-                            return FloatTextContent(
-                                dx: offset.dx, dy: offset.dy);
+                            return FloatTextContent(dx: offset.dx, dy: offset.dy);
                           }));
                     },
-                    child: Padding(
-                        padding: EdgeInsets.all(9),
-                        child: icon,
-                        key: anchorKey))
+                    child: Padding(padding: EdgeInsets.all(9), child: icon, key: anchorKey))
                 : Container(),
             Expanded(
               flex: 1,
@@ -700,24 +642,15 @@ class ChooseContent extends StatelessWidget {
                         ),
                         Padding(
                           padding: EdgeInsets.only(left: 20, right: 2),
-                          child: Image.asset('images/icon_jinbi_da_bai.png',
-                              width: 20),
+                          child: Image.asset('images/icon_jinbi_da_bai.png', width: 20),
                         ),
                         Text(
                           '×' + (chooseLevelInfo.entryCoin ?? 0).toString(),
-                          style: TextStyle(
-                              color: Colors.white,
-                              fontSize: 15,
-                              fontWeight: FontWeight.w500),
+                          style: TextStyle(color: Colors.white, fontSize: 15, fontWeight: FontWeight.w500),
                         )
                       ],
                     )
-                  : Text(val ?? '',
-                      style: TextStyle(
-                          fontSize: 15,
-                          color: Colors.white,
-                          fontWeight: FontWeight.w500),
-                      textAlign: TextAlign.right),
+                  : Text(val ?? '', style: TextStyle(fontSize: 15, color: Colors.white, fontWeight: FontWeight.w500), textAlign: TextAlign.right),
             ),
             Image.asset('images/icon_inter.png', width: 24)
           ],
@@ -729,8 +662,7 @@ class ChooseContent extends StatelessWidget {
 }
 
 class InputContent extends StatefulWidget {
-  InputContent({Key key, this.title, this.value, this.onTextChange})
-      : super(key: key);
+  InputContent({Key key, this.title, this.value, this.onTextChange}) : super(key: key);
   final String title;
   final String value;
   final ValueChanged onTextChange;
@@ -757,21 +689,18 @@ class InputContentState extends State<InputContent> {
   Widget build(BuildContext context) {
     return Container(
       height: 60,
-      color: BG_COLOR,
       padding: EdgeInsets.symmetric(horizontal: 15, vertical: 8),
       child: TextField(
         controller: _controller,
         textAlign: TextAlign.end,
-        style: TextStyle(
-            fontSize: 15, color: Colors.white, fontWeight: FontWeight.w500),
+        style: TextStyle(fontSize: 15, color: Colors.white, fontWeight: FontWeight.w500),
         maxLength: 10,
         decoration: InputDecoration(
             hintText: '请输入' + widget.title,
             hintStyle: TextStyle(color: Color(0xFF727785), fontSize: 13),
             prefixIcon: Padding(
               padding: EdgeInsets.symmetric(vertical: 12),
-              child: Text(widget.title,
-                  style: TextStyle(fontSize: 14, color: Colors.white)),
+              child: Text(widget.title, style: TextStyle(fontSize: 14, color: Colors.white)),
             ),
             border: InputBorder.none,
             counterStyle: TextStyle(fontSize: 0)),
@@ -802,13 +731,8 @@ class FloatTextContent extends StatelessWidget {
                 padding: EdgeInsets.all(10),
                 constraints: BoxConstraints(maxWidth: 241),
                 color: Color(0xFF3A3E61),
-                child: Text(
-                    '房主可以选择不同人次的房卡进行开始比赛,同步消耗自己相应的参赛名额,比如选择50人次房卡,系统从我的账号上扣除50人次参赛名额,房间内最多可进入50人参加比赛',
-                    style: TextStyle(
-                        color: Colors.white,
-                        fontSize: 12,
-                        fontWeight: FontWeight.w400,
-                        decoration: TextDecoration.none)),
+                child: Text('房主可以选择不同人次的房卡进行开始比赛,同步消耗自己相应的参赛名额,比如选择50人次房卡,系统从我的账号上扣除50人次参赛名额,房间内最多可进入50人参加比赛',
+                    style: TextStyle(color: Colors.white, fontSize: 12, fontWeight: FontWeight.w400, decoration: TextDecoration.none)),
               ),
             )
           ],

+ 55 - 15
lib/pages/RankList.dart

@@ -9,9 +9,10 @@ import 'package:flutter_redux/flutter_redux.dart';
 import '../redux/AppState.dart';
 import '../model/CompetitionSeason.dart';
 import '../widget/Dialog.dart';
+import 'dart:math';
 
 class RankList extends StatefulWidget {
-  RankList({Key key, this.raceId, this.gameId}) : super(key: key);
+  RankList({Key key, this.raceId = 0, this.gameId}) : super(key: key);
   final int raceId; // 用来储存传递过来的值
   final int gameId;
   @override
@@ -26,12 +27,15 @@ class RankListState extends State<RankList> {
   bool scrollFlag = true;
   int currentPage = 1;
   int raceId = 0;
+  int gameId = 0;
   List<CompetitionSeason> seasonList = [];
   PlayerInfo myPlayInfo;
 
   Future<void> getUserRank() async {
     Result res = await HttpManager.get('playerInfo/seasonUserRank',
-        data: {'seasonId': raceId, 'userId': StoreProvider.of<AppState>(context).state.userInfo.id, 'gameId': widget.gameId});
+        data: {'seasonId': raceId, 'userId': StoreProvider.of<AppState>(context).state.userInfo.id, 'gameId': gameId});
+    print('*******************************************');
+    print(res.data);
     if (res.success && res.data != null) {
       setState(() {
         myPlayInfo = PlayerInfo.fromJson(res.data);
@@ -115,11 +119,16 @@ class RankListState extends State<RankList> {
         seasonList = list;
       });
     } else {}
+
+    if (seasonList.length > 0) {
+      raceId = seasonList[0].id;
+      gameId = seasonList[0].gameId;
+      getUserRank();
+    }
   }
 
   @override
   void initState() {
-    print(widget.raceId);
     raceId = widget.raceId;
     super.initState();
     _mcontroller = ScrollController();
@@ -133,7 +142,6 @@ class RankListState extends State<RankList> {
     });
 
     Future.delayed(Duration.zero, () {
-      getUserRank();
       getSeasonInfo();
     });
   }
@@ -162,20 +170,25 @@ class RankListState extends State<RankList> {
                   physics: AlwaysScrollableScrollPhysics(),
                   slivers: <Widget>[
                     _sliverAppBar(),
-                    // _slievrToBoxAdapter(),
+                    myPlayInfo == null
+                        ? SliverToBoxAdapter()
+                        : SliverPersistentHeader(
+                            pinned: true, //是否固定在顶部
+                            floating: true,
+                            delegate: _SliverAppBarDelegate(
+                                minHeight: 66, //收起的高度
+                                maxHeight:66, //展开的最大高度
+                                child: RankItem(
+                                  myPlayInfo,
+                                  myPlayInfo.rank,
+                                  height: 66,
+                                  color: 0xFF23253C,
+                                )),
+                          ),
                     _sliverList()
                   ],
                 )),
           ),
-          floatingActionButton: myPlayInfo == null
-              ? Container()
-              : RankItem(
-                  myPlayInfo,
-                  myPlayInfo.rank,
-                  height: 48,
-                  color: 0xFF363759,
-                ),
-          floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
         ),
         onWillPop: () {
           Toast.hide();
@@ -194,7 +207,6 @@ class RankListState extends State<RankList> {
     return SliverAppBar(
         title: Text('排行榜'),
         centerTitle: true,
-        backgroundColor:Color(0xFF363759),
         actions: <Widget>[
           PopupMenuButton(
               initialValue: raceId,
@@ -548,3 +560,31 @@ class Medal extends StatelessWidget {
     );
   }
 }
+
+class _SliverAppBarDelegate extends SliverPersistentHeaderDelegate {
+  _SliverAppBarDelegate({
+    @required this.minHeight,
+    @required this.maxHeight,
+    @required this.child,
+  });
+
+  final double minHeight;
+  final double maxHeight;
+  final Widget child;
+
+  @override
+  double get minExtent => minHeight;
+
+  @override
+  double get maxExtent => max(maxHeight, minHeight);
+
+  @override
+  Widget build(BuildContext context, double shrinkOffset, bool overlapsContent) {
+    return new SizedBox.expand(child: child);
+  }
+
+  @override
+  bool shouldRebuild(_SliverAppBarDelegate oldDelegate) {
+    return maxHeight != oldDelegate.maxHeight || minHeight != oldDelegate.minHeight || child != oldDelegate.child;
+  }
+}

+ 1 - 0
lib/pages/RecordList.dart

@@ -12,6 +12,7 @@ import '../pages/RoomInfo.dart';
 import 'package:flutter_redux/flutter_redux.dart';
 import '../redux/AppState.dart';
 import '../widget/ScoreType.dart';
+import 'package:cached_network_image/cached_network_image.dart';
 
 class RecordList extends StatefulWidget {
   @override

+ 37 - 16
lib/pages/RoomInfo.dart

@@ -489,9 +489,9 @@ class RoomInfoState extends State<RoomInfo> with SingleTickerProviderStateMixin
                           houseInfo != null ? VideoWidget(videoSrc: houseInfo.video) : Container(),
                           // Image.network(topImg, width: double.infinity),
                           Container(
-                              padding: EdgeInsets.only(top: 10),
+                              padding: EdgeInsets.all(15),
                               child: Row(
-                                mainAxisAlignment: MainAxisAlignment.center,
+                                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                                 children: <Widget>[
                                   Container(
                                     child: Text(
@@ -500,9 +500,34 @@ class RoomInfoState extends State<RoomInfo> with SingleTickerProviderStateMixin
                                     ),
                                   ),
                                   Container(
-                                    width: 5,
-                                  ),
-                                  houseInfo != null ? ScoreType(houseInfo.scoreType) : Container(),
+                                    width: 66,
+                                    child: LinearButton(
+                                      btntext: '竞赛须知',
+                                      btnHeight: 28.0,
+                                      textColor: Color(0xFF2E3049),
+                                      textSize: 12.0,
+                                      colorList: [Color(0xFFFFB726), Color(0xFFFFB726)],
+                                      onTapHomeMenu: () {
+                                        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 CompetitionInformation(houseInfo);
+                                            }));
+                                      },
+                                    ),
+                                  )
+                                  // Container(
+                                  //   width: 5,
+                                  // ),
+                                  // houseInfo != null ? ScoreType(houseInfo.scoreType) : Container(),
                                   // Image.network(
                                   //   houseLevelInfo.containsKey('icon')
                                   //       ? houseLevelInfo['icon']
@@ -518,15 +543,10 @@ class RoomInfoState extends State<RoomInfo> with SingleTickerProviderStateMixin
                                   // )
                                 ],
                               )),
-                          Container(
-                            margin: EdgeInsets.only(top: 6),
-                            child: Text(
-                              roomInfo.containsKey('houseAbstract') ? roomInfo['houseAbstract'] : '',
-                              style: TextStyle(color: Color(0xFF9BA0AE), fontSize: 12),
-                            ),
-                          ),
-                          Row(
-                            mainAxisAlignment: MainAxisAlignment.center,
+                         Container(
+                           padding: EdgeInsets.symmetric(horizontal: 15),
+                           child:  Row(
+                            // mainAxisAlignment: MainAxisAlignment.center,
                             children: <Widget>[
                               Image.asset(
                                 'images/icon_renshu.png',
@@ -537,9 +557,10 @@ class RoomInfoState extends State<RoomInfo> with SingleTickerProviderStateMixin
                                     '/' +
                                     (houseInfo != null ? houseInfo.maxNumber.toString() : '0'),
                                 style: TextStyle(fontSize: 14, fontWeight: FontWeight.w500, color: Color(0xFFB1B2C0)),
-                              )
+                              ),
+                              Text('房间ID:' + (houseInfo.houseCode != null ? houseInfo.houseCode : ''))
                             ],
-                          ),
+                          ),),
                           // Container(
                           //   margin: EdgeInsets.only(top: 14),
                           //   width: 200,

+ 1 - 0
lib/pages/UserChange.dart

@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
 import 'package:file_picker/file_picker.dart';
 import 'package:flutter/cupertino.dart';
 import 'package:flutter_screenutil/flutter_screenutil.dart';
+import 'package:cached_network_image/cached_network_image.dart';
 import 'package:dio/dio.dart';
 import 'package:intl/intl.dart';
 import 'package:package_info/package_info.dart';

+ 16 - 13
lib/pages/UserPage.dart

@@ -1,6 +1,7 @@
 import 'package:flutter/material.dart';
 import 'package:redux/redux.dart';
 import 'package:flutter_redux/flutter_redux.dart';
+import 'package:cached_network_image/cached_network_image.dart';
 import 'package:flutter/cupertino.dart';
 import '../redux/AppState.dart';
 import '../model/UserInfo.dart';
@@ -59,18 +60,18 @@ class _UserPageState extends State<UserPage> with WidgetsBindingObserver {
                         child: Column(
                           mainAxisAlignment: MainAxisAlignment.center,
                           children: <Widget>[
-                            ClipOval(
-                                child: InkWell(
-                              child: Image.network(
-                                userInfo.icon,
+                            InkWell(
+                              child: ClipOval(
+                                  child: CachedNetworkImage(
+                                imageUrl: userInfo.icon,
                                 width: 86,
                                 height: 86,
                                 fit: BoxFit.cover,
-                              ),
+                              )),
                               onTap: () {
                                 Navigator.push(context, CupertinoPageRoute(builder: (context) => UserChange()));
                               },
-                            )),
+                            ),
                             Container(
                               height: 4,
                             ),
@@ -92,7 +93,7 @@ class _UserPageState extends State<UserPage> with WidgetsBindingObserver {
                                     colorList: [Colors.white, Colors.white],
                                     textColor: Color(0xFF252532),
                                     textSize: 13.0,
-                                    onTapHomeMenu: (){
+                                    onTapHomeMenu: () {
                                       Navigator.push(context, CupertinoPageRoute(builder: (context) => OpenRoom(roomFlag: '0')));
                                     },
                                   ),
@@ -103,8 +104,8 @@ class _UserPageState extends State<UserPage> with WidgetsBindingObserver {
                                       btntext: '充值参赛券',
                                       btnHeight: 38.0,
                                       textSize: 13.0,
-                                      onTapHomeMenu: (){
-                                         Navigator.push(context, CupertinoPageRoute(builder: (context) => ShoppingMall()));
+                                      onTapHomeMenu: () {
+                                        Navigator.push(context, CupertinoPageRoute(builder: (context) => ShoppingMall()));
                                       },
                                     ))
                               ],
@@ -166,10 +167,12 @@ class _UserPageState extends State<UserPage> with WidgetsBindingObserver {
                 width: 53,
                 height: 130,
                 // color: Colors.white,
-                padding: EdgeInsets.fromLTRB(0,90, 10, 0),
-                child: GestureDetector(onTap: () {
-                   Navigator.push(context, CupertinoPageRoute(builder: (context) => Setting()));
-                }, child: Image.asset('images/info_icon_shezhi.png'))),
+                padding: EdgeInsets.fromLTRB(0, 90, 10, 0),
+                child: GestureDetector(
+                    onTap: () {
+                      Navigator.push(context, CupertinoPageRoute(builder: (context) => Setting()));
+                    },
+                    child: Image.asset('images/info_icon_shezhi.png'))),
             floatingActionButtonLocation: FloatingActionButtonLocation.endTop,
           );
         });

+ 1 - 0
lib/widget/HomeDrawer.dart

@@ -1,6 +1,7 @@
 import 'package:flutter/material.dart';
 import 'package:redux/redux.dart';
 import 'package:flutter_redux/flutter_redux.dart';
+import 'package:cached_network_image/cached_network_image.dart';
 import 'package:flutter/cupertino.dart';
 import '../redux/AppState.dart';
 import '../model/UserInfo.dart';

+ 18 - 14
lib/widget/HouseItem.dart

@@ -3,6 +3,7 @@ import 'package:flutter/cupertino.dart';
 import '../model/HouseInfo.dart';
 import '../model/GameInfo.dart';
 import '../pages/RoomInfo.dart';
+import 'package:cached_network_image/cached_network_image.dart';
 import 'dart:ui';
 
 class HouseItem extends StatelessWidget {
@@ -10,34 +11,36 @@ class HouseItem extends StatelessWidget {
   HouseInfo houseInfo;
   GameInfo gameInfo;
 
-  List<String> imageList=['images/img_fangjian_hong.png','images/img_fangjian_huise.png'];
+  List<String> imageList = ['images/img_fangjian_hong.png', 'images/img_fangjian_huise.png'];
 
   @override
   Widget build(BuildContext context) {
     return Container(
-        margin: EdgeInsets.only(bottom: 10,left: 15,right: 15),
-        decoration: BoxDecoration(
-            color: Colors.white,
-            borderRadius: BorderRadius.all(Radius.circular(4))),
+        margin: EdgeInsets.only(bottom: 10, left: 15, right: 15),
+        decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.all(Radius.circular(4))),
         child: Material(
             color: Colors.transparent,
             child: InkWell(
                 onTap: () {
-                   Navigator.push(context, CupertinoPageRoute(builder: (context) => RoomInfo(roomId: houseInfo.id.toString())));
+                  Navigator.push(context, CupertinoPageRoute(builder: (context) => RoomInfo(roomId: houseInfo.id.toString())));
                 },
                 child: Container(
                   height: 80,
                   decoration: BoxDecoration(
-                      image: DecorationImage(image: AssetImage(imageList[houseInfo.statusFlag==0?0:1]), fit: BoxFit.fitHeight, alignment: Alignment.bottomRight),
-                     ),
+                    image: DecorationImage(
+                        image: AssetImage(imageList[houseInfo.statusFlag == 0 ? 0 : 1]), fit: BoxFit.fitHeight, alignment: Alignment.bottomRight),
+                  ),
                   padding: EdgeInsets.all(10),
                   child: Row(
                     children: <Widget>[
-                      Image.network(
-                        gameInfo.icon,
-                        fit: BoxFit.cover,
-                        width: 60,
-                        height: 60,
+                      ClipRRect(
+                       borderRadius: BorderRadius.circular(4.0),
+                        child: CachedNetworkImage(
+                          imageUrl:gameInfo.icon,
+                          width: 60,
+                          height: 60,
+                          fit: BoxFit.cover,
+                        ),
                       ),
                       Container(
                         width: 10,
@@ -52,7 +55,8 @@ class HouseItem extends StatelessWidget {
                             Container(
                               height: 4,
                             ),
-                            Text(''+(houseInfo.scoreType==0?'评分':'吃鸡')+'模式', overflow: TextOverflow.ellipsis, style: TextStyle(fontSize: 13, color: Color(0xFF999999)))
+                            Text('' + (houseInfo.scoreType == 0 ? '评分' : '吃鸡') + '模式',
+                                overflow: TextOverflow.ellipsis, style: TextStyle(fontSize: 13, color: Color(0xFF999999)))
                           ],
                         ),
                       ),

+ 4 - 2
lib/widget/LinearButton.dart

@@ -10,6 +10,7 @@ class LinearButton extends StatelessWidget {
   final Widget childWidget;
   final Color textColor;
   final num textSize;
+  final num radius;
   LinearButton(
       {this.btntext = '',
       this.onTapHomeMenu,
@@ -17,7 +18,8 @@ class LinearButton extends StatelessWidget {
       this.btnHeight = 48.0,
       this.childWidget,
       this.textColor = Colors.white,
-      this.textSize = 16.0});
+      this.textSize = 16.0,
+      this.radius = 4.0});
 
   @override
   Widget build(BuildContext context) {
@@ -25,7 +27,7 @@ class LinearButton extends StatelessWidget {
       height: btnHeight,
       decoration: BoxDecoration(
           gradient: LinearGradient(begin: Alignment.topCenter, end: Alignment.bottomCenter, colors: colorList),
-          borderRadius: BorderRadius.all(Radius.circular(4))),
+          borderRadius: BorderRadius.all(Radius.circular(radius))),
       child: Material(
         color: Colors.transparent,
         child: InkWell(

+ 1 - 0
lib/widget/RoomItem.dart

@@ -1,6 +1,7 @@
 import 'package:flutter/material.dart';
 import 'package:flutter/cupertino.dart';
 import 'dart:ui';
+import 'package:cached_network_image/cached_network_image.dart';
 import '../model/HouseInfo.dart';
 import '../model/GameInfo.dart';
 import '../pages/RoomInfo.dart';

+ 1 - 0
lib/widget/VideoWidget.dart

@@ -1,5 +1,6 @@
 import 'package:video_player/video_player.dart';
 import 'package:flutter/material.dart';
+import 'package:cached_network_image/cached_network_image.dart';
 
 class VideoWidget extends StatefulWidget {
   VideoWidget({Key key, this.videoSrc}) : super(key: key);