FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

bugfix · codingYWJ/Coding-iOS@5a8348d · GitHub

Commit 5a8348d

Browse files
panshiyu
committed
bugfix
1 parent 591460a commit 5a8348d

5 files changed

Lines changed: 220 additions & 5 deletions

File tree

‎Coding_iOS/Controllers/Topic/CSHotTopicVC.m‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reus
257257
- (void)updateDisplayByTopic:(NSDictionary*)data {
258258

259259
_nameLabel.text = [NSString stringWithFormat:@"#%@#",data[@"name"]];
260-
_userCountLabel.text = [NSString stringWithFormat:@"%@人参与",data[@"speackers"]];
260+
_userCountLabel.text = [NSString stringWithFormat:@"%@人参与",(data[@"speackers"]?data[@"speackers"]:@(0))];
261261

262262
if (data[@"hot_tweet"]) {
263263
Tweet *tweet = [NSObject objectOfClass:@"Tweet" fromJSON:data[@"hot_tweet"]];

‎Coding_iOS/Controllers/Topic/CSTopicDetailVC.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,7 @@
1313
//@property (nonatomic,strong)NSDictionary *topic;
1414
@property (nonatomic,assign)int topicID;
1515
@end
16+
17+
@interface CSTopTweetDescCell : UITableViewCell
18+
- (void)updateUI;
19+
@end

‎Coding_iOS/Controllers/Topic/CSTopicDetailVC.m‎

Lines changed: 200 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,20 @@
1515
#import "Tweet.h"
1616
#import "Tweets.h"
1717

18-
@interface CSTopicDetailVC ()<UITableViewDataSource,UITableViewDelegate>
18+
#import "UserInfoViewController.h"
19+
#import "LikersViewController.h"
20+
#import "TweetSendLocationDetailViewController.h"
21+
#import "UIMessageInputView.h"
22+
#import "TweetDetailViewController.h"
23+
24+
@interface CSTopicDetailVC ()<UITableViewDataSource,UITableViewDelegate,UIMessageInputViewDelegate>
1925
@property (nonatomic,strong)UITableView *myTableView;
2026

2127
@property (nonatomic,strong)Tweets *curTweets;
22-
28+
@property (nonatomic,strong)Tweet *curTopWteet;
2329
@property (nonatomic,strong)CSTopicHeaderView *tableHeader;
30+
31+
@property (nonatomic, strong) UIMessageInputView *myMsgInputView;
2432
@end
2533

2634
@implementation CSTopicDetailVC
@@ -33,6 +41,7 @@ - (void)viewDidLoad {
3341

3442
[self.myTableView reloadData];
3543
[self refreshheader];
44+
[self refreshTopTweet];
3645
[self sendRequest];
3746
}
3847

@@ -60,6 +69,17 @@ - (void)sendRequest{
6069
}];
6170
}
6271

