1616
1717
1818@interface LikersViewController ()
19+ @property (strong , nonatomic ) NSArray *like_reward_users;
1920
2021@property (strong , nonatomic ) UITableView *myTableView;
2122
@@ -39,7 +40,7 @@ - (void)viewDidLoad
3940{
4041 [super viewDidLoad ];
4142 // Do any additional setup after loading the view.
42- self.title = @" 点赞的人 " ;
43+ self.title = @" 赞赏的人 " ;
4344 _myTableView = ({
4445 UITableView *tableView = [[UITableView alloc ] initWithFrame: self .view.bounds style: UITableViewStylePlain];
4546 tableView.backgroundColor = [UIColor clearColor ];
@@ -70,37 +71,49 @@ - (void)refresh{
7071 if (_curTweet.isLoading ) {
7172 return ;
7273 }
73- if (_curTweet. like_users .count <= 0 ) {
74+ if (_like_reward_users .count <= 0 ) {
7475 [self .view beginLoading ];
7576 }
7677 __weak typeof (self) weakSelf = self;
77- [[Coding_NetAPIManager sharedManager ] request_Tweet_Likers_WithObj : _curTweet andBlock: ^(id data, NSError *error) {
78+ [[Coding_NetAPIManager sharedManager ] request_Tweet_LikesAndRewards_WithObj : _curTweet andBlock: ^(id data, NSError *error) {
7879 [weakSelf.view endLoading ];
7980 [weakSelf.myRefreshControl endRefreshing ];
80- if (data) {
81- weakSelf.curTweet .like_users = data;
82- weakSelf.curTweet .likes = [NSNumber numberWithInteger: weakSelf.curTweet.like_users.count];
83- [weakSelf.myTableView reloadData ];
81+ if ([data isKindOfClass: [NSDictionary class ]]) {
82+ [weakSelf refreshWithData: data];
8483 }
8584 }];
8685}
86+
87+ - (void )refreshWithData : (NSDictionary *)data {
88+ if (data[@" likeUsers" ]) {
89+ _curTweet.like_users = [NSObject arrayFromJSON: data[@" likeUsers" ] ofObjects: @" User" ];
90+ }
91+ if (data[@" rewardUsers" ]) {
92+ _curTweet.reward_users = [NSObject arrayFromJSON: data[@" rewardUsers" ] ofObjects: @" User" ];
93+ }
94+ _like_reward_users = [_curTweet like_reward_users ];
95+ [self .myTableView reloadData ];
96+ }
97+
8798#pragma mark Table M
8899- (NSInteger )tableView : (UITableView *)tableView numberOfRowsInSection : (NSInteger )section {
89- if (_curTweet. like_users ) {
90- return [_curTweet.like_users count ];
100+ if (_like_reward_users ) {
101+ return [_like_reward_users count ];
91102 }else {
92103 return 0 ;
93104 }
94105}
95106
96107- (UITableViewCell *)tableView : (UITableView *)tableView cellForRowAtIndexPath : (NSIndexPath *)indexPath {
97- UserCell *cell = [tableView dequeueReusableCellWithIdentifier: kCellIdentifier_UserCell ];
98- if (cell == nil ) {
99- cell = [[UserCell alloc ] initWithStyle: UITableViewCellStyleDefault reuseIdentifier: kCellIdentifier_UserCell ] ;
100- }
101- User *curUser = [_curTweet.like_users objectAtIndex: indexPath.row];
108+ UserCell *cell = [tableView dequeueReusableCellWithIdentifier: kCellIdentifier_UserCell forIndexPath: indexPath ];
109+
110+ cell. userIconView . layer . borderColor = [UIColor colorWithHexString: @" 0xFFAE03 " ]. CGColor ;
111+
112+ User *curUser = [_like_reward_users objectAtIndex: indexPath.row];
102113 cell.curUser = curUser;
103114 cell.usersType = UsersTypeTweetLikers;
115+
116+ cell.userIconView .layer .borderWidth = [_curTweet rewardedBy: curUser]? 1.0 : 0 ;
104117 [tableView addLineforPlainCell: cell forRowAtIndexPath: indexPath withLeftSpace: 60 ];
105118 return cell;
106119}
@@ -111,7 +124,7 @@ - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPa
111124
112125- (void )tableView : (UITableView *)tableView didSelectRowAtIndexPath : (NSIndexPath *)indexPath {
113126 [tableView deselectRowAtIndexPath: indexPath animated: YES ];
114- User *user = [_curTweet.like_users objectAtIndex: indexPath.row];
127+ User *user = [_like_reward_users objectAtIndex: indexPath.row];
115128 UserInfoViewController *vc = [[UserInfoViewController alloc ] init ];
116129 vc.curUser = user;
117130 [self .navigationController pushViewController: vc animated: YES ];
0 commit comments