|
|
@@ -2,10 +2,16 @@ import 'package:flutter/material.dart';
|
|
|
import '../styles/colors.dart';
|
|
|
import 'dart:ui';
|
|
|
import '../styles/totast.dart';
|
|
|
+import '../model/PlayerInfo.dart';
|
|
|
+import '../net/HttpManager.dart';
|
|
|
+import '../net/Result.dart';
|
|
|
+import 'package:flutter_redux/flutter_redux.dart';
|
|
|
+import '../redux/AppState.dart';
|
|
|
+import '../model/CompetitionSeason.dart';
|
|
|
|
|
|
class RankList extends StatefulWidget {
|
|
|
RankList({Key key, this.raceId}) : super(key: key);
|
|
|
- final String raceId; // 用来储存传递过来的值
|
|
|
+ final int raceId; // 用来储存传递过来的值
|
|
|
@override
|
|
|
RankListState createState() => RankListState();
|
|
|
}
|
|
|
@@ -13,118 +19,126 @@ class RankList extends StatefulWidget {
|
|
|
class RankListState extends State<RankList> {
|
|
|
String raceName = '2019';
|
|
|
List raceNameList = ['2019', '2018', '2017'];
|
|
|
- List rankList = [
|
|
|
- {
|
|
|
- "icon":
|
|
|
- 'http://h.hiphotos.baidu.com/zhidao/wh%3D450%2C600/sign=0d023672312ac65c67506e77cec29e27/9f2f070828381f30dea167bbad014c086e06f06c.jpg',
|
|
|
- "money": '568449',
|
|
|
- "name": '汪大宝'
|
|
|
- },
|
|
|
- {
|
|
|
- "icon":
|
|
|
- 'http://h.hiphotos.baidu.com/zhidao/wh%3D450%2C600/sign=0d023672312ac65c67506e77cec29e27/9f2f070828381f30dea167bbad014c086e06f06c.jpg',
|
|
|
- "money": '56849',
|
|
|
- "name": 'Crona'
|
|
|
- },
|
|
|
- {
|
|
|
- "icon":
|
|
|
- 'http://h.hiphotos.baidu.com/zhidao/wh%3D450%2C600/sign=0d023672312ac65c67506e77cec29e27/9f2f070828381f30dea167bbad014c086e06f06c.jpg',
|
|
|
- "money": '38449',
|
|
|
- "name": 'Ewell'
|
|
|
- },
|
|
|
- {
|
|
|
- "icon":
|
|
|
- 'http://h.hiphotos.baidu.com/zhidao/wh%3D450%2C600/sign=0d023672312ac65c67506e77cec29e27/9f2f070828381f30dea167bbad014c086e06f06c.jpg',
|
|
|
- "money": '568449',
|
|
|
- "name": '汪大宝'
|
|
|
- },
|
|
|
- {
|
|
|
- "icon":
|
|
|
- 'http://h.hiphotos.baidu.com/zhidao/wh%3D450%2C600/sign=0d023672312ac65c67506e77cec29e27/9f2f070828381f30dea167bbad014c086e06f06c.jpg',
|
|
|
- "money": '56849',
|
|
|
- "name": 'Crona'
|
|
|
- },
|
|
|
- {
|
|
|
- "icon":
|
|
|
- 'http://h.hiphotos.baidu.com/zhidao/wh%3D450%2C600/sign=0d023672312ac65c67506e77cec29e27/9f2f070828381f30dea167bbad014c086e06f06c.jpg',
|
|
|
- "money": '38449',
|
|
|
- "name": 'Ewell'
|
|
|
- },
|
|
|
- {
|
|
|
- "icon":
|
|
|
- 'http://h.hiphotos.baidu.com/zhidao/wh%3D450%2C600/sign=0d023672312ac65c67506e77cec29e27/9f2f070828381f30dea167bbad014c086e06f06c.jpg',
|
|
|
- "money": '568449',
|
|
|
- "name": '汪大宝'
|
|
|
- },
|
|
|
- {
|
|
|
- "icon":
|
|
|
- 'http://h.hiphotos.baidu.com/zhidao/wh%3D450%2C600/sign=0d023672312ac65c67506e77cec29e27/9f2f070828381f30dea167bbad014c086e06f06c.jpg',
|
|
|
- "money": '56849',
|
|
|
- "name": 'Crona'
|
|
|
- },
|
|
|
- {
|
|
|
- "icon":
|
|
|
- 'http://h.hiphotos.baidu.com/zhidao/wh%3D450%2C600/sign=0d023672312ac65c67506e77cec29e27/9f2f070828381f30dea167bbad014c086e06f06c.jpg',
|
|
|
- "money": '38449',
|
|
|
- "name": 'Ewell'
|
|
|
- },
|
|
|
- {
|
|
|
- "icon":
|
|
|
- 'http://h.hiphotos.baidu.com/zhidao/wh%3D450%2C600/sign=0d023672312ac65c67506e77cec29e27/9f2f070828381f30dea167bbad014c086e06f06c.jpg',
|
|
|
- "money": '568449',
|
|
|
- "name": '汪大宝'
|
|
|
- },
|
|
|
- {
|
|
|
- "icon":
|
|
|
- 'http://h.hiphotos.baidu.com/zhidao/wh%3D450%2C600/sign=0d023672312ac65c67506e77cec29e27/9f2f070828381f30dea167bbad014c086e06f06c.jpg',
|
|
|
- "money": '56849',
|
|
|
- "name": 'Crona汪大宝汪大宝汪大宝汪大宝汪大宝汪大宝汪大宝汪大宝汪大宝汪大宝汪大宝汪大宝汪大宝汪大宝汪大宝'
|
|
|
- },
|
|
|
- {
|
|
|
- "icon":
|
|
|
- 'http://h.hiphotos.baidu.com/zhidao/wh%3D450%2C600/sign=0d023672312ac65c67506e77cec29e27/9f2f070828381f30dea167bbad014c086e06f06c.jpg',
|
|
|
- "money": '38449',
|
|
|
- "name": 'Ewell'
|
|
|
- }
|
|
|
- ];
|
|
|
-
|
|
|
+ List<PlayerInfo> rankList = [];
|
|
|
ScrollController _mcontroller;
|
|
|
bool scrollFlag = true;
|
|
|
int currentPage = 1;
|
|
|
+ int raceId = 0;
|
|
|
+ List<CompetitionSeason> seasonList = [];
|
|
|
+ PlayerInfo myPlayInfo;
|
|
|
+
|
|
|
+ void getUserRank() async {
|
|
|
+ print('***********');
|
|
|
+
|
|
|
+ Result res = await HttpManager.get("playerInfo/seasonUserRank", data: {
|
|
|
+ "seasonId": raceId,
|
|
|
+ "userId": StoreProvider.of<AppState>(context).state.userInfo.id
|
|
|
+ });
|
|
|
+ print(res.data);
|
|
|
+ if (res.success && res.data != null) {
|
|
|
+ setState(() {
|
|
|
+ myPlayInfo = PlayerInfo.fromJson(res.data);
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ setState(() {
|
|
|
+ myPlayInfo = null;
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ currentPage = 1;
|
|
|
+ getListPage();
|
|
|
+ }
|
|
|
+
|
|
|
+ void getListPage() async {
|
|
|
+ scrollFlag = false;
|
|
|
+ Toast.show(context, '加载中', -1, 'loading');
|
|
|
+ Result res = await HttpManager.get("playerInfo/seasonRankPage", data: {
|
|
|
+ "seasonId": raceId,
|
|
|
+ "currentPage": currentPage,
|
|
|
+ "pageNumber": 20
|
|
|
+ });
|
|
|
+ Toast.hide();
|
|
|
+ List<PlayerInfo> list = rankList;
|
|
|
+ if (currentPage == 1) {
|
|
|
+ list = [];
|
|
|
+ }
|
|
|
+ if (res.success) {
|
|
|
+ for (var item in res.data['pp']) {
|
|
|
+ PlayerInfo tip = PlayerInfo.fromJson(item);
|
|
|
+ list.add(tip);
|
|
|
+ }
|
|
|
+ if (res.data['page']['currentPage'] < res.data['page']['totalPage']) {
|
|
|
+ scrollFlag = true;
|
|
|
+ }
|
|
|
+ } else {}
|
|
|
+ setState(() {
|
|
|
+ rankList = list;
|
|
|
+ });
|
|
|
+
|
|
|
+ if (rankList.length == 0) {
|
|
|
+ showBackDialog();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //没有赛季排行数据弹窗
|
|
|
+ showBackDialog() {
|
|
|
+ showDialog<Null>(
|
|
|
+ context: context,
|
|
|
+ barrierDismissible: false,
|
|
|
+ builder: (BuildContext context) {
|
|
|
+ return new AlertDialog(
|
|
|
+ content: Container(
|
|
|
+ height: 50,
|
|
|
+ child: Text(
|
|
|
+ '该赛季暂未产生排行数据,尽情期待...',
|
|
|
+ style: TextStyle(color: Colors.black),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ actions: <Widget>[
|
|
|
+ new FlatButton(
|
|
|
+ child: new Text('确定'),
|
|
|
+ onPressed: () {
|
|
|
+ Navigator.of(context).pop();
|
|
|
+ },
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ );
|
|
|
+ },
|
|
|
+ ).then((val) {
|
|
|
+ Navigator.of(context).pop();
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ void getSeasonInfo() async {
|
|
|
+ Result res = await HttpManager.get("competitionSeason/all");
|
|
|
+ if (res.success) {
|
|
|
+ List<CompetitionSeason> list = [];
|
|
|
+ for (var item in res.data) {
|
|
|
+ list.add(CompetitionSeason.fromJson(item));
|
|
|
+ }
|
|
|
+ setState(() {
|
|
|
+ seasonList = list;
|
|
|
+ });
|
|
|
+ } else {}
|
|
|
+ }
|
|
|
+
|
|
|
@override
|
|
|
void initState() {
|
|
|
+ raceId = widget.raceId;
|
|
|
super.initState();
|
|
|
_mcontroller = ScrollController();
|
|
|
_mcontroller.addListener(() {
|
|
|
if (_mcontroller.position.pixels ==
|
|
|
_mcontroller.position.maxScrollExtent) {
|
|
|
if (scrollFlag) {
|
|
|
- print(currentPage);
|
|
|
- // setState(() {
|
|
|
- // rankList.addAll([
|
|
|
- // {
|
|
|
- // "icon":
|
|
|
- // 'http://h.hiphotos.baidu.com/zhidao/wh%3D450%2C600/sign=0d023672312ac65c67506e77cec29e27/9f2f070828381f30dea167bbad014c086e06f06c.jpg',
|
|
|
- // "money": '568449',
|
|
|
- // "name": '汪大宝'
|
|
|
- // },
|
|
|
- // {
|
|
|
- // "icon":
|
|
|
- // 'http://h.hiphotos.baidu.com/zhidao/wh%3D450%2C600/sign=0d023672312ac65c67506e77cec29e27/9f2f070828381f30dea167bbad014c086e06f06c.jpg',
|
|
|
- // "money": '56849',
|
|
|
- // "name": 'Crona'
|
|
|
- // },
|
|
|
- // {
|
|
|
- // "icon":
|
|
|
- // 'http://h.hiphotos.baidu.com/zhidao/wh%3D450%2C600/sign=0d023672312ac65c67506e77cec29e27/9f2f070828381f30dea167bbad014c086e06f06c.jpg',
|
|
|
- // "money": '38449',
|
|
|
- // "name": 'Ewell'
|
|
|
- // }
|
|
|
- // ]);
|
|
|
- // });
|
|
|
+ currentPage++;
|
|
|
+ getListPage();
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
+
|
|
|
+ Future.delayed(Duration(milliseconds: 100), () => getUserRank());
|
|
|
+ getSeasonInfo();
|
|
|
}
|
|
|
|
|
|
@override
|
|
|
@@ -144,6 +158,7 @@ class RankListState extends State<RankList> {
|
|
|
backgroundColor: BG_COLOR,
|
|
|
onRefresh: () async {
|
|
|
await new Future.delayed(const Duration(seconds: 1));
|
|
|
+ getUserRank();
|
|
|
},
|
|
|
child: CustomScrollView(
|
|
|
controller: _mcontroller,
|
|
|
@@ -155,64 +170,84 @@ class RankListState extends State<RankList> {
|
|
|
],
|
|
|
)),
|
|
|
),
|
|
|
- floatingActionButton: Container(
|
|
|
- padding: EdgeInsets.only(left: 20,right: 15),
|
|
|
- height: 48,
|
|
|
- decoration: BoxDecoration(
|
|
|
- gradient: LinearGradient(
|
|
|
- begin: Alignment.topRight,
|
|
|
- colors: [Color(0xFF59607A), Color(0xFF3C3C67)],
|
|
|
- )
|
|
|
- ),
|
|
|
- child: Row(
|
|
|
- children: <Widget>[
|
|
|
- Container(
|
|
|
- width:30,
|
|
|
- height: 30,
|
|
|
- child: CircleAvatar(
|
|
|
- backgroundImage: NetworkImage('http://h.hiphotos.baidu.com/zhidao/wh%3D450%2C600/sign=0d023672312ac65c67506e77cec29e27/9f2f070828381f30dea167bbad014c086e06f06c.jpg'),
|
|
|
+ floatingActionButton: myPlayInfo == null
|
|
|
+ ? Container()
|
|
|
+ : Container(
|
|
|
+ padding: EdgeInsets.only(left: 20, right: 15),
|
|
|
+ height: 48,
|
|
|
+ decoration: BoxDecoration(
|
|
|
+ gradient: LinearGradient(
|
|
|
+ begin: Alignment.topRight,
|
|
|
+ colors: [Color(0xFF59607A), Color(0xFF3C3C67)],
|
|
|
+ )),
|
|
|
+ child: Row(
|
|
|
+ children: <Widget>[
|
|
|
+ Container(
|
|
|
+ width: 30,
|
|
|
+ height: 30,
|
|
|
+ child: CircleAvatar(
|
|
|
+ backgroundImage:
|
|
|
+ NetworkImage(myPlayInfo.userInfo.icon ?? '')),
|
|
|
+ ),
|
|
|
+ Padding(
|
|
|
+ padding: EdgeInsets.symmetric(horizontal: 10),
|
|
|
+ child: Text(myPlayInfo.userInfo.nickname ?? '',
|
|
|
+ style:
|
|
|
+ TextStyle(color: Colors.white, fontSize: 14)),
|
|
|
+ ),
|
|
|
+ Image.asset('images/icon_jinbi_da_bai.png', width: 20),
|
|
|
+ Padding(
|
|
|
+ padding: EdgeInsets.only(left: 2),
|
|
|
+ child: Text((myPlayInfo.bonus ?? 0).toString(),
|
|
|
+ style: TextStyle(
|
|
|
+ color: Colors.white,
|
|
|
+ fontSize: 14,
|
|
|
+ fontWeight: FontWeight.w500)),
|
|
|
+ ),
|
|
|
+ myPlayInfo.rank == null
|
|
|
+ ? Container()
|
|
|
+ : Expanded(
|
|
|
+ flex: 1,
|
|
|
+ child: Text(
|
|
|
+ '第 ' + myPlayInfo.rank.toString() + ' 名',
|
|
|
+ style: TextStyle(
|
|
|
+ color: Colors.white,
|
|
|
+ fontSize: 14,
|
|
|
+ fontWeight: FontWeight.w500),
|
|
|
+ textAlign: TextAlign.right),
|
|
|
+ )
|
|
|
+ ],
|
|
|
),
|
|
|
),
|
|
|
- Padding(
|
|
|
- padding: EdgeInsets.symmetric(horizontal: 10),
|
|
|
- child: Text('粉条',style: TextStyle(color: Colors.white,fontSize: 14)),
|
|
|
- ),
|
|
|
- Image.asset('images/icon_jinbi_da_bai.png',width: 20),
|
|
|
- Padding(
|
|
|
- padding: EdgeInsets.only(left: 2),
|
|
|
- child: Text('568449',style: TextStyle(color: Colors.white,fontSize: 14,fontWeight: FontWeight.w500)),
|
|
|
- ),
|
|
|
- Expanded(
|
|
|
- flex: 1,
|
|
|
- child: Text('第 28 名',style: TextStyle(color: Colors.white,fontSize: 14,fontWeight: FontWeight.w500),textAlign: TextAlign.right),
|
|
|
- )
|
|
|
- ],
|
|
|
- ),
|
|
|
- ),
|
|
|
floatingActionButtonLocation:
|
|
|
FloatingActionButtonLocation.centerDocked,
|
|
|
),
|
|
|
onWillPop: () {
|
|
|
Toast.hide();
|
|
|
- print("返回键点击了");
|
|
|
Navigator.pop(context);
|
|
|
return Future.value(false);
|
|
|
});
|
|
|
}
|
|
|
|
|
|
Widget _sliverAppBar() {
|
|
|
+ CompetitionSeason competitionSeason;
|
|
|
+ for (var item in seasonList) {
|
|
|
+ if (item.id == raceId) {
|
|
|
+ competitionSeason = item;
|
|
|
+ }
|
|
|
+ }
|
|
|
return SliverAppBar(
|
|
|
title: Text('排行榜'),
|
|
|
centerTitle: true,
|
|
|
actions: <Widget>[
|
|
|
PopupMenuButton(
|
|
|
- initialValue: raceName,
|
|
|
+ initialValue: raceId,
|
|
|
child: Row(
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
children: <Widget>[
|
|
|
Text(
|
|
|
- raceName + '赛季',
|
|
|
+ competitionSeason != null ? competitionSeason.season : '',
|
|
|
style: TextStyle(
|
|
|
color: Colors.white,
|
|
|
fontSize: 13,
|
|
|
@@ -229,13 +264,14 @@ class RankListState extends State<RankList> {
|
|
|
),
|
|
|
onSelected: (value) {
|
|
|
setState(() {
|
|
|
- raceName = value;
|
|
|
+ raceId = value;
|
|
|
});
|
|
|
+ getUserRank();
|
|
|
},
|
|
|
itemBuilder: (BuildContext context) {
|
|
|
- return raceNameList.map((choice) {
|
|
|
+ return seasonList.map((choice) {
|
|
|
return new PopupMenuItem(
|
|
|
- child: new Text(choice + '赛季'), value: choice);
|
|
|
+ child: new Text(choice.season), value: choice.id);
|
|
|
}).toList();
|
|
|
}),
|
|
|
],
|
|
|
@@ -278,7 +314,8 @@ class RankListState extends State<RankList> {
|
|
|
height: 36,
|
|
|
margin: EdgeInsets.only(right: 15),
|
|
|
child: CircleAvatar(
|
|
|
- backgroundImage: NetworkImage(rankList[index]['icon']),
|
|
|
+ backgroundImage:
|
|
|
+ NetworkImage(rankList[index].userInfo.icon),
|
|
|
),
|
|
|
),
|
|
|
Expanded(
|
|
|
@@ -287,7 +324,7 @@ class RankListState extends State<RankList> {
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
children: <Widget>[
|
|
|
- Text(rankList[index]['name'],
|
|
|
+ Text(rankList[index].userInfo.nickname,
|
|
|
style: TextStyle(
|
|
|
color: PRIMARY_COLOR,
|
|
|
fontSize: 14,
|
|
|
@@ -299,7 +336,7 @@ class RankListState extends State<RankList> {
|
|
|
width: 20),
|
|
|
Padding(
|
|
|
padding: EdgeInsets.only(left: 2),
|
|
|
- child: Text(rankList[index]['money'],
|
|
|
+ child: Text(rankList[index].bonus.toString(),
|
|
|
style: TextStyle(
|
|
|
color: Colors.white,
|
|
|
fontSize: 14,
|
|
|
@@ -384,7 +421,8 @@ class RankListState extends State<RankList> {
|
|
|
blurRadius: 4.0)
|
|
|
]),
|
|
|
child: CircleAvatar(
|
|
|
- backgroundImage: NetworkImage(rankList[0]['icon']))),
|
|
|
+ backgroundImage:
|
|
|
+ NetworkImage(rankList[0].userInfo.icon))),
|
|
|
Positioned(
|
|
|
bottom: 0,
|
|
|
left: 24,
|
|
|
@@ -395,7 +433,7 @@ class RankListState extends State<RankList> {
|
|
|
),
|
|
|
Padding(
|
|
|
padding: EdgeInsets.only(top: 7, bottom: 3),
|
|
|
- child: Text(rankList[0]["name"],
|
|
|
+ child: Text(rankList[0].userInfo.nickname,
|
|
|
style: TextStyle(color: Color(0xFF2E3049), fontSize: 14)),
|
|
|
),
|
|
|
Row(
|
|
|
@@ -404,7 +442,7 @@ class RankListState extends State<RankList> {
|
|
|
padding: EdgeInsets.only(right: 2),
|
|
|
child: Image.asset('images/icon_jinbi_da_bai.png', width: 20),
|
|
|
),
|
|
|
- Text(rankList[0]["money"],
|
|
|
+ Text(rankList[0].bonus.toString(),
|
|
|
style: TextStyle(
|
|
|
color: Colors.white,
|
|
|
fontSize: 14,
|
|
|
@@ -447,7 +485,7 @@ class RankListState extends State<RankList> {
|
|
|
]),
|
|
|
child: CircleAvatar(
|
|
|
backgroundImage:
|
|
|
- NetworkImage(rankList[1]['icon']))),
|
|
|
+ NetworkImage(rankList[1].userInfo.icon))),
|
|
|
Positioned(
|
|
|
bottom: 0,
|
|
|
left: 19,
|
|
|
@@ -458,7 +496,7 @@ class RankListState extends State<RankList> {
|
|
|
),
|
|
|
Padding(
|
|
|
padding: EdgeInsets.only(top: 7, bottom: 3),
|
|
|
- child: Text(rankList[1]["name"],
|
|
|
+ child: Text(rankList[1].userInfo.nickname,
|
|
|
style: TextStyle(color: Color(0xFF2E3049), fontSize: 14)),
|
|
|
),
|
|
|
Row(
|
|
|
@@ -468,7 +506,7 @@ class RankListState extends State<RankList> {
|
|
|
child: Image.asset('images/icon_jinbi_da_bai.png',
|
|
|
width: 20),
|
|
|
),
|
|
|
- Text(rankList[1]["money"],
|
|
|
+ Text(rankList[1].bonus.toString(),
|
|
|
style: TextStyle(
|
|
|
color: Colors.white,
|
|
|
fontSize: 14,
|
|
|
@@ -507,7 +545,8 @@ class RankListState extends State<RankList> {
|
|
|
blurRadius: 4.0)
|
|
|
]),
|
|
|
child: CircleAvatar(
|
|
|
- backgroundImage: NetworkImage(rankList[2]['icon']))),
|
|
|
+ backgroundImage:
|
|
|
+ NetworkImage(rankList[2].userInfo.icon))),
|
|
|
Positioned(
|
|
|
bottom: 0,
|
|
|
left: 19,
|
|
|
@@ -518,7 +557,7 @@ class RankListState extends State<RankList> {
|
|
|
),
|
|
|
Padding(
|
|
|
padding: EdgeInsets.only(top: 7, bottom: 3),
|
|
|
- child: Text(rankList[2]["name"],
|
|
|
+ child: Text(rankList[2].userInfo.nickname,
|
|
|
style: TextStyle(color: Color(0xFF2E3049), fontSize: 14)),
|
|
|
),
|
|
|
Row(
|
|
|
@@ -527,7 +566,7 @@ class RankListState extends State<RankList> {
|
|
|
padding: EdgeInsets.only(right: 2),
|
|
|
child: Image.asset('images/icon_jinbi_da_bai.png', width: 20),
|
|
|
),
|
|
|
- Text(rankList[2]["money"],
|
|
|
+ Text(rankList[2].bonus.toString(),
|
|
|
style: TextStyle(
|
|
|
color: Colors.white,
|
|
|
fontSize: 14,
|