GroupSquareCell.m 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. //
  2. // GroupSquareCell.m
  3. // smartRhino
  4. //
  5. // Created by niuzhen on 2020/5/6.
  6. // Copyright © 2020 tederen. All rights reserved.
  7. //
  8. #import "GroupSquareCell.h"
  9. @implementation GroupSquareCell
  10. - (void)awakeFromNib {
  11. [super awakeFromNib];
  12. self.JoinBtn.layer.cornerRadius = 2.f;
  13. self.JoinBtn.layer.borderWidth = 0.5f;
  14. self.JoinBtn.layer.borderColor = UIColorHex(0x13A3FF).CGColor;
  15. self.JoinBtn.layer.masksToBounds = YES;
  16. }
  17. + (CGFloat)configCell0Height
  18. {
  19. return 60.f;
  20. }
  21. + (CGFloat)configCell1Height
  22. {
  23. return 98.f;
  24. }
  25. + (GroupSquareCell *)configCell0:(UITableView *)tableView indexPath:(NSIndexPath *)indexPath{
  26. static NSString *cellIdentifer = @"GroupSquareCell0";
  27. GroupSquareCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifer];
  28. if (cell == nil) {
  29. cell = [[[NSBundle mainBundle] loadNibNamed:@"GroupSquareCell" owner:nil options:nil] objectAtIndex:0];
  30. }
  31. return cell;
  32. }
  33. + (GroupSquareCell *)configCell1:(UITableView *)tableView indexPath:(NSIndexPath *)indexPath{
  34. static NSString *cellIdentifer = @"GroupSquareCell1";
  35. GroupSquareCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifer];
  36. if (cell == nil) {
  37. cell = [[[NSBundle mainBundle] loadNibNamed:@"GroupSquareCell" owner:nil options:nil] objectAtIndex:1];
  38. }
  39. return cell;
  40. }
  41. - (void)setLeftDataModel:(GroupSquareModel *)model
  42. {
  43. self.BlueView.hidden = !model.isSelect;
  44. if (model.isSelect) {
  45. self.NameL.textColor = UIColorHex(0x262626);
  46. self.contentView.backgroundColor = UIColorHex(0xffffff);
  47. self.NameL.font = [UIFont systemFontOfSize:15];
  48. }else{
  49. self.NameL.textColor = UIColorHex(0x333333);
  50. self.contentView.backgroundColor = UIColorHex(0xF2F2F2);
  51. self.NameL.font = [UIFont systemFontOfSize:13];
  52. }
  53. self.NameL.text = model.PiazzaName;
  54. }
  55. - (void)setRightDataSubModel:(GroupSquareSubModel *)model
  56. {
  57. [self.IconView sd_setImageWithURL:[NSURL URLWithString:model.AvatarUrl] placeholderImage:IMG(@"img_placeHolder")];
  58. self.titleL.text = model.Name;
  59. self.userCountL.text = [self userCountText:model.UserCount];
  60. self.TopicCountL.text = [self userCountText:model.TopicCount];
  61. self.subTitleL.text = model.Introduce;
  62. if (model.IsUser) {
  63. self.JoinBtn.layer.borderColor = UIColorHex(0xBBBBBB).CGColor;
  64. [self.JoinBtn setTitle:@"已加入" forState:UIControlStateNormal];
  65. [self.JoinBtn setTitleColor:UIColorHex(0xBBBBBB) forState:UIControlStateNormal];
  66. self.JoinBtn.enabled = NO;
  67. }else{
  68. if (model.IsApply) {
  69. self.JoinBtn.layer.borderColor = UIColorHex(0xBBBBBB).CGColor;
  70. [self.JoinBtn setTitle:@"已申请" forState:UIControlStateNormal];
  71. [self.JoinBtn setTitleColor:UIColorHex(0xBBBBBB) forState:UIControlStateNormal];
  72. self.JoinBtn.enabled = NO;
  73. }else{
  74. self.JoinBtn.layer.borderColor = UIColorHex(0x13A3FF).CGColor;
  75. [self.JoinBtn setTitle:@"加入" forState:UIControlStateNormal];
  76. [self.JoinBtn setTitleColor:UIColorHex(0x13A3FF) forState:UIControlStateNormal];
  77. self.JoinBtn.enabled = YES;
  78. }
  79. }
  80. }
  81. - (void)setRightDataSubModel:(GroupSquareSubModel *)model withSearchText:(NSString *)text
  82. {
  83. [self.IconView sd_setImageWithURL:[NSURL URLWithString:model.AvatarUrl] placeholderImage:IMG(@"img_placeHolder")];
  84. self.titleL.attributedText = [ZYCTool checkOfString:model.Name withSearchText:text withColor:UIColorHex(0xFF5252)];
  85. self.userCountL.text = [self userCountText:model.UserCount];
  86. self.TopicCountL.text = [self userCountText:model.TopicCount];
  87. self.subTitleL.text = model.Introduce;
  88. if (model.IsUser) {
  89. self.JoinBtn.layer.borderColor = UIColorHex(0xBBBBBB).CGColor;
  90. [self.JoinBtn setTitle:@"已加入" forState:UIControlStateNormal];
  91. [self.JoinBtn setTitleColor:UIColorHex(0xBBBBBB) forState:UIControlStateNormal];
  92. self.JoinBtn.enabled = NO;
  93. }else{
  94. if (model.IsApply) {
  95. self.JoinBtn.layer.borderColor = UIColorHex(0xBBBBBB).CGColor;
  96. [self.JoinBtn setTitle:@"已申请" forState:UIControlStateNormal];
  97. [self.JoinBtn setTitleColor:UIColorHex(0xBBBBBB) forState:UIControlStateNormal];
  98. self.JoinBtn.enabled = NO;
  99. }else{
  100. self.JoinBtn.layer.borderColor = UIColorHex(0x13A3FF).CGColor;
  101. [self.JoinBtn setTitle:@"加入" forState:UIControlStateNormal];
  102. [self.JoinBtn setTitleColor:UIColorHex(0x13A3FF) forState:UIControlStateNormal];
  103. self.JoinBtn.enabled = YES;
  104. }
  105. }
  106. }
  107. - (NSString *)userCountText:(NSInteger)userCount
  108. {
  109. if (userCount >= 1000) {
  110. CGFloat s = userCount / 1000;
  111. return [NSString stringWithFormat:@"%.1f%@",s,@"k"];
  112. }else{
  113. return [NSString stringWithFormat:@"%ld",userCount];
  114. }
  115. }
  116. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  117. [super setSelected:selected animated:animated];
  118. // Configure the view for the selected state
  119. }
  120. @end