Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
230 lines (202 loc) · 7.56 KB

File metadata and controls

230 lines (202 loc) · 7.56 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
//
// MeDisplayViewController.m
// Coding_iOS
//
// Created by Ease on 2016/9/9.
// Copyright © 2016年 Coding. All rights reserved.
//
#import "MeDisplayViewController.h"
#import "EaseUserHeaderView.h"
#import "StartImagesManager.h"
#import "Login.h"
#import "UsersViewController.h"
#import "MJPhotoBrowser.h"
#import <APParallaxHeader/UIScrollView+APParallaxHeader.h>
#import "XTSegmentControl.h"
#import "CSHotTopicView.h"
#import "CSTopicDetailVC.h"
#import "SVPullToRefresh.h"
#import "Coding_NetAPIManager.h"
#import "SettingMineInfoViewController.h"
@interface MeDisplayViewController ()
@property (strong, nonatomic) UIView *tableHeaderView;
@property (strong, nonatomic) EaseUserHeaderView *eaV;
@property (strong, nonatomic) UIView *sectionHeaderView;
@property (strong, nonatomic) User *curUser;
@property (assign, nonatomic) NSInteger dataIndex;
@property (strong, nonatomic) NSMutableArray *dataList;//特指「话题列表」的数据
@property (assign, nonatomic) BOOL canLoadMore, willLoadMore, isLoading;
@property (nonatomic, assign) NSInteger curPage;
@end
@implementation MeDisplayViewController
- (void)viewDidLoad{
_curUser = [Login curLoginUser];
_dataIndex = 0;
_dataList = @[].mutableCopy;
_canLoadMore = YES;
_willLoadMore = _isLoading = NO;
_curPage = 0;
[super viewDidLoad];
self.title = @"个人主页";
[self.myTableView registerClass:[CSTopicCell class] forCellReuseIdentifier:kCellIdentifier_TopicCell];
[self setupHeaderV];
}
- (void)setupHeaderV{
__weak typeof(self) weakSelf = self;
if (!_tableHeaderView) {
_eaV = [EaseUserHeaderView userHeaderViewWithUser:_curUser image:[StartImagesManager shareManager].curImage.image];
_eaV.userIconClicked = ^(){
[weakSelf userIconClicked];
};
_eaV.fansCountBtnClicked = ^(){
[weakSelf fansCountBtnClicked];
};
_eaV.followsCountBtnClicked = ^(){
[weakSelf followsCountBtnClicked];
};
_eaV.nameBtnClicked = ^(){
[weakSelf goToSettingInfo];
};
_eaV.clipsToBounds = YES;
_tableHeaderView = [[UIView alloc] initWithFrame:_eaV.bounds];
[_tableHeaderView addSubview:_eaV];
self.myTableView.tableHeaderView = _tableHeaderView;
}
if (!_sectionHeaderView) {
_sectionHeaderView = [[XTSegmentControl alloc] initWithFrame:CGRectMake(0, 0, kScreen_Width, 44.0) Items:@[@"冒泡", @"话题"] selectedBlock:^(NSInteger index) {
weakSelf.dataIndex = index;
}];
_sectionHeaderView.backgroundColor = kColorTableBG;
}
[self.myTableView bringSubviewToFront:self.refreshControl];
}
- (void)setDataIndex:(NSInteger)dataIndex{
_dataIndex = dataIndex;
[self.myTableView reloadData];
if ((_dataIndex == 0 && self.curTweets.list.count <= 0) ||
(_dataIndex == 1 && _dataList.count <= 0)) {
[self refresh];
}
}
#pragma mark Refresh M
- (void)refresh{
if (_dataIndex == 0) {
[super refresh];
}else{
if (!_isLoading) {
[self requestTopicsMore:NO];
}
}
}
- (void)refreshMore{
if (_dataIndex == 0) {
[super refreshMore];
}else{
if (!_isLoading && _canLoadMore) {
[self requestTopicsMore:YES];
}else{
[self.myTableView.infiniteScrollingView stopAnimating];
}
}
}
- (void)requestTopicsMore:(BOOL)loadMore{
_willLoadMore = loadMore;
_curPage = _willLoadMore? _curPage + 1: 0;
if (_dataList.count <= 0) {
[self.view beginLoading];
}
__weak typeof(self) weakSelf = self;
[[Coding_NetAPIManager sharedManager] request_JoinedTopicsWithUserGK:_curUser.global_key page:weakSelf.curPage block:^(id data, BOOL hasMoreData, NSError *error) {
[weakSelf.refreshControl endRefreshing];
[weakSelf.view endLoading];
[weakSelf.myTableView.infiniteScrollingView stopAnimating];
if (data) {
[weakSelf.dataList addObjectsFromArray:data[@"list"]];
[weakSelf.myTableView reloadData];
weakSelf.myTableView.showsInfiniteScrolling = hasMoreData;
}
[weakSelf.view configBlankPage:EaseBlankPageTypeMyJoinedTopic hasData:weakSelf.dataList.count > 0 hasError:error != nil reloadButtonBlock:^(id sender) {
[weakSelf refresh];
}];
}];
}
#pragma mark headerV
- (void)fansCountBtnClicked{
UsersViewController *vc = [[UsersViewController alloc] init];
vc.curUsers = [Users usersWithOwner:_curUser Type:UsersTypeFollowers];
[self.navigationController pushViewController:vc animated:YES];
}
- (void)followsCountBtnClicked{
UsersViewController *vc = [[UsersViewController alloc] init];
vc.curUsers = [Users usersWithOwner:_curUser Type:UsersTypeFriends_Attentive];
[self.navigationController pushViewController:vc animated:YES];
}
- (void)userIconClicked{
// 显示大图
MJPhoto *photo = [[MJPhoto alloc] init];
photo.url = [_curUser.avatar urlWithCodePath];
MJPhotoBrowser *browser = [[MJPhotoBrowser alloc] init];
browser.currentPhotoIndex = 0;
browser.photos = [NSArray arrayWithObject:photo];
[browser show];
}
- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
if (scrollView == self.myTableView) {
CGFloat offsetY = scrollView.contentOffset.y;
CGFloat originalHeight = [_eaV originalHeight];
CGRect eaFrame = CGRectMake(0, MIN(0, offsetY), _eaV.width, MAX(originalHeight, originalHeight - offsetY));
_eaV.frame = eaFrame;
}
}
#pragma mark TableM
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
return self.sectionHeaderView;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
return 44.0;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
if (_dataIndex == 0) {
return [super tableView:tableView numberOfRowsInSection:section];
}else{
return _dataList.count;
}
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
if (_dataIndex == 0) {
return [super tableView:tableView cellForRowAtIndexPath:indexPath];
}else{
NSDictionary *topic = _dataList[indexPath.row];
CSTopicCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellIdentifier_TopicCell forIndexPath:indexPath];
[cell updateDisplayByTopic:topic];
[tableView addLineforPlainCell:cell forRowAtIndexPath:indexPath withLeftSpace:kPaddingLeftWidth];
return cell;
}
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
if (_dataIndex == 0) {
return [super tableView:tableView heightForRowAtIndexPath:indexPath];
}else{
NSDictionary *topic = _dataList[indexPath.row];
return [CSTopicCell cellHeightWithData:topic];
}
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
if (_dataIndex == 0) {
[super tableView:tableView didSelectRowAtIndexPath:indexPath];
}else{
NSDictionary *topic = _dataList[indexPath.row];
[self goToTopic:topic];
}
}
#pragma mark goTo
- (void)goToTopic:(NSDictionary*)topic{
CSTopicDetailVC *vc = [[CSTopicDetailVC alloc] init];
vc.topicID = [topic[@"id"] intValue];
[self.navigationController pushViewController:vc animated:YES];
}
- (void)goToSettingInfo{
SettingMineInfoViewController *vc = [[SettingMineInfoViewController alloc] init];
[self.navigationController pushViewController:vc animated:YES];
}
@end
Morty Proxy This is a proxified and sanitized view of the page, visit original site.