@@ -2,6 +2,7 @@ import 'dart:async';
22
33import 'package:flutter/material.dart' ;
44import 'package:flutter/rendering.dart' ;
5+ import 'package:gsy_github_app_flutter/common/dao/repos_dao.dart' ;
56import 'package:gsy_github_app_flutter/common/dao/user_dao.dart' ;
67import 'package:gsy_github_app_flutter/common/model/Event.dart' ;
78import 'package:gsy_github_app_flutter/common/model/User.dart' ;
@@ -14,6 +15,7 @@ import 'package:gsy_github_app_flutter/widget/pull/nested/nested_refresh.dart';
1415import 'package:gsy_github_app_flutter/widget/state/gsy_list_state.dart' ;
1516import 'package:gsy_github_app_flutter/widget/user_header.dart' ;
1617import 'package:gsy_github_app_flutter/widget/user_item.dart' ;
18+ import 'package:provider/provider.dart' ;
1719
1820/**
1921 * Created by guoshuyu
@@ -30,6 +32,8 @@ abstract class BasePersonState<T extends StatefulWidget> extends State<T>
3032
3133 final List <UserOrg > orgList = new List ();
3234
35+ final HonorModel honorModel = HonorModel ();
36+
3337 @override
3438 showRefreshLoading () {
3539 new Future .delayed (const Duration (seconds: 0 ), () {
@@ -95,7 +99,8 @@ abstract class BasePersonState<T extends StatefulWidget> extends State<T>
9599 User userInfo, Color notifyColor, String beStaredCount, refreshCallBack) {
96100 double headerSize = 210 ;
97101 double bottomSize = 70 ;
98- double chartSize = (userInfo.login != null && userInfo.type == "Organization" ) ? 70 : 215 ;
102+ double chartSize =
103+ (userInfo.login != null && userInfo.type == "Organization" ) ? 70 : 215 ;
99104 return < Widget > [
100105 ///头部信息
101106 SliverPersistentHeader (
@@ -145,7 +150,18 @@ abstract class BasePersonState<T extends StatefulWidget> extends State<T>
145150 return SizedBox .expand (
146151 child: Padding (
147152 padding: EdgeInsets .only (bottom: 10 , left: 0 , right: 0 ),
148- child: UserHeaderBottom (userInfo, beStaredCount, radius),
153+ /// MultiProvider 共享 HonorModel 状态
154+ child: MultiProvider (
155+ providers: [
156+ ChangeNotifierProvider (builder: (_) => honorModel),
157+ ],
158+ child: Consumer <HonorModel >(
159+ builder: (context, honorModel, _) {
160+ return UserHeaderBottom (userInfo,
161+ honorModel.beStaredCount? .toString () ?? "---" , radius, honorModel.honorList);
162+ },
163+ ),
164+ ),
149165 ),
150166 );
151167 }),
@@ -174,4 +190,38 @@ abstract class BasePersonState<T extends StatefulWidget> extends State<T>
174190 ),
175191 ];
176192 }
193+
194+ ///获取用户仓库前100个star统计数据
195+ getHonor (name) {
196+ ReposDao .getUserRepository100StatusDao (name).then ((res) {
197+ if (res != null && res.result) {
198+ if (isShow) {
199+ ///提交到 Provider HonorMode
200+ honorModel.beStaredCount = res.data["stared" ];
201+ honorModel.honorList = res.data["list" ];
202+ }
203+ }
204+ });
205+ }
206+ }
207+
208+ /// Provider HonorModel
209+ class HonorModel extends ChangeNotifier {
210+ int _beStaredCount;
211+
212+ int get beStaredCount => _beStaredCount;
213+
214+ set beStaredCount (int value) {
215+ _beStaredCount = value;
216+ notifyListeners ();
217+ }
218+
219+ List _honorList;
220+
221+ List get honorList => _honorList;
222+
223+ set honorList (List value) {
224+ _honorList = value;
225+ notifyListeners ();
226+ }
177227}
0 commit comments