| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -257,7 +257,7 @@ - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reus | |||
| 257 | 257 | - (void)updateDisplayByTopic:(NSDictionary*)data { | |
| 258 | 258 | ||
| 259 | 259 | _nameLabel.text = [NSString stringWithFormat:@"#%@#",data[@"name"]]; | |
| 260 | - _userCountLabel.text = [NSString stringWithFormat:@"%@人参与",data[@"speackers"]]; | ||
| 260 | + _userCountLabel.text = [NSString stringWithFormat:@"%@人参与",(data[@"speackers"]?data[@"speackers"]:@(0))]; | ||
| 261 | 261 | ||
| 262 | 262 | if (data[@"hot_tweet"]) { | |
| 263 | 263 | Tweet *tweet = [NSObject objectOfClass:@"Tweet" fromJSON:data[@"hot_tweet"]]; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -13,3 +13,7 @@ | |||
| 13 | 13 | //@property (nonatomic,strong)NSDictionary *topic; | |
| 14 | 14 | @property (nonatomic,assign)int topicID; | |
| 15 | 15 | @end | |
| 16 | + | ||
| 17 | + @interface CSTopTweetDescCell : UITableViewCell | ||
| 18 | + - (void)updateUI; | ||
| 19 | + @end | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -15,12 +15,20 @@ | |||
| 15 | 15 | #import "Tweet.h" | |
| 16 | 16 | #import "Tweets.h" | |
| 17 | 17 | ||
| 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> | ||
| 19 | 25 | @property (nonatomic,strong)UITableView *myTableView; | |
| 20 | 26 | ||
| 21 | 27 | @property (nonatomic,strong)Tweets *curTweets; | |
| 22 | - | ||
| 28 | + @property (nonatomic,strong)Tweet *curTopWteet; | ||
| 23 | 29 | @property (nonatomic,strong)CSTopicHeaderView *tableHeader; | |
| 30 | + | ||
| 31 | + @property (nonatomic, strong) UIMessageInputView *myMsgInputView; | ||
| 24 | 32 | @end | |
| 25 | 33 | ||
| 26 | 34 | @implementation CSTopicDetailVC | |
@@ -33,6 +41,7 @@ - (void)viewDidLoad { | |||
| 33 | 41 | ||
| 34 | 42 | [self.myTableView reloadData]; | |
| 35 | 43 | [self refreshheader]; | |
| 44 | + [self refreshTopTweet]; | ||
| 36 | 45 | [self sendRequest]; | |
| 37 | 46 | } | |
| 38 | 47 | ||
@@ -60,6 +69,17 @@ - (void)sendRequest{ | |||
| 60 | 69 | }]; | |
| 61 | 70 | } | |
| 62 | 71 | ||
| 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 | + | ||
| 63 | 83 | - (void)refreshheader { | |
| 64 | 84 | [[Coding_NetAPIManager sharedManager]request_TopicDetailsWithTopicID:_topicID block:^(id data, NSError *error) { | |
| 65 | 85 | if (data) { | |
@@ -70,7 +90,19 @@ - (void)refreshheader { | |||
| 70 | 90 | ||
| 71 | 91 | #pragma mark - table view | |
| 72 | 92 | ||
| 93 | + - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { | ||
| 94 | + return 2; | ||
| 95 | + } | ||
| 96 | + | ||
| 73 | 97 | - (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 | + | ||
| 74 | 106 | if (_curTweets && _curTweets.list) { | |
| 75 | 107 | return [_curTweets.list count]; | |
| 76 | 108 | }else{ | |
@@ -79,12 +111,104 @@ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger | |||
| 79 | 111 | } | |
| 80 | 112 | ||
| 81 | 113 | - (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 | + | ||
| 82 | 122 | 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 | + | ||
| 84 | 182 | return cell; | |
| 85 | 183 | } | |
| 86 | 184 | ||
| 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 | + | ||
| 87 | 200 | - (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 | + | ||
| 88 | 212 | return [TweetCell cellHeightWithObj:[_curTweets.list objectAtIndex:indexPath.row]]; | |
| 89 | 213 | } | |
| 90 | 214 | ||
@@ -96,6 +220,62 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath | |||
| 96 | 220 | // } | |
| 97 | 221 | } | |
| 98 | 222 | ||
| 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 | + } | ||
| 99 | 279 | ||
| 100 | 280 | #pragma mark - | |
| 101 | 281 | ||
@@ -111,6 +291,8 @@ - (void) setupUI { | |||
| 111 | 291 | tableView.delegate = self; | |
| 112 | 292 | tableView.separatorStyle = UITableViewCellSeparatorStyleNone; | |
| 113 | 293 | [tableView registerClass:[TweetCell class] forCellReuseIdentifier:kCellIdentifier_Tweet]; | |
| 294 | + [tableView registerClass:[CSTopTweetDescCell class] forCellReuseIdentifier:@"CSTopTweetDescCell"]; | ||
| 295 | + | ||
| 114 | 296 | [self.view addSubview:tableView]; | |
| 115 | 297 | ||
| 116 | 298 | CSTopicHeaderView *header = [[CSTopicHeaderView alloc] initWithFrame:CGRectMake(0, 0, kScreen_Width, 191)]; | |
@@ -123,6 +305,9 @@ - (void) setupUI { | |||
| 123 | 305 | _tableHeader = header; | |
| 124 | 306 | tableView; | |
| 125 | 307 | }); | |
| 308 | + | ||
| 309 | + _myMsgInputView = [UIMessageInputView messageInputViewWithType:UIMessageInputViewContentTypeTweet]; | ||
| 310 | + _myMsgInputView.delegate = self; | ||
| 126 | 311 | } | |
| 127 | 312 | ||
| 128 | 313 | - (void)setupData { | |
@@ -161,7 +346,18 @@ - (void)sendTweet{ | |||
| 161 | 346 | [self.parentViewController presentViewController:nav animated:YES completion:nil]; | |
| 162 | 347 | } | |
| 163 | 348 | ||
| 164 | - | ||
| 165 | 349 | @end | |
| 166 | 350 | ||
| 167 | 351 | ||
| 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 | + | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -217,6 +217,7 @@ typedef NS_ENUM(NSUInteger, VerifyType){ | |||
| 217 | 217 | - (void)request_Tweet_WithSearchString:(NSString *)strSearch andPage:(NSInteger)page andBlock:(void (^)(id data, NSError *error))block; | |
| 218 | 218 | ||
| 219 | 219 | - (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; | ||
| 220 | 221 | ||
| 221 | 222 | - (void)request_JoinedTopicsWithUserGK:(NSString *)userGK page:(NSInteger)page block:(void (^)(id data, BOOL hasMoreData, NSError *error))block; | |
| 222 | 223 | - (void)request_WatchedTopicsWithUserGK:(NSString *)userGK page:(NSInteger)page block:(void (^)(id data, BOOL hasMoreData, NSError *error))block; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2045,6 +2045,20 @@ - (void)request_TopicDetailsWithTopicID:(int)topicID block:(void (^)(id data, NS | |||
| 2045 | 2045 | }]; | |
| 2046 | 2046 | } | |
| 2047 | 2047 | ||
| 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 | + | ||
| 2048 | 2062 | ||
| 2049 | 2063 | - (void)request_JoinedTopicsWithUserGK:(NSString *)userGK page:(NSInteger)page block:(void (^)(id data, BOOL hasMoreData, NSError *error))block { | |
| 2050 | 2064 | NSString *path = [[NSString stringWithFormat:@"api/user/%@/tweet_topic/joined",userGK] stringByAppendingString:[NSString stringWithFormat:@"?page=%d", (int)page]]; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments