123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296 |
- //
- // YOUPAILZLiveAnchorHotCell.m
- // VQU
- //
- // Created by 肖浩然的mac on 2021/7/23.
- // Copyright © 2021 leo. All rights reserved.
- //
- #import "YOUPAILZLiveAnchorHotCell.h"
- #import "YYAnimatedImageView.h"
- #import "YYImage.h"
- #import "RippleAnimationView.h"
- #import "YOUPAILZLevelView.h"
- #import "YOUPAILZAvatarView.h"
- @interface YOUPAILZLiveAnchorHotCell ()
- @property (nonatomic, weak) UIImageView *youpaiprankImgV;
- @property (nonatomic, weak) UILabel *youpaiprankL;
- @property (nonatomic, weak) YOUPAILZAvatarView *youpaipavatarView;
- @property (nonatomic, weak) UILabel *youpaipnicknameL;
- @property (nonatomic, weak) UIImageView *youpaipsexV;
- @property (nonatomic, weak) UIImageView *youpaipvipImgV;
- @property (nonatomic, weak) YOUPAILZLevelView *youpaiplevelView;
- @property (nonatomic, weak) UILabel *youpaipcontributionL;
- @property (nonatomic, weak) UIButton *youpaipfollowBtn;
- @property (nonatomic, strong) YOUPAILZLiveMemberModel *youpaipmemberModel;
- @property (nonatomic, strong) UIColor *youpaipthemeColor;
- @property (nonatomic, strong) RippleAnimationView *youpaipavatorBgAnimationV; // 头像背景动画
- @property (nonatomic, strong) UIButton *youpaipliveBtn; // 直播
- @end
- @implementation YOUPAILZLiveAnchorHotCell
- - (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 *youpaiprankImgV = [[UIImageView alloc] init];
- [self.contentView addSubview:youpaiprankImgV];
- self.youpaiprankImgV = youpaiprankImgV;
- [youpaiprankImgV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.offset(7.0f);
- make.centerY.equalTo(self.contentView);
- make.size.mas_offset(CGSizeMake(38.0f, 28.0f));
- }];
-
- UILabel *youpaiprankL = [[UILabel alloc] init];
- youpaiprankL.textColor = HexColorFromRGB(0x9F9DA5);
- youpaiprankL.textAlignment = NSTextAlignmentCenter;
- youpaiprankL.font = LCFont12;
- [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));
- }];
-
- // YYAnimatedImageView *youpaipavatorBgAnimationV = [[YYAnimatedImageView alloc] init];
- // youpaipavatorBgAnimationV.image = self.youpaipicLiveUserHeader;
- // youpaipavatorBgAnimationV.contentMode = UIViewContentModeScaleAspectFit;
- // [self.contentView addSubview:youpaipavatorBgAnimationV];
- // self.youpaipavatorBgAnimationV = youpaipavatorBgAnimationV;
- // [youpaipavatorBgAnimationV mas_makeConstraints:^(MASConstraintMaker *make) {
- // make.left.offset(52.0f);
- // make.centerY.equalTo(self.contentView.mas_centerY);
- // make.size.mas_offset(CGSizeMake(48.0f, 48.0f));
- // }];
-
-
-
- YOUPAILZAvatarView *youpaipavatarView = [YOUPAILZAvatarView youpaifavatarViewWithFrame:CGRectMake(0, 0, 43, 43) avatarURL:nil personalityBoxURL:nil];
- [self.contentView addSubview:youpaipavatarView];
- self.youpaipavatarView = youpaipavatarView;
- [youpaipavatarView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(52.0f);
- make.centerY.mas_equalTo(self.contentView.mas_centerY);
- make.size.mas_equalTo(CGSizeMake(43.0f, 43.0f));
- }];
-
-
- // UIImageView *youpaipavatarImgV = [[UIImageView alloc] init];
- // youpaipavatarImgV.contentMode = UIViewContentModeScaleAspectFill;
- // youpaipavatarImgV.layer.cornerRadius = 20.0f;
- // youpaipavatarImgV.clipsToBounds = YES;
- // youpaipavatarImgV.layer.borderWidth = 1.0f;
- // [self.contentView addSubview:youpaipavatarImgV];
- // self.youpaipavatarImgV = youpaipavatarImgV;
- // [youpaipavatarImgV mas_makeConstraints:^(MASConstraintMaker *make) {
- // make.left.mas_equalTo(52.0f);
- // make.centerY.mas_equalTo(self.contentView.mas_centerY);
- // make.size.mas_equalTo(CGSizeMake(43.0f, 43.0f));
- // }];
-
- RippleAnimationView *viewB = [[RippleAnimationView alloc] initWithFrame:CGRectMake(0, 0, 43, 43) animationType:AnimationTypeWithoutBackground];
- viewB.center = youpaipavatarView.center;
- self.youpaipavatorBgAnimationV = viewB;
- [self.contentView addSubview:viewB];
- [viewB mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(52.0f);
- make.centerY.mas_equalTo(self.contentView.mas_centerY);
- make.size.mas_equalTo(CGSizeMake(43.0f, 43.0f));
- }];
-
- UIButton *youpaipliveBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- [youpaipliveBtn setBackgroundImage:[UIImage imageNamed:@"vqu_images_L_bootom_live"] forState:UIControlStateNormal];
- [youpaipliveBtn setBackgroundImage:[UIImage imageNamed:@"vqu_images_L_bootom_live"] forState:UIControlStateHighlighted];
- youpaipliveBtn.userInteractionEnabled = NO;
- [youpaipavatarView addSubview:youpaipliveBtn];
- self.youpaipliveBtn = youpaipliveBtn;
- [youpaipliveBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerX.equalTo(0.0f);
- make.bottom.equalTo(youpaipavatarView.youpaipavatarImgV.mas_bottom).offset(0.0f);
- make.size.equalTo(youpaipavatarView.youpaipavatarImgV);
- }];
-
- 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 *youpaipsexV = [[UIImageView alloc] init];
- [self.contentView addSubview:youpaipsexV];
- self.youpaipsexV = youpaipsexV;
- [youpaipsexV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(youpaipnicknameL.mas_right).offset(3.0f);
- make.centerY.equalTo(youpaipnicknameL);
- make.size.mas_offset(CGSizeMake(15.0f, 15.0f));
- }];
-
- UIImageView *youpaipvipImgV = [[UIImageView alloc] init];
- [self.contentView addSubview:youpaipvipImgV];
- self.youpaipvipImgV = youpaipvipImgV;
- [youpaipvipImgV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(youpaipsexV.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(youpaipsexV.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(2.0f);
- }];
- UIButton *youpaipfollowBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- youpaipfollowBtn.layer.cornerRadius = 11.0f;
- youpaipfollowBtn.clipsToBounds = YES;
- youpaipfollowBtn.layer.borderColor = HexColorFromRGB(0xFFDD8D).CGColor;
- youpaipfollowBtn.layer.borderWidth = 0.5f;
- [youpaipfollowBtn setTitle:@"关注" forState:UIControlStateNormal];
- [youpaipfollowBtn setTitleColor:HexColorFromRGB(0xFFDD8D) forState:UIControlStateNormal];
- youpaipfollowBtn.titleLabel.font = LCFont12;
- [youpaipfollowBtn addTarget:self action:@selector(youpaiffollowBtnClick) forControlEvents:UIControlEventTouchUpInside];
- [self.contentView addSubview:youpaipfollowBtn];
- self.youpaipfollowBtn = youpaipfollowBtn;
- [youpaipfollowBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerY.equalTo(self.contentView);
- make.right.offset(-12.0f);
- make.size.mas_offset(CGSizeMake(56.0f, 22.0f));
- }];
- }
- - (void)youpaifreloadWithModel:(YOUPAILZLiveMemberModel *)member indexPath:(NSIndexPath *)indexPath type:(LZLiveAnchorHotListType)type youpaipthemeColor:(UIColor *)youpaipthemeColor{
- self.youpaipmemberModel = member;
- self.youpaipthemeColor = youpaipthemeColor;
- if(member.youpaipis_liveing == 0){
- self.youpaipliveBtn.hidden = YES;
- self.youpaipavatorBgAnimationV.hidden = YES;
- }else{
- self.youpaipliveBtn.hidden = NO;
- self.youpaipavatorBgAnimationV.hidden = NO;
- }
- // if (indexPath.row + 1 <= 3 && type != LZLiveMemberListTypeOnline) {
- // self.youpaiprankImgV.hidden = NO;
- // self.youpaiprankL.hidden = YES;
- // self.youpaiprankImgV.image = [UIImage imageNamed:[NSString stringWithFormat:@"vqu_images_L_live_rank_consumption_%@",@(indexPath.row + 1)]];
- // NSArray <UIColor *>*colors = @[HexColorFromRGB(0xF5C686),HexColorFromRGB(0xDFF6FF),HexColorFromRGB(0xB8CC8B)];
- // self.youpaipavatarImgV.layer.borderColor = colors[indexPath.row].CGColor;
- // }else{
- self.youpaiprankImgV.hidden = YES;
- self.youpaiprankL.hidden = NO;
- self.youpaipavatarView.youpaipavatarImgV.layer.borderColor = HexColorFromRGB(0x9F9DA5).CGColor;
- // }
- self.youpaiprankL.text = [NSString stringWithFormat:@"%@",@(indexPath.row + 1)];
- self.youpaipfollowBtn.hidden = NO;
- if (member.youpaipis_follow == 1){
- self.youpaipfollowBtn.layer.borderColor = HexColorFromRGB(0x4F4B5B).CGColor;
- [self.youpaipfollowBtn setTitleColor:HexColorFromRGB(0x4F4B5B) forState:UIControlStateNormal];
- [self.youpaipfollowBtn setTitle:@"已关注" forState:UIControlStateNormal];
- }else if (member.youpaipis_follow == 0){
- self.youpaipfollowBtn.layer.borderColor = youpaipthemeColor.CGColor;
- [self.youpaipfollowBtn setTitleColor:youpaipthemeColor forState:UIControlStateNormal];
- [self.youpaipfollowBtn setTitle:@"关注" forState:UIControlStateNormal];
-
- }else{
- self.youpaipfollowBtn.hidden = YES;
- }
- self.youpaipavatarView.youpaipavatarURL = [LCTools getImageUrlWithAddress:member.youpaipavatar];
- self.youpaipavatarView.youpaippersonalityBoxURL = [LCTools getImageUrlWithAddress:member.youpaipavatar_frame];
- self.youpaipnicknameL.text = member.youpaipnickname;
- if (member.youpaipgender == 1) {//0未知 1女 2男
- self.youpaipsexV.image = [UIImage imageNamed:@"vqu_images_D_dynamic_woman"];
- }else{
- self.youpaipsexV.image = [UIImage imageNamed:@"vqu_images_D_dynamic_man"];
- }
-
-
- self.youpaipvipImgV.hidden = YES;
- self.youpaiplevelView.hidden = YES;
-
- UIView *frontV;
-
- if (member.youpaipvip_icon.length != 0) {
- self.youpaipvipImgV.hidden = NO;
- [self.youpaipvipImgV sd_setImageWithURL:[LCTools getImageUrlWithAddress:member.youpaipvip_icon]];
- [self.youpaipvipImgV mas_makeConstraints:^(MASConstraintMaker *make) {
- if (frontV == nil) {
- make.left.equalTo(self.youpaipsexV.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;
- }
-
- self.youpaiplevelView.hidden = NO;
- [self.youpaiplevelView youpaifreloadWithIcon:member.youpaipgrade.youpaipimg1 iconWidth:member.youpaipgrade.youpaipicon_width bgImg:member.youpaipgrade.youpaipimg2 bgImgWidth:member.youpaipgrade.youpaipicon1_width levelName:member.youpaipgrade.youpaipgrade_name level:member.youpaipgrade.youpaipgrade];
- [self.youpaiplevelView mas_remakeConstraints:^(MASConstraintMaker *make) {
- if (frontV == nil) {
- make.left.equalTo(self.youpaipsexV.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:@"魅力值:" subTitle:[NSString stringWithFormat:@"%@",member.youpaipscore] titleColor:[UIColor whiteColor] subTitleColor:HexColorFromRGB(0xFFDD8D) titleFontSize:10.0f subTitleFontSize:10.0f];
-
- }
- - (void)youpaiffollowBtnClick{
- self.youpaipmemberModel.youpaipis_follow = self.youpaipmemberModel.youpaipis_follow == 1 ? 0 : 1;
- if (self.youpaipmemberModel.youpaipis_follow== 1){
- self.youpaipfollowBtn.layer.borderColor = HexColorFromRGB(0x4F4B5B).CGColor;
- [self.youpaipfollowBtn setTitleColor:HexColorFromRGB(0x4F4B5B) forState:UIControlStateNormal];
- [self.youpaipfollowBtn setTitle:@"已关注" forState:UIControlStateNormal];
- }else{
- self.youpaipfollowBtn.layer.borderColor = self.youpaipthemeColor.CGColor;
-
- [self.youpaipfollowBtn setTitleColor:self.youpaipthemeColor forState:UIControlStateNormal];
- [self.youpaipfollowBtn setTitle:@"关注" forState:UIControlStateNormal];
- }
- [LCCommonHttp followUserId:self.youpaipmemberModel.youpaipid];
- }
- - (YYImage *)youpaipicLiveUserHeader{
- NSString *path = [[NSBundle mainBundle] pathForResource:@"ic_live_header" ofType:@"gif"];
- return [YYImage imageWithData:[NSData dataWithContentsOfFile:path]];
- }
- @end
|