// // YOUPAILZChatRoomInviationUpSeatCell.m // VQU // // Created by CY on 2021/11/5. // Copyright © 2021 MS. All rights reserved. // #import "YOUPAILZChatRoomInviationUpSeatCell.h" #import "YOUPAILZAvatarView.h" #import "YOUPAILZLevelView.h" @interface YOUPAILZChatRoomInviationUpSeatCell () @property (nonatomic, weak) UIImageView *youpaiprankImageV; @property (nonatomic, weak) UILabel *youpaiprankL; /// 排名 @property (nonatomic, weak) YOUPAILZAvatarView *youpaipavatarView; // 头像 @property (nonatomic, weak) UILabel *youpaipnicknameL; // 昵称 @property (nonatomic, weak) UIImageView *youpaipvipImgV; // 贵族 @property (nonatomic, weak) UIImageView *youpaipboardImgV; // 榜单 @property (nonatomic, weak) YOUPAILZLevelView *youpaiplevelView; // 等级 @property (nonatomic, weak) UILabel *youpaipcontributionL; // 贡献值 @property (nonatomic, weak) UIButton *youpaipinviationBtn; // 邀请 @property (nonatomic, weak) UIButton *youpaipfollowBtn; // 关注 @property (nonatomic, strong) YOUPAILZChatRoomMemberModel *youpaipmodel; @end @implementation YOUPAILZChatRoomInviationUpSeatCell - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{ if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) { self.selectionStyle = UITableViewCellSelectionStyleNone; self.backgroundColor = [UIColor clearColor]; [self youpaifinitUI]; } return self; } - (void)youpaifinitUI{ UIImageView *youpaiprankImageV = [[UIImageView alloc] init]; [self.contentView addSubview:youpaiprankImageV]; self.youpaiprankImageV = youpaiprankImageV; [youpaiprankImageV mas_makeConstraints:^(MASConstraintMaker *make) { make.left.offset(10.0f); make.centerY.equalTo(self.contentView); make.size.mas_offset(CGSizeMake(32.0f, 32.0f)); }]; UILabel *youpaiprankL = [[UILabel alloc] init]; youpaiprankL.textColor = HexColorFromRGB(0x9F9DA5); youpaiprankL.textAlignment = NSTextAlignmentCenter; youpaiprankL.font = LCBoldFont(12.0f); [self.contentView addSubview:youpaiprankL]; self.youpaiprankL = youpaiprankL; [youpaiprankL mas_makeConstraints:^(MASConstraintMaker *make) { make.left.offset(7.0f); make.centerY.equalTo(self.centerY); make.size.mas_offset(CGSizeMake(38.0f, 28.0f)); }]; YOUPAILZAvatarView *youpaipavatarView = [YOUPAILZAvatarView youpaifavatarViewWithFrame:CGRectMake(0, 0, 40, 40) avatarURL:nil personalityBoxURL:nil]; [self.contentView addSubview:youpaipavatarView]; self.youpaipavatarView = youpaipavatarView; [youpaipavatarView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.offset(52.0f); make.centerY.equalTo(self.contentView.mas_centerY); make.size.mas_offset(CGSizeMake(40.0f, 40.0f)); }]; UILabel *youpaipnicknameL = [[UILabel alloc] init]; youpaipnicknameL.font = LCBoldFont(14.0f); youpaipnicknameL.textColor = [UIColor whiteColor]; [self.contentView addSubview:youpaipnicknameL]; self.youpaipnicknameL = youpaipnicknameL; [youpaipnicknameL mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(youpaipavatarView.mas_right).offset(8.0f); make.top.offset(15.0f); }]; UIImageView *youpaipvipImgV = [[UIImageView alloc] init]; [self.contentView addSubview:youpaipvipImgV]; self.youpaipvipImgV = youpaipvipImgV; [youpaipvipImgV mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(youpaipnicknameL.mas_right).offset(3.0f); make.centerY.equalTo(youpaipnicknameL); }]; UIImageView *youpaipboardImgV = [[UIImageView alloc] init]; [self.contentView addSubview:youpaipboardImgV]; self.youpaipboardImgV = youpaipboardImgV; [youpaipboardImgV mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(youpaipnicknameL.mas_right).offset(3.0f); make.centerY.equalTo(youpaipnicknameL); }]; YOUPAILZLevelView *youpaiplevelView = [[YOUPAILZLevelView alloc] init]; [self.contentView addSubview:youpaiplevelView]; self.youpaiplevelView = youpaiplevelView; [youpaiplevelView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(youpaipnicknameL.mas_right).offset(3.0f); make.centerY.equalTo(youpaipnicknameL); }]; UILabel *youpaipcontributionL = [[UILabel alloc] init]; youpaipcontributionL.font = LCFont(10.0f); youpaipcontributionL.textColor = [UIColor whiteColor]; [self.contentView addSubview:youpaipcontributionL]; self.youpaipcontributionL = youpaipcontributionL; [youpaipcontributionL mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(youpaipavatarView.mas_right).offset(8.0f); make.top.equalTo(youpaipnicknameL.mas_bottom).offset(5.0f); }]; UIButton *youpaipinviationBtn = [UIButton buttonWithType:UIButtonTypeCustom]; youpaipinviationBtn.layer.cornerRadius = 11.0f; youpaipinviationBtn.clipsToBounds = YES; [youpaipinviationBtn setTitle:@"邀上麦" forState:UIControlStateNormal]; [youpaipinviationBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; [youpaipinviationBtn setBackgroundImage:[LCTools ColorImage:CGSizeMake(56.0f, 22.0f) FromColors:@[HexColorFromRGB(0xFF0084),HexColorFromRGB(0xFF3A00)] ByGradientType:GradientLeftToRight] forState:UIControlStateNormal]; youpaipinviationBtn.titleLabel.font = LCFont12; youpaipinviationBtn.hidden = YES; [youpaipinviationBtn addTarget:self action:@selector(youpaifinviationBtnClick) forControlEvents:UIControlEventTouchUpInside]; [self.contentView addSubview:youpaipinviationBtn]; self.youpaipinviationBtn = youpaipinviationBtn; [youpaipinviationBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.centerY.equalTo(self.contentView); make.right.offset(-14.0f); make.size.mas_offset(CGSizeMake(56.0f, 22.0f)); }]; UIButton *youpaipfollowBtn = [UIButton buttonWithType:UIButtonTypeCustom]; [youpaipfollowBtn setBackgroundImage:[LCTools ColorImage:CGSizeMake(56.0f, 22.0f) FromColors:@[HexColorFromRGB(0xFF0084),HexColorFromRGB(0xFF3A00)] ByGradientType:GradientLeftToRight] forState:UIControlStateNormal]; [youpaipfollowBtn setBackgroundImage:[LCTools ColorImage:CGSizeMake(56.0f, 22.0f) FromColors:@[HexColorFromRGB(0x4F4B5B),HexColorFromRGB(0x4F4B5B)] ByGradientType:GradientLeftToRight] forState:UIControlStateSelected]; [youpaipfollowBtn setTitle:@"关注" forState:UIControlStateNormal]; [youpaipfollowBtn setTitle:@"已关注" forState:UIControlStateSelected]; [youpaipfollowBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; [youpaipfollowBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateSelected]; youpaipfollowBtn.titleLabel.font = LCFont(12.0f); youpaipfollowBtn.layer.cornerRadius = 11.0f; youpaipfollowBtn.clipsToBounds = YES; youpaipfollowBtn.hidden = YES; [youpaipfollowBtn addTarget:self action:@selector(youpaiffollowBtnClick:) forControlEvents:UIControlEventTouchUpInside]; [self addSubview:youpaipfollowBtn]; self.youpaipfollowBtn = youpaipfollowBtn; [youpaipfollowBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.centerY.equalTo(self.contentView); make.right.offset(-14.0f); make.size.mas_offset(CGSizeMake(56.0f, 22.0f)); }]; } - (void)youpaifreloadWithModel:(YOUPAILZChatRoomMemberModel *)model index:(NSInteger)index buttonType:(LZChatRoomInviationUpSeatCellButtonType)buttonType rankType:(LZChatRoomInviationUpSeatCellRankType)rankType contributionName:(NSString *)contributionName{ self.youpaipmodel = model; self.youpaiprankImageV.hidden = YES; self.youpaiprankL.hidden = YES; if (index + 1 <= 3 && rankType == LZChatRoomInviationUpSeatCellRankTypeWithTopThree) { self.youpaiprankImageV.hidden = NO; self.youpaiprankL.hidden = YES; self.youpaiprankImageV.image = [UIImage imageNamed:[NSString stringWithFormat:@"vqu_images_Chatroom_rank_%@",@(index + 1)]]; }else{ self.youpaiprankImageV.hidden = YES; self.youpaiprankL.hidden = NO; } self.youpaiprankL.text = [NSString stringWithFormat:@"%@",@(index + 1)]; self.youpaipavatarView.youpaipavatarURL = [LCTools getImageUrlWithAddress:model.youpaipavatar]; self.youpaipavatarView.youpaippersonalityBoxURL = [LCTools getImageUrlWithAddress:model.youpaipavatar_frame]; self.youpaipnicknameL.text = model.youpaipnickname; self.youpaipvipImgV.hidden = YES; self.youpaipboardImgV.hidden = YES; self.youpaiplevelView.hidden = YES; UIView *frontV; if (model.youpaipvip_icon.length != 0) { self.youpaipvipImgV.hidden = NO; [self.youpaipvipImgV sd_setImageWithURL:[LCTools getImageUrlWithAddress:model.youpaipvip_icon]]; [self.youpaipvipImgV mas_remakeConstraints:^(MASConstraintMaker *make) { if (frontV == nil) { make.left.equalTo(self.youpaipnicknameL.mas_right).offset(3.0f); }else{ make.left.equalTo(frontV.mas_right).offset(3.0f); } make.centerY.equalTo(self.youpaipnicknameL); make.size.mas_offset(CGSizeMake(30.0f, 19.0f)); }]; frontV = self.youpaipvipImgV; } if (model.youpaiprankInfo.youpaipimg.length != 0) { self.youpaipboardImgV.hidden = NO; [self.youpaipboardImgV sd_setImageWithURL:[LCTools getImageUrlWithAddress:model.youpaiprankInfo.youpaipimg]]; [self.youpaipboardImgV mas_remakeConstraints:^(MASConstraintMaker *make) { if (frontV == nil) { make.left.equalTo(self.youpaipnicknameL.mas_right).offset(3.0f); }else{ make.left.equalTo(frontV.mas_right).offset(3.0f); } make.centerY.equalTo(self.youpaipnicknameL); make.size.mas_offset(CGSizeMake(21.0f, 18.0f)); }]; frontV = self.youpaipboardImgV; } self.youpaiplevelView.hidden = NO; [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]; [self.youpaiplevelView mas_remakeConstraints:^(MASConstraintMaker *make) { if (frontV == nil) { make.left.equalTo(self.youpaipnicknameL.mas_right).offset(3.0f); }else{ make.left.equalTo(frontV.mas_right).offset(3.0f); } make.centerY.equalTo(self.youpaipnicknameL); make.size.mas_offset(self.youpaiplevelView.mj_size); }]; self.youpaipcontributionL.attributedText = [LCTools setRichTextWithTitle:[NSString stringWithFormat:@"%@:",contributionName] subTitle:[NSString stringWithFormat:@"%@",model.youpaipscore] titleColor:[UIColor whiteColor] subTitleColor:HexColorFromRGB(0xFFDD8D) titleFontSize:10.0f subTitleFontSize:10.0f]; self.youpaipinviationBtn.hidden = YES; self.youpaipfollowBtn.hidden = YES; switch (buttonType) { case LZChatRoomInviationUpSeatCellButtonTypeWithFollow:{ self.youpaipfollowBtn.hidden = NO; } break; case LZChatRoomInviationUpSeatCellButtonTypeWithInviation:{ self.youpaipinviationBtn.hidden = NO; } break; default: break; } //是否在麦上 0否 1是 if (model.youpaipis_seat == 1) { self.youpaipinviationBtn.userInteractionEnabled = NO; [self.youpaipinviationBtn setBackgroundImage:[LCTools ColorImage:CGSizeMake(56.0f, 22.0f) FromColors:@[HexColorFromRGB(0x4F4B5B),HexColorFromRGB(0x4F4B5B)] ByGradientType:GradientLeftToRight] forState:UIControlStateNormal]; [self.youpaipinviationBtn setTitle:@"已上麦" forState:UIControlStateNormal]; }else{ self.youpaipinviationBtn.userInteractionEnabled = YES; [self.youpaipinviationBtn setBackgroundImage:[LCTools ColorImage:CGSizeMake(56.0f, 22.0f) FromColors:@[HexColorFromRGB(0xFF0084),HexColorFromRGB(0xFF3A00)] ByGradientType:GradientLeftToRight] forState:UIControlStateNormal]; [self.youpaipinviationBtn setTitle:@"邀上麦" forState:UIControlStateNormal]; } //1关注,0未关注 -1本身 if (model.youpaipis_follow == 1){ self.youpaipfollowBtn.selected = YES; }else if (model.youpaipis_follow == 0){ self.youpaipfollowBtn.selected = NO; }else{ self.youpaipfollowBtn.hidden = YES; } } - (void)youpaifinviationBtnClick{ if (self.youpaipinviationBtnClickBlock != nil) { self.youpaipinviationBtnClickBlock(self.youpaipmodel); } } - (void)youpaiffollowBtnClick:(UIButton *)sender{ sender.selected = !sender.selected; [LCCommonHttp followUserId:self.youpaipmodel.youpaipid]; } @end