|
@@ -1,6 +1,7 @@
|
|
|
import 'dart:convert';
|
|
|
import 'dart:io';
|
|
|
|
|
|
+import 'package:cached_network_image/cached_network_image.dart';
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
import 'package:flutter/material.dart';
|
|
|
import 'package:flutter/services.dart';
|
|
@@ -12,6 +13,7 @@ import 'package:sport/provider/user_model.dart';
|
|
|
import 'package:sport/router/navigator_util.dart';
|
|
|
import 'package:sport/router/routes.dart';
|
|
|
import 'package:sport/services/api/inject_api.dart';
|
|
|
+import 'package:sport/services/userid.dart';
|
|
|
import 'package:sport/widgets/area.dart';
|
|
|
import 'package:sport/widgets/decoration.dart';
|
|
|
import 'package:sport/widgets/image.dart';
|
|
@@ -34,7 +36,7 @@ class RankDetailPage extends StatefulWidget {
|
|
|
}
|
|
|
|
|
|
class _RankDetailPageState extends State<RankDetailPage>
|
|
|
- with TickerProviderStateMixin, InjectApi {
|
|
|
+ with TickerProviderStateMixin, InjectApi, UserId {
|
|
|
bool _isLoading;
|
|
|
RankGameInfoData _data;
|
|
|
String _id;
|
|
@@ -70,17 +72,22 @@ class _RankDetailPageState extends State<RankDetailPage>
|
|
|
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;
|
|
|
+ String _scope = _tabController.index == 0 ? "world" : "friend";
|
|
|
+ if (widget.type == "1") {
|
|
|
+ _data = (await api.getRankGameInfo(widget.id, scope: _scope)).data;
|
|
|
+ }else{
|
|
|
+ _data = (await api.getRankSportInfo(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")));
|
|
|
+ userName: prefs.getString("name"),
|
|
|
+ userAvatar: prefs.getString("avatar"),
|
|
|
+ ));
|
|
|
}
|
|
|
+ // 忘了空set 一手...
|
|
|
+ setState(() {});
|
|
|
});
|
|
|
}
|
|
|
|
|
@@ -102,7 +109,9 @@ class _RankDetailPageState extends State<RankDetailPage>
|
|
|
} else if (data.data.user == null) {
|
|
|
_data.records.add(new User(
|
|
|
userName: prefs.getString("name"),
|
|
|
- userAvatar: prefs.getString("avatar")));
|
|
|
+ userAvatar: prefs.getString("avatar"),
|
|
|
+ userId: int.parse(selfId),
|
|
|
+ ));
|
|
|
}
|
|
|
_isLoading = false;
|
|
|
});
|
|
@@ -272,11 +281,18 @@ class _RankDetailPageState extends State<RankDetailPage>
|
|
|
InkWell(
|
|
|
onTap: () {
|
|
|
if (data is User) {
|
|
|
- if (data.id != 0)
|
|
|
+ if (data.id != 0 && data.duration != null)
|
|
|
NavigatorUtil.goRankPeopleDetails(context, details: data);
|
|
|
}
|
|
|
},
|
|
|
child: Container(
|
|
|
+ decoration: data.userId == int.parse(selfId) || data.userId == null
|
|
|
+ ? BoxDecoration(
|
|
|
+ image: DecorationImage(
|
|
|
+ image: AssetImage("lib/assets/img/rank_bg_my.png"),
|
|
|
+ ),
|
|
|
+ )
|
|
|
+ : null,
|
|
|
padding: EdgeInsets.symmetric(horizontal: 12.0, vertical: 6.0),
|
|
|
child: Row(
|
|
|
children: <Widget>[
|
|
@@ -336,7 +352,22 @@ class _RankDetailPageState extends State<RankDetailPage>
|
|
|
child: Container(
|
|
|
width: MediaQuery.of(context).size.width * 0.95,
|
|
|
height: 72.0,
|
|
|
- decoration: card(),
|
|
|
+ decoration: BoxDecoration(
|
|
|
+ // color: Colors.white, // 底色
|
|
|
+ borderRadius:
|
|
|
+ new BorderRadius.all(Radius.circular(10.0)), // 也可控件一边圆角大小
|
|
|
+ boxShadow: [
|
|
|
+ BoxShadow(
|
|
|
+ offset: Offset(0.0, 0),
|
|
|
+ blurRadius: 7,
|
|
|
+ spreadRadius: 0,
|
|
|
+ color: Color.fromRGBO(0, 0, 0, 0.07))
|
|
|
+ ],
|
|
|
+ image: _data.user != null
|
|
|
+ ? DecorationImage(
|
|
|
+ image: AssetImage("lib/assets/img/rank_bg_my.png"),
|
|
|
+ )
|
|
|
+ : null),
|
|
|
child: Padding(
|
|
|
padding: EdgeInsets.symmetric(horizontal: 12.0),
|
|
|
child: Row(
|
|
@@ -487,6 +518,11 @@ class _RankDetailPageState extends State<RankDetailPage>
|
|
|
|
|
|
@override
|
|
|
Widget build(BuildContext context) {
|
|
|
+ // if(_data?.records?.length != null){
|
|
|
+ // for(var i = 0;i<_data.records.length;i++){
|
|
|
+ // print("${_data.records[i].toJson()}-=============-=-=-=-=-=-=-=-=-=-=-=-=-=-");
|
|
|
+ // }
|
|
|
+ // }
|
|
|
return AnnotatedRegion<SystemUiOverlayStyle>(
|
|
|
value: SystemUiOverlayStyle.light,
|
|
|
child: Scaffold(
|
|
@@ -498,11 +534,18 @@ class _RankDetailPageState extends State<RankDetailPage>
|
|
|
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.cover)),
|
|
|
+ height: _data?.rank?.isGame != 1
|
|
|
+ ? MediaQuery.of(context).size.width * 611 / 1125
|
|
|
+ : MediaQuery.of(context).size.width * 500 / 750,
|
|
|
+ decoration: _data?.rank?.isGame == null
|
|
|
+ ? null
|
|
|
+ : BoxDecoration(
|
|
|
+ image: DecorationImage(
|
|
|
+ image: _data?.rank?.isGame != 1
|
|
|
+ ? AssetImage("lib/assets/img/rank_bg.png")
|
|
|
+ : AssetImage(
|
|
|
+ "lib/assets/img/rand_bg_consume.png"),
|
|
|
+ fit: BoxFit.cover)),
|
|
|
child: SafeArea(
|
|
|
child: Align(
|
|
|
alignment: Alignment.centerLeft,
|
|
@@ -518,45 +561,88 @@ class _RankDetailPageState extends State<RankDetailPage>
|
|
|
)),
|
|
|
),
|
|
|
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),
|
|
|
+ _data?.rank?.isGame != 1
|
|
|
+ ? 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 != null ? _data.user.position - 1 :
|
|
|
+ _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,
|
|
|
+ ))),
|
|
|
+ ],
|
|
|
),
|
|
|
),
|
|
|
- Padding(
|
|
|
- padding: EdgeInsets.symmetric(vertical: 2.0),
|
|
|
- child: Text(
|
|
|
- "${_data.rank.introduce}",
|
|
|
- style: Theme.of(context).textTheme.bodyText1,
|
|
|
- ),
|
|
|
+ )
|
|
|
+ : SafeArea(
|
|
|
+ child: Column(
|
|
|
+ children: <Widget>[
|
|
|
+ Padding(
|
|
|
+ padding: EdgeInsets.only(top: 16.0),
|
|
|
+ child: ClipRRect(
|
|
|
+ borderRadius: BorderRadius.circular(8),
|
|
|
+ child: CachedNetworkImage(
|
|
|
+ imageUrl: _data.rank.logo,
|
|
|
+ width: 100,
|
|
|
+ height: 100))),
|
|
|
+ Padding(
|
|
|
+ padding: EdgeInsets.only(top: 10.0),
|
|
|
+ child: Text(
|
|
|
+ "${_data.rank.name}",
|
|
|
+ style: TextStyle(
|
|
|
+ fontSize: 16.0, color: Color(0xffffffff)),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ GestureDetector(
|
|
|
+ onTap: () {
|
|
|
+ itemScrollController.scrollTo(
|
|
|
+ index: _data?.user?.position != null ? _data.user.position - 1 :
|
|
|
+ _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,
|
|
|
+ ))),
|
|
|
+ ],
|
|
|
),
|
|
|
- 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,
|
|
@@ -585,7 +671,9 @@ class _RankDetailPageState extends State<RankDetailPage>
|
|
|
)),
|
|
|
if (!_isLoading)
|
|
|
Positioned(
|
|
|
- top: MediaQuery.of(context).size.width * 611 / 1125 - 10,
|
|
|
+ top: _data?.rank?.isGame != 1
|
|
|
+ ? MediaQuery.of(context).size.width * 611 / 1125 - 10
|
|
|
+ : MediaQuery.of(context).size.width * 500 / 750 - 10,
|
|
|
left: 0,
|
|
|
right: 0,
|
|
|
bottom: 0,
|