YOUPAILZLiveInviteCell.m 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. //
  2. // YOUPAILZLiveInviteCell.m
  3. // TIANYAN
  4. //
  5. // Created by CY on 2021/5/28.
  6. // Copyright © 2021 leo. All rights reserved.
  7. //
  8. #import "YOUPAILZLiveInviteCell.h"
  9. #import "YOUPAILZLevelView.h"
  10. @interface YOUPAILZLiveInviteCell ()
  11. @property (nonatomic, weak) UIImageView *youpaipavatarImgV; // 头像
  12. @property (nonatomic, weak) UILabel *youpaipnicknameL; // 昵称
  13. @property (nonatomic, weak) UIButton *youpaipinviteBtn; // 邀请按钮
  14. @property (nonatomic, weak) YOUPAILZLevelView *youpaiplevelView;
  15. @property (nonatomic, weak) YOUPAILZLiveInviteModel *youpaipmodel;
  16. @end
  17. @implementation YOUPAILZLiveInviteCell
  18. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
  19. if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
  20. self.selectionStyle = UITableViewCellSelectionStyleNone;
  21. self.backgroundColor = [UIColor clearColor];
  22. [self youpaifinitUI];
  23. }
  24. return self;
  25. }
  26. - (void)youpaifinitUI{
  27. UIImageView *youpaipavatarImgV = [[UIImageView alloc] init];
  28. youpaipavatarImgV.contentMode = UIViewContentModeScaleAspectFill;
  29. youpaipavatarImgV.layer.cornerRadius = 20.0f;
  30. youpaipavatarImgV.clipsToBounds = YES;
  31. youpaipavatarImgV.layer.borderColor = HexColorFromRGB(0x9F9DA5).CGColor;
  32. youpaipavatarImgV.layer.borderWidth = 1.0f;
  33. [self.contentView addSubview:youpaipavatarImgV];
  34. self.youpaipavatarImgV = youpaipavatarImgV;
  35. [youpaipavatarImgV mas_makeConstraints:^(MASConstraintMaker *make) {
  36. make.left.offset(19.0f);
  37. make.centerY.equalTo(self.contentView.mas_centerY);
  38. make.size.mas_offset(CGSizeMake(40.0f, 40.0f));
  39. }];
  40. UIButton *youpaipinviteBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  41. youpaipinviteBtn.titleLabel.font = LCFont12;
  42. [youpaipinviteBtn setTitle:@"邀请" forState:UIControlStateNormal];
  43. [youpaipinviteBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  44. youpaipinviteBtn.layer.cornerRadius = 11.0f;
  45. youpaipinviteBtn.clipsToBounds = YES;
  46. [youpaipinviteBtn addTarget:self action:@selector(youpaifinviteBtnClick) forControlEvents:UIControlEventTouchUpInside];
  47. [self.contentView addSubview:youpaipinviteBtn];
  48. self.youpaipinviteBtn = youpaipinviteBtn;
  49. [youpaipinviteBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  50. make.right.offset(-14.0f);
  51. make.size.mas_offset(CGSizeMake(56.0f, 22.0f));
  52. make.centerY.equalTo(self.contentView.mas_centerY);
  53. }];
  54. UILabel *youpaipnicknameL = [[UILabel alloc] init];
  55. youpaipnicknameL.font = LCFont14;
  56. youpaipnicknameL.textColor = [UIColor whiteColor];
  57. [self.contentView addSubview:youpaipnicknameL];
  58. self.youpaipnicknameL = youpaipnicknameL;
  59. [youpaipnicknameL mas_makeConstraints:^(MASConstraintMaker *make) {
  60. make.left.equalTo(youpaipavatarImgV.mas_right).offset(8.0f);
  61. make.top.bottom.offset(0.0f);
  62. }];
  63. YOUPAILZLevelView *youpaiplevelView = [[YOUPAILZLevelView alloc] init];
  64. [self.contentView addSubview:youpaiplevelView];
  65. self.youpaiplevelView = youpaiplevelView;
  66. [youpaiplevelView mas_makeConstraints:^(MASConstraintMaker *make) {
  67. make.left.equalTo(youpaipnicknameL.mas_right).offset(5.0f);
  68. make.centerY.equalTo(youpaipnicknameL);
  69. }];
  70. }
  71. - (void)youpaifreloadWithModel:(YOUPAILZLiveInviteModel *)model type:(LZLiveInviteType)type{
  72. self.youpaipmodel = model;
  73. [self.youpaipavatarImgV sd_setImageWithURL:[LCTools getImageUrlWithAddress:model.youpaipanchor_avatar]];
  74. if ([model.youpaipstatus isEqual:@"over"]) {
  75. [self.youpaipinviteBtn setBackgroundImage:[LCTools ColorImage:CGSizeMake(56.0f, 22.0f) FromColors:@[HexColorFromRGB(0x4F4B5B),HexColorFromRGB(0x4F4B5B)] ByGradientType:GradientLeftToRight] forState:UIControlStateNormal];
  76. self.youpaipinviteBtn.userInteractionEnabled = NO;
  77. }else{
  78. [self.youpaipinviteBtn setBackgroundImage:[self youpaifinviteBtnBackgoundImageWithType:type] forState:UIControlStateNormal];
  79. self.youpaipinviteBtn.userInteractionEnabled = YES;
  80. }
  81. self.youpaipnicknameL.text = model.youpaipanchor_name;
  82. [self.youpaiplevelView youpaifreloadWithIcon:model.youpaipgrade.youpaipimg1 iconWidth:model.youpaipgrade.youpaipicon_width bgImg:model.youpaipgrade.youpaipimg2 bgImgWidth:model.youpaipgrade.youpaipicon1_width levelName:model.youpaipgrade.youpaipgrade_name level:model.youpaipgrade.youpaipgrade];
  83. [self.youpaiplevelView mas_updateConstraints:^(MASConstraintMaker *make) {
  84. make.size.mas_offset(self.youpaiplevelView.mj_size);
  85. }];
  86. }
  87. - (void)youpaifinviteBtnClick{
  88. if (self.youpaipinviteBlock != nil) {
  89. self.youpaipinviteBlock(self.youpaipmodel);
  90. }
  91. }
  92. - (UIImage *)youpaifinviteBtnBackgoundImageWithType:(LZLiveInviteType)type{
  93. if (type == LZLiveInviteTypePK) {
  94. return [LCTools ColorImage:CGSizeMake(56.0f, 22.0f) FromColors:@[HexColorFromRGB(0x75DFFF),HexColorFromRGB(0x0038FF)] ByGradientType:GradientLeftToRight];
  95. }else{
  96. return [LCTools ColorImage:CGSizeMake(56.0f, 22.0f) FromColors:@[HexColorFromRGB(0xFF3BDC),HexColorFromRGB(0xFC2F55)] ByGradientType:GradientLeftToRight];
  97. }
  98. }
  99. @end