123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414 |
- //
- // YOUPAIEyeCatchingWaiterCell.m
- // 4.看视频
- //
- // Created by apple on 2020/7/28.
- // Copyright © 2020 apple. All rights reserved.
- //
- #import "YOUPAIEyeCatchingWaiterCell.h"
- #import "YYAnimatedImageView.h"
- #import "YYImage.h"
- #import "RippleAnimationView.h"
- @interface YOUPAIEyeCatchingWaiterCell ()
- @property (nonatomic, strong) UIImageView *coverImageView; // 封面
- @property (nonatomic, strong) UILabel *nickNameLabel; // 昵称
- @property (nonatomic,strong)UIImageView *vipV; // Vip
- @property (nonatomic, strong) UILabel *desLabel; // 描述label
- @property (nonatomic, strong) UIButton *callVideoBtn; // 拨打视频
- @property (nonatomic, strong) UIButton *viewersBtn; // 浏览数
- @property (nonatomic, strong) UIButton *likeBtn; // 点赞
- @property (nonatomic, strong) UIButton *giftBtn; // 送礼物
- @property (nonatomic, strong) RippleAnimationView *avatorBgAnimationV; // 头像背景动画
- @property (nonatomic, strong) UIButton *avatarBtn; // 头像
- @property (nonatomic, strong) UIButton *liveBtn; // 直播
- //
- ////头像
- //@property (nonatomic, strong) UIImageView *avatarImgView;
- ////关注按钮
- //@property (nonatomic, strong) UIButton *followBtn;
- //// 赞
- //@property (nonatomic, strong) UIButton *supportBtn;
- //// 点赞数
- //@property (nonatomic, strong) UILabel *supportLab;
- //
- //// 浏览数
- //@property (nonatomic, strong) UIButton *viewersBtn;
- //// 浏览数
- //@property (nonatomic, strong) UILabel *viewersLab;
- ////// 打视频
- ////@property (nonatomic, strong) UIButton *videoBtn;
- //// 比心
- //@property (nonatomic, strong) UIButton *bixinBtn;
- //
- ////比心数
- //@property (nonatomic, strong) UILabel *bixinLab;
- //
- @end
- @implementation YOUPAIEyeCatchingWaiterCell
- - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
- self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
- if (self) {
- [self youpaifinitSubviews];
- }
- return self;
- }
- - (void)youpaifinitSubviews{
-
-
- UIImageView *coverImageView = [[UIImageView alloc] init];
- coverImageView.userInteractionEnabled = YES;
- coverImageView.contentMode = UIViewContentModeScaleAspectFit;
- coverImageView.clipsToBounds = YES;
- coverImageView.tag = 100;
- [self.contentView addSubview:coverImageView];
- self.coverImageView = coverImageView;
- [coverImageView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.top.bottom.offset(0.0f);
- }];
-
- UIView *footerV = [[UIView alloc] init];
- CAGradientLayer *gradientLayerBot = [LCTools getGradientLayerWithSize:footerV.mj_size twoColors:@[[[UIColor blackColor] colorWithAlphaComponent:0.0f],[[UIColor blackColor] colorWithAlphaComponent:0.41f]] gradientType:GradientTopToBottom];
- [footerV.layer addSublayer:gradientLayerBot];
- [self.contentView addSubview:footerV];
- [footerV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.offset(0.0f);
- make.bottom.mas_equalTo(-10);
- make.height.offset(120.0f);
- }];
-
- UILabel *desLabel = [[UILabel alloc]init];
- desLabel.textColor = HexColorFromRGB(0xFFFFFF);
- desLabel.font = LCFont14;
- desLabel.numberOfLines = 0;
- [self.contentView addSubview:desLabel];
- self.desLabel = desLabel;
- [desLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.offset(14.0f);
- make.right.offset(-14.0f);
- make.bottom.offset(-25.0f-SafeHeight);
- }];
-
- UILabel *nickNameLabel = [[UILabel alloc]init];
- nickNameLabel.textColor = HexColorFromRGB(0xFFFFFF);
- nickNameLabel.font = LCBoldFont(16);
- nickNameLabel.userInteractionEnabled = YES;
- UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(clickNickNameAction)];
- [nickNameLabel addGestureRecognizer:tap];
- [self.contentView addSubview:nickNameLabel];
- self.nickNameLabel = nickNameLabel;
- [nickNameLabel makeConstraints:^(MASConstraintMaker *make) {
- make.left.offset(14);
- make.bottom.equalTo(desLabel.mas_top).offset(-10);
- }];
-
- UIImageView *vipV = [[UIImageView alloc] init];
- [self.contentView addSubview:vipV];
- self.vipV = vipV;
- [vipV makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.nickNameLabel.right).offset(5);
- make.centerY.equalTo(self.nickNameLabel);
- make.size.mas_offset(CGSizeMake(30.0f, 19.0f));
- }];
-
- UIButton *callVideoBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- [callVideoBtn setImage:[UIImage imageNamed:@"vqu_images_D_dynamic_call_video"] forState:UIControlStateNormal];
- [callVideoBtn setTitle:@"与TA视频" forState:UIControlStateNormal];
- [callVideoBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
- callVideoBtn.titleLabel.font = LCFont12;
- callVideoBtn.frame = CGRectMake(0.0f, 0.0f, 55.0f, 69.0f);
- [callVideoBtn addTarget:self action:@selector(youpaifvideoBtn:) forControlEvents:UIControlEventTouchUpInside];
- [self initButton:callVideoBtn imageSize:CGSizeMake(39.0f, 39.0f) spacing:8.0f];
- [self.contentView addSubview:callVideoBtn];
- self.callVideoBtn = callVideoBtn;
- [callVideoBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.offset(-6.0f);
- make.bottom.equalTo(nickNameLabel.mas_top).offset(-40.0f);
- make.size.mas_offset(CGSizeMake(55.0f, 69.0f));
- }];
-
- UIButton *viewersBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- [viewersBtn setImage:[UIImage imageNamed:@"vqu_images_D_dynamic_viewers"] forState:UIControlStateNormal];
- [viewersBtn setTitle:@"0" forState:UIControlStateNormal];
- [viewersBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
- viewersBtn.titleLabel.font = LCFont12;
- viewersBtn.frame = CGRectMake(0.0f, 0.0f, 55.0f, 61.0f);
- [self initButton:viewersBtn imageSize:CGSizeMake(39.0f, 39.0f) spacing:0.0f];
- UIEdgeInsets imageEdgeInsets = viewersBtn.imageEdgeInsets;
- imageEdgeInsets.left = 8.0f;
- viewersBtn.imageEdgeInsets = imageEdgeInsets;
- [self.contentView addSubview:viewersBtn];
- self.viewersBtn = viewersBtn;
- [viewersBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.offset(-6.0f);
- make.bottom.equalTo(callVideoBtn.mas_top).offset(-19.0f);
- make.size.mas_offset(CGSizeMake(55.0f, 61.0f));
- }];
-
- UIButton *likeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- [likeBtn setImage:[UIImage imageNamed:@"vqu_images_D_dynamic_like_none"] forState:UIControlStateNormal];
- [likeBtn setImage:[UIImage imageNamed:@"vqu_images_D_dynamic_like_selected"] forState:UIControlStateSelected];
- [likeBtn setTitle:@"0" forState:UIControlStateNormal];
- [likeBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
- likeBtn.titleLabel.font = LCFont12;
- likeBtn.frame = CGRectMake(0.0f, 0.0f, 55.0f, 61.0f);
- [likeBtn addTarget:self action:@selector(supportBtn:) forControlEvents:UIControlEventTouchUpInside];
- [self initButton:likeBtn imageSize:CGSizeMake(39.0f, 39.0f) spacing:0.0f];
- [self.contentView addSubview:likeBtn];
- self.likeBtn = likeBtn;
- [likeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.offset(-6.0f);
- make.bottom.equalTo(viewersBtn.mas_top).offset(-19.0f);
- make.size.mas_offset(CGSizeMake(55.0f, 61.0f));
- }];
-
- UIButton *giftBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- [giftBtn setImage:[UIImage imageNamed:@"vqu_images_D_dynamic_gift_send"] forState:UIControlStateNormal];
- [giftBtn setTitle:@"送礼物" forState:UIControlStateNormal];
- [giftBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
- giftBtn.titleLabel.font = LCFont12;
- giftBtn.frame = CGRectMake(0.0f, 0.0f, 55.0f, 61.0f);
- [self initButton:giftBtn imageSize:CGSizeMake(39.0f, 39.0f) spacing:0.0f];
- [giftBtn addTarget:self action:@selector(youpaifgiftBtnClick) forControlEvents:UIControlEventTouchUpInside];
- [self.contentView addSubview:giftBtn];
- self.giftBtn = giftBtn;
- [giftBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.offset(-6.0f);
- make.bottom.equalTo(likeBtn.mas_top).offset(-19.0f);
- make.size.mas_offset(CGSizeMake(55.0f, 61.0f));
- }];
-
- // YYAnimatedImageView *avatorBgAnimationV = [[YYAnimatedImageView alloc] init];
- // avatorBgAnimationV.image = self.icLiveUserHeader;
- // avatorBgAnimationV.contentMode = UIViewContentModeScaleAspectFit;
- // [self.contentView addSubview:avatorBgAnimationV];
- // self.avatorBgAnimationV = avatorBgAnimationV;
- // [avatorBgAnimationV mas_makeConstraints:^(MASConstraintMaker *make) {
- // make.centerX.equalTo(callVideoBtn.mas_centerX);
- // make.bottom.equalTo(giftBtn.mas_top).offset(-19.0f);
- // make.size.mas_offset(CGSizeMake(48.0f, 48.0f));
- // }];
-
-
-
-
- UIButton *avatarBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- avatarBtn.layer.cornerRadius = 20.0f;
- avatarBtn.clipsToBounds = YES;
- avatarBtn.imageView.contentMode = UIViewContentModeScaleAspectFill;
- avatarBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentFill;
- avatarBtn.contentVerticalAlignment = UIControlContentVerticalAlignmentFill;
- avatarBtn.layer.borderColor = HexColorFromRGB(0xFF3A00).CGColor;
- avatarBtn.layer.borderWidth = 1.0f;
- [avatarBtn addTarget:self action:@selector(youpaifclickAvatarImgView) forControlEvents:UIControlEventTouchUpInside];
- [self.contentView addSubview:avatarBtn];
- self.avatarBtn = avatarBtn;
- [avatarBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerX.equalTo(callVideoBtn.mas_centerX);
- make.bottom.equalTo(giftBtn.mas_top).offset(-19.0f);
- make.size.mas_offset(CGSizeMake(40.0f, 40.0f));
- }];
-
- RippleAnimationView *viewB = [[RippleAnimationView alloc] initWithFrame:CGRectMake(0, 0, 40, 40) animationType:AnimationTypeWithoutBackground];
- viewB.center = avatarBtn.center;
- self.avatorBgAnimationV = viewB;
- [self.contentView addSubview:viewB];
- [viewB mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerX.equalTo(callVideoBtn.mas_centerX);
- make.bottom.equalTo(giftBtn.mas_top).offset(-19.0f);
- make.size.mas_offset(CGSizeMake(40.0f, 40.0f));
- }];
- UITapGestureRecognizer *viewBTouch = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(youpaifclickAvatarImgView)];
- [viewB addGestureRecognizer:viewBTouch];
-
- UIButton *liveBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- [liveBtn setBackgroundImage:[UIImage imageNamed:@"vqu_images_D_dynamic_live_tag"] forState:UIControlStateNormal];
- [liveBtn setBackgroundImage:[UIImage imageNamed:@"vqu_images_D_dynamic_live_tag"] forState:UIControlStateHighlighted];
- liveBtn.userInteractionEnabled = NO;
- [avatarBtn addSubview:liveBtn];
- self.liveBtn = liveBtn;
- [liveBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerX.equalTo(0.0f);
- make.top.offset(0.0f);
- make.size.mas_offset(CGSizeMake(40.0f, 40.0f));
- }];
-
- UIButton *followBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- [followBtn setBackgroundImage:[UIImage imageNamed:@"vqu_images_ic_user_show_follow"] forState:UIControlStateNormal];
- [followBtn setBackgroundImage:[UIImage imageNamed:@"vqu_images_ic_user_show_follow"] forState:UIControlStateHighlighted];
- [followBtn addTarget:self action:@selector(followBtnAction:) forControlEvents:UIControlEventTouchUpInside];
- [self.contentView addSubview:followBtn];
- self.followBtn = followBtn;
- [followBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerX.equalTo(callVideoBtn.mas_centerX);
- make.top.equalTo(avatarBtn.mas_bottom).offset(-7.0f);
- make.size.mas_offset(CGSizeMake(14.0f, 14.0f));
- }];
-
- }
- //将按钮设置为图片在上,文字在下
- -(void)initButton:(UIButton*)btn imageSize:(CGSize)size spacing:(CGFloat)spacing{
- CGSize imageSize = size;
- CGSize titleSize = btn.titleLabel.frame.size;
- CGSize textSize = [btn.titleLabel.text sizeWithAttributes:@{NSFontAttributeName : btn.titleLabel.font}];
- CGSize frameSize = CGSizeMake(ceilf(textSize.width), ceilf(textSize.height));
- if (titleSize.width + 0.5 < frameSize.width) {
- titleSize.width = frameSize.width;
- }
- CGFloat totalHeight = (imageSize.height + titleSize.height + spacing);
- btn.imageEdgeInsets = UIEdgeInsetsMake(- (totalHeight - imageSize.height), 0.0, 0.0, - titleSize.width);
- btn.titleEdgeInsets = UIEdgeInsetsMake(0, - imageSize.width, - (totalHeight - titleSize.height), 0);
- }
- - (void)setHidesBottomBar:(BOOL)hidesBottomBar {
- _hidesBottomBar = hidesBottomBar;
- if (hidesBottomBar) {
- [self.desLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
- make.left.offset(14.0f);
- make.right.offset(-14.0f);
- make.bottom.offset(-25.0f-SafeHeight);
- }];
- }else{
- [self.desLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
- make.left.offset(14.0f);
- make.right.offset(-14.0f);
- make.bottom.offset(-25.0f);
- }];
- }
- }
- -(void)setModel:(YOUPAIZYVideoModel *)model
- {
- _model = model;
- [[SDWebImageDownloader sharedDownloader] downloadImageWithURL:[NSURL URLWithString:model.youpaipcover_url] options:SDWebImageDownloaderUseNSURLCache progress:^(NSInteger receivedSize, NSInteger expectedSize, NSURL * _Nullable targetURL) {} completed:^(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, BOOL finished) {
- if (image.size.width >= image.size.height) {
- self->_coverImageView.contentMode = UIViewContentModeScaleAspectFit;
- }else{
- self->_coverImageView.contentMode = UIViewContentModeScaleAspectFill;
- }
- self.model.youpaipmode = self.coverImageView.contentMode;
- }];
- [_coverImageView sd_setImageWithURL:[NSURL URLWithString:model.youpaipcover_url]];
- [self.avatarBtn sd_setImageWithURL:[NSURL URLWithString:model.youpaipavatar] forState:UIControlStateNormal];
- self.likeBtn.selected = model.youpaipis_like;
- [self.likeBtn setTitle:[NSString stringWithFormat:@"%ld",model.youpaiplike_count] forState:UIControlStateNormal];;
- self.followBtn.hidden = model.youpaipis_follow;
- [self.viewersBtn setTitle:[NSString stringWithFormat:@"%ld",model.youpaipview_count] forState:UIControlStateNormal];
- self.nickNameLabel.text = [NSString stringWithFormat:@"%@%@",@"@",model.youpaipnickname];
- self.desLabel.text = [NSString stringWithFormat:@"%@",model.youpaipcontent];
-
- self.vipV.hidden = YES;
- if (model.youpaipvip_icon.length != 0) {
- self.vipV.hidden = NO;
- [self.vipV sd_setImageWithURL:[LCTools getImageUrlWithAddress:model.youpaipvip_icon]];
- }
-
- self.callVideoBtn.hidden = NO;
- if ([[LCSaveModel getUserModel].youpaipuserinfo.youpaipuser_id isEqualToString:model.youpaipuser_id] || model.youpaipis_anchor == 0) {
- self.callVideoBtn.hidden = YES;
- [self.viewersBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
- make.right.offset(-6.0f);
- make.bottom.equalTo(self.nickNameLabel.mas_top).offset(-40.0f);
- make.size.mas_offset(CGSizeMake(55.0f, 61.0f));
- }];
- }else{
- [self.viewersBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
- make.right.offset(-6.0f);
- make.bottom.equalTo(self.callVideoBtn.mas_top).offset(-19.0f);
- make.size.mas_offset(CGSizeMake(55.0f, 61.0f));
- }];
- }
-
- if(model.youpaipis_liveing == 0){
- self.liveBtn.hidden = YES;
- self.avatorBgAnimationV.hidden = YES;
- }else{
- self.liveBtn.hidden = NO;
- self.avatorBgAnimationV.hidden = NO;
- }
- // self.bixinLab.text = [NSString stringWithFormat:@"%ld",model.heart_count];
-
- }
- //点击了昵称
- -(void)clickNickNameAction
- {
- if (self.delegate && [self.delegate respondsToSelector:@selector(youpaifclickNikname:)]) {
- [self.delegate youpaifclickNikname:self.model];
- }
- }
- //点击头像
- -(void)youpaifclickAvatarImgView
- {
- if (self.delegate && [self.delegate respondsToSelector:@selector(youpaifclickAvatar:)]) {
- [self.delegate youpaifclickAvatar:self.model];
- }
- }
- //点击关注、取消关注
- -(void)followBtnAction:(UIButton *)button
- {
- if (self.delegate && [self.delegate respondsToSelector:@selector(youpaifclickAttention:)]) {
- [self.delegate youpaifclickAttention:self.model];
- }
- }
- //视频点赞
- -(void)supportBtn:(UIButton *)button
- {
- [LCHttpHelper requestWithURLString:TrendsLike parameters:@{@"vt_id":self.model.youpaipvideoId} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
- NSDictionary* dict = (NSDictionary*)responseObject;
- NSInteger code = [[dict objectForKey:@"code"] integerValue];
- if (code==0) {//成功
- NSInteger type = [[[dict objectForKey:@"data"] objectForKey:@"type"] integerValue];
- NSString *like_count = [NSString stringWithFormat:@"%@",[[dict objectForKey:@"data"] objectForKey:@"like_count"]];
- // button.selected = type;
- // self.supportLab.text = like_count;
- self.model.youpaiplike_count = [like_count integerValue];
- self.model.youpaipis_like = type;
- if (self.delegate && [self.delegate respondsToSelector:@selector(youpaifclickSupport:)]) {
- [self.delegate youpaifclickSupport:self.model];
- }
- }
- } failure:^(NSError *error) {
-
- }];
-
- }
- //点击拨打视频
- -(void)youpaifvideoBtn:(UIButton *)button
- {
- if (self.delegate && [self.delegate respondsToSelector:@selector(youpaifclickImVideo:)]) {
- [self.delegate youpaifclickImVideo:self.model];
- }
- }
- //点击了比心
- -(void)_bixinBtn:(UIButton *)button
- {
- if (self.delegate && [self.delegate respondsToSelector:@selector(youpaifclickBiXin:)]) {
- [self.delegate youpaifclickBiXin:self.model];
- }
- }
- // 点击了礼物
- - (void)youpaifgiftBtnClick{
- if (self.delegate && [self.delegate respondsToSelector:@selector(youpaifclickGift:)]) {
- [self.delegate youpaifclickGift:self.model];
- }
- }
- - (YYImage *)icLiveUserHeader{
- NSString *path = [[NSBundle mainBundle] pathForResource:@"ic_live_header" ofType:@"gif"];
- return [YYImage imageWithData:[NSData dataWithContentsOfFile:path]];
- }
- @end
|