72+
- (void)refreshTopTweet {
73+
__weak typeof(self) weakSelf = self;
74+
75+
[[Coding_NetAPIManager sharedManager] request_TopTweetWithTopicID:_topicID block:^(id data, NSError *error) {
76+
if (data) {
77+
weakSelf.curTopWteet = data;
78+
[weakSelf.myTableView reloadData];
79+
}
80+
}];
81+
}
82+
6383
- (void)refreshheader {
6484
[[Coding_NetAPIManager sharedManager]request_TopicDetailsWithTopicID:_topicID block:^(id data, NSError *error) {
6585
if (data) {
@@ -70,7 +90,19 @@ - (void)refreshheader {
7090

7191
#pragma mark - table view
7292

93+
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
94+
return 2;
95+
}
96+
7397
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
98+
if (section == 0) {
99+
if (_curTopWteet) {
100+
return 2;
101+
}else {
102+
return 0;
103+
}
104+
}
105+
74106
if (_curTweets && _curTweets.list) {
75107
return [_curTweets.list count];
76108
}else{
@@ -79,12 +111,104 @@ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger
79111
}
80112

81113
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
114+
115+
if (indexPath.section == 0 && indexPath.row ==0) {
116+
CSTopTweetDescCell *cell0 = [tableView dequeueReusableCellWithIdentifier:@"CSTopTweetDescCell" forIndexPath:indexPath];
117+
[cell0 updateUI];
118+
[tableView addLineforPlainCell:cell0 forRowAtIndexPath:indexPath withLeftSpace:0];
119+
return cell0;
120+
}
121+
82122
TweetCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellIdentifier_Tweet forIndexPath:indexPath];
83-
cell.tweet = [_curTweets.list objectAtIndex:indexPath.row];
123+
124+
if (indexPath.section == 0) {
125+
cell.tweet = _curTopWteet;
126+
}else{
127+
cell.tweet = [_curTweets.list objectAtIndex:indexPath.row];
128+
}
129+
130+
__weak typeof(self) weakSelf = self;
131+
cell.commentClickedBlock = ^(Tweet *tweet, NSInteger index, id sender){
132+
// if ([self.myMsgInputView isAndResignFirstResponder]) {
133+
// return ;
134+
// }
135+
// weakSelf.commentTweet = tweet;
136+
// weakSelf.commentIndex = index;
137+
// weakSelf.commentSender = sender;
138+
//
139+
// weakSelf.myMsgInputView.commentOfId = tweet.id;
140+
//
141+
// if (weakSelf.commentIndex >= 0) {
142+
// weakSelf.commentToUser = ((Comment*)[weakSelf.commentTweet.comment_list objectAtIndex:weakSelf.commentIndex]).owner;
143+
// weakSelf.myMsgInputView.toUser = ((Comment*)[weakSelf.commentTweet.comment_list objectAtIndex:weakSelf.commentIndex]).owner;
144+
//
145+
// if ([Login isLoginUserGlobalKey:weakSelf.commentToUser.global_key]) {
146+
// ESWeakSelf
147+
// UIActionSheet *actionSheet = [UIActionSheet bk_actionSheetCustomWithTitle:@"删除此评论" buttonTitles:nil destructiveTitle:@"确认删除" cancelTitle:@"取消" andDidDismissBlock:^(UIActionSheet *sheet, NSInteger index) {
148+
// ESStrongSelf
149+
// if (index == 0 && _self.commentIndex >= 0) {
150+
// Comment *comment = [_self.commentTweet.comment_list objectAtIndex:_self.commentIndex];
151+
// [_self deleteComment:comment ofTweet:_self.commentTweet];
152+
// }
153+
// }];
154+
// [actionSheet showInView:self.view];
155+
// return;
156+
// }
157+
// }else{
158+
// weakSelf.myMsgInputView.toUser = nil;
159+
// }
160+
// [_myMsgInputView notAndBecomeFirstResponder];
161+
};
162+
cell.likeBtnClickedBlock = ^(Tweet *tweet){
163+
[weakSelf.myTableView reloadData];
164+
};
165+
cell.userBtnClickedBlock = ^(User *curUser){
166+
UserInfoViewController *vc = [[UserInfoViewController alloc] init];
167+
vc.curUser = curUser;
168+
[self.navigationController pushViewController:vc animated:YES];
169+
};
170+
cell.moreLikersBtnClickedBlock = ^(Tweet *curTweet){
171+
LikersViewController *vc = [[LikersViewController alloc] init];
172+
vc.curTweet = curTweet;
173+
[self.navigationController pushViewController:vc animated:YES];
174+
};
175+
cell.goToDetailTweetBlock = ^(Tweet *curTweet){
176+
[self goToDetailWithTweet:curTweet];
177+
};
178+
179+
180+
[tableView addLineforPlainCell:cell forRowAtIndexPath:indexPath withLeftSpace:0];
181+
84182
return cell;
85183
}
86184

185+
- (void)goToDetailWithTweet:(Tweet *)curTweet{
186+
TweetDetailViewController *vc = [[TweetDetailViewController alloc] init];
187+
vc.curTweet = curTweet;
188+
__weak typeof(self) weakSelf = self;
189+
vc.deleteTweetBlock = ^(Tweet *toDeleteTweet){
190+
// Tweets *curTweets = [weakSelf.tweetsDict objectForKey:[NSNumber numberWithInteger:weakSelf.curIndex]];
191+
// [curTweets.list removeObject:toDeleteTweet];
192+
// [weakSelf.myTableView reloadData];
193+
// [weakSelf.view configBlankPage:EaseBlankPageTypeTweet hasData:(curTweets.list.count > 0) hasError:NO reloadButtonBlock:^(id sender) {
194+
// [weakSelf sendRequest];
195+
// }];
196+
};
197+
[self.navigationController pushViewController:vc animated:YES];
198+
}
199+
87200
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
201+
if (indexPath.section == 0) {
202+
if (_curTopWteet && indexPath.row ==0) {
203+
return 36;
204+
}else if(_curTopWteet && indexPath.row == 1){
205+
return [TweetCell cellHeightWithObj:_curTopWteet];
206+
}
207+
else {
208+
return 0;
209+
}
210+
}
211+
88212
return [TweetCell cellHeightWithObj:[_curTweets.list objectAtIndex:indexPath.row]];
89213
}
90214

@@ -96,6 +220,62 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
96220
// }
97221
}
98222

223+
#pragma mark UIMessageInputViewDelegate
224+
- (void)messageInputView:(UIMessageInputView *)inputView sendText:(NSString *)text{
225+
[self sendCommentMessage:text];
226+
}
227+
228+
- (void)messageInputView:(UIMessageInputView *)inputView heightToBottomChenged:(CGFloat)heightToBottom{
229+
[UIView animateWithDuration:0.25 delay:0.0f options:UIViewAnimationOptionTransitionFlipFromBottom animations:^{
230+
UIEdgeInsets contentInsets= UIEdgeInsetsMake(0.0, 0.0, heightToBottom, 0.0);;
231+
CGFloat msgInputY = kScreen_Height - heightToBottom - 64;
232+
233+
self.myTableView.contentInset = contentInsets;
234+
235+
// if ([_commentSender isKindOfClass:[UIView class]] && !self.myTableView.isDragging && heightToBottom > 60) {
236+
// UIView *senderView = _commentSender;
237+
// CGFloat senderViewBottom = [_myTableView convertPoint:CGPointZero fromView:senderView].y+ CGRectGetMaxY(senderView.bounds);
238+
// CGFloat contentOffsetY = MAX(0, senderViewBottom- msgInputY);
239+
// [self.myTableView setContentOffset:CGPointMake(0, contentOffsetY) animated:YES];
240+
// }
241+
} completion:nil];
242+
}
243+
244+
245+
- (void)sendCommentMessage:(id)obj{
246+
// if (_commentIndex >= 0) {
247+
// _commentTweet.nextCommentStr = [NSString stringWithFormat:@"@%@ %@", _commentToUser.name, obj];
248+
// }else{
249+
// _commentTweet.nextCommentStr = obj;
250+
// }
251+
// [self sendCurComment:_commentTweet];
252+
// {
253+
// _commentTweet = nil;
254+
// _commentIndex = kCommentIndexNotFound;
255+
// _commentSender = nil;
256+
// _commentToUser = nil;
257+
// }
258+
self.myMsgInputView.toUser = nil;
259+
[self.myMsgInputView isAndResignFirstResponder];
260+
}
261+
262+
- (void)sendCurComment:(Tweet *)commentObj{
263+
__weak typeof(self) weakSelf = self;
264+
[[Coding_NetAPIManager sharedManager] request_Tweet_DoComment_WithObj:commentObj andBlock:^(id data, NSError *error) {
265+
if (data) {
266+
Comment *resultCommnet = (Comment *)data;
267+
resultCommnet.owner = [Login curLoginUser];
268+
[commentObj addNewComment:resultCommnet];
269+
[weakSelf.myTableView reloadData];
270+
}
271+
}];
272+
}
273+
274+
- (void)dealloc
275+
{
276+
_myTableView.delegate = nil;
277+
_myTableView.dataSource = nil;
278+
}
99279

100280
#pragma mark -
101281

@@ -111,6 +291,8 @@ - (void) setupUI {
111291
tableView.delegate = self;
112292
tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
113293
[tableView registerClass:[TweetCell class] forCellReuseIdentifier:kCellIdentifier_Tweet];
294+
[tableView registerClass:[CSTopTweetDescCell class] forCellReuseIdentifier:@"CSTopTweetDescCell"];
295+
114296
[self.view addSubview:tableView];
115297

116298
CSTopicHeaderView *header = [[CSTopicHeaderView alloc] initWithFrame:CGRectMake(0, 0, kScreen_Width, 191)];
@@ -123,6 +305,9 @@ - (void) setupUI {
123305
_tableHeader = header;
124306
tableView;
125307
});
308+
309+
_myMsgInputView = [UIMessageInputView messageInputViewWithType:UIMessageInputViewContentTypeTweet];
310+
_myMsgInputView.delegate = self;
126311
}
127312

128313
- (void)setupData {
@@ -161,7 +346,18 @@ - (void)sendTweet{
161346
[self.parentViewController presentViewController:nav animated:YES completion:nil];
162347
}
163348

164-
165349
@end
166350

167351

352+
@implementation CSTopTweetDescCell
353+
354+
- (void)updateUI {
355+
self.textLabel.backgroundColor = [UIColor clearColor];
356+
self.textLabel.frame = CGRectMake(12, 0, 100, 36);
357+
self.textLabel.font = [UIFont systemFontOfSize:12];
358+
self.textLabel.textColor = [UIColor colorWithHexString:@"0x666666"];
359+
self.textLabel.text = @"置顶话题";
360+
}
361+
362+
@end
363+

‎Coding_iOS/Util/Manager/Coding_NetAPIManager.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ typedef NS_ENUM(NSUInteger, VerifyType){
217217
- (void)request_Tweet_WithSearchString:(NSString *)strSearch andPage:(NSInteger)page andBlock:(void (^)(id data, NSError *error))block;
218218

219219
- (void)request_TopicDetailsWithTopicID:(int)topicID block:(void (^)(id data, NSError *error))block;
220+
- (void)request_TopTweetWithTopicID:(int)topicID block:(void (^)(id data, NSError *error))block;
220221

221222
- (void)request_JoinedTopicsWithUserGK:(NSString *)userGK page:(NSInteger)page block:(void (^)(id data, BOOL hasMoreData, NSError *error))block;
222223
- (void)request_WatchedTopicsWithUserGK:(NSString *)userGK page:(NSInteger)page block:(void (^)(id data, BOOL hasMoreData, NSError *error))block;

‎Coding_iOS/Util/Manager/Coding_NetAPIManager.m‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2045,6 +2045,20 @@ - (void)request_TopicDetailsWithTopicID:(int)topicID block:(void (^)(id data, NS
20452045
}];
20462046
}
20472047

2048+
- (void)request_TopTweetWithTopicID:(int)topicID block:(void (^)(id data, NSError *error))block {
2049+
NSString *path = [NSString stringWithFormat:@"api/public_tweets/topic/%d/top",topicID];
2050+
[[CodingNetAPIClient sharedJsonClient] requestJsonDataWithPath:path withParams:nil withMethodType:Get andBlock:^(id data, NSError *error) {
2051+
if(data) {
2052+
id resultData = data[@"data"];
2053+
Tweet *tweet =[NSObject objectOfClass:@"Tweet" fromJSON:resultData];
2054+
block(tweet, nil);
2055+
}else {
2056+
2057+
block(nil, error);
2058+
}
2059+
}];
2060+
}
2061+
20482062

20492063
- (void)request_JoinedTopicsWithUserGK:(NSString *)userGK page:(NSInteger)page block:(void (^)(id data, BOOL hasMoreData, NSError *error))block {
20502064
NSString *path = [[NSString stringWithFormat:@"api/user/%@/tweet_topic/joined",userGK] stringByAppendingString:[NSString stringWithFormat:@"?page=%d", (int)page]];

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL