|
@@ -1,10 +1,13 @@
|
|
|
import 'dart:convert';
|
|
|
+import 'dart:io';
|
|
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
import 'package:flutter/material.dart';
|
|
|
+import 'package:flutter/services.dart';
|
|
|
import 'package:provider/provider.dart';
|
|
|
import 'package:sport/bean/rank_game_info.dart';
|
|
|
import 'package:sport/bean/user.dart';
|
|
|
+import 'package:sport/pages/my/shop_detail.dart';
|
|
|
import 'package:sport/provider/user_model.dart';
|
|
|
import 'package:sport/router/navigator_util.dart';
|
|
|
import 'package:sport/router/routes.dart';
|
|
@@ -14,6 +17,9 @@ import 'package:sport/widgets/decoration.dart';
|
|
|
import 'package:sport/widgets/image.dart';
|
|
|
import 'package:sport/widgets/loading.dart';
|
|
|
import 'package:sport/widgets/space.dart';
|
|
|
+import 'package:sport/widgets/persistent_header.dart';
|
|
|
+import 'package:scrollable_positioned_list/scrollable_positioned_list.dart';
|
|
|
+import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
|
|
class RankDetailPage extends StatefulWidget {
|
|
|
final String id;
|
|
@@ -27,12 +33,27 @@ class RankDetailPage extends StatefulWidget {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-class _RankDetailPageState extends State<RankDetailPage> with InjectApi {
|
|
|
+class _RankDetailPageState extends State<RankDetailPage>
|
|
|
+ with TickerProviderStateMixin, InjectApi {
|
|
|
bool _isLoading;
|
|
|
RankGameInfoData _data;
|
|
|
String _id;
|
|
|
-
|
|
|
+ ScrollController _controller = new ScrollController();
|
|
|
+ final ItemScrollController itemScrollController = ItemScrollController();
|
|
|
+ final ItemPositionsListener itemPositionsListener =
|
|
|
+ ItemPositionsListener.create();
|
|
|
+ TabController _tabController;
|
|
|
+ final List<String> _tabs = [
|
|
|
+ '世界榜',
|
|
|
+ '好友榜',
|
|
|
+ ];
|
|
|
String _rank;
|
|
|
+ final List<String> rankImages = [
|
|
|
+ "",
|
|
|
+ "rank_icon_first.png",
|
|
|
+ "rank_icon_second.png",
|
|
|
+ "rank_icon_third.png",
|
|
|
+ ];
|
|
|
|
|
|
@override
|
|
|
void initState() {
|
|
@@ -45,14 +66,44 @@ class _RankDetailPageState extends State<RankDetailPage> with InjectApi {
|
|
|
} else {
|
|
|
_isLoading = false;
|
|
|
}
|
|
|
+ _tabController =
|
|
|
+ TabController(length: _tabs.length, initialIndex: 0, vsync: this)
|
|
|
+ ..addListener(() async {
|
|
|
+ SharedPreferences prefs = await SharedPreferences.getInstance();
|
|
|
+ String _scope = _tabController.index == 0 ? "world": "friend";
|
|
|
+ // if(_tabController.index == 0)
|
|
|
+ // print(_tabController.index);
|
|
|
+ _data = (await api.getRankGameInfo(widget.id,scope: _scope)).data;
|
|
|
+ if (_data.user != null && _data.user.position > 10) {
|
|
|
+ _data.records.add(_data.user);
|
|
|
+ } else if (_data.user == null) {
|
|
|
+ _data.records.add(new User(
|
|
|
+ userName: prefs.getString("name"),
|
|
|
+ userAvatar: prefs.getString("avatar")));
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
+ // @override
|
|
|
+ // void dispose() {
|
|
|
+ // _controller?.dispose();
|
|
|
+ // }
|
|
|
+
|
|
|
// 缓存数据...
|
|
|
initData() async {
|
|
|
+ SharedPreferences prefs = await SharedPreferences.getInstance();
|
|
|
if (widget.type == "1") {
|
|
|
api.getRankGameInfo(widget.id).then((data) {
|
|
|
setState(() {
|
|
|
_data = data.data;
|
|
|
+ print("${data.data.user}====================");
|
|
|
+ if (data.data.user != null && data.data.user.position > 10) {
|
|
|
+ _data.records.add(data.data.user);
|
|
|
+ } else if (data.data.user == null) {
|
|
|
+ _data.records.add(new User(
|
|
|
+ userName: prefs.getString("name"),
|
|
|
+ userAvatar: prefs.getString("avatar")));
|
|
|
+ }
|
|
|
_isLoading = false;
|
|
|
});
|
|
|
});
|
|
@@ -60,39 +111,57 @@ class _RankDetailPageState extends State<RankDetailPage> with InjectApi {
|
|
|
api.getRankSportInfo(widget.id).then((data) {
|
|
|
setState(() {
|
|
|
_data = data.data;
|
|
|
+ print("${data.data.user}====================");
|
|
|
+ if (data.data.user != null && data.data.user.position > 10) {
|
|
|
+ _data.records.add(data.data.user);
|
|
|
+ } else if (data.data.user == null) {
|
|
|
+ _data.records.add(new User(
|
|
|
+ userName: prefs.getString("name"),
|
|
|
+ userAvatar: prefs.getString("avatar")));
|
|
|
+ }
|
|
|
_isLoading = false;
|
|
|
});
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- area(bool all, bool province, int provinceId, int cityId) {
|
|
|
- setState(() {
|
|
|
- _isLoading = true;
|
|
|
- });
|
|
|
- if (widget.type == "1") {
|
|
|
- api.getRankGameInfo(widget.id, provinceId: all ? null : provinceId, cityId: all ? null : province ? null : cityId).then((data) {
|
|
|
- setState(() {
|
|
|
- _data = data.data;
|
|
|
- _isLoading = false;
|
|
|
- });
|
|
|
- });
|
|
|
- } else {
|
|
|
- api.getRankSportInfo(widget.id, provinceId: all ? null : provinceId, cityId: all ? null : province ? null : cityId).then((data) {
|
|
|
- setState(() {
|
|
|
- _data = data.data;
|
|
|
- _isLoading = false;
|
|
|
- });
|
|
|
- });
|
|
|
- }
|
|
|
- }
|
|
|
+ // area(bool all, bool province, int provinceId, int cityId) {
|
|
|
+ // setState(() {
|
|
|
+ // _isLoading = true;
|
|
|
+ // });
|
|
|
+ // if (widget.type == "1") {
|
|
|
+ // api
|
|
|
+ // .getRankGameInfo(widget.id,
|
|
|
+ // )
|
|
|
+ // .then((data) {
|
|
|
+ // setState(() {
|
|
|
+ // _data = data.data;
|
|
|
+ // _isLoading = false;
|
|
|
+ // });
|
|
|
+ // });
|
|
|
+ // } else {
|
|
|
+ // api
|
|
|
+ // .getRankSportInfo(widget.id,
|
|
|
+ // provinceId: all ? null : provinceId,
|
|
|
+ // cityId: all ? null : province ? null : cityId)
|
|
|
+ // .then((data) {
|
|
|
+ // setState(() {
|
|
|
+ // _data = data.data;
|
|
|
+ // _isLoading = false;
|
|
|
+ // });
|
|
|
+ // });
|
|
|
+ // }
|
|
|
+ // }
|
|
|
|
|
|
initUser(int rank) {
|
|
|
return User(position: rank, userName: '虚位以待', score: 0, id: 0);
|
|
|
}
|
|
|
|
|
|
Widget _buildRankWidget() {
|
|
|
- dynamic user1 = initUser(1), user2 = initUser(2), user3 = initUser(3), user4;
|
|
|
+ dynamic user1 = initUser(1),
|
|
|
+ user2 = initUser(2),
|
|
|
+ user3 = initUser(3),
|
|
|
+ user4;
|
|
|
if (_data != null && _data.records != null) {
|
|
|
for (var i = 0; i < _data.records.length; i++) {
|
|
|
var item = _data.records[i];
|
|
@@ -113,9 +182,21 @@ class _RankDetailPageState extends State<RankDetailPage> with InjectApi {
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
|
crossAxisAlignment: CrossAxisAlignment.end,
|
|
|
children: <Widget>[
|
|
|
- Container(width: 94, child: user2 != null ? _buildRankHeaderWidget(user2) : _buildRankHeaderWidget(initUser(2))),
|
|
|
- Container(width: 120, child: user1 != null ? _buildRankHeaderWidget(user1) : _buildRankHeaderWidget(initUser(1))),
|
|
|
- Container(width: 94, child: user3 != null ? _buildRankHeaderWidget(user3) : _buildRankHeaderWidget(initUser(3))),
|
|
|
+ Container(
|
|
|
+ width: 94,
|
|
|
+ child: user2 != null
|
|
|
+ ? _buildRankHeaderWidget(user2)
|
|
|
+ : _buildRankHeaderWidget(initUser(2))),
|
|
|
+ Container(
|
|
|
+ width: 120,
|
|
|
+ child: user1 != null
|
|
|
+ ? _buildRankHeaderWidget(user1)
|
|
|
+ : _buildRankHeaderWidget(initUser(1))),
|
|
|
+ Container(
|
|
|
+ width: 94,
|
|
|
+ child: user3 != null
|
|
|
+ ? _buildRankHeaderWidget(user3)
|
|
|
+ : _buildRankHeaderWidget(initUser(3))),
|
|
|
],
|
|
|
),
|
|
|
),
|
|
@@ -140,7 +221,10 @@ class _RankDetailPageState extends State<RankDetailPage> with InjectApi {
|
|
|
? Stack(
|
|
|
alignment: Alignment.center,
|
|
|
children: <Widget>[
|
|
|
- CircleAvatar(backgroundImage: userAvatarProvider(user.userAvatar == null ? "" : user.userAvatar), radius: 46.0),
|
|
|
+ CircleAvatar(
|
|
|
+ backgroundImage: userAvatarProvider(
|
|
|
+ user.userAvatar == null ? "" : user.userAvatar),
|
|
|
+ radius: 46.0),
|
|
|
Image.asset(
|
|
|
"lib/assets/img/rank_image_no$rank.png",
|
|
|
)
|
|
@@ -149,7 +233,12 @@ class _RankDetailPageState extends State<RankDetailPage> with InjectApi {
|
|
|
: Stack(
|
|
|
alignment: Alignment.topCenter,
|
|
|
children: <Widget>[
|
|
|
- Positioned(top: 3, child: CircleAvatar(backgroundImage: userAvatarProvider(user.userAvatar == null ? "" : user.userAvatar), radius: 35.0)),
|
|
|
+ Positioned(
|
|
|
+ top: 3,
|
|
|
+ child: CircleAvatar(
|
|
|
+ backgroundImage: userAvatarProvider(
|
|
|
+ user.userAvatar == null ? "" : user.userAvatar),
|
|
|
+ radius: 35.0)),
|
|
|
Image.asset(
|
|
|
"lib/assets/img/rank_image_no$rank.png",
|
|
|
)
|
|
@@ -170,34 +259,35 @@ class _RankDetailPageState extends State<RankDetailPage> with InjectApi {
|
|
|
],
|
|
|
),
|
|
|
onTap: () {
|
|
|
- if (user.id != 0) NavigatorUtil.goRankPeopleDetails(context, details: user);
|
|
|
+ if (user.id != 0)
|
|
|
+ NavigatorUtil.goRankPeopleDetails(context, details: user);
|
|
|
},
|
|
|
);
|
|
|
}
|
|
|
|
|
|
Widget _buildRankItemWidget(int number, User data) {
|
|
|
+ // print("lib/assets/img/${rankImages[number]}")
|
|
|
return Column(
|
|
|
children: <Widget>[
|
|
|
InkWell(
|
|
|
onTap: () {
|
|
|
if (data is User) {
|
|
|
- if (data.id != 0) NavigatorUtil.goRankPeopleDetails(context, details: data);
|
|
|
+ if (data.id != 0)
|
|
|
+ NavigatorUtil.goRankPeopleDetails(context, details: data);
|
|
|
}
|
|
|
},
|
|
|
child: Container(
|
|
|
padding: EdgeInsets.symmetric(horizontal: 12.0, vertical: 6.0),
|
|
|
child: Row(
|
|
|
children: <Widget>[
|
|
|
- Container(
|
|
|
- width: 20,
|
|
|
- child: Text(
|
|
|
- "$number",
|
|
|
- style: Theme.of(context).textTheme.bodyText2,
|
|
|
- ),
|
|
|
- ),
|
|
|
+ _buildTitle(number, data.id != null),
|
|
|
Padding(
|
|
|
padding: const EdgeInsets.fromLTRB(0, 6, 10.0, 6),
|
|
|
- child: CircleAvatar(backgroundColor:Colors.transparent, backgroundImage: userAvatarProvider(data.userAvatar == null ? "" : data.userAvatar), radius: 22),
|
|
|
+ child: CircleAvatar(
|
|
|
+ backgroundColor: Colors.transparent,
|
|
|
+ backgroundImage: userAvatarProvider(
|
|
|
+ data.userAvatar == null ? "" : data.userAvatar),
|
|
|
+ radius: 22),
|
|
|
),
|
|
|
Expanded(
|
|
|
child: Text(
|
|
@@ -223,7 +313,7 @@ class _RankDetailPageState extends State<RankDetailPage> with InjectApi {
|
|
|
List<Widget> getRankItems() {
|
|
|
List<Widget> rankItems = [];
|
|
|
if (_data != null && _data.records != null) {
|
|
|
- for (var i = 3; i < _data.records.length; i++) {
|
|
|
+ for (var i = 0; i < _data.records.length; i++) {
|
|
|
var item = _data.records[i];
|
|
|
rankItems.add(_buildRankItemWidget(i + 1, item));
|
|
|
}
|
|
@@ -264,7 +354,8 @@ class _RankDetailPageState extends State<RankDetailPage> with InjectApi {
|
|
|
? _data.user.up != 0 && _data.user.upNew != 0
|
|
|
? Padding(
|
|
|
padding: EdgeInsets.only(right: 8),
|
|
|
- child: Image.asset("lib/assets/img/rand_icon_${_data.user.up >= 0 ? 'top' : 'down'}.png"),
|
|
|
+ child: Image.asset(
|
|
|
+ "lib/assets/img/rand_icon_${_data.user.up >= 0 ? 'top' : 'down'}.png"),
|
|
|
)
|
|
|
: Container()
|
|
|
: Container(),
|
|
@@ -275,7 +366,12 @@ class _RankDetailPageState extends State<RankDetailPage> with InjectApi {
|
|
|
return Row(
|
|
|
mainAxisSize: MainAxisSize.max,
|
|
|
children: <Widget>[
|
|
|
- CircleAvatar(backgroundImage: userAvatarProvider(model?.user?.avatar != null ? model.user.avatar : ""), radius: 22),
|
|
|
+ CircleAvatar(
|
|
|
+ backgroundImage: userAvatarProvider(
|
|
|
+ model?.user?.avatar != null
|
|
|
+ ? model.user.avatar
|
|
|
+ : ""),
|
|
|
+ radius: 22),
|
|
|
SizedBox(
|
|
|
width: 10,
|
|
|
),
|
|
@@ -295,7 +391,17 @@ class _RankDetailPageState extends State<RankDetailPage> with InjectApi {
|
|
|
),
|
|
|
),
|
|
|
),
|
|
|
- _data.user == null ? Text("暂无记录", style: Theme.of(context).textTheme.bodyText1,) : _data.rank.userCountMax < _data.user.position ? Text("暂未上榜", style: Theme.of(context).textTheme.bodyText1,) : _dataText(_data.rank, _data.user),
|
|
|
+ _data.user == null
|
|
|
+ ? Text(
|
|
|
+ "暂无记录",
|
|
|
+ style: Theme.of(context).textTheme.bodyText1,
|
|
|
+ )
|
|
|
+ : _data.rank.userCountMax < _data.user.position
|
|
|
+ ? Text(
|
|
|
+ "暂未上榜",
|
|
|
+ style: Theme.of(context).textTheme.bodyText1,
|
|
|
+ )
|
|
|
+ : _dataText(_data.rank, _data.user),
|
|
|
Container(
|
|
|
width: 12.0,
|
|
|
height: 14.0,
|
|
@@ -316,13 +422,19 @@ class _RankDetailPageState extends State<RankDetailPage> with InjectApi {
|
|
|
var unit = _dataUnit(rank);
|
|
|
if (rank != null) {
|
|
|
if (rank.field == null || rank.field == "") {
|
|
|
- return Text(user.score == null || user.score == 0 ? "" : "${user.score.toStringAsFixed(1)}$unit",
|
|
|
+ return Text(
|
|
|
+ user.score == null || user.score == 0
|
|
|
+ ? "暂无成绩"
|
|
|
+ : "${user.score.toStringAsFixed(1)}$unit",
|
|
|
style: TextStyle(color: Color.fromRGBO(255, 196, 0, 1)));
|
|
|
} else {
|
|
|
if (rank.field == 'consume') {
|
|
|
- return Text(user.consume == null ? "" : "${user.consume.round()}$unit", style: TextStyle(color: Color.fromRGBO(255, 196, 0, 1)));
|
|
|
+ return Text(
|
|
|
+ user.consume == null ? "" : "${user.consume.round()}$unit",
|
|
|
+ style: TextStyle(color: Color.fromRGBO(255, 196, 0, 1)));
|
|
|
} else if (rank.field == 'duration') {
|
|
|
- return Text(user.duration == null ? "" : "${user.duration}$unit", style: TextStyle(color: Color.fromRGBO(255, 196, 0, 1)));
|
|
|
+ return Text(user.duration == null ? "" : "${user.duration}$unit",
|
|
|
+ style: TextStyle(color: Color.fromRGBO(255, 196, 0, 1)));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -344,140 +456,185 @@ class _RankDetailPageState extends State<RankDetailPage> with InjectApi {
|
|
|
return "";
|
|
|
}
|
|
|
|
|
|
+ Widget _buildTitle(int number, bool isInRank) {
|
|
|
+ // 直接先未上榜的...
|
|
|
+ if (number > 10 || !isInRank)
|
|
|
+ return Container(
|
|
|
+ width: 40,
|
|
|
+ margin: EdgeInsets.fromLTRB(5, 0, 5, 0),
|
|
|
+ child: Text(
|
|
|
+ "未上榜",
|
|
|
+ style: Theme.of(context).textTheme.bodyText2.copyWith(fontSize: 11.0),
|
|
|
+ ),
|
|
|
+ );
|
|
|
+ // 这里是 看是 前三 还是后七
|
|
|
+ if (number <= rankImages.length - 1 && rankImages[number] != null)
|
|
|
+ return Container(
|
|
|
+ margin: EdgeInsets.fromLTRB(0, 0, 5, 0),
|
|
|
+ width: 25.0,
|
|
|
+ child: Image.asset("lib/assets/img/${rankImages[number]}"));
|
|
|
+ else {
|
|
|
+ return Container(
|
|
|
+ width: 20,
|
|
|
+ margin: EdgeInsets.fromLTRB(5, 0, 5, 0),
|
|
|
+ child: Text(
|
|
|
+ "$number",
|
|
|
+ style: Theme.of(context).textTheme.bodyText2,
|
|
|
+ ),
|
|
|
+ );
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@override
|
|
|
Widget build(BuildContext context) {
|
|
|
- return Scaffold(
|
|
|
- backgroundColor: Colors.white,
|
|
|
- body: SingleChildScrollView(
|
|
|
- child: Column(
|
|
|
- children: <Widget>[
|
|
|
- //header
|
|
|
- Stack(
|
|
|
- overflow: Overflow.visible,
|
|
|
- children: <Widget>[
|
|
|
- Container(
|
|
|
+ return AnnotatedRegion<SystemUiOverlayStyle>(
|
|
|
+ value: SystemUiOverlayStyle.light,
|
|
|
+ child: Scaffold(
|
|
|
+ backgroundColor: Colors.white,
|
|
|
+ body: Stack(
|
|
|
+ fit: StackFit.expand,
|
|
|
+ children: <Widget>[
|
|
|
+ Align(
|
|
|
+ alignment: Alignment.topCenter,
|
|
|
+ child: Container(
|
|
|
width: MediaQuery.of(context).size.width,
|
|
|
height: MediaQuery.of(context).size.width * 611 / 1125,
|
|
|
- decoration: BoxDecoration(image: DecorationImage(image: AssetImage("lib/assets/img/rank_bg.png"), fit: BoxFit.fill)),
|
|
|
+ decoration: BoxDecoration(
|
|
|
+ image: DecorationImage(
|
|
|
+ image: AssetImage("lib/assets/img/rank_bg.png"),
|
|
|
+ fit: BoxFit.cover)),
|
|
|
child: SafeArea(
|
|
|
child: Align(
|
|
|
alignment: Alignment.centerLeft,
|
|
|
child: Padding(
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 12),
|
|
|
- child: _data?.rank == null
|
|
|
- ? Container()
|
|
|
- : Column(
|
|
|
- crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
- mainAxisSize: MainAxisSize.min,
|
|
|
- children: <Widget>[
|
|
|
- Padding(
|
|
|
- padding: EdgeInsets.symmetric(vertical: 6.0),
|
|
|
- child: Text(
|
|
|
- "${_data.rank.name}",
|
|
|
- style: TextStyle(color: Colors.white, fontSize: 20, fontWeight: FontWeight.w600),
|
|
|
- ),
|
|
|
- ),
|
|
|
- Padding(
|
|
|
- padding: EdgeInsets.symmetric(vertical: 2.0),
|
|
|
- child: Text(
|
|
|
- "${_data.rank.introduce}",
|
|
|
- style: Theme.of(context).textTheme.bodyText1,
|
|
|
- ),
|
|
|
- ),
|
|
|
- Padding(
|
|
|
- padding: EdgeInsets.symmetric(vertical: 2.0),
|
|
|
- child: Text(
|
|
|
- "${_data.rank.rateBegin} ~ ${_data.rank.rateEnd}",
|
|
|
- style: Theme.of(context).textTheme.bodyText1,
|
|
|
- ),
|
|
|
- ),
|
|
|
- SizedBox(
|
|
|
- height: 10,
|
|
|
- )
|
|
|
- ],
|
|
|
- ),
|
|
|
+ child: Column(
|
|
|
+ crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
+ mainAxisSize: MainAxisSize.min,
|
|
|
+ children: <Widget>[],
|
|
|
+ ),
|
|
|
),
|
|
|
),
|
|
|
)),
|
|
|
- if (_data != null) getUserRank(),
|
|
|
- Positioned(
|
|
|
- left: 0.0,
|
|
|
- top: 0.0,
|
|
|
- child: SafeArea(
|
|
|
- child: IconButton(
|
|
|
- icon: Image.asset("lib/assets/img/topbar_return_white.png"),
|
|
|
- onPressed: () {
|
|
|
- Navigator.pop(context);
|
|
|
- },
|
|
|
- ),
|
|
|
- )),
|
|
|
+ ),
|
|
|
+ if (!_isLoading)
|
|
|
+ SafeArea(
|
|
|
+ child: Padding(
|
|
|
+ padding: EdgeInsets.fromLTRB(24.0, 36.0, 0, 0),
|
|
|
+ child: Column(
|
|
|
+ crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
+ mainAxisSize: MainAxisSize.min,
|
|
|
+ children: <Widget>[
|
|
|
+ Padding(
|
|
|
+ padding: EdgeInsets.symmetric(vertical: 6.0),
|
|
|
+ child: Text(
|
|
|
+ "${_data.rank.name}",
|
|
|
+ style: TextStyle(
|
|
|
+ color: Colors.white,
|
|
|
+ fontSize: 20,
|
|
|
+ fontWeight: FontWeight.w600),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ Padding(
|
|
|
+ padding: EdgeInsets.symmetric(vertical: 2.0),
|
|
|
+ child: Text(
|
|
|
+ "${_data.rank.introduce}",
|
|
|
+ style: Theme.of(context).textTheme.bodyText1,
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ GestureDetector(
|
|
|
+ onTap: (){
|
|
|
+ itemScrollController.scrollTo(index: _data?.user?.position??_data.records.length-1, duration: Duration(microseconds: 10));
|
|
|
+ },
|
|
|
+ child: Container(
|
|
|
+ margin: EdgeInsets.fromLTRB(0.0, 12.0, 0, 0),
|
|
|
+ child: Image.asset(
|
|
|
+ "lib/assets/img/rank_btn_myrank.png",
|
|
|
+ width: 103.0,
|
|
|
+ height: 28.0,
|
|
|
+ ))),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ if (_isLoading) Container(child: RequestLoadingWidget()),
|
|
|
+ Positioned(
|
|
|
+ left: 0.0,
|
|
|
+ top: 0.0,
|
|
|
+ child: SafeArea(
|
|
|
+ child: IconButton(
|
|
|
+ icon: Image.asset(
|
|
|
+ "lib/assets/img/topbar_return_white.png"),
|
|
|
+ onPressed: () {
|
|
|
+ Navigator.pop(context);
|
|
|
+ },
|
|
|
+ ),
|
|
|
+ )),
|
|
|
+ Positioned(
|
|
|
+ top: 0,
|
|
|
+ right: 0,
|
|
|
+ child: SafeArea(
|
|
|
+ child: IconButton(
|
|
|
+ icon: Image.asset("lib/assets/img/topbar_problom.png"),
|
|
|
+ onPressed: () {
|
|
|
+ if (_data == null) return;
|
|
|
+ NavigatorUtil.go(context,
|
|
|
+ "${Routes.rankIntroduce}?data=${Uri.encodeComponent(json.encode(_data))}");
|
|
|
+ },
|
|
|
+ ),
|
|
|
+ )),
|
|
|
+ if (!_isLoading)
|
|
|
Positioned(
|
|
|
- top: 0,
|
|
|
+ top: MediaQuery.of(context).size.width * 611 / 1125 - 10,
|
|
|
+ left: 0,
|
|
|
right: 0,
|
|
|
- child: SafeArea(
|
|
|
- child: IconButton(
|
|
|
- icon: Image.asset("lib/assets/img/topbar_problom.png"),
|
|
|
- onPressed: () {
|
|
|
- if(_data == null)
|
|
|
- return;
|
|
|
-
|
|
|
- NavigatorUtil.go(context, "${Routes.rankIntroduce}?data=${Uri.encodeComponent(json.encode(_data))}");
|
|
|
- },
|
|
|
- ),
|
|
|
+ bottom: 0,
|
|
|
+ child: CustomScrollView(
|
|
|
+ controller: _controller,
|
|
|
+ slivers: <Widget>[
|
|
|
+ SliverPersistentHeader(
|
|
|
+ delegate: PersistentHeader(
|
|
|
+ min: 60,
|
|
|
+ max: 60,
|
|
|
+ child: Container(
|
|
|
+ height: 80.0,
|
|
|
+ alignment: Alignment.center,
|
|
|
+ decoration: BoxDecoration(
|
|
|
+ borderRadius: BorderRadius.only(
|
|
|
+ topRight: Radius.circular(10.0),
|
|
|
+ topLeft: Radius.circular(10.0)),
|
|
|
+ color: Colors.white,
|
|
|
+ ),
|
|
|
+ padding:
|
|
|
+ EdgeInsets.only(bottom: 10, top: 10.0),
|
|
|
+ child: TabBar(
|
|
|
+ isScrollable: true,
|
|
|
+ indicatorPadding:
|
|
|
+ EdgeInsets.symmetric(horizontal: 8),
|
|
|
+ indicatorWeight: 3,
|
|
|
+ labelPadding:
|
|
|
+ EdgeInsets.symmetric(horizontal: 30),
|
|
|
+ controller: _tabController,
|
|
|
+ tabs:
|
|
|
+ _tabs.map((e) => Tab(text: e)).toList(),
|
|
|
+ ),
|
|
|
+ )),
|
|
|
+ pinned: true,
|
|
|
+ ),
|
|
|
+ SliverFillRemaining(
|
|
|
+ child: ScrollablePositionedList.builder(
|
|
|
+ itemCount: _data.records.length,
|
|
|
+ itemBuilder: (context, index) {
|
|
|
+ return _buildRankItemWidget(
|
|
|
+ index + 1, _data.records[index]);
|
|
|
+ },
|
|
|
+ itemScrollController: itemScrollController,
|
|
|
+ itemPositionsListener: itemPositionsListener,
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ],
|
|
|
))
|
|
|
- ],
|
|
|
- ),
|
|
|
- if (!_isLoading)
|
|
|
- Padding(
|
|
|
- padding: const EdgeInsets.only(top: 50.0),
|
|
|
- child: Row(
|
|
|
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
- children: <Widget>[
|
|
|
- Consumer<UserModel>(
|
|
|
- builder: (_, model, __) => model.user.city == null || _rank == "全国榜" || _rank == null
|
|
|
- ? Container()
|
|
|
- : Container(
|
|
|
- padding: EdgeInsets.symmetric(horizontal: 12.0),
|
|
|
- child: Row(
|
|
|
- children: <Widget>[
|
|
|
- Image.asset("lib/assets/img/rank_icon_position.png"),
|
|
|
- SizedBox(
|
|
|
- width: 6,
|
|
|
- ),
|
|
|
- Text(
|
|
|
- "${_rank == '全省榜' ? model.user?.province : model.user?.city}",
|
|
|
- style: Theme.of(context).textTheme.bodyText2,
|
|
|
- )
|
|
|
- ],
|
|
|
- ),
|
|
|
- ),
|
|
|
- ),
|
|
|
- NotificationListener<AreaNotification>(
|
|
|
- onNotification: (n) {
|
|
|
- _rank = n.rank;
|
|
|
- area(n.all, n.province, n.provinceId, n.cityId);
|
|
|
- return true;
|
|
|
- },
|
|
|
- child: AreaPage(
|
|
|
- area: _rank,
|
|
|
- ),
|
|
|
- )
|
|
|
- ],
|
|
|
- ),
|
|
|
- ),
|
|
|
- if (_isLoading)
|
|
|
- Container(child: RequestLoadingWidget()),
|
|
|
- if (!_isLoading)
|
|
|
- Padding(
|
|
|
- padding: EdgeInsets.only(top: 12.0),
|
|
|
- child: _buildRankWidget(),
|
|
|
- ),
|
|
|
- if (!_isLoading)
|
|
|
- Column(
|
|
|
- children: getRankItems(),
|
|
|
- )
|
|
|
- ],
|
|
|
- ),
|
|
|
- ));
|
|
|
+ ],
|
|
|
+ )));
|
|
|
}
|
|
|
}
|