Skip to content

Commit 6e6e554

Browse files
committed
我的页面增加额外兼容
1 parent 37d705e commit 6e6e554

File tree

1 file changed

+29
-6
lines changed

1 file changed

+29
-6
lines changed

lib/page/MyPage.dart

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@ import 'package:gsy_github_app_flutter/common/redux/GSYState.dart';
1111
import 'package:gsy_github_app_flutter/common/redux/UserRedux.dart';
1212
import 'package:gsy_github_app_flutter/common/style/GSYStyle.dart';
1313
import 'package:gsy_github_app_flutter/common/utils/EventUtils.dart';
14+
import 'package:gsy_github_app_flutter/common/utils/NavigatorUtils.dart';
1415
import 'package:gsy_github_app_flutter/widget/EventItem.dart';
1516
import 'package:gsy_github_app_flutter/widget/GSYListState.dart';
1617
import 'package:gsy_github_app_flutter/widget/GSYPullLoadWidget.dart';
1718
import 'package:gsy_github_app_flutter/widget/UserHeader.dart';
19+
import 'package:gsy_github_app_flutter/widget/UserItem.dart';
1820
import 'package:redux/redux.dart';
1921

2022
/**
@@ -47,10 +49,17 @@ class _MyPageState extends GSYListState<MyPage> {
4749
orgList: orgList,
4850
);
4951
}
50-
Event event = pullLoadWidgetControl.dataList[index - 1];
51-
return new EventItem(EventViewModel.fromEventMap(pullLoadWidgetControl.dataList[index - 1]), onPressed: () {
52-
EventUtils.ActionUtils(context, event, "");
53-
});
52+
53+
if (getUserType() == "Organization") {
54+
return new UserItem(UserItemViewModel.fromMap(pullLoadWidgetControl.dataList[index - 1]), onPressed: () {
55+
NavigatorUtils.goPerson(context, UserItemViewModel.fromMap(pullLoadWidgetControl.dataList[index - 1]).userName);
56+
});
57+
} else {
58+
Event event = pullLoadWidgetControl.dataList[index - 1];
59+
return new EventItem(EventViewModel.fromEventMap(event), onPressed: () {
60+
EventUtils.ActionUtils(context, event, "");
61+
});
62+
}
5463
}
5564

5665
Store<GSYState> _getStore() {
@@ -64,6 +73,13 @@ class _MyPageState extends GSYListState<MyPage> {
6473
return _getStore().state.userInfo.login;
6574
}
6675

76+
getUserType() {
77+
if (_getStore().state.userInfo == null) {
78+
return null;
79+
}
80+
return _getStore().state.userInfo.type;
81+
}
82+
6783
_refreshNotify() {
6884
UserDao.getNotifyDao(false, false, 0).then((res) {
6985
if (res != null && res.result && res.data.length > 0) {
@@ -105,6 +121,13 @@ class _MyPageState extends GSYListState<MyPage> {
105121
super.initState();
106122
}
107123

124+
_getDataLogic() async {
125+
if (getUserType() == "Organization") {
126+
return await UserDao.getMemberDao(_getUserName(), page);
127+
}
128+
return await EventDao.getEventDao(_getUserName(), page: page, needDb: page <= 1);
129+
}
130+
108131
@override
109132
requestRefresh() async {
110133
UserDao.getUserInfo(null).then((res) {
@@ -123,12 +146,12 @@ class _MyPageState extends GSYListState<MyPage> {
123146
}
124147
});
125148
_refreshNotify();
126-
return await EventDao.getEventDao(_getUserName(), page: page, needDb: true);
149+
return await _getDataLogic();
127150
}
128151

129152
@override
130153
requestLoadMore() async {
131-
return await EventDao.getEventDao(_getUserName(), page: page);
154+
return await _getDataLogic();
132155
}
133156

134157
@override

0 commit comments

Comments
 (0)