Browse Source

fix:v1.3.1版本的UI

Primroses 3 years ago
parent
commit
f8a24315f4

BIN
lib/assets/img/rand_bg_consume.png


BIN
lib/assets/img/rank_bg_my.png


+ 140 - 52
lib/pages/game/rank_detail.dart

@@ -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,

+ 9 - 3
lib/pages/my/score_shop.dart

@@ -10,6 +10,8 @@ import 'package:sport/provider/shop_model.dart';
 import 'package:sport/provider/user_friend_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/utils/toast.dart';
 import 'package:sport/widgets/appbar.dart';
 import 'package:sport/widgets/button_primary.dart';
 import 'package:sport/widgets/space.dart';
@@ -23,7 +25,7 @@ class ScoreShopPage extends StatefulWidget {
 }
 
 class _ScoreShopPageState extends ViewStateLifecycle<ScoreShopPage, ShopModel>
-    with ChangeNotifier {
+    with ChangeNotifier,InjectApi  {
   @override
   ShopModel createModel() {
     // TODO: implement createModel
@@ -87,7 +89,7 @@ class _ScoreShopPageState extends ViewStateLifecycle<ScoreShopPage, ShopModel>
                           },
                         ),
                         Text(
-                          "积分商城",
+                          "",
                           style: TextStyle(
                               color: Colors.white,
                               fontSize: 18,
@@ -308,7 +310,11 @@ class _ScoreShopPageState extends ViewStateLifecycle<ScoreShopPage, ShopModel>
                                       padding: EdgeInsets.fromLTRB(
                                           15.0, 0, 15.0, 15.0),
                                       child: PrimaryButton(
-                                        callback: () {},
+                                        callback: () async {
+                                          // print("${item.id}-----------------------------");
+                                          var data = (await api.buyItem('${item.id}'));
+                                          ToastUtil.show("${data.msg}");
+                                        },
                                         content: "兑换",
                                         height: 35.0,
                                       ),

+ 3 - 0
lib/services/api/rest_client.dart

@@ -364,4 +364,7 @@ abstract class RestClient {
 
   @GET("/score/record")
   Future<RespData<ScoreList>> getScoreIndex();
+
+  @POST("/shop/buy")
+  Future<RespData<String>> buyItem(@Query("item_id") String id,);
 }

+ 19 - 0
lib/services/api/rest_client.g.dart

@@ -1991,6 +1991,25 @@ class _RestClient implements RestClient {
     return value;
   }
 
+  @override
+  buyItem(id) async {
+    ArgumentError.checkNotNull(id, 'id');
+    const _extra = <String, dynamic>{};
+    final queryParameters = <String, dynamic>{r'item_id': id};
+    final _data = <String, dynamic>{};
+    final Response<Map<String, dynamic>> _result = await _dio.request(
+        '/shop/buy',
+        queryParameters: queryParameters,
+        options: RequestOptions(
+            method: 'POST',
+            headers: <String, dynamic>{},
+            extra: _extra,
+            baseUrl: baseUrl),
+        data: _data);
+    final value = RespData<String>.fromJson(_result.data);
+    return value;
+  }
+
   RequestOptions newRequestOptions(Options options) {
     if (options is RequestOptions) {
       return options;

+ 3 - 1
lib/widgets/appbar.dart

@@ -92,7 +92,7 @@ Widget buildBackButton(BuildContext context) {
   );
 }
 
-Widget buildAppBar(BuildContext context, {String title, List<Widget> actions}) {
+Widget buildAppBar(BuildContext context, {String title, List<Widget> actions,Brightness brightness}) {
   return AppBar(
     titleSpacing: -16.0,
     centerTitle: false,
@@ -104,5 +104,7 @@ Widget buildAppBar(BuildContext context, {String title, List<Widget> actions}) {
           ),
     leading: buildBackButton(context),
     actions: actions,
+    brightness: brightness,
+    // backgroundColor: Colors.black,
   );
 }