MGNewDTNearPeopleCell.m 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. //
  2. // MGNewDTNearPeopleCell.m
  3. // BuguLive
  4. //
  5. // Created by 宋晨光 on 2019/12/18.
  6. // Copyright © 2019 xfg. All rights reserved.
  7. //
  8. #import "MGNewDTNearPeopleCell.h"
  9. @implementation MGNewDTNearPeopleCell
  10. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
  11. if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
  12. [self setUpView];
  13. }
  14. return self;
  15. }
  16. -(void)setUpView{
  17. UIImageView *headImgView = [[UIImageView alloc]init];
  18. _headImgView = headImgView;
  19. UIImageView *sexImgView = [[UIImageView alloc]init];
  20. _sexImgView = sexImgView;
  21. QMUIButton *certImgView = [QMUIButton buttonWithType:UIButtonTypeCustom];
  22. [certImgView setImage:[UIImage imageNamed:@"mg_dt_near_cert"] forState:UIControlStateNormal];
  23. certImgView.backgroundColor = [UIColor colorWithHexString:@"#EAF9FF"];
  24. // [certImgView setBackgroundImage:[UIImage imageNamed:@"mg_dt_near_cert_bg"]];
  25. [certImgView setTitle:ASLocalizedString(@"支付宝认证")forState:UIControlStateNormal];
  26. certImgView.titleLabel.font = [UIFont systemFontOfSize:8];
  27. [certImgView setTitleColor:[UIColor colorWithHexString:@"#04AEFB"] forState:UIControlStateNormal];
  28. certImgView.imagePosition = QMUIButtonImagePositionLeft;
  29. certImgView.spacingBetweenImageAndTitle = 2;
  30. _certImgView = certImgView;
  31. UILabel *nickNameL = [UILabel new];
  32. nickNameL.font = [UIFont systemFontOfSize:14];
  33. nickNameL.text = ASLocalizedString(@"昵称");
  34. _nickNameL = nickNameL;
  35. UILabel *contentL = [UILabel new];
  36. contentL.font = [UIFont systemFontOfSize:14];
  37. contentL.text = ASLocalizedString(@"讨论");
  38. contentL.textColor = [UIColor colorWithHexString:@"#666666"];
  39. _contentL = contentL;
  40. UILabel *timeL = [UILabel new];
  41. timeL.textAlignment = NSTextAlignmentRight;
  42. timeL.font = [UIFont systemFontOfSize:11];
  43. timeL.text = ASLocalizedString(@"时间");
  44. timeL.textColor = [UIColor colorWithHexString:@"#999999"];
  45. _timeL = timeL;
  46. UILabel *distanceL = [UILabel new];
  47. distanceL.font = [UIFont systemFontOfSize:11];
  48. distanceL.textAlignment = NSTextAlignmentRight;
  49. distanceL.text = ASLocalizedString(@"距离");
  50. distanceL.textColor = [UIColor colorWithHexString:@"#999999"];
  51. _distanceL = distanceL;
  52. _line = [UIView new];
  53. _line.backgroundColor = KMGLineColor;
  54. [self.contentView addSubview:headImgView];
  55. [self.contentView addSubview:sexImgView];
  56. [self.contentView addSubview:certImgView];
  57. [self.contentView addSubview:contentL];
  58. [self.contentView addSubview:nickNameL];
  59. [self.contentView addSubview:timeL];
  60. [self.contentView addSubview:distanceL];
  61. [self.contentView addSubview:self.line];
  62. _contentL.hidden = _sexImgView.hidden = _certImgView.hidden = YES;
  63. _timeL.hidden = _distanceL.hidden = YES;
  64. }
  65. -(void)resetModelWithModel:(id)model type:(MGNEWDT_TYPE)dtType{
  66. self.dtType = dtType;
  67. MGDynamicTopicModel *topicModel = model;
  68. if (dtType == MGNEWDTTYPE_TOPIC) {
  69. [self.headImgView sd_setImageWithURL:[NSURL URLWithString:topicModel.img] placeholderImage:nil];
  70. self.headImgView.layer.masksToBounds = YES;
  71. self.headImgView.layer.cornerRadius = 4;
  72. self.nickNameL.text = topicModel.name;
  73. self.contentL.text = [NSString stringWithFormat:ASLocalizedString(@"%@ 人讨论"),topicModel.num];
  74. _contentL.hidden = NO;
  75. _sexImgView.hidden = _certImgView.hidden = _timeL.hidden = _distanceL.hidden = YES;
  76. }else{
  77. _contentL.hidden = YES;
  78. _sexImgView.hidden = _certImgView.hidden = _timeL.hidden = _distanceL.hidden = NO;
  79. MGNewDTNearlistModel *nearModel = model;
  80. [self.headImgView sd_setImageWithURL:[NSURL URLWithString:nearModel.head_image] placeholderImage:nil];
  81. self.headImgView.layer.masksToBounds = YES;
  82. self.headImgView.layer.cornerRadius = kRealValue(40 / 2);
  83. self.nickNameL.text = nearModel.nick_name;
  84. self.timeL.text = nearModel.logout_time;
  85. self.distanceL.text = nearModel.juli;
  86. [self.sexImgView setImage:[UIImage imageNamed:[nearModel.sex isEqualToString:@"1"] ? @"dy_sex_male" :@"dy_sex_female"]];
  87. self.certImgView.hidden = ![nearModel.v_type isEqualToString:@"1"];
  88. // self.certImgView
  89. }
  90. self.contentL.hidden = self.dtType == MGNEWDTTYPE_NEAR_PEOPLE;//如果是附近就隐藏掉
  91. self.headImgView.frame = CGRectMake(kRealValue(10), kRealValue(10), kRealValue(40), kRealValue(40));
  92. self.nickNameL.frame = CGRectMake(self.headImgView.right + kRealValue(10), self.headImgView.top + kRealValue(3), kScreenW / 2, kRealValue(18));
  93. self.contentL.frame = CGRectMake(self.nickNameL.left, self.nickNameL.bottom + kRealValue(5), kScreenW * 0.6, kRealValue(15));
  94. self.sexImgView.frame = CGRectMake(self.nickNameL.left, self.nickNameL.bottom + kRealValue(5), kRealValue(10), kRealValue(10));
  95. self.certImgView.frame = CGRectMake(self.sexImgView.right + kRealValue(5), 0, kRealValue(66), kRealValue(13));
  96. self.certImgView.layer.masksToBounds = YES;
  97. self.certImgView.layer.cornerRadius = kRealValue(13 / 2);
  98. self.certImgView.centerY = self.sexImgView.centerY;
  99. self.timeL.frame = CGRectMake(self.nickNameL.right + kRealValue(2), self.nickNameL.top, kScreenW - self.nickNameL.right - kRealValue(10), kRealValue(15));
  100. self.distanceL.frame = CGRectMake(self.timeL.left, self.timeL.bottom + kRealValue(5), self.timeL.width, kRealValue(15));
  101. self.line.frame = CGRectMake(0, self.headImgView.bottom + kRealValue(10) - 1, kScreenW, 1);
  102. }
  103. @end