@@ -2,11 +2,13 @@ import 'package:flutter/material.dart';
22import 'package:flutter_spinkit/flutter_spinkit.dart' ;
33import 'package:flutter_svg/flutter_svg.dart' ;
44import 'package:gsy_github_app_flutter/common/model/User.dart' ;
5+ import 'package:gsy_github_app_flutter/common/model/UserOrg.dart' ;
56import 'package:gsy_github_app_flutter/common/style/GSYStyle.dart' ;
67import 'package:gsy_github_app_flutter/common/utils/CommonUtils.dart' ;
78import 'package:gsy_github_app_flutter/common/utils/NavigatorUtils.dart' ;
89import 'package:gsy_github_app_flutter/widget/GSYCardItem.dart' ;
910import 'package:gsy_github_app_flutter/widget/GSYIConText.dart' ;
11+ import 'package:gsy_github_app_flutter/widget/GSYUserIconWidget.dart' ;
1012
1113/**
1214 * 用户详情头部
@@ -22,12 +24,16 @@ class UserHeaderItem extends StatelessWidget {
2224
2325 final VoidCallback refreshCallBack;
2426
25- UserHeaderItem (this .userInfo, this .beStaredCount, {this .notifyColor, this .refreshCallBack});
27+ final List <UserOrg > orgList;
28+
29+ UserHeaderItem (this .userInfo, this .beStaredCount, {this .notifyColor, this .refreshCallBack, this .orgList});
2630
2731 ///底部状态栏
2832 _getBottomItem (String title, var value, onPressed) {
2933 String data = value == null ? "" : value.toString ();
30- TextStyle valueStyle = (value != null && value.toString ().length > 4 ) ? GSYConstant .minSmallText : GSYConstant .subSmallText;
34+ TextStyle valueStyle = (value != null && value
35+ .toString ()
36+ .length > 4 ) ? GSYConstant .minSmallText : GSYConstant .subSmallText;
3137 return new Expanded (
3238 child: new Center (
3339 child: new FlatButton (
@@ -70,46 +76,92 @@ class UserHeaderItem extends StatelessWidget {
7076 });
7177 }
7278
79+ ///用户组织
80+ _renderOrgs (BuildContext context, List <UserOrg > orgList) {
81+ if (orgList == null || orgList.length == 0 ) {
82+ return new Container ();
83+ }
84+ List <Widget > list = new List ();
85+
86+ renderOrgsItem (UserOrg orgs) {
87+ return GSYUserIconWidget (
88+ padding: const EdgeInsets .only (right: 5.0 , left: 5.0 ),
89+ width: 30.0 ,
90+ height: 30.0 ,
91+ image: orgs.avatarUrl ?? GSYICons .DEFAULT_REMOTE_PIC ,
92+ onPressed: () {
93+ NavigatorUtils .goPerson (context, orgs.login);
94+ });
95+ }
96+
97+ int length = orgList.length > 3 ? 3 : orgList.length;
98+
99+ list.add (new Text (GSYStrings .user_orgs_title + ":" , style: GSYConstant .subLightSmallText));
100+
101+ for (int i = 0 ; i < length; i++ ) {
102+ list.add (renderOrgsItem (orgList[i]));
103+ }
104+ if (orgList.length > 3 ) {
105+ list.add (new RawMaterialButton (
106+ onPressed: () {
107+ NavigatorUtils .gotoCommonList (context, userInfo.login + " " + GSYStrings .user_orgs_title, "org" , "user_orgs" , userName: userInfo.login);
108+ },
109+ materialTapTargetSize: MaterialTapTargetSize .shrinkWrap,
110+ padding: const EdgeInsets .only (right: 5.0 , left: 5.0 ),
111+ constraints: const BoxConstraints (minWidth: 0.0 , minHeight: 0.0 ),
112+ child: Icon (
113+ Icons .more_horiz,
114+ color: Color (GSYColors .white),
115+ size: 18.0 ,
116+ )));
117+ }
118+ return Row (children: list);
119+ }
120+
73121 _renderChart (context) {
74122 double height = 140.0 ;
75- double width = 3 * MediaQuery .of (context).size.width / 2 ;
76- if (userInfo.login != null && userInfo.type == "Organization" ) {
123+ double width = 3 * MediaQuery
124+ .of (context)
125+ .size
126+ .width / 2 ;
127+ if (userInfo.login != null && userInfo.type == "Organization" ) {
77128 return new Container ();
78129 }
79130 return (userInfo.login != null )
80131 ? new Card (
81- margin: EdgeInsets .only (top: 0.0 , left: 10.0 , right: 10.0 , bottom: 10.0 ),
82- color: Colors .white,
83- child: new SingleChildScrollView (
84- scrollDirection: Axis .horizontal,
85- child: new Container (
86- padding: EdgeInsets .only (left: 10.0 , right: 10.0 ),
87- width: width,
88- height: height,
132+ margin: EdgeInsets .only (top: 0.0 , left: 10.0 , right: 10.0 , bottom: 10.0 ),
133+ color: Colors .white,
134+ child: new SingleChildScrollView (
135+ scrollDirection: Axis .horizontal,
136+ child: new Container (
137+ padding: EdgeInsets .only (left: 10.0 , right: 10.0 ),
138+ width: width,
139+ height: height,
89140
90- ///svg chart
91- child: new SvgPicture .network (
92- CommonUtils .getUserChartAddress (userInfo.login),
93- width: width,
94- height: height - 10 ,
95- allowDrawingOutsideViewBox: true ,
96- placeholderBuilder: (BuildContext context) => new Container (
97- height: height,
98- width: width,
99- child: Center (
100- child: const SpinKitRipple (color: Color (GSYColors .primaryValue)),
101- ),
102- ),
103- ),
141+ ///svg chart
142+ child: new SvgPicture .network (
143+ CommonUtils .getUserChartAddress (userInfo.login),
144+ width: width,
145+ height: height - 10 ,
146+ allowDrawingOutsideViewBox: true ,
147+ placeholderBuilder: (BuildContext context) =>
148+ new Container (
149+ height: height,
150+ width: width,
151+ child: Center (
152+ child: const SpinKitRipple (color: Color (GSYColors .primaryValue)),
104153 ),
105154 ),
106- )
155+ ),
156+ ),
157+ ),
158+ )
107159 : new Container (
108- height: height,
109- child: Center (
110- child: const SpinKitRipple (color: Color (GSYColors .primaryValue)),
111- ),
112- );
160+ height: height,
161+ child: Center (
162+ child: const SpinKitRipple (color: Color (GSYColors .primaryValue)),
163+ ),
164+ );
113165 }
114166
115167 @override
@@ -129,6 +181,7 @@ class UserHeaderItem extends StatelessWidget {
129181 new Row (
130182 crossAxisAlignment: CrossAxisAlignment .start,
131183 children: < Widget > [
184+
132185 ///用户头像
133186 new RawMaterialButton (
134187 onPressed: () {
@@ -156,6 +209,7 @@ class UserHeaderItem extends StatelessWidget {
156209 children: < Widget > [
157210 new Row (
158211 children: < Widget > [
212+
159213 ///用户名
160214 new Text (userInfo.login ?? "" , style: GSYConstant .largeTextWhiteBold),
161215 _getNotifyIcon (context, notifyColor),
@@ -189,7 +243,7 @@ class UserHeaderItem extends StatelessWidget {
189243 ),
190244 new Container (
191245
192- ///用户博客
246+ ///用户博客
193247 child: new RawMaterialButton (
194248 onPressed: () {
195249 if (userInfo.blog != null ) {
@@ -211,6 +265,9 @@ class UserHeaderItem extends StatelessWidget {
211265 margin: new EdgeInsets .only (top: 6.0 , bottom: 2.0 ),
212266 alignment: Alignment .topLeft),
213267
268+ ///组织
269+ _renderOrgs (context, orgList),
270+
214271 ///用户描述
215272 new Container (
216273 child: new Text (
@@ -233,39 +290,40 @@ class UserHeaderItem extends StatelessWidget {
233290 _getBottomItem (
234291 GSYStrings .user_tab_repos,
235292 userInfo.public_repos,
236- () {
293+ () {
237294 NavigatorUtils .gotoCommonList (context, userInfo.login, "repository" , "user_repos" , userName: userInfo.login);
238295 },
239296 ),
240297 new Container (width: 0.3 , height: 40.0 , color: Color (GSYColors .subLightTextColor)),
241298 _getBottomItem (
242299 GSYStrings .user_tab_fans,
243300 userInfo.followers,
244- () {
301+ () {
245302 NavigatorUtils .gotoCommonList (context, userInfo.login, "user" , "follower" , userName: userInfo.login);
246303 },
247304 ),
248305 new Container (width: 0.3 , height: 40.0 , color: Color (GSYColors .subLightTextColor)),
249306 _getBottomItem (
250307 GSYStrings .user_tab_focus,
251308 userInfo.following,
252- () {
309+ () {
253310 NavigatorUtils .gotoCommonList (context, userInfo.login, "user" , "followed" , userName: userInfo.login);
254311 },
255312 ),
256313 new Container (width: 0.3 , height: 40.0 , color: Color (GSYColors .subLightTextColor)),
257314 _getBottomItem (
258315 GSYStrings .user_tab_star,
259316 userInfo.starred,
260- () {
317+ () {
261318 NavigatorUtils .gotoCommonList (context, userInfo.login, "repository" , "user_star" , userName: userInfo.login);
262319 },
263320 ),
264321 new Container (width: 0.3 , height: 40.0 , color: Color (GSYColors .subLightTextColor)),
265322 _getBottomItem (
266323 GSYStrings .user_tab_honor,
267324 beStaredCount,
268- () {},
325+ () {
326+ },
269327 ),
270328 ],
271329 ),
0 commit comments