x1ongzhu 6 лет назад
Родитель
Сommit
77ef9faa23

+ 3 - 0
copyicon.js

@@ -20,6 +20,9 @@ function copyAssets(srcDir) {
             var fileName = baseName.replace(/@\dx/g, '')
             var execRes = /@(\dx)/.exec(baseName)
             var subDir = execRes ? execRes[1] : ''
+            if ('1x' === subDir) {
+                subDir = ''
+            }
             if (subDir) {
                 if (!fs.existsSync(path.resolve(dstDir, subDir))) {
                     fs.mkdirSync(path.resolve(dstDir, subDir), { recursive: true })

BIN
images/1x/icon_paihangbang_04.png


BIN
images/2x/icon_dengdaizhong.png


BIN
images/2x/icon_jinxingzhong.png


BIN
images/2x/icon_paihangbang.png


BIN
images/2x/icon_yijiesu.png


BIN
images/3x/icon_dengdaizhong.png


BIN
images/3x/icon_jinxingzhong.png


BIN
images/3x/icon_paihangbang.png


BIN
images/3x/icon_yijiesu.png


BIN
images/icon_dengdaizhong.png


+ 0 - 0
images/1x/icon_jifen.png → images/icon_jifen.png


+ 0 - 0
images/1x/icon_jinbi.png → images/icon_jinbi.png


BIN
images/icon_jinxingzhong.png


BIN
images/icon_paihangbang.png


BIN
images/icon_paihangbang_04.png


BIN
images/icon_yijiesu.png


+ 3 - 4
lib/main.dart

@@ -36,12 +36,11 @@ class MobileCyberGamesApp extends StatelessWidget {
           ChineseCupertinoLocalizations.delegate,
         ],
         theme: ThemeData(
-          cardColor: Color(0xFF2B2B42),
-          backgroundColor: Color(0xFF222335),
+          backgroundColor: BG_COLOR,
           primaryColor: PRIMARY_COLOR,
-          buttonColor: PRIMARY_COLOR,
           accentColor: PRIMARY_COLOR,
-          textSelectionColor: Colors.white,
+          appBarTheme: AppBarTheme(color: SUB_COLOR),
+          scaffoldBackgroundColor: BG_COLOR,
           textTheme: TextTheme(
             subhead: TextStyle(color: Colors.white),
           ),

+ 5 - 2
lib/model/CompetitionInfo.dart

@@ -1,20 +1,23 @@
 import 'package:json_annotation/json_annotation.dart';
-
+import './ParticipatingInfo.dart';
 part 'CompetitionInfo.g.dart';
 
 @JsonSerializable()
 class CompetitionInfo {
   CompetitionInfo.empty();
 
-  CompetitionInfo(this.competitionName, this.startTime, this.endTime, this.type, this.bonus);
+  CompetitionInfo(this.id, this.competitionName, this.startTime, this.endTime, this.type, this.bonus, this.intro, this.participatingInfo);
 
   factory CompetitionInfo.fromJson(Map<String, dynamic> json) => _$CompetitionInfoFromJson(json);
 
+  int id;
   String competitionName;
   int startTime;
   int endTime;
   int type;
   int bonus;
+  String intro;
+  ParticipatingInfo participatingInfo;
 
   Map<String, dynamic> toJson() => _$CompetitionInfoToJson(this);
 

+ 11 - 2
lib/model/CompetitionInfo.g.dart

@@ -8,18 +8,27 @@ part of 'CompetitionInfo.dart';
 
 CompetitionInfo _$CompetitionInfoFromJson(Map<String, dynamic> json) {
   return CompetitionInfo(
+      json['id'] as int,
       json['competitionName'] as String,
       json['startTime'] as int,
       json['endTime'] as int,
       json['type'] as int,
-      json['bonus'] as int);
+      json['bonus'] as int,
+      json['intro'] as String,
+      json['participatingInfo'] == null
+          ? null
+          : ParticipatingInfo.fromJson(
+              json['participatingInfo'] as Map<String, dynamic>));
 }
 
 Map<String, dynamic> _$CompetitionInfoToJson(CompetitionInfo instance) =>
     <String, dynamic>{
+      'id': instance.id,
       'competitionName': instance.competitionName,
       'startTime': instance.startTime,
       'endTime': instance.endTime,
       'type': instance.type,
-      'bonus': instance.bonus
+      'bonus': instance.bonus,
+      'intro': instance.intro,
+      'participatingInfo': instance.participatingInfo
     };

+ 26 - 0
lib/model/ParticipatingInfo.dart

@@ -0,0 +1,26 @@
+import 'package:json_annotation/json_annotation.dart';
+part 'ParticipatingInfo.g.dart';
+
+@JsonSerializable()
+class ParticipatingInfo {
+  ParticipatingInfo.empty();
+
+  ParticipatingInfo(this.userId, this.competitionId, this.points, this.bonus, this.received, this.rank, this.currentRank);
+
+  factory ParticipatingInfo.fromJson(Map<String, dynamic> json) => _$ParticipatingInfoFromJson(json);
+
+  int userId;
+  int competitionId;
+  int points;
+  int bonus;
+  int received;
+  int rank;
+  int currentRank;
+
+  Map<String, dynamic> toJson() => _$ParticipatingInfoToJson(this);
+
+  @override
+  String toString() {
+    return _$ParticipatingInfoToJson(this).toString();
+  }
+}

+ 29 - 0
lib/model/ParticipatingInfo.g.dart

@@ -0,0 +1,29 @@
+// GENERATED CODE - DO NOT MODIFY BY HAND
+
+part of 'ParticipatingInfo.dart';
+
+// **************************************************************************
+// JsonSerializableGenerator
+// **************************************************************************
+
+ParticipatingInfo _$ParticipatingInfoFromJson(Map<String, dynamic> json) {
+  return ParticipatingInfo(
+      json['userId'] as int,
+      json['competitionId'] as int,
+      json['points'] as int,
+      json['bonus'] as int,
+      json['received'] as int,
+      json['rank'] as int,
+      json['currentRank'] as int);
+}
+
+Map<String, dynamic> _$ParticipatingInfoToJson(ParticipatingInfo instance) =>
+    <String, dynamic>{
+      'userId': instance.userId,
+      'competitionId': instance.competitionId,
+      'points': instance.points,
+      'bonus': instance.bonus,
+      'received': instance.received,
+      'rank': instance.rank,
+      'currentRank': instance.currentRank
+    };

+ 4 - 4
lib/model/UserInfo.dart

@@ -12,12 +12,12 @@ class UserInfo {
   String icon;
   String phone;
   String sex;
-  int moneyCoin; //余额
+  double moneyCoin; //余额
   double moneyPoint; //积分
   int birthday;
-  bool noticeFlag; //是否通知
-  bool remindFlag; //是否通知
-  bool createFlag; //创建房间权限
+  String noticeFlag; //是否通知
+  String remindFlag; //是否通知
+  String createFlag; //创建房间权限
   String ttdjId;
   String token;
   int isVip;

+ 4 - 4
lib/model/UserInfo.g.dart

@@ -14,12 +14,12 @@ UserInfo _$UserInfoFromJson(Map<String, dynamic> json) {
       json['icon'] as String,
       json['phone'] as String,
       json['sex'] as String,
-      (json['moneyCoin'] as num)?.toInt(),
+      (json['moneyCoin'] as num)?.toDouble(),
       (json['moneyPoint'] as num)?.toDouble(),
       json['birthday'] as int,
-      json['noticeFlag'] == 'Y',
-      json['remindFlag'] == 'Y',
-      json['createFlag'] == 'Y',
+      json['noticeFlag'] as String,
+      json['remindFlag'] as String,
+      json['createFlag'] as String,
       json['ttdjId'] as String,
       json['isVip'] as int,
       json['startDate'] as String,

+ 19 - 0
lib/model/UserPlayTimes.dart

@@ -0,0 +1,19 @@
+import 'package:json_annotation/json_annotation.dart';
+part 'UserPlayTimes.g.dart';
+
+@JsonSerializable()
+class UserPlayTimes {
+  UserPlayTimes.empty();
+  UserPlayTimes(this.totalNormal, this.totalAdvanced, this.usedNormal, this.usedAdvanced);
+  int totalNormal;
+  int totalAdvanced;
+  int usedNormal;
+  int usedAdvanced;
+  factory UserPlayTimes.fromJson(Map<String, dynamic> json) => _$UserPlayTimesFromJson(json);
+
+  Map<String, dynamic> toJson() => _$UserPlayTimesToJson(this);
+  @override
+  String toString() {
+    return _$UserPlayTimesToJson(this).toString();
+  }
+}

+ 20 - 0
lib/model/UserPlayTimes.g.dart

@@ -0,0 +1,20 @@
+// GENERATED CODE - DO NOT MODIFY BY HAND
+
+part of 'UserPlayTimes.dart';
+
+// **************************************************************************
+// JsonSerializableGenerator
+// **************************************************************************
+
+UserPlayTimes _$UserPlayTimesFromJson(Map<String, dynamic> json) {
+  return UserPlayTimes(json['totalNormal'] as int, json['totalAdvanced'] as int,
+      json['usedNormal'] as int, json['usedAdvanced'] as int);
+}
+
+Map<String, dynamic> _$UserPlayTimesToJson(UserPlayTimes instance) =>
+    <String, dynamic>{
+      'totalNormal': instance.totalNormal,
+      'totalAdvanced': instance.totalAdvanced,
+      'usedNormal': instance.usedNormal,
+      'usedAdvanced': instance.usedAdvanced
+    };

+ 239 - 0
lib/pages/CompetitionRooms.dart

@@ -0,0 +1,239 @@
+import 'package:flutter/material.dart';
+import 'package:flutter/widgets.dart';
+import 'package:wanna_battle/model/UserPlayTimes.dart';
+import '../model/CompetitionInfo.dart';
+import '../styles/colors.dart';
+import 'package:gradient_text/gradient_text.dart';
+import '../model/HouseInfo.dart';
+import '../net/HttpManager.dart';
+import '../net/Result.dart';
+
+class CompetitionRooms extends StatefulWidget {
+  CompetitionRooms(this.competitionInfo);
+
+  final CompetitionInfo competitionInfo;
+
+  @override
+  State<StatefulWidget> createState() {
+    return _CompetitionRoomsState(competitionInfo);
+  }
+}
+
+class _CompetitionRoomsState extends State<CompetitionRooms> {
+  _CompetitionRoomsState(this.competitionInfo);
+
+  final CompetitionInfo competitionInfo;
+  List<HouseInfo> houseList = [];
+  int restTimes = 0;
+
+  @override
+  void initState() {
+    super.initState();
+    Future.delayed(Duration.zero, () {
+      _getRooms();
+      _getPlayTimes();
+    });
+  }
+
+  @override
+  Widget build(BuildContext context) {
+    return Scaffold(
+      appBar: AppBar(
+        title: Text(competitionInfo.competitionName),
+        centerTitle: true,
+        elevation: 0,
+        actions: <Widget>[
+          GestureDetector(
+            onTap: () {},
+            child: Image.asset('images/icon_paihangbang.png'),
+          )
+        ],
+      ),
+      body: Column(
+        children: <Widget>[
+          Container(
+            color: SUB_COLOR,
+            height: 116,
+            child: Column(
+              mainAxisAlignment: MainAxisAlignment.center,
+              crossAxisAlignment: CrossAxisAlignment.center,
+              children: <Widget>[
+                Row(
+                  mainAxisAlignment: MainAxisAlignment.center,
+                  crossAxisAlignment: CrossAxisAlignment.baseline,
+                  textBaseline: TextBaseline.alphabetic,
+                  children: <Widget>[
+                    GradientText('¥',
+                        gradient: LinearGradient(
+                          colors: [Color(0xFFFFC84B), Color(0xFFA26A23)],
+                          begin: Alignment.topCenter,
+                          end: Alignment.bottomCenter,
+                        ),
+                        style: TextStyle(fontSize: 17),
+                        textAlign: TextAlign.center),
+                    GradientText(competitionInfo.bonus.toString().replaceAllMapped(RegExp(r'(\d{1,3})(?=(\d{3})+(?!\d))'), (Match m) => '${m[1]},'),
+                        gradient: LinearGradient(
+                          colors: [Color(0xFFFFC84B), Color(0xFFA26A23)],
+                          begin: Alignment.topCenter,
+                          end: Alignment.bottomCenter,
+                        ),
+                        style: TextStyle(fontSize: 27),
+                        textAlign: TextAlign.center),
+                  ],
+                ),
+                Container(
+                  color: Colors.yellow,
+                  margin: EdgeInsets.only(top: 10),
+                  padding: EdgeInsets.fromLTRB(6, 1, 6, 2),
+                  child: Text(
+                    '剩余参赛次数 $restTimes次',
+                    style: TextStyle(
+                      color: Color(0xFF293354),
+                      fontSize: 12,
+                    ),
+                  ),
+                ),
+                Container(
+                  margin: EdgeInsets.only(top: 10),
+                  child: Text(
+                    competitionInfo.intro ?? '',
+                    style: TextStyle(
+                      color: Color(0xADFFFFFF),
+                      fontSize: 13,
+                    ),
+                  ),
+                )
+              ],
+            ),
+          ),
+          Expanded(
+            child: ListView(
+              padding: EdgeInsets.only(bottom: 10),
+              children: houseList.map((f) => _Room(f)).toList(),
+            ),
+          )
+        ],
+      ),
+    );
+  }
+
+  Future<void> _getRooms() async {
+    final Result res = await HttpManager.get('houseInfo/all', data: {'competitionId': competitionInfo.id});
+    final List<HouseInfo> list = [];
+    if (res.success && res.data != null) {
+      for (var item in res.data) {
+        final HouseInfo _temHouse = HouseInfo.fromJson(item);
+        list.add(_temHouse);
+      }
+      setState(() {
+        houseList = list;
+      });
+    }
+  }
+
+  Future<void> _getPlayTimes() async {
+    final Result res = await HttpManager.get('playerInfo/getTodayPlayTimes');
+    if (res.success) {
+      int rest = 0;
+      UserPlayTimes userPlayTimes = UserPlayTimes.fromJson(res.data);
+      if (competitionInfo.type == 1) {
+        rest = userPlayTimes.totalNormal - userPlayTimes.usedNormal;
+      } else {
+        rest = userPlayTimes.totalAdvanced - userPlayTimes.usedAdvanced;
+      }
+      if (rest < 0) {
+        rest = 0;
+      }
+      setState(() {
+        restTimes = rest;
+      });
+    }
+    print(res);
+  }
+}
+
+class _Room extends StatelessWidget {
+  _Room(this.houseInfo);
+  final HouseInfo houseInfo;
+  @override
+  Widget build(BuildContext context) {
+    var status;
+    var borderColor;
+    var backgroundColor;
+    var imgSrc;
+    switch (houseInfo.statusFlag) {
+      case 0:
+      case 1:
+        status = '等待中';
+        borderColor = Color(0xFF1C62A7);
+        backgroundColor = Color(0x990D2F54);
+        imgSrc = 'images/icon_dengdaizhong.png';
+        break;
+      case 2:
+        status = '进行中';
+        borderColor = Color(0xFF8C8146);
+        backgroundColor = Color(0x990D2F54);
+        imgSrc = 'images/icon_jinxingzhong.png';
+        break;
+      default:
+        status = '已结束';
+        borderColor = Color(0xFF414854);
+        backgroundColor = Color(0xFF152536);
+        imgSrc = 'images/icon_yijiesu.png';
+        break;
+    }
+    return Container(
+      height: 43,
+      margin: EdgeInsets.fromLTRB(15, 10, 15, 0),
+      decoration: BoxDecoration(
+        color: backgroundColor,
+        border: Border.all(color: borderColor, width: 2),
+      ),
+      child: Row(
+        children: <Widget>[
+          Expanded(
+            child: Container(
+              margin: EdgeInsets.only(left: 13),
+              child: Text(
+                houseInfo.houseName,
+                style: TextStyle(fontSize: 14, color: Colors.white),
+              ),
+            ),
+          ),
+          Container(
+            width: 105,
+            child: RichText(
+              text: TextSpan(
+                style: TextStyle(color: Colors.white, fontSize: 11),
+                children: <TextSpan>[
+                  TextSpan(text: '参赛人数:'),
+                  TextSpan(text: houseInfo.playerNumber.toString(), style: TextStyle(color: Color(0xFF38A968))),
+                  TextSpan(text: '/${houseInfo.maxNumber}'),
+                ],
+              ),
+            ),
+          ),
+          Container(
+            width: 60,
+            height: 43,
+            padding: EdgeInsets.only(left: 10),
+            alignment: Alignment.center,
+            decoration: BoxDecoration(
+              image: DecorationImage(
+                image: AssetImage(imgSrc),
+                fit: BoxFit.cover,
+              ),
+            ),
+            child: Text(
+              status,
+              style: TextStyle(
+                color: Colors.white,
+                fontSize: 14,
+              ),
+            ),
+          )
+        ],
+      ),
+    );
+  }
+}

+ 21 - 11
lib/pages/Competitions.dart

@@ -92,6 +92,21 @@ class _CompetitionState extends State<Competitions> {
                                                   fontSize: 13,
                                                   fontWeight: FontWeight.bold,
                                                 ),
+                                              ),
+                                              Container(
+                                                margin: EdgeInsets.only(left: 23),
+                                                child: Image.asset('images/icon_jinbi.png'),
+                                              ),
+                                              Container(
+                                                margin: EdgeInsets.only(left: 2),
+                                                child: Text(
+                                                  '8888'.replaceAllMapped(RegExp(r'(\d{1,3})(?=(\d{3})+(?!\d))'), (Match m) => '${m[1]},'),
+                                                  style: TextStyle(
+                                                    color: Colors.white,
+                                                    fontWeight: FontWeight.bold,
+                                                    fontSize: 16,
+                                                  ),
+                                                ),
                                               )
                                             ],
                                           )
@@ -142,14 +157,9 @@ class _CompetitionState extends State<Competitions> {
                         child: RefreshIndicator(
                           child: Container(
                             width: double.infinity,
-                            child: SingleChildScrollView(
-                              physics: AlwaysScrollableScrollPhysics(),
-                              padding: EdgeInsets.only(bottom: 7),
-                              child: Flex(
-                                direction: Axis.vertical,
-                                crossAxisAlignment: CrossAxisAlignment.stretch,
-                                children: buidChildren(),
-                              ),
+                            child: ListView(
+                              padding: EdgeInsets.fromLTRB(0, 7, 0, 7),
+                              children: buidChildren(),
                             ),
                           ),
                           onRefresh: () {
@@ -173,14 +183,14 @@ class _CompetitionState extends State<Competitions> {
         fit: BoxFit.contain,
       ),
     ));
-    competitionInfoList.forEach((competitionInfo) {
+    for (CompetitionInfo competitionInfo in competitionInfoList) {
       list.add(Competition(competitionInfo));
-    });
+    }
     return list;
   }
 
   Future<void> _getCompetitions() async {
-    Result res = await HttpManager.get('competition/all', data: {'status': 1});
+    Result res = await HttpManager.get('competition/getCompetitionList', data: {'status': 1});
     if (res.success) {
       List<CompetitionInfo> list = [];
       for (var item in res.data) {

+ 1 - 1
lib/pages/openRoom.dart

@@ -62,7 +62,7 @@ class OpenRoomState extends State<OpenRoom> {
   }
 
   Future<void> saveInfo() async {
-    if (!StoreProvider.of<AppState>(context).state.userInfo.createFlag) {
+    if (!(StoreProvider.of<AppState>(context).state.userInfo.createFlag == 'Y')) {
       showSysDialog(1);
       return;
     }

+ 20 - 33
lib/pages/roomList.dart

@@ -94,7 +94,6 @@ class RoomListState extends State<RoomList> {
 
     return Scaffold(
         appBar: AppBar(
-          backgroundColor: PRIMARY_COLOR,
           title: Text('房间列表'),
           centerTitle: true,
           elevation: 0,
@@ -125,24 +124,13 @@ class RoomListState extends State<RoomList> {
                     SliverFixedExtentList(
                       itemExtent: ScreenUtil().setWidth(78),
                       delegate: SliverChildBuilderDelegate((BuildContext context, int index) {
-                        if(roomList.isEmpty){
-                          return Text('暂无数据',style: TextStyle(
-                            color: Colors.grey,
-                            fontSize: 13,
-                            height:3
-                          ),textAlign: TextAlign.center);
-                        }else if(index ==roomList.length){
-                            return Text('更多房间敬请期待...',style: TextStyle(
-                            color: Colors.grey,
-                            fontSize: 13,
-                            height:3
-                          ),textAlign: TextAlign.center);
+                        if (roomList.isEmpty) {
+                          return Text('暂无数据', style: TextStyle(color: Colors.grey, fontSize: 13, height: 3), textAlign: TextAlign.center);
+                        } else if (index == roomList.length) {
+                          return Text('更多房间敬请期待...', style: TextStyle(color: Colors.grey, fontSize: 13, height: 3), textAlign: TextAlign.center);
                         }
-                        return HouseItem(
-                          roomInfo: roomList[index],
-                          gameInfo:roomList[index].gameInfo
-                        );
-                      }, childCount: roomList.length+1),
+                        return HouseItem(roomInfo: roomList[index], gameInfo: roomList[index].gameInfo);
+                      }, childCount: roomList.length + 1),
                     )
                   ],
                 ),
@@ -205,7 +193,7 @@ class RoomListState extends State<RoomList> {
             setState(() {
               gameId = value;
             });
-            currentPage=1;
+            currentPage = 1;
             getRoomInfo();
           },
           itemBuilder: (BuildContext context) {
@@ -258,7 +246,7 @@ class RoomListState extends State<RoomList> {
             setState(() {
               houseLevel = value;
             });
-            currentPage=1;
+            currentPage = 1;
             getRoomInfo();
           },
           itemBuilder: (BuildContext context) {
@@ -311,7 +299,7 @@ class RoomListState extends State<RoomList> {
             setState(() {
               houseType = value;
             });
-            currentPage=1;
+            currentPage = 1;
             getRoomInfo();
           },
           itemBuilder: (BuildContext context) {
@@ -364,7 +352,7 @@ class RoomListState extends State<RoomList> {
             setState(() {
               statusFlag = value;
             });
-            currentPage=1;
+            currentPage = 1;
             getRoomInfo();
           },
           itemBuilder: (BuildContext context) {
@@ -381,7 +369,6 @@ class RoomListState extends State<RoomList> {
   }
 
   Future<void> getRoomInfo() async {
-   
     Map<String, dynamic> data = {
       'currentPage': currentPage,
       'pageNumber': 20,
@@ -401,25 +388,25 @@ class RoomListState extends State<RoomList> {
     } else {
       data['statusStr'] = '0,4';
     }
-    List<HouseInfo> _allList=roomList;
-    if(currentPage==1){
-      _allList=[];
+    List<HouseInfo> _allList = roomList;
+    if (currentPage == 1) {
+      _allList = [];
     }
     Result res = await HttpManager.get('houseInfo/page', data: data);
     if (res.success && res.data['pp'] != null) {
       for (var item in res.data['pp']) {
-        HouseInfo _temHouse=HouseInfo.fromJson(item);
+        HouseInfo _temHouse = HouseInfo.fromJson(item);
         _allList.add(_temHouse);
       }
       if (res.data['page']['currentPage'] < res.data['page']['totalPage']) {
-          scrollFlag = true;
-        } else {
-          scrollFlag = false;
-        }
-      } else {}
+        scrollFlag = true;
+      } else {
+        scrollFlag = false;
+      }
+    } else {}
 
     setState(() {
-     roomList=_allList; 
+      roomList = _allList;
     });
 
     // final response = await Dio().get(domain + 'houseInfo/page', data: data);

+ 2 - 2
lib/pages/setting.dart

@@ -73,7 +73,7 @@ class SettingState extends State<Setting> {
                                 _cell(
                                     '是否接收消息',
                                     Switch(
-                                        value: userInfo.noticeFlag,
+                                        value: userInfo.noticeFlag == 'Y',
                                         onChanged: (val) {
                                           updateUserInfo(userInfo, val ? 'Y' : 'N', 'noticeFlag');
                                         }),
@@ -81,7 +81,7 @@ class SettingState extends State<Setting> {
                                 _cell(
                                     '是否查看房间提醒',
                                     Switch(
-                                        value: userInfo.remindFlag,
+                                        value: userInfo.remindFlag == 'Y',
                                         onChanged: (val) {
                                           updateUserInfo(userInfo, val ? 'Y' : 'N', 'remindFlag');
                                         }),

+ 2 - 2
lib/styles/colors.dart

@@ -4,10 +4,10 @@ import 'package:flutter/material.dart';
 const PRIMARY_COLOR = Color(0xFF1990F8);
 
 //辅助色
-const SUB_COLOR = Color(0xFF1C62A7);
+const SUB_COLOR = Color(0xFF293354);
 
 //背景色
-const BG_COLOR = Color(0xFF2B2B42);
+const BG_COLOR = Color(0XFF0E1D32);
 
 //辅助背景色
 const BG_SUB_COLOR = Color(0xFF222335);

+ 68 - 18
lib/widget/Competition.dart

@@ -3,6 +3,8 @@ import 'package:flutter/cupertino.dart';
 import '../model/CompetitionInfo.dart';
 import 'package:intl/intl.dart';
 import '../pages/RoomList.dart';
+import '../pages/CompetitionRooms.dart';
+import 'package:gradient_text/gradient_text.dart';
 
 class Competition extends StatelessWidget {
   final CompetitionInfo competitionInfo;
@@ -45,19 +47,21 @@ class Competition extends StatelessWidget {
                             style: TextStyle(fontSize: 14, color: Colors.white),
                           ),
                           Expanded(
-                            child: Text(
-                              '¥' + competitionInfo.bonus.toString(),
-                              style: TextStyle(
-                                fontSize: 20,
-                                foreground: Paint()..shader = linearGradient,
-                              ),
-                            ),
+                            child: GradientText(
+                                '¥' + competitionInfo.bonus.toString().replaceAllMapped(RegExp(r'(\d{1,3})(?=(\d{3})+(?!\d))'), (Match m) => '${m[1]},'),
+                                gradient: LinearGradient(
+                                  colors: [Color(0xFFFFC84B), Color(0xFFA26A23)],
+                                  begin: Alignment.topCenter,
+                                  end: Alignment.bottomCenter,
+                                ),
+                                style: TextStyle(fontSize: 20),
+                                textAlign: TextAlign.center),
                           ),
                           Text(
                             '比赛时间' +
-                                DateFormat('yyyy.MM.dd').format(new DateTime.fromMicrosecondsSinceEpoch(competitionInfo.startTime * 1000)) +
+                                DateFormat('yyyy.MM.dd').format(DateTime.fromMicrosecondsSinceEpoch(competitionInfo.startTime * 1000)) +
                                 '-' +
-                                DateFormat('yyyy.MM.dd').format(new DateTime.fromMicrosecondsSinceEpoch(competitionInfo.endTime * 1000)),
+                                DateFormat('yyyy.MM.dd').format(DateTime.fromMicrosecondsSinceEpoch(competitionInfo.endTime * 1000)),
                             style: TextStyle(
                               color: Color(0xFF9A9CA2),
                               fontSize: 11,
@@ -92,19 +96,65 @@ class Competition extends StatelessWidget {
               ),
             ),
             Positioned(
-                right: 60,
-                top: -2,
-                width: 52,
-                height: 35,
-                child: Container(
-                  transform: Matrix4.translationValues(0.0, -2.0, 0.0),
-                  child: Image.asset('images/icon_paiming01.png'),
-                ))
+              right: 60,
+              top: -2,
+              width: 52,
+              height: 35,
+              child: Container(
+                transform: Matrix4.translationValues(0.0, -2.0, 0.0),
+                child: Builder(
+                  builder: (context) {
+                    var src = 'images/icon_paimingno.png';
+                    if (competitionInfo.participatingInfo != null && competitionInfo.participatingInfo.rank > 0) {
+                      if (competitionInfo.participatingInfo.rank == 1) {
+                        src = 'images/icon_paiming01.png';
+                      } else if (competitionInfo.participatingInfo.rank == 2) {
+                        src = 'images/icon_paiming02.png';
+                      } else if (competitionInfo.participatingInfo.rank == 3) {
+                        src = 'images/icon_paiming03.png';
+                      } else {
+                        return Stack(
+                          children: <Widget>[
+                            Image.asset('images/icon_paiming0000.png'),
+                            Align(
+                              alignment: Alignment.topCenter,
+                              child: Container(
+                                margin: EdgeInsets.only(top: 10),
+                                child: Text(
+                                  competitionInfo.participatingInfo.rank.toString(),
+                                  style: TextStyle(
+                                    fontSize: 16,
+                                    fontWeight: FontWeight.bold,
+                                    color: Colors.white,
+                                  ),
+                                ),
+                              ),
+                            ),
+                          ],
+                        );
+                      }
+                    }
+                    return Image.asset(src);
+                  },
+                ),
+              ),
+            ),
+            Align(
+              alignment: Alignment.topLeft,
+              child: Opacity(
+                opacity: competitionInfo.type == 2 ? 1.0 : 0,
+                child: Image.asset(
+                  'images/home_icon_vip.png',
+                  width: 28,
+                  height: 24,
+                ),
+              ),
+            )
           ],
         ),
       ),
       onTap: () {
-        Navigator.push(context, CupertinoPageRoute(builder: (context) => RoomList()));
+        Navigator.push(context, CupertinoPageRoute(builder: (context) => CompetitionRooms(competitionInfo)));
       },
     );
   }

+ 16 - 9
pubspec.lock

@@ -21,7 +21,7 @@ packages:
       name: async
       url: "https://pub.dartlang.org"
     source: hosted
-    version: "2.0.8"
+    version: "2.1.0"
   boolean_selector:
     dependency: transitive
     description:
@@ -247,6 +247,13 @@ packages:
       url: "https://pub.dartlang.org"
     source: hosted
     version: "1.1.7"
+  gradient_text:
+    dependency: "direct main"
+    description:
+      name: gradient_text
+      url: "https://pub.dartlang.org"
+    source: hosted
+    version: "1.0.2"
   graphs:
     dependency: transitive
     description:
@@ -295,7 +302,7 @@ packages:
       name: intl
       url: "https://pub.dartlang.org"
     source: hosted
-    version: "0.15.7"
+    version: "0.15.8"
   io:
     dependency: transitive
     description:
@@ -351,7 +358,7 @@ packages:
       name: matcher
       url: "https://pub.dartlang.org"
     source: hosted
-    version: "0.12.3+1"
+    version: "0.12.5"
   meta:
     dependency: transitive
     description:
@@ -407,7 +414,7 @@ packages:
       name: pedantic
       url: "https://pub.dartlang.org"
     source: hosted
-    version: "1.4.0"
+    version: "1.5.0"
   platform:
     dependency: transitive
     description:
@@ -449,7 +456,7 @@ packages:
       name: quiver
       url: "https://pub.dartlang.org"
     source: hosted
-    version: "2.0.1"
+    version: "2.0.2"
   redux:
     dependency: "direct main"
     description:
@@ -524,7 +531,7 @@ packages:
       name: source_span
       url: "https://pub.dartlang.org"
     source: hosted
-    version: "1.5.4"
+    version: "1.5.5"
   sqflite:
     dependency: transitive
     description:
@@ -545,7 +552,7 @@ packages:
       name: stream_channel
       url: "https://pub.dartlang.org"
     source: hosted
-    version: "1.6.8"
+    version: "2.0.0"
   stream_transform:
     dependency: transitive
     description:
@@ -580,7 +587,7 @@ packages:
       name: test_api
       url: "https://pub.dartlang.org"
     source: hosted
-    version: "0.2.2"
+    version: "0.2.4"
   timing:
     dependency: transitive
     description:
@@ -659,5 +666,5 @@ packages:
     source: hosted
     version: "2.1.15"
 sdks:
-  dart: ">=2.1.1 <3.0.0"
+  dart: ">=2.2.0 <3.0.0"
   flutter: ">=1.2.1 <2.0.0"

+ 1 - 0
pubspec.yaml

@@ -37,6 +37,7 @@ dependencies:
   ttdj_plugin:
     path: ./ttdj_plugin
   cached_network_image: ^0.8.0
+  gradient_text: ^1.0.2
 
 dev_dependencies:
   build_runner: ^1.1.1