19
19
#import " SVPullToRefresh.h"
20
20
#import " Coding_NetAPIManager.h"
21
21
#import " SettingMineInfoViewController.h"
22
-
22
+ #import " EaseUserInfoCell.h"
23
+ #import " UserActiveGraphCell.h"
23
24
24
25
@interface MeDisplayViewController ()
25
- @property (strong , nonatomic ) UIView *tableHeaderView;
26
26
@property (strong , nonatomic ) EaseUserHeaderView *eaV;
27
27
@property (strong , nonatomic ) UIView *sectionHeaderView;
28
28
@@ -31,13 +31,13 @@ @interface MeDisplayViewController ()
31
31
@property (strong , nonatomic ) NSMutableArray *dataList;// 特指「话题列表」的数据
32
32
@property (assign , nonatomic ) BOOL canLoadMore, willLoadMore, isLoading;
33
33
@property (nonatomic , assign ) NSInteger curPage;
34
-
34
+ @property (nonatomic , strong ) EaseUserInfoCell *userInfoCell;
35
+ @property (nonatomic , strong ) ActivenessModel *activenessModel;
35
36
@end
36
37
37
38
@implementation MeDisplayViewController
38
39
39
40
- (void )viewDidLoad {
40
- _curUser = [Login curLoginUser ];
41
41
_dataIndex = 0 ;
42
42
_dataList = @[].mutableCopy ;
43
43
_canLoadMore = YES ;
@@ -47,30 +47,39 @@ - (void)viewDidLoad{
47
47
[super viewDidLoad ];
48
48
self.title = @" 个人主页" ;
49
49
[self .myTableView registerClass: [CSTopicCell class ] forCellReuseIdentifier: kCellIdentifier_TopicCell ];
50
+ [self .myTableView registerClass: [UserActiveGraphCell class ] forCellReuseIdentifier: kCellIdentifier_UserActiveGraphCell ];
50
51
[self setupHeaderV ];
51
52
}
52
53
54
+ - (void )viewWillAppear : (BOOL )animated {
55
+ [super viewWillAppear: animated];
56
+ _curUser = [Login curLoginUser ];
57
+ [self .myTableView reloadData ];
58
+
59
+ }
60
+
53
61
- (void )setupHeaderV {
54
62
__weak typeof (self) weakSelf = self;
55
- if (!_tableHeaderView) {
56
- _eaV = [EaseUserHeaderView userHeaderViewWithUser: _curUser image: [StartImagesManager shareManager ].curImage.image];
57
- _eaV.userIconClicked = ^(){
58
- [weakSelf userIconClicked ];
59
- };
60
- _eaV.fansCountBtnClicked = ^(){
61
- [weakSelf fansCountBtnClicked ];
62
- };
63
- _eaV.followsCountBtnClicked = ^(){
64
- [weakSelf followsCountBtnClicked ];
65
- };
66
- _eaV.nameBtnClicked = ^(){
67
- [weakSelf goToSettingInfo ];
68
- };
69
- _eaV.clipsToBounds = YES ;
70
- _tableHeaderView = [[UIView alloc ] initWithFrame: _eaV.bounds];
71
- [_tableHeaderView addSubview: _eaV];
72
- self.myTableView .tableHeaderView = _tableHeaderView;
73
- }
63
+ _userInfoCell = [[EaseUserInfoCell alloc ] initWithStyle: UITableViewCellStyleDefault reuseIdentifier: kCellIdentifier_EaseUserInfoCell ];
64
+ _userInfoCell.userIconClicked = ^(){
65
+ [weakSelf userIconClicked ]; // 用户头像点击
66
+ };
67
+ _userInfoCell.fansCountBtnClicked = ^(){
68
+ [weakSelf fansCountBtnClicked ]; // 粉丝
69
+ };
70
+ _userInfoCell.followsCountBtnClicked = ^(){
71
+ [weakSelf followsCountBtnClicked ]; // 关注
72
+ };
73
+ _userInfoCell.editButtonClicked = ^(){
74
+ [weakSelf goToSettingInfo ]; // 编辑
75
+ };
76
+
77
+ [[Coding_NetAPIManager sharedManager ] request_Users_activenessWithGlobalKey: _curUser.global_key andBlock: ^(ActivenessModel *data, NSError *error) {
78
+ weakSelf.activenessModel = data;
79
+ [weakSelf.myTableView reloadData ];
80
+ }];
81
+
82
+
74
83
if (!_sectionHeaderView) {
75
84
_sectionHeaderView = [[XTSegmentControl alloc ] initWithFrame: CGRectMake (0 , 0 , kScreen_Width , 44.0 ) Items: @[@" 冒泡" , @" 话题" ] selectedBlock: ^(NSInteger index) {
76
85
weakSelf.dataIndex = index;
@@ -93,6 +102,13 @@ - (void)setDataIndex:(NSInteger)dataIndex{
93
102
94
103
- (void )refresh {
95
104
if (_dataIndex == 0 ) {
105
+ _curUser = [Login curLoginUser ];
106
+ [self .myTableView reloadData ];
107
+ __weak typeof (self) weakSelf = self;
108
+ [[Coding_NetAPIManager sharedManager ] request_Users_activenessWithGlobalKey: _curUser.global_key andBlock: ^(ActivenessModel *data, NSError *error) {
109
+ weakSelf.activenessModel = data;
110
+ [weakSelf.myTableView reloadData ];
111
+ }];
96
112
[super refresh ];
97
113
}else {
98
114
if (!_isLoading) {
@@ -133,7 +149,9 @@ - (void)requestTopicsMore:(BOOL)loadMore{
133
149
[weakSelf.myTableView reloadData ];
134
150
weakSelf.myTableView .showsInfiniteScrolling = hasMoreData;
135
151
}
136
- [weakSelf.view configBlankPage: EaseBlankPageTypeMyJoinedTopic hasData: weakSelf.dataList.count > 0 hasError: error != nil offsetY: [_eaV originalHeight ] + 60 reloadButtonBlock: ^(id sender) {
152
+
153
+ CGFloat offsetY = _userInfoCell.frame .size .height + [UserActiveGraphCell cellHeight ] + 100 ;
154
+ [weakSelf.view configBlankPage: EaseBlankPageTypeMyJoinedTopic hasData: weakSelf.dataList.count > 0 hasError: error != nil offsetY: offsetY reloadButtonBlock: ^(id sender) {
137
155
[weakSelf refresh ];
138
156
}];
139
157
@@ -173,15 +191,38 @@ - (void)scrollViewDidScroll:(UIScrollView *)scrollView{
173
191
}
174
192
175
193
#pragma mark TableM
194
+ - (NSInteger )numberOfSectionsInTableView : (UITableView *)tableView {
195
+ return 3 ;
196
+ }
197
+
176
198
- (UIView *)tableView : (UITableView *)tableView viewForHeaderInSection : (NSInteger )section {
199
+ if (section < 2 ) {
200
+ return nil ;
201
+ }
177
202
return self.sectionHeaderView ;
203
+
178
204
}
179
205
180
206
- (CGFloat)tableView : (UITableView *)tableView heightForHeaderInSection : (NSInteger )section {
207
+ if (section < 2 ) {
208
+ return 0.0 ;
209
+ }
181
210
return 44.0 ;
182
211
}
183
212
213
+ - (CGFloat)tableView : (UITableView *)tableView heightForFooterInSection : (NSInteger )section {
214
+ if (section < 2 ) {
215
+ return 20 ;
216
+ }
217
+
218
+ return 0 ;
219
+ }
220
+
221
+
184
222
- (NSInteger )tableView : (UITableView *)tableView numberOfRowsInSection : (NSInteger )section {
223
+ if (section < 2 ) {
224
+ return 1 ;
225
+ }
185
226
if (_dataIndex == 0 ) {
186
227
return [super tableView: tableView numberOfRowsInSection: section];
187
228
}else {
@@ -190,9 +231,18 @@ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger
190
231
}
191
232
192
233
- (UITableViewCell *)tableView : (UITableView *)tableView cellForRowAtIndexPath : (NSIndexPath *)indexPath {
193
- if (_dataIndex == 0 ) {
234
+ if (indexPath.section == 0 ) {
235
+ EaseUserInfoCell *cell = self.userInfoCell ;
236
+ cell.user = _curUser;
237
+ return cell;
238
+ } else if (indexPath.section == 1 ) {
239
+ UserActiveGraphCell *cell = [tableView dequeueReusableCellWithIdentifier: kCellIdentifier_UserActiveGraphCell forIndexPath: indexPath];
240
+ cell.activenessModel = _activenessModel;
241
+ return cell;
242
+
243
+ } else if (_dataIndex == 0 ) {
194
244
return [super tableView: tableView cellForRowAtIndexPath: indexPath];
195
- }else {
245
+ } else {
196
246
NSDictionary *topic = _dataList[indexPath.row];
197
247
CSTopicCell *cell = [tableView dequeueReusableCellWithIdentifier: kCellIdentifier_TopicCell forIndexPath: indexPath];
198
248
[cell updateDisplayByTopic: topic];
@@ -202,7 +252,12 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
202
252
}
203
253
204
254
- (CGFloat)tableView : (UITableView *)tableView heightForRowAtIndexPath : (NSIndexPath *)indexPath {
205
- if (_dataIndex == 0 ) {
255
+ if (indexPath.section == 0 ) {
256
+ return [tableView cellHeightForIndexPath: indexPath model: _curUser keyPath: @" user" cellClass: [EaseUserInfoCell class ] contentViewWidth: kScreen_Width ];
257
+
258
+ } else if (indexPath.section == 1 ) {
259
+ return [UserActiveGraphCell cellHeight ];
260
+ } else if (_dataIndex == 0 ) {
206
261
return [super tableView: tableView heightForRowAtIndexPath: indexPath];
207
262
}else {
208
263
NSDictionary *topic = _dataList[indexPath.row];
@@ -211,6 +266,9 @@ - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPa
211
266
}
212
267
213
268
- (void )tableView : (UITableView *)tableView didSelectRowAtIndexPath : (NSIndexPath *)indexPath {
269
+ if (indexPath.section < 2 ) {
270
+ return ;
271
+ }
214
272
if (_dataIndex == 0 ) {
215
273
[super tableView: tableView didSelectRowAtIndexPath: indexPath];
216
274
}else {
0 commit comments