forked from CarGuo/gsy_github_app_flutter
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBasePersonState.dart
More file actions
72 lines (64 loc) · 2.46 KB
/
BasePersonState.dart
File metadata and controls
72 lines (64 loc) · 2.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:gsy_github_app_flutter/common/dao/UserDao.dart';
import 'package:gsy_github_app_flutter/common/model/Event.dart';
import 'package:gsy_github_app_flutter/common/model/User.dart';
import 'package:gsy_github_app_flutter/common/model/UserOrg.dart';
import 'package:gsy_github_app_flutter/common/utils/EventUtils.dart';
import 'package:gsy_github_app_flutter/common/utils/NavigatorUtils.dart';
import 'package:gsy_github_app_flutter/widget/EventItem.dart';
import 'package:gsy_github_app_flutter/widget/GSYListState.dart';
import 'package:gsy_github_app_flutter/widget/UserHeader.dart';
import 'package:gsy_github_app_flutter/widget/UserItem.dart';
/**
* Created by guoshuyu
* Date: 2018-08-30
*/
abstract class BasePersonState<T extends StatefulWidget> extends State<T> with AutomaticKeepAliveClientMixin<T>, GSYListState<T> {
final List<UserOrg> orgList = new List();
@protected
renderItem(index, User userInfo, String beStaredCount, Color notifyColor, VoidCallback refreshCallBack, List<UserOrg> orgList) {
if (index == 0) {
return new UserHeaderItem(userInfo, beStaredCount, Theme.of(context).primaryColor,
notifyColor: notifyColor, refreshCallBack: refreshCallBack, orgList: orgList);
}
if (userInfo.type == "Organization") {
return new UserItem(UserItemViewModel.fromMap(pullLoadWidgetControl.dataList[index - 1]), onPressed: () {
NavigatorUtils.goPerson(context, UserItemViewModel.fromMap(pullLoadWidgetControl.dataList[index - 1]).userName);
});
} else {
Event event = pullLoadWidgetControl.dataList[index - 1];
return new EventItem(EventViewModel.fromEventMap(event), onPressed: () {
EventUtils.ActionUtils(context, event, "");
});
}
}
@override
bool get wantKeepAlive => true;
@override
bool get isRefreshFirst => true;
@override
bool get needHeader => true;
@protected
getUserOrg(String userName) {
if (page <= 1) {
UserDao.getUserOrgsDao(userName, page, needDb: true).then((res) {
if (res != null && res.result) {
setState(() {
orgList.clear();
orgList.addAll(res.data);
});
return res.next;
}
return new Future.value(null);
}).then((res) {
if (res != null && res.result) {
setState(() {
orgList.clear();
orgList.addAll(res.data);
});
}
});
}
}
}