// // YOUPAILCRelationCell.m // LiveChat // // Created by 张灿 on 2018/8/31. // Copyright © 2018年 caicai. All rights reserved. // #import "YOUPAILCRelationCell.h" #import "RippleAnimationView.h" #import "YOUPAILZAvatarView.h" //#import "YOUPAIHRAgeSexView.h" #import "YOUPAISexView.h" @interface YOUPAILCRelationCell() @property(nonatomic,strong)UIView* youpaipredView; @property(nonatomic,strong)YOUPAILZAvatarView* youpaipavatarImgV; @property(nonatomic,strong)UILabel* youpaipnickLab; @property(nonatomic,strong)UILabel* youpaipcityLab; @property(nonatomic,strong)UILabel* youpaiptimeLab; @property(nonatomic,strong)UIButton* youpaipfootBtn; @property(nonatomic,strong)UIImageView *youpaipvipV; @property (nonatomic, strong) RippleAnimationView *youpaipavatorBgAnimationV; @property (nonatomic, strong) UIButton *youpaipliveBtn; // 直播 //@property (nonatomic,strong) UIButton *sexAndAgeBgView; @property (nonatomic,strong) YOUPAISexView *youpaipsexView; /// 性别 //@property (nonatomic,strong) UILabel *ageL;/// 年龄 @property (nonatomic,strong) UIImageView *youpaipanchorTagImgV; // 女神标记 @property (nonatomic,strong) UILabel *youpaipdescL; // 介绍 //@property (nonatomic,strong) UILabel *statusL;/// 在线状态 @end @implementation YOUPAILCRelationCell - (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{ self.youpaipredView = [[UIView alloc]init]; self.youpaipredView.backgroundColor = ZYPinkColor; self.youpaipredView.layer.cornerRadius = 4.0; self.youpaipredView.layer.masksToBounds = YES; self.youpaipredView.hidden = YES; [self.contentView addSubview:self.youpaipredView]; [self.youpaipredView makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(@2); make.centerY.equalTo(self.contentView.mas_centerY); make.size.mas_equalTo(CGSizeMake(8, 8)); }]; YOUPAILZAvatarView *avatarImgV = [YOUPAILZAvatarView youpaifavatarViewWithFrame:CGRectMake(0.0f, 0.0f, 43, 43) avatarURL:nil personalityBoxURL:nil]; [self.contentView addSubview:avatarImgV]; self.youpaipavatarImgV = avatarImgV; [avatarImgV mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(12); make.centerY.equalTo(self.contentView.mas_centerY); make.size.mas_equalTo(CGSizeMake(43, 43)); }]; RippleAnimationView *viewB = [[RippleAnimationView alloc] initWithFrame:CGRectMake(0, 0, 43, 43) animationType:AnimationTypeWithoutBackground]; viewB.center = self.youpaipavatarImgV.center; self.youpaipavatorBgAnimationV = viewB; [self.contentView addSubview:viewB]; [viewB mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(@14); make.centerY.equalTo(self.contentView.mas_centerY); make.size.mas_equalTo(CGSizeMake(43, 43)); }]; UITapGestureRecognizer *viewBTouch = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(youpaifclickAvatarImgView)]; [viewB addGestureRecognizer:viewBTouch]; UIButton *liveBtn = [UIButton buttonWithType:UIButtonTypeCustom]; [liveBtn setBackgroundImage:[UIImage imageNamed:@"vqu_images_L_bootom_live"] forState:UIControlStateNormal]; [liveBtn setBackgroundImage:[UIImage imageNamed:@"vqu_images_L_bootom_live"] forState:UIControlStateHighlighted]; liveBtn.userInteractionEnabled = NO; [self.youpaipavatarImgV addSubview:liveBtn]; self.youpaipliveBtn = liveBtn; [liveBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.equalTo(0.0f); make.bottom.equalTo(avatarImgV.youpaipavatarImgV.mas_bottom).offset(0.0f); make.size.equalTo(avatarImgV.youpaipavatarImgV); }]; UIImageView *anchorTagImgV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"vqu_images_anchor_vlog"]]; anchorTagImgV.hidden = YES; [self addSubview:anchorTagImgV]; self.youpaipanchorTagImgV = anchorTagImgV; [anchorTagImgV mas_makeConstraints:^(MASConstraintMaker *make) { make.right.equalTo(self.youpaipavatarImgV.youpaipavatarImgV.mas_right).offset(0.0f); make.bottom.equalTo(self.youpaipavatarImgV.youpaipavatarImgV.mas_bottom).offset(0.0f); make.size.mas_offset(CGSizeMake(10.0f, 10.0f)); }]; UILabel* nickLab = [[UILabel alloc]init]; nickLab.textColor = LZ273145Color; nickLab.font = LCFont16; [self.contentView addSubview:nickLab]; self.youpaipnickLab = nickLab; [nickLab makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.youpaipavatarImgV.mas_right).offset(@8); make.top.equalTo(self.youpaipavatarImgV.mas_top); }]; // UIButton *sexAndAgeBgView = [[UIButton alloc] init]; //// [sexAndAgeBgView.layer addSublayer:[LCTools getGradientLayerWithSize:CGSizeMake(32, 15) twoColors:@[HexColorFromRGB(0xFFB4DE),HexColorFromRGB(0xFF8CF7)] gradientType:(GradientLeftToRight)]]; // sexAndAgeBgView.layer.cornerRadius = 7.5f; // sexAndAgeBgView.clipsToBounds = YES; // sexAndAgeBgView.userInteractionEnabled = NO; // [self.contentView addSubview:sexAndAgeBgView]; // self.sexAndAgeBgView = sexAndAgeBgView; // [sexAndAgeBgView makeConstraints:^(MASConstraintMaker *make) { // make.left.equalTo(self.nickLab.right).offset(@6); // make.centerY.equalTo(nickLab); // make.size.mas_equalTo(CGSizeMake(32, 15)); // }]; // // UIImageView *sexImgV = [[UIImageView alloc] init]; // [sexImgV setImage:[UIImage imageNamed:@"vqu_images_ic_profile_woman"]]; // [self.sexAndAgeBgView addSubview:sexImgV]; // self.sexImgV = sexImgV; // [sexImgV makeConstraints:^(MASConstraintMaker *make) { // make.left.offset(3.0f); // make.centerY.equalTo(sexAndAgeBgView); // make.size.mas_equalTo(CGSizeMake(11, 11)); // }]; // // UILabel* ageL = [[UILabel alloc]init]; // ageL.textColor = [UIColor whiteColor]; // ageL.font = LCFont(10.0f); // ageL.textAlignment = NSTextAlignmentCenter; // [self.sexAndAgeBgView addSubview:ageL]; // self.ageL = ageL; // [ageL makeConstraints:^(MASConstraintMaker *make) { // make.left.equalTo(self.sexImgV.right).offset(@1); // make.centerY.equalTo(sexImgV); // make.right.offset(-3.0f); // }]; // // UIImageView *vipV = [[UIImageView alloc] init]; // [self.contentView addSubview:vipV]; // self.vipV = vipV; // [vipV mas_makeConstraints:^(MASConstraintMaker *make) { // make.left.equalTo(sexAndAgeBgView.mas_right).offset(5.0f); // make.centerY.equalTo(sexAndAgeBgView); // }]; YOUPAISexView *sexView = [[YOUPAISexView alloc] init]; [self.contentView addSubview:sexView]; self.youpaipsexView = sexView; [sexView makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(nickLab.mas_right).offset(@3); make.centerY.equalTo(nickLab); make.size.mas_equalTo(CGSizeMake(30, 15)); }]; UIImageView *vipV = [[UIImageView alloc] init]; [self.contentView addSubview:vipV]; self.youpaipvipV = vipV; [vipV mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(sexView.mas_right).offset(5.0f); make.centerY.equalTo(sexView); make.size.mas_offset(CGSizeMake(30.0f, 19.0f)); }]; self.youpaipfootBtn = [[UIButton alloc]init]; self.youpaipfootBtn.layer.cornerRadius = 14.5f; self.youpaipfootBtn.layer.masksToBounds = YES; [self.youpaipfootBtn setBackgroundImage:[LCTools ColorImage:CGSizeMake(60,29) FromColors:@[LZBFB6FFColor,LZ7C69FEColor] ByGradientType:(GradientLeftToRight)] forState:(UIControlStateNormal)]; [self.youpaipfootBtn setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)]; self.youpaipfootBtn.titleLabel.font = LCFont(12); [self.youpaipfootBtn addTarget:self action:@selector(youpaiffootBtnClick) forControlEvents:(UIControlEventTouchUpInside)]; [self.contentView addSubview:self.youpaipfootBtn]; // [self.footBtn setEnlargeEdge:10]; [self.youpaipfootBtn makeConstraints:^(MASConstraintMaker *make) { make.right.equalTo(-12); make.centerY.equalTo(self.contentView.mas_centerY); make.size.mas_equalTo(CGSizeMake(60,29)); }]; UILabel *descL = [[UILabel alloc]init]; descL.textColor = LZA3AABEColor; descL.font = LCFont12; [self.contentView addSubview:descL]; self.youpaipdescL = descL; [descL makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.youpaipavatarImgV.mas_right).offset(@8); make.bottom.equalTo(self.youpaipavatarImgV.mas_bottom); make.right.equalTo(self.youpaipfootBtn.mas_left).offset(-8.0f); }]; [self addLineWithColor:LZF5F4F7Color lineRect:CGRectMake(12.0f, 69.5f, KScreenWidth - 24.0f, 0.5f)]; // UILabel* cityLab = [[UILabel alloc]init]; // cityLab.textColor = LCTextGray; // cityLab.font = LCFont12; // [self.contentView addSubview:cityLab]; // self.cityLab = cityLab; // [cityLab makeConstraints:^(MASConstraintMaker *make) { // make.left.equalTo(self.avatarImgV.right).offset(@8); // make.top.equalTo(nickLab.bottom).offset(@4); // make.height.equalTo(@15); // }]; // // UIView* lineView = [[UIView alloc]init]; // lineView.backgroundColor = LCTextGray; // [self.contentView addSubview:lineView]; // [lineView makeConstraints:^(MASConstraintMaker *make) { // make.left.equalTo(self.cityLab.right).offset(@5); // make.top.equalTo(nickLab.bottom).offset(@5.5); // make.size.mas_equalTo(CGSizeMake(1,12)); // }]; // // UILabel* ageLab = [[UILabel alloc]init]; // ageLab.font = LCFont12; // [self.contentView addSubview:ageLab]; // self.ageLab = ageLab; // [ageLab makeConstraints:^(MASConstraintMaker *make) { // make.left.equalTo(lineView.right).offset(@8); // make.top.equalTo(nickLab.bottom).offset(@4); // make.height.equalTo(@15); // }]; // // UIView* lineView1 = [[UIView alloc]init]; // lineView1.backgroundColor = LCTextGray; // [self.contentView addSubview:lineView1]; // [lineView1 makeConstraints:^(MASConstraintMaker *make) { // make.left.equalTo(self.ageLab.right).offset(@5); // make.top.equalTo(nickLab.bottom).offset(@5.5); // make.size.mas_equalTo(CGSizeMake(1,12)); // }]; // // UILabel* timeLab = [[UILabel alloc]init]; // timeLab.textColor = LCTextGray; // timeLab.font = LCFont12; // [self.contentView addSubview:timeLab]; // self.timeLab = timeLab; // [timeLab makeConstraints:^(MASConstraintMaker *make) { // make.left.equalTo(lineView1.right).offset(@8); // make.top.equalTo(nickLab.bottom).offset(@4); // make.height.equalTo(@15); // }]; } -(void)youpaifclickAvatarImgView{ if (self.youpaipdidIconBlock) { self.youpaipdidIconBlock(self.youpaiprelationModel); } } - (void)setYoupaiprelationModel:(YOUPAILCRelationModel *)relationModel{ _youpaiprelationModel = relationModel; if(relationModel.youpaiplive_status == 1){ self.youpaipliveBtn.hidden = NO; self.youpaipavatorBgAnimationV.hidden = NO; }else{ self.youpaipliveBtn.hidden = YES; self.youpaipavatorBgAnimationV.hidden = YES; } self.youpaipavatarImgV.youpaipavatarURL = [LCTools getImageUrlWithAddress:relationModel.youpaipavatar]; self.youpaipavatarImgV.youpaippersonalityBoxURL = [LCTools getImageUrlWithAddress:relationModel.youpaipavatar_frame]; // if(!([relationModel.avatar rangeOfString:@"://"].location != NSNotFound)){ // [self.avatarImgV sd_setImageWithURL:[LCTools getImageUrlWithAddress:relationModel.avatar]]; // }else{ // [self.avatarImgV sd_setImageWithURL:[NSURL URLWithString:relationModel.avatar]]; // } self.youpaipanchorTagImgV.hidden = relationModel.youpaipis_live != 1; self.youpaipnickLab.text = relationModel.youpaipnickname; // self.vipV.hidden = YES; // UIImage *vipImg = [LCTools getVipNameImageWithLevel:relationModel.vip]; // self.vipV.image = vipImg; // if (vipImg != nil) { // self.vipV.hidden = NO; // [self.vipV mas_remakeConstraints:^(MASConstraintMaker *make) { // make.left.equalTo(self.sexAndAgeBgView.mas_right).offset(5.0f); // make.centerY.equalTo(self.sexAndAgeBgView); // make.size.mas_offset([LCTools getVipNameSizeWithLevel:relationModel.vip]); // }]; // } // self.ageL.text = [NSString stringWithFormat:@"%zd",relationModel.age]; // if (relationModel.gender == 1) {//0未知 1女 2男 // [self.sexAndAgeBgView setBackgroundImage:[LCTools ColorImage:CGSizeMake(32, 15) FromColors:@[HexColorFromRGB(0xFFA1D5),HexColorFromRGB(0x911BBD)] ByGradientType:GradientLeftToRight] forState:UIControlStateNormal]; // self.sexImgV.image = [UIImage imageNamed:@"vqu_images_ic_profile_woman"]; // }else{ // [self.sexAndAgeBgView setBackgroundImage:[LCTools ColorImage:CGSizeMake(32, 15) FromColors:@[HexColorFromRGB(0x96E3F8),HexColorFromRGB(0x3773E8)] ByGradientType:GradientLeftToRight] forState:UIControlStateNormal]; // self.sexAndAgeBgView.backgroundColor = HexColorFromRGB(0xE5FBFF); // self.sexImgV.image = [UIImage imageNamed:@"vqu_images_ic_profile_man"]; // } self.youpaipvipV.hidden = YES; if (relationModel.youpaipvip_icon.length != 0) { self.youpaipvipV.hidden = NO; [self.youpaipvipV sd_setImageWithURL:[LCTools getImageUrlWithAddress:relationModel.youpaipvip_icon]]; } [self.youpaipsexView youpaifreloadWithSex:relationModel.youpaipgender age:relationModel.youpaipage]; // [self.youpaipsexView youpaifreloadWith:relationModel.youpaipgender Age:relationModel.youpaipage]; NSString *text = relationModel.youpaipcity; if (relationModel.youpaipsign.length != 0) { text = [NSString stringWithFormat:@"%@ | %@",text,relationModel.youpaipsign]; } self.youpaipdescL.text = text; // self.cityLab.text = relationModel.city; // self.ageLab.text = [NSString stringWithFormat:@"%zd岁",relationModel.age]; // if (relationModel.gender == 1) { // self.ageLab.textColor = ZYPinkColor; // }else{ // self.ageLab.textColor = HexColorFromRGB(0x38BBF2); // } if ([self.youpaiprelationType isEqualToString:@"fans"] || [self.youpaiprelationType isEqualToString:@"seen"] ) { if (relationModel.youpaipis_watch == 0) { self.youpaipredView.hidden = NO; }else{ self.youpaipredView.hidden = YES; } }else{ // self.backgroundColor = [UIColor whiteColor]; self.youpaipredView.hidden = YES; } if ([self.youpaiprelationType isEqualToString:@"blacklist"]) { // self.timeLab.text = relationModel.create_time; [self.youpaipfootBtn setTitle:@"移出" forState:(UIControlStateNormal)]; [self.youpaipfootBtn setBackgroundImage:[LCTools ColorImage:CGSizeMake(64,22) FromColors:@[LZBFB6FFColor,LZ7C69FEColor] ByGradientType:(GradientLeftToRight)] forState:(UIControlStateNormal)]; [self.youpaipfootBtn setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)]; // self.youpaipfootBtn.backgroundColor = HexColorFromRGB(0x4F4B5B); }else{ // if([self.relationType isEqualToString:@"fans"]){ // self.timeLab.text = [NSString stringWithFormat:@"%@关注了你",relationModel.add_time]; // }else{ // self.timeLab.text = relationModel.add_time; // } if (relationModel.youpaipis_follow == 0) { [self.youpaipfootBtn setBackgroundImage:[LCTools ColorImage:CGSizeMake(64,22) FromColors:@[LZBFB6FFColor,LZ7C69FEColor] ByGradientType:(GradientLeftToRight)] forState:(UIControlStateNormal)]; [self.youpaipfootBtn setTitle:@"关注" forState:(UIControlStateNormal)]; [self.youpaipfootBtn setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)]; self.youpaipfootBtn.backgroundColor = nil; }else{ if (self.youpaiprelationModel.youpaipis_fans == 0) { [self.youpaipfootBtn setTitle:@"已关注" forState:(UIControlStateNormal)]; }else{ [self.youpaipfootBtn setTitle:@"已互关" forState:(UIControlStateNormal)]; } [self.youpaipfootBtn setBackgroundImage:nil forState:(UIControlStateNormal)]; [self.youpaipfootBtn setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)]; self.youpaipfootBtn.backgroundColor = LZD3D1D7Color; } } } - (void)youpaiffootBtnClick{ if ([self.youpaiprelationType isEqualToString:@"blacklist"]) { if (self.youpaipcancelBlack) { [LCCommonHttp blackUserId:self.youpaiprelationModel.youpaipuserid]; self.youpaipcancelBlack(); } }else{ if (self.youpaiprelationModel.youpaipis_follow==1) { [LCCommonHttp followUserId:self.youpaiprelationModel.youpaipuserid]; self.youpaiprelationModel.youpaipis_follow = 0; }else{ [LCCommonHttp followUserId:self.youpaiprelationModel.youpaipuserid]; self.youpaiprelationModel.youpaipis_follow = 1; } [self youpaifupdateBtnStatu]; } } - (void)youpaifupdateBtnStatu{ if ([self.youpaiprelationType isEqualToString:@"blacklist"]) { }else{ if (self.youpaiprelationModel.youpaipis_follow == 0) { [self.youpaipfootBtn setBackgroundImage:[LCTools ColorImage:CGSizeMake(64,22) FromColors:@[LZBFB6FFColor,LZ7C69FEColor] ByGradientType:(GradientLeftToRight)] forState:(UIControlStateNormal)]; [self.youpaipfootBtn setTitle:@"关注" forState:(UIControlStateNormal)]; [self.youpaipfootBtn setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)]; self.youpaipfootBtn.backgroundColor = nil; // self.footBtn.layer.borderColor = [UIColor clearColor].CGColor; }else{ if (self.youpaiprelationModel.youpaipis_fans == 0) { [self.youpaipfootBtn setTitle:@"已关注" forState:(UIControlStateNormal)]; }else{ [self.youpaipfootBtn setTitle:@"已互关" forState:(UIControlStateNormal)]; } [self.youpaipfootBtn setBackgroundImage:nil forState:(UIControlStateNormal)]; [self.youpaipfootBtn setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)]; self.youpaipfootBtn.backgroundColor = LZD3D1D7Color; // self.footBtn.layer.borderColor =HexColorFromRGB(0x999999).CGColor; // self.footBtn.layer.borderWidth = 0.5; } } } @end