11import 'dart:async' ;
22
33import 'package:flutter/material.dart' ;
4+ import 'package:fluttertoast/fluttertoast.dart' ;
45import 'package:gsy_github_app_flutter/common/dao/EventDao.dart' ;
56import 'package:gsy_github_app_flutter/common/dao/ReposDao.dart' ;
67import 'package:gsy_github_app_flutter/common/dao/UserDao.dart' ;
78import 'package:gsy_github_app_flutter/common/model/User.dart' ;
9+ import 'package:gsy_github_app_flutter/common/style/GSYStyle.dart' ;
810import 'package:gsy_github_app_flutter/common/utils/CommonUtils.dart' ;
11+ import 'package:gsy_github_app_flutter/common/utils/NavigatorUtils.dart' ;
912import 'package:gsy_github_app_flutter/widget/EventItem.dart' ;
1013import 'package:gsy_github_app_flutter/widget/GSYListState.dart' ;
1114import 'package:gsy_github_app_flutter/widget/GSYPullLoadWidget.dart' ;
1215import 'package:gsy_github_app_flutter/widget/UserHeader.dart' ;
16+ import 'package:gsy_github_app_flutter/widget/UserItem.dart' ;
1317
1418/**
1519 * 个人详情
@@ -56,7 +60,7 @@ class _PersonState extends GSYListState<PersonPage> {
5660 } else {
5761 return null ;
5862 }
59- var res = await EventDao . getEventDao ( _getUserName (), page : page );
63+ var res = await _getDataLogic ( );
6064 if (res != null && res.result) {
6165 pullLoadWidgetControl.dataList.clear ();
6266 setState (() {
@@ -79,7 +83,7 @@ class _PersonState extends GSYListState<PersonPage> {
7983 _getFocusStatus () async {
8084 var focusRes = await UserDao .checkFollowDao (userName);
8185 setState (() {
82- focus = (focusRes != null && focusRes.result) ? "已关注" : "关注" ;
86+ focus = (focusRes != null && focusRes.result) ? GSYStrings .user_focus : GSYStrings .user_un_focus ;
8387 focusStatus = (focusRes != null && focusRes.result);
8488 });
8589 }
@@ -88,7 +92,13 @@ class _PersonState extends GSYListState<PersonPage> {
8892 if (index == 0 ) {
8993 return new UserHeaderItem (userInfo, beStaredCount);
9094 }
91- return new EventItem (pullLoadWidgetControl.dataList[index - 1 ]);
95+ if (userInfo.type == "Organization" ) {
96+ return new UserItem (pullLoadWidgetControl.dataList[index - 1 ], onPressed: () {
97+ NavigatorUtils .goPerson (context, pullLoadWidgetControl.dataList[index - 1 ].userName);
98+ });
99+ } else {
100+ return new EventItem (pullLoadWidgetControl.dataList[index - 1 ]);
101+ }
92102 }
93103
94104 _getUserName () {
@@ -98,6 +108,13 @@ class _PersonState extends GSYListState<PersonPage> {
98108 return userInfo.login;
99109 }
100110
111+ _getDataLogic () async {
112+ if (userInfo.type == "Organization" ) {
113+ return await UserDao .getMemberDao (_getUserName (), page);
114+ }
115+ return await EventDao .getEventDao (_getUserName (), page: page);
116+ }
117+
101118 @override
102119 bool get wantKeepAlive => true ;
103120
@@ -106,7 +123,7 @@ class _PersonState extends GSYListState<PersonPage> {
106123
107124 @override
108125 requestLoadMore () async {
109- return await EventDao . getEventDao ( _getUserName (), page : page );
126+ return await _getDataLogic ( );
110127 }
111128
112129 @override
@@ -127,6 +144,10 @@ class _PersonState extends GSYListState<PersonPage> {
127144 if (focus == '' ) {
128145 return ;
129146 }
147+ if (userInfo.type == "Organization" ) {
148+ Fluttertoast .showToast (msg: GSYStrings .user_focus_no_support);
149+ return ;
150+ }
130151 CommonUtils .showLoadingDialog (context);
131152 UserDao .doFollowDao (userName, focusStatus).then ((res) {
132153 Navigator .pop (context);
0 commit comments