JXCourseListCell.m 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. //
  2. // JXCourseListCell.m
  3. // shiku_im
  4. //
  5. // Created by p on 2017/10/20.
  6. // Copyright © 2017年 Reese. All rights reserved.
  7. //
  8. #import "JXCourseListCell.h"
  9. @interface JXCourseListCell()
  10. @property (nonatomic, strong) UILabel *nameLabel;
  11. @property (nonatomic, strong) UILabel *timeLabel;
  12. @property (nonatomic, strong) UIImageView *nextImage;
  13. @end
  14. @implementation JXCourseListCell
  15. - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
  16. {
  17. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  18. if(self){
  19. _nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, 10, JX_SCREEN_WIDTH -60 - 80, 20)];
  20. _nameLabel.textColor = [UIColor blackColor];
  21. _nameLabel.userInteractionEnabled = NO;
  22. _nameLabel.backgroundColor = [UIColor clearColor];
  23. _nameLabel.font = g_factory.font16;
  24. _nameLabel.tag = self.index;
  25. _nameLabel.text = [NSString stringWithFormat:@"%@:",Localized(@"JX_CourseName")];
  26. [self.contentView addSubview:_nameLabel];
  27. _timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, CGRectGetMaxY(_nameLabel.frame) + 10, JX_SCREEN_WIDTH -60 - 80, 20)];
  28. _timeLabel.textColor = [UIColor grayColor];
  29. _timeLabel.userInteractionEnabled = NO;
  30. _timeLabel.backgroundColor = [UIColor clearColor];
  31. _timeLabel.font = g_factory.font13;
  32. _timeLabel.tag = self.index;
  33. _timeLabel.text = [NSString stringWithFormat:@"%@:",Localized(@"JX_RecordingTime")];
  34. [self.contentView addSubview:_timeLabel];
  35. _nextImage = [[UIImageView alloc] initWithFrame:CGRectMake(JX_SCREEN_WIDTH-15-7, (70-13)/2, 7, 13)];
  36. _nextImage.image = [UIImage imageNamed:@"new_icon_>"];
  37. _nextImage.hidden = NO;
  38. [self.contentView addSubview:_nextImage];
  39. UIView *line = [[UIView alloc] initWithFrame:CGRectMake(15, 70 - LINE_WH, JX_SCREEN_WIDTH-15, LINE_WH)];
  40. line.backgroundColor = THE_LINE_COLOR;
  41. [self.contentView addSubview:line];
  42. _multiselectBtn = [[UIButton alloc] initWithFrame:CGRectMake(JX_SCREEN_WIDTH-20-15, 25, 20, 20)];
  43. _multiselectBtn.backgroundColor = [UIColor whiteColor];
  44. [self.contentView addSubview:_multiselectBtn];
  45. [_multiselectBtn addTarget:self action:@selector(btnAction) forControlEvents:UIControlEventTouchUpInside];
  46. [_multiselectBtn setTitleColor:THEMECOLOR forState:UIControlStateNormal];
  47. _multiselectBtn.titleLabel.font = g_factory.font10;
  48. _multiselectBtn.layer.cornerRadius = _multiselectBtn.frame.size.width / 2;
  49. _multiselectBtn.layer.masksToBounds = YES;
  50. _multiselectBtn.layer.borderWidth = 1.0;
  51. _multiselectBtn.layer.borderColor = [THEMECOLOR CGColor];
  52. _multiselectBtn.hidden = YES;
  53. }
  54. return self;
  55. }
  56. - (void)btnAction {
  57. NSInteger num = [self.vc getSelNum:[_multiselectBtn.titleLabel.text integerValue] indexNum:self.indexNum];
  58. if (num > 0) {
  59. [_multiselectBtn setTitle:[NSString stringWithFormat:@"%ld",num] forState:UIControlStateNormal];
  60. }else {
  61. _multiselectBtn.titleLabel.text = @"";
  62. [_multiselectBtn setTitle:@"" forState:UIControlStateNormal];
  63. }
  64. }
  65. - (void)setData:(NSDictionary *)dict {
  66. if (self.isMultiselect) {
  67. _multiselectBtn.hidden = NO;
  68. _nextImage.hidden = YES;
  69. }else {
  70. _multiselectBtn.hidden = YES;
  71. _nextImage.hidden = NO;
  72. _multiselectBtn.titleLabel.text = @"";
  73. [_multiselectBtn setTitle:@"" forState:UIControlStateNormal];
  74. }
  75. NSArray *arr = dict[@"messageIds"];
  76. _nameLabel.text = [NSString stringWithFormat:@"%@:%@ (%ld)",Localized(@"JX_CourseName"),dict[@"courseName"],arr.count];
  77. _timeLabel.text = [NSString stringWithFormat:@"%@:%@",Localized(@"JX_RecordingTime"),[TimeUtil formatDate:[NSDate dateWithTimeIntervalSince1970:[dict[@"createTime"] longLongValue]] format:@"MM-dd HH:mm"]];;
  78. }
  79. - (void)awakeFromNib {
  80. [super awakeFromNib];
  81. // Initialization code
  82. }
  83. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  84. [super setSelected:selected animated:animated];
  85. // Configure the view for the selected state
  86. }
  87. @end