NIMTeamAnnouncementListCell.m 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. //
  2. // TeamAnnouncementListCell.m
  3. // NIM
  4. //
  5. // Created by Xuhui on 15/3/31.
  6. // Copyright (c) 2015年 Netease. All rights reserved.
  7. //
  8. #import "NIMTeamAnnouncementListCell.h"
  9. #import "NIMUsrInfoData.h"
  10. #import "NIMKitUtil.h"
  11. @interface NIMTeamAnnouncementListCell ()
  12. @property (strong, nonatomic) UILabel *titleLabel;
  13. @property (strong, nonatomic) UILabel *infoLabel;
  14. @property (strong, nonatomic) UIView *line;
  15. @property (strong, nonatomic) UILabel *contentLabel;
  16. @end
  17. @implementation NIMTeamAnnouncementListCell
  18. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
  19. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  20. if (self) {
  21. _titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(11, 15, 298, 16)];
  22. _titleLabel.font = [UIFont systemFontOfSize:16.f];
  23. _titleLabel.textColor = [UIColor blackColor];
  24. _titleLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth;
  25. [self addSubview:_titleLabel];
  26. _infoLabel = [[UILabel alloc] initWithFrame:CGRectMake(11, 39, 298, 13)];
  27. _infoLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth;
  28. _infoLabel.font = [UIFont systemFontOfSize:13.f];
  29. _infoLabel.textColor = [UIColor grayColor];
  30. [self addSubview:_infoLabel];
  31. _line = [[UIView alloc] initWithFrame:CGRectMake(11, 64, 298, .5)];
  32. _line.backgroundColor = [UIColor lightGrayColor];
  33. _line.autoresizingMask = UIViewAutoresizingFlexibleWidth;
  34. [self addSubview:_line];
  35. _contentLabel = [[UILabel alloc] initWithFrame:CGRectMake(11, 73, 298, 178)];
  36. _contentLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth;
  37. _contentLabel.textColor = [UIColor blackColor];
  38. _contentLabel.font = [UIFont systemFontOfSize:14.f];
  39. [self addSubview:_contentLabel];
  40. }
  41. return self;
  42. }
  43. - (void)refreshData:(NSDictionary *)data team:(NIMTeam *)team{
  44. NSString *title = [data objectForKey:@"title"];
  45. _titleLabel.text = title;
  46. NSString *content = [data objectForKey:@"content"];
  47. _contentLabel.text = content;
  48. NSString *creatorId = [data objectForKey:@"creator"];
  49. NSNumber *time = [data objectForKey:@"time"];
  50. NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
  51. [dateFormatter setDateFormat:@"MM-dd HH:mm"];
  52. NSDate * date = [NSDate dateWithTimeIntervalSince1970:time.integerValue];
  53. NIMSession *session = [NIMSession session:team.teamId type:NIMSessionTypeTeam];
  54. NSString *nick = [NIMKitUtil showNick:creatorId inSession:session];
  55. _infoLabel.text = [NSString stringWithFormat:@"%@ %@", nick, [dateFormatter stringFromDate:date]];
  56. }
  57. @end