YOUPAILZLiveAnchorHotCell.m 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. //
  2. // YOUPAILZLiveAnchorHotCell.m
  3. // VQU
  4. //
  5. // Created by 肖浩然的mac on 2021/7/23.
  6. // Copyright © 2021 leo. All rights reserved.
  7. //
  8. #import "YOUPAILZLiveAnchorHotCell.h"
  9. #import "YYAnimatedImageView.h"
  10. #import "YYImage.h"
  11. #import "RippleAnimationView.h"
  12. #import "YOUPAILZLevelView.h"
  13. #import "YOUPAILZAvatarView.h"
  14. @interface YOUPAILZLiveAnchorHotCell ()
  15. @property (nonatomic, weak) UIImageView *youpaiprankImgV;
  16. @property (nonatomic, weak) UILabel *youpaiprankL;
  17. @property (nonatomic, weak) YOUPAILZAvatarView *youpaipavatarView;
  18. @property (nonatomic, weak) UILabel *youpaipnicknameL;
  19. @property (nonatomic, weak) UIImageView *youpaipsexV;
  20. @property (nonatomic, weak) UIImageView *youpaipvipImgV;
  21. @property (nonatomic, weak) YOUPAILZLevelView *youpaiplevelView;
  22. @property (nonatomic, weak) UILabel *youpaipcontributionL;
  23. @property (nonatomic, weak) UIButton *youpaipfollowBtn;
  24. @property (nonatomic, strong) YOUPAILZLiveMemberModel *youpaipmemberModel;
  25. @property (nonatomic, strong) UIColor *youpaipthemeColor;
  26. @property (nonatomic, strong) RippleAnimationView *youpaipavatorBgAnimationV; // 头像背景动画
  27. @property (nonatomic, strong) UIButton *youpaipliveBtn; // 直播
  28. @end
  29. @implementation YOUPAILZLiveAnchorHotCell
  30. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
  31. if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
  32. self.selectionStyle = UITableViewCellSelectionStyleNone;
  33. self.backgroundColor = [UIColor clearColor];
  34. [self youpaifinitUI];
  35. }
  36. return self;
  37. }
  38. - (void)youpaifinitUI{
  39. UIImageView *youpaiprankImgV = [[UIImageView alloc] init];
  40. [self.contentView addSubview:youpaiprankImgV];
  41. self.youpaiprankImgV = youpaiprankImgV;
  42. [youpaiprankImgV mas_makeConstraints:^(MASConstraintMaker *make) {
  43. make.left.offset(7.0f);
  44. make.centerY.equalTo(self.contentView);
  45. make.size.mas_offset(CGSizeMake(38.0f, 28.0f));
  46. }];
  47. UILabel *youpaiprankL = [[UILabel alloc] init];
  48. youpaiprankL.textColor = HexColorFromRGB(0x9F9DA5);
  49. youpaiprankL.textAlignment = NSTextAlignmentCenter;
  50. youpaiprankL.font = LCFont12;
  51. [self.contentView addSubview:youpaiprankL];
  52. self.youpaiprankL = youpaiprankL;
  53. [youpaiprankL mas_makeConstraints:^(MASConstraintMaker *make) {
  54. make.left.offset(7.0f);
  55. make.centerY.equalTo(self.centerY);
  56. make.size.mas_offset(CGSizeMake(38.0f, 28.0f));
  57. }];
  58. // YYAnimatedImageView *youpaipavatorBgAnimationV = [[YYAnimatedImageView alloc] init];
  59. // youpaipavatorBgAnimationV.image = self.youpaipicLiveUserHeader;
  60. // youpaipavatorBgAnimationV.contentMode = UIViewContentModeScaleAspectFit;
  61. // [self.contentView addSubview:youpaipavatorBgAnimationV];
  62. // self.youpaipavatorBgAnimationV = youpaipavatorBgAnimationV;
  63. // [youpaipavatorBgAnimationV mas_makeConstraints:^(MASConstraintMaker *make) {
  64. // make.left.offset(52.0f);
  65. // make.centerY.equalTo(self.contentView.mas_centerY);
  66. // make.size.mas_offset(CGSizeMake(48.0f, 48.0f));
  67. // }];
  68. YOUPAILZAvatarView *youpaipavatarView = [YOUPAILZAvatarView youpaifavatarViewWithFrame:CGRectMake(0, 0, 43, 43) avatarURL:nil personalityBoxURL:nil];
  69. [self.contentView addSubview:youpaipavatarView];
  70. self.youpaipavatarView = youpaipavatarView;
  71. [youpaipavatarView mas_makeConstraints:^(MASConstraintMaker *make) {
  72. make.left.mas_equalTo(52.0f);
  73. make.centerY.mas_equalTo(self.contentView.mas_centerY);
  74. make.size.mas_equalTo(CGSizeMake(43.0f, 43.0f));
  75. }];
  76. // UIImageView *youpaipavatarImgV = [[UIImageView alloc] init];
  77. // youpaipavatarImgV.contentMode = UIViewContentModeScaleAspectFill;
  78. // youpaipavatarImgV.layer.cornerRadius = 20.0f;
  79. // youpaipavatarImgV.clipsToBounds = YES;
  80. // youpaipavatarImgV.layer.borderWidth = 1.0f;
  81. // [self.contentView addSubview:youpaipavatarImgV];
  82. // self.youpaipavatarImgV = youpaipavatarImgV;
  83. // [youpaipavatarImgV mas_makeConstraints:^(MASConstraintMaker *make) {
  84. // make.left.mas_equalTo(52.0f);
  85. // make.centerY.mas_equalTo(self.contentView.mas_centerY);
  86. // make.size.mas_equalTo(CGSizeMake(43.0f, 43.0f));
  87. // }];
  88. RippleAnimationView *viewB = [[RippleAnimationView alloc] initWithFrame:CGRectMake(0, 0, 43, 43) animationType:AnimationTypeWithoutBackground];
  89. viewB.center = youpaipavatarView.center;
  90. self.youpaipavatorBgAnimationV = viewB;
  91. [self.contentView addSubview:viewB];
  92. [viewB mas_makeConstraints:^(MASConstraintMaker *make) {
  93. make.left.mas_equalTo(52.0f);
  94. make.centerY.mas_equalTo(self.contentView.mas_centerY);
  95. make.size.mas_equalTo(CGSizeMake(43.0f, 43.0f));
  96. }];
  97. UIButton *youpaipliveBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  98. [youpaipliveBtn setBackgroundImage:[UIImage imageNamed:@"vqu_images_L_bootom_live"] forState:UIControlStateNormal];
  99. [youpaipliveBtn setBackgroundImage:[UIImage imageNamed:@"vqu_images_L_bootom_live"] forState:UIControlStateHighlighted];
  100. youpaipliveBtn.userInteractionEnabled = NO;
  101. [youpaipavatarView addSubview:youpaipliveBtn];
  102. self.youpaipliveBtn = youpaipliveBtn;
  103. [youpaipliveBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  104. make.centerX.equalTo(0.0f);
  105. make.bottom.equalTo(youpaipavatarView.youpaipavatarImgV.mas_bottom).offset(0.0f);
  106. make.size.equalTo(youpaipavatarView.youpaipavatarImgV);
  107. }];
  108. UILabel *youpaipnicknameL = [[UILabel alloc] init];
  109. youpaipnicknameL.font = LCBoldFont(14.0f);
  110. youpaipnicknameL.textColor = [UIColor whiteColor];
  111. [self.contentView addSubview:youpaipnicknameL];
  112. self.youpaipnicknameL = youpaipnicknameL;
  113. [youpaipnicknameL mas_makeConstraints:^(MASConstraintMaker *make) {
  114. make.left.equalTo(youpaipavatarView.mas_right).offset(8.0f);
  115. make.top.offset(15.0f);
  116. }];
  117. UIImageView *youpaipsexV = [[UIImageView alloc] init];
  118. [self.contentView addSubview:youpaipsexV];
  119. self.youpaipsexV = youpaipsexV;
  120. [youpaipsexV mas_makeConstraints:^(MASConstraintMaker *make) {
  121. make.left.equalTo(youpaipnicknameL.mas_right).offset(3.0f);
  122. make.centerY.equalTo(youpaipnicknameL);
  123. make.size.mas_offset(CGSizeMake(15.0f, 15.0f));
  124. }];
  125. UIImageView *youpaipvipImgV = [[UIImageView alloc] init];
  126. [self.contentView addSubview:youpaipvipImgV];
  127. self.youpaipvipImgV = youpaipvipImgV;
  128. [youpaipvipImgV mas_makeConstraints:^(MASConstraintMaker *make) {
  129. make.left.equalTo(youpaipsexV.mas_right).offset(3.0f);
  130. make.centerY.equalTo(youpaipnicknameL);
  131. }];
  132. YOUPAILZLevelView *youpaiplevelView = [[YOUPAILZLevelView alloc] init];
  133. [self.contentView addSubview:youpaiplevelView];
  134. self.youpaiplevelView = youpaiplevelView;
  135. [youpaiplevelView mas_makeConstraints:^(MASConstraintMaker *make) {
  136. make.left.equalTo(youpaipsexV.mas_right).offset(3.0f);
  137. make.centerY.equalTo(youpaipnicknameL);
  138. }];
  139. UILabel *youpaipcontributionL = [[UILabel alloc] init];
  140. youpaipcontributionL.font = LCFont(10.0f);
  141. youpaipcontributionL.textColor = [UIColor whiteColor];
  142. [self.contentView addSubview:youpaipcontributionL];
  143. self.youpaipcontributionL = youpaipcontributionL;
  144. [youpaipcontributionL mas_makeConstraints:^(MASConstraintMaker *make) {
  145. make.left.equalTo(youpaipavatarView.mas_right).offset(8.0f);
  146. make.top.equalTo(youpaipnicknameL.mas_bottom).offset(2.0f);
  147. }];
  148. UIButton *youpaipfollowBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  149. youpaipfollowBtn.layer.cornerRadius = 11.0f;
  150. youpaipfollowBtn.clipsToBounds = YES;
  151. youpaipfollowBtn.layer.borderColor = HexColorFromRGB(0xFFDD8D).CGColor;
  152. youpaipfollowBtn.layer.borderWidth = 0.5f;
  153. [youpaipfollowBtn setTitle:@"关注" forState:UIControlStateNormal];
  154. [youpaipfollowBtn setTitleColor:HexColorFromRGB(0xFFDD8D) forState:UIControlStateNormal];
  155. youpaipfollowBtn.titleLabel.font = LCFont12;
  156. [youpaipfollowBtn addTarget:self action:@selector(youpaiffollowBtnClick) forControlEvents:UIControlEventTouchUpInside];
  157. [self.contentView addSubview:youpaipfollowBtn];
  158. self.youpaipfollowBtn = youpaipfollowBtn;
  159. [youpaipfollowBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  160. make.centerY.equalTo(self.contentView);
  161. make.right.offset(-12.0f);
  162. make.size.mas_offset(CGSizeMake(56.0f, 22.0f));
  163. }];
  164. }
  165. - (void)youpaifreloadWithModel:(YOUPAILZLiveMemberModel *)member indexPath:(NSIndexPath *)indexPath type:(LZLiveAnchorHotListType)type youpaipthemeColor:(UIColor *)youpaipthemeColor{
  166. self.youpaipmemberModel = member;
  167. self.youpaipthemeColor = youpaipthemeColor;
  168. if(member.youpaipis_liveing == 0){
  169. self.youpaipliveBtn.hidden = YES;
  170. self.youpaipavatorBgAnimationV.hidden = YES;
  171. }else{
  172. self.youpaipliveBtn.hidden = NO;
  173. self.youpaipavatorBgAnimationV.hidden = NO;
  174. }
  175. // if (indexPath.row + 1 <= 3 && type != LZLiveMemberListTypeOnline) {
  176. // self.youpaiprankImgV.hidden = NO;
  177. // self.youpaiprankL.hidden = YES;
  178. // self.youpaiprankImgV.image = [UIImage imageNamed:[NSString stringWithFormat:@"vqu_images_L_live_rank_consumption_%@",@(indexPath.row + 1)]];
  179. // NSArray <UIColor *>*colors = @[HexColorFromRGB(0xF5C686),HexColorFromRGB(0xDFF6FF),HexColorFromRGB(0xB8CC8B)];
  180. // self.youpaipavatarImgV.layer.borderColor = colors[indexPath.row].CGColor;
  181. // }else{
  182. self.youpaiprankImgV.hidden = YES;
  183. self.youpaiprankL.hidden = NO;
  184. self.youpaipavatarView.youpaipavatarImgV.layer.borderColor = HexColorFromRGB(0x9F9DA5).CGColor;
  185. // }
  186. self.youpaiprankL.text = [NSString stringWithFormat:@"%@",@(indexPath.row + 1)];
  187. self.youpaipfollowBtn.hidden = NO;
  188. if (member.youpaipis_follow == 1){
  189. self.youpaipfollowBtn.layer.borderColor = HexColorFromRGB(0x4F4B5B).CGColor;
  190. [self.youpaipfollowBtn setTitleColor:HexColorFromRGB(0x4F4B5B) forState:UIControlStateNormal];
  191. [self.youpaipfollowBtn setTitle:@"已关注" forState:UIControlStateNormal];
  192. }else if (member.youpaipis_follow == 0){
  193. self.youpaipfollowBtn.layer.borderColor = youpaipthemeColor.CGColor;
  194. [self.youpaipfollowBtn setTitleColor:youpaipthemeColor forState:UIControlStateNormal];
  195. [self.youpaipfollowBtn setTitle:@"关注" forState:UIControlStateNormal];
  196. }else{
  197. self.youpaipfollowBtn.hidden = YES;
  198. }
  199. self.youpaipavatarView.youpaipavatarURL = [LCTools getImageUrlWithAddress:member.youpaipavatar];
  200. self.youpaipavatarView.youpaippersonalityBoxURL = [LCTools getImageUrlWithAddress:member.youpaipavatar_frame];
  201. self.youpaipnicknameL.text = member.youpaipnickname;
  202. if (member.youpaipgender == 1) {//0未知 1女 2男
  203. self.youpaipsexV.image = [UIImage imageNamed:@"vqu_images_D_dynamic_woman"];
  204. }else{
  205. self.youpaipsexV.image = [UIImage imageNamed:@"vqu_images_D_dynamic_man"];
  206. }
  207. self.youpaipvipImgV.hidden = YES;
  208. self.youpaiplevelView.hidden = YES;
  209. UIView *frontV;
  210. if (member.youpaipvip_icon.length != 0) {
  211. self.youpaipvipImgV.hidden = NO;
  212. [self.youpaipvipImgV sd_setImageWithURL:[LCTools getImageUrlWithAddress:member.youpaipvip_icon]];
  213. [self.youpaipvipImgV mas_makeConstraints:^(MASConstraintMaker *make) {
  214. if (frontV == nil) {
  215. make.left.equalTo(self.youpaipsexV.mas_right).offset(3.0f);
  216. }else{
  217. make.left.equalTo(frontV.mas_right).offset(3.0f);
  218. }
  219. make.centerY.equalTo(self.youpaipnicknameL);
  220. make.size.mas_offset(CGSizeMake(30.0f, 19.0f));
  221. }];
  222. frontV = self.youpaipvipImgV;
  223. }
  224. self.youpaiplevelView.hidden = NO;
  225. [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];
  226. [self.youpaiplevelView mas_remakeConstraints:^(MASConstraintMaker *make) {
  227. if (frontV == nil) {
  228. make.left.equalTo(self.youpaipsexV.mas_right).offset(3.0f);
  229. }else{
  230. make.left.equalTo(frontV.mas_right).offset(3.0f);
  231. }
  232. make.centerY.equalTo(self.youpaipnicknameL);
  233. make.size.mas_offset(self.youpaiplevelView.mj_size);
  234. }];
  235. self.youpaipcontributionL.attributedText = [LCTools setRichTextWithTitle:@"魅力值:" subTitle:[NSString stringWithFormat:@"%@",member.youpaipscore] titleColor:[UIColor whiteColor] subTitleColor:HexColorFromRGB(0xFFDD8D) titleFontSize:10.0f subTitleFontSize:10.0f];
  236. }
  237. - (void)youpaiffollowBtnClick{
  238. self.youpaipmemberModel.youpaipis_follow = self.youpaipmemberModel.youpaipis_follow == 1 ? 0 : 1;
  239. if (self.youpaipmemberModel.youpaipis_follow== 1){
  240. self.youpaipfollowBtn.layer.borderColor = HexColorFromRGB(0x4F4B5B).CGColor;
  241. [self.youpaipfollowBtn setTitleColor:HexColorFromRGB(0x4F4B5B) forState:UIControlStateNormal];
  242. [self.youpaipfollowBtn setTitle:@"已关注" forState:UIControlStateNormal];
  243. }else{
  244. self.youpaipfollowBtn.layer.borderColor = self.youpaipthemeColor.CGColor;
  245. [self.youpaipfollowBtn setTitleColor:self.youpaipthemeColor forState:UIControlStateNormal];
  246. [self.youpaipfollowBtn setTitle:@"关注" forState:UIControlStateNormal];
  247. }
  248. [LCCommonHttp followUserId:self.youpaipmemberModel.youpaipid];
  249. }
  250. - (YYImage *)youpaipicLiveUserHeader{
  251. NSString *path = [[NSBundle mainBundle] pathForResource:@"ic_live_header" ofType:@"gif"];
  252. return [YYImage imageWithData:[NSData dataWithContentsOfFile:path]];
  253. }
  254. @end