@@ -5,6 +5,7 @@ import 'package:gsy_github_app_flutter/common/dao/EventDao.dart';
55import 'package:gsy_github_app_flutter/common/dao/ReposDao.dart' ;
66import 'package:gsy_github_app_flutter/common/dao/UserDao.dart' ;
77import 'package:gsy_github_app_flutter/common/model/User.dart' ;
8+ import 'package:gsy_github_app_flutter/common/utils/CommonUtils.dart' ;
89import 'package:gsy_github_app_flutter/widget/EventItem.dart' ;
910import 'package:gsy_github_app_flutter/widget/GSYListState.dart' ;
1011import 'package:gsy_github_app_flutter/widget/GSYPullLoadWidget.dart' ;
@@ -27,11 +28,14 @@ class PersonPage extends StatefulWidget {
2728}
2829
2930class _PersonState extends GSYListState <PersonPage > {
30-
3131 final String userName;
3232
3333 String beStaredCount = "---" ;
3434
35+ bool focusStatus = false ;
36+
37+ String focus = "" ;
38+
3539 User userInfo = User .empty ();
3640
3741 _PersonState (this .userName);
@@ -61,7 +65,7 @@ class _PersonState extends GSYListState<PersonPage> {
6165 }
6266 resolveDataResult (res);
6367 isLoading = false ;
64-
68+ _getFocusStatus ();
6569 ReposDao .getUserRepository100StatusDao (_getUserName ()).then ((res) {
6670 if (res != null && res.result) {
6771 setState (() {
@@ -72,6 +76,13 @@ class _PersonState extends GSYListState<PersonPage> {
7276 return null ;
7377 }
7478
79+ _getFocusStatus () async {
80+ var focusRes = await UserDao .checkFollowDao (userName);
81+ setState (() {
82+ focus = (focusRes != null && focusRes.result) ? "已关注" : "关注" ;
83+ focusStatus = (focusRes != null && focusRes.result);
84+ });
85+ }
7586
7687 _renderEventItem (index) {
7788 if (index == 0 ) {
@@ -90,10 +101,8 @@ class _PersonState extends GSYListState<PersonPage> {
90101 @override
91102 bool get wantKeepAlive => true ;
92103
93-
94104 @override
95- requestRefresh () async {
96- }
105+ requestRefresh () async {}
97106
98107 @override
99108 requestLoadMore () async {
@@ -106,20 +115,30 @@ class _PersonState extends GSYListState<PersonPage> {
106115 @override
107116 bool get needHeader => true ;
108117
109-
110118 @override
111119 Widget build (BuildContext context) {
112120 return new Scaffold (
113121 appBar: new AppBar (
114122 title: new Text ((userInfo != null && userInfo.login != null ) ? userInfo.login : "" ),
115123 ),
124+ floatingActionButton: new FloatingActionButton (
125+ child: new Text (focus),
126+ onPressed: () {
127+ if (focus == '' ) {
128+ return ;
129+ }
130+ CommonUtils .showLoadingDialog (context);
131+ UserDao .doFollowDao (userName, focusStatus).then ((res) {
132+ Navigator .pop (context);
133+ _getFocusStatus ();
134+ });
135+ }),
116136 body: GSYPullLoadWidget (
117137 pullLoadWidgetControl,
118- (BuildContext context, int index) => _renderEventItem (index),
138+ (BuildContext context, int index) => _renderEventItem (index),
119139 handleRefresh,
120140 onLoadMore,
121141 refreshKey: refreshIndicatorKey,
122142 ));
123143 }
124-
125144}
0 commit comments