YOUPAILZChatRoomInviationUpSeatCell.m 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. //
  2. // YOUPAILZChatRoomInviationUpSeatCell.m
  3. // VQU
  4. //
  5. // Created by CY on 2021/11/5.
  6. // Copyright © 2021 MS. All rights reserved.
  7. //
  8. #import "YOUPAILZChatRoomInviationUpSeatCell.h"
  9. #import "YOUPAILZAvatarView.h"
  10. #import "YOUPAILZLevelView.h"
  11. @interface YOUPAILZChatRoomInviationUpSeatCell ()
  12. @property (nonatomic, weak) UIImageView *youpaiprankImageV;
  13. @property (nonatomic, weak) UILabel *youpaiprankL; /// 排名
  14. @property (nonatomic, weak) YOUPAILZAvatarView *youpaipavatarView; // 头像
  15. @property (nonatomic, weak) UILabel *youpaipnicknameL; // 昵称
  16. @property (nonatomic, weak) UIImageView *youpaipvipImgV; // 贵族
  17. @property (nonatomic, weak) UIImageView *youpaipboardImgV; // 榜单
  18. @property (nonatomic, weak) YOUPAILZLevelView *youpaiplevelView; // 等级
  19. @property (nonatomic, weak) UILabel *youpaipcontributionL; // 贡献值
  20. @property (nonatomic, weak) UIButton *youpaipinviationBtn; // 邀请
  21. @property (nonatomic, weak) UIButton *youpaipfollowBtn; // 关注
  22. @property (nonatomic, strong) YOUPAILZChatRoomMemberModel *youpaipmodel;
  23. @end
  24. @implementation YOUPAILZChatRoomInviationUpSeatCell
  25. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
  26. if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
  27. self.selectionStyle = UITableViewCellSelectionStyleNone;
  28. self.backgroundColor = [UIColor clearColor];
  29. [self youpaifinitUI];
  30. }
  31. return self;
  32. }
  33. - (void)youpaifinitUI{
  34. UIImageView *youpaiprankImageV = [[UIImageView alloc] init];
  35. [self.contentView addSubview:youpaiprankImageV];
  36. self.youpaiprankImageV = youpaiprankImageV;
  37. [youpaiprankImageV mas_makeConstraints:^(MASConstraintMaker *make) {
  38. make.left.offset(10.0f);
  39. make.centerY.equalTo(self.contentView);
  40. make.size.mas_offset(CGSizeMake(32.0f, 32.0f));
  41. }];
  42. UILabel *youpaiprankL = [[UILabel alloc] init];
  43. youpaiprankL.textColor = HexColorFromRGB(0x9F9DA5);
  44. youpaiprankL.textAlignment = NSTextAlignmentCenter;
  45. youpaiprankL.font = LCBoldFont(12.0f);
  46. [self.contentView addSubview:youpaiprankL];
  47. self.youpaiprankL = youpaiprankL;
  48. [youpaiprankL mas_makeConstraints:^(MASConstraintMaker *make) {
  49. make.left.offset(7.0f);
  50. make.centerY.equalTo(self.centerY);
  51. make.size.mas_offset(CGSizeMake(38.0f, 28.0f));
  52. }];
  53. YOUPAILZAvatarView *youpaipavatarView = [YOUPAILZAvatarView youpaifavatarViewWithFrame:CGRectMake(0, 0, 40, 40) avatarURL:nil personalityBoxURL:nil];
  54. [self.contentView addSubview:youpaipavatarView];
  55. self.youpaipavatarView = youpaipavatarView;
  56. [youpaipavatarView mas_makeConstraints:^(MASConstraintMaker *make) {
  57. make.left.offset(52.0f);
  58. make.centerY.equalTo(self.contentView.mas_centerY);
  59. make.size.mas_offset(CGSizeMake(40.0f, 40.0f));
  60. }];
  61. UILabel *youpaipnicknameL = [[UILabel alloc] init];
  62. youpaipnicknameL.font = LCBoldFont(14.0f);
  63. youpaipnicknameL.textColor = [UIColor whiteColor];
  64. [self.contentView addSubview:youpaipnicknameL];
  65. self.youpaipnicknameL = youpaipnicknameL;
  66. [youpaipnicknameL mas_makeConstraints:^(MASConstraintMaker *make) {
  67. make.left.equalTo(youpaipavatarView.mas_right).offset(8.0f);
  68. make.top.offset(15.0f);
  69. }];
  70. UIImageView *youpaipvipImgV = [[UIImageView alloc] init];
  71. [self.contentView addSubview:youpaipvipImgV];
  72. self.youpaipvipImgV = youpaipvipImgV;
  73. [youpaipvipImgV mas_makeConstraints:^(MASConstraintMaker *make) {
  74. make.left.equalTo(youpaipnicknameL.mas_right).offset(3.0f);
  75. make.centerY.equalTo(youpaipnicknameL);
  76. }];
  77. UIImageView *youpaipboardImgV = [[UIImageView alloc] init];
  78. [self.contentView addSubview:youpaipboardImgV];
  79. self.youpaipboardImgV = youpaipboardImgV;
  80. [youpaipboardImgV mas_makeConstraints:^(MASConstraintMaker *make) {
  81. make.left.equalTo(youpaipnicknameL.mas_right).offset(3.0f);
  82. make.centerY.equalTo(youpaipnicknameL);
  83. }];
  84. YOUPAILZLevelView *youpaiplevelView = [[YOUPAILZLevelView alloc] init];
  85. [self.contentView addSubview:youpaiplevelView];
  86. self.youpaiplevelView = youpaiplevelView;
  87. [youpaiplevelView mas_makeConstraints:^(MASConstraintMaker *make) {
  88. make.left.equalTo(youpaipnicknameL.mas_right).offset(3.0f);
  89. make.centerY.equalTo(youpaipnicknameL);
  90. }];
  91. UILabel *youpaipcontributionL = [[UILabel alloc] init];
  92. youpaipcontributionL.font = LCFont(10.0f);
  93. youpaipcontributionL.textColor = [UIColor whiteColor];
  94. [self.contentView addSubview:youpaipcontributionL];
  95. self.youpaipcontributionL = youpaipcontributionL;
  96. [youpaipcontributionL mas_makeConstraints:^(MASConstraintMaker *make) {
  97. make.left.equalTo(youpaipavatarView.mas_right).offset(8.0f);
  98. make.top.equalTo(youpaipnicknameL.mas_bottom).offset(5.0f);
  99. }];
  100. UIButton *youpaipinviationBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  101. youpaipinviationBtn.layer.cornerRadius = 11.0f;
  102. youpaipinviationBtn.clipsToBounds = YES;
  103. [youpaipinviationBtn setTitle:@"邀上麦" forState:UIControlStateNormal];
  104. [youpaipinviationBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  105. [youpaipinviationBtn setBackgroundImage:[LCTools ColorImage:CGSizeMake(56.0f, 22.0f) FromColors:@[HexColorFromRGB(0xFF0084),HexColorFromRGB(0xFF3A00)] ByGradientType:GradientLeftToRight] forState:UIControlStateNormal];
  106. youpaipinviationBtn.titleLabel.font = LCFont12;
  107. youpaipinviationBtn.hidden = YES;
  108. [youpaipinviationBtn addTarget:self action:@selector(youpaifinviationBtnClick) forControlEvents:UIControlEventTouchUpInside];
  109. [self.contentView addSubview:youpaipinviationBtn];
  110. self.youpaipinviationBtn = youpaipinviationBtn;
  111. [youpaipinviationBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  112. make.centerY.equalTo(self.contentView);
  113. make.right.offset(-14.0f);
  114. make.size.mas_offset(CGSizeMake(56.0f, 22.0f));
  115. }];
  116. UIButton *youpaipfollowBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  117. [youpaipfollowBtn setBackgroundImage:[LCTools ColorImage:CGSizeMake(56.0f, 22.0f) FromColors:@[HexColorFromRGB(0xFF0084),HexColorFromRGB(0xFF3A00)] ByGradientType:GradientLeftToRight] forState:UIControlStateNormal];
  118. [youpaipfollowBtn setBackgroundImage:[LCTools ColorImage:CGSizeMake(56.0f, 22.0f) FromColors:@[HexColorFromRGB(0x4F4B5B),HexColorFromRGB(0x4F4B5B)] ByGradientType:GradientLeftToRight] forState:UIControlStateSelected];
  119. [youpaipfollowBtn setTitle:@"关注" forState:UIControlStateNormal];
  120. [youpaipfollowBtn setTitle:@"已关注" forState:UIControlStateSelected];
  121. [youpaipfollowBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  122. [youpaipfollowBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateSelected];
  123. youpaipfollowBtn.titleLabel.font = LCFont(12.0f);
  124. youpaipfollowBtn.layer.cornerRadius = 11.0f;
  125. youpaipfollowBtn.clipsToBounds = YES;
  126. youpaipfollowBtn.hidden = YES;
  127. [youpaipfollowBtn addTarget:self action:@selector(youpaiffollowBtnClick:) forControlEvents:UIControlEventTouchUpInside];
  128. [self addSubview:youpaipfollowBtn];
  129. self.youpaipfollowBtn = youpaipfollowBtn;
  130. [youpaipfollowBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  131. make.centerY.equalTo(self.contentView);
  132. make.right.offset(-14.0f);
  133. make.size.mas_offset(CGSizeMake(56.0f, 22.0f));
  134. }];
  135. }
  136. - (void)youpaifreloadWithModel:(YOUPAILZChatRoomMemberModel *)model index:(NSInteger)index buttonType:(LZChatRoomInviationUpSeatCellButtonType)buttonType rankType:(LZChatRoomInviationUpSeatCellRankType)rankType contributionName:(NSString *)contributionName{
  137. self.youpaipmodel = model;
  138. self.youpaiprankImageV.hidden = YES;
  139. self.youpaiprankL.hidden = YES;
  140. if (index + 1 <= 3 && rankType == LZChatRoomInviationUpSeatCellRankTypeWithTopThree) {
  141. self.youpaiprankImageV.hidden = NO;
  142. self.youpaiprankL.hidden = YES;
  143. self.youpaiprankImageV.image = [UIImage imageNamed:[NSString stringWithFormat:@"vqu_images_Chatroom_rank_%@",@(index + 1)]];
  144. }else{
  145. self.youpaiprankImageV.hidden = YES;
  146. self.youpaiprankL.hidden = NO;
  147. }
  148. self.youpaiprankL.text = [NSString stringWithFormat:@"%@",@(index + 1)];
  149. self.youpaipavatarView.youpaipavatarURL = [LCTools getImageUrlWithAddress:model.youpaipavatar];
  150. self.youpaipavatarView.youpaippersonalityBoxURL = [LCTools getImageUrlWithAddress:model.youpaipavatar_frame];
  151. self.youpaipnicknameL.text = model.youpaipnickname;
  152. self.youpaipvipImgV.hidden = YES;
  153. self.youpaipboardImgV.hidden = YES;
  154. self.youpaiplevelView.hidden = YES;
  155. UIView *frontV;
  156. if (model.youpaipvip_icon.length != 0) {
  157. self.youpaipvipImgV.hidden = NO;
  158. [self.youpaipvipImgV sd_setImageWithURL:[LCTools getImageUrlWithAddress:model.youpaipvip_icon]];
  159. [self.youpaipvipImgV mas_remakeConstraints:^(MASConstraintMaker *make) {
  160. if (frontV == nil) {
  161. make.left.equalTo(self.youpaipnicknameL.mas_right).offset(3.0f);
  162. }else{
  163. make.left.equalTo(frontV.mas_right).offset(3.0f);
  164. }
  165. make.centerY.equalTo(self.youpaipnicknameL);
  166. make.size.mas_offset(CGSizeMake(30.0f, 19.0f));
  167. }];
  168. frontV = self.youpaipvipImgV;
  169. }
  170. if (model.youpaiprankInfo.youpaipimg.length != 0) {
  171. self.youpaipboardImgV.hidden = NO;
  172. [self.youpaipboardImgV sd_setImageWithURL:[LCTools getImageUrlWithAddress:model.youpaiprankInfo.youpaipimg]];
  173. [self.youpaipboardImgV mas_remakeConstraints:^(MASConstraintMaker *make) {
  174. if (frontV == nil) {
  175. make.left.equalTo(self.youpaipnicknameL.mas_right).offset(3.0f);
  176. }else{
  177. make.left.equalTo(frontV.mas_right).offset(3.0f);
  178. }
  179. make.centerY.equalTo(self.youpaipnicknameL);
  180. make.size.mas_offset(CGSizeMake(21.0f, 18.0f));
  181. }];
  182. frontV = self.youpaipboardImgV;
  183. }
  184. self.youpaiplevelView.hidden = NO;
  185. [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];
  186. [self.youpaiplevelView mas_remakeConstraints:^(MASConstraintMaker *make) {
  187. if (frontV == nil) {
  188. make.left.equalTo(self.youpaipnicknameL.mas_right).offset(3.0f);
  189. }else{
  190. make.left.equalTo(frontV.mas_right).offset(3.0f);
  191. }
  192. make.centerY.equalTo(self.youpaipnicknameL);
  193. make.size.mas_offset(self.youpaiplevelView.mj_size);
  194. }];
  195. 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];
  196. self.youpaipinviationBtn.hidden = YES;
  197. self.youpaipfollowBtn.hidden = YES;
  198. switch (buttonType) {
  199. case LZChatRoomInviationUpSeatCellButtonTypeWithFollow:{
  200. self.youpaipfollowBtn.hidden = NO;
  201. }
  202. break;
  203. case LZChatRoomInviationUpSeatCellButtonTypeWithInviation:{
  204. self.youpaipinviationBtn.hidden = NO;
  205. }
  206. break;
  207. default:
  208. break;
  209. }
  210. //是否在麦上 0否 1是
  211. if (model.youpaipis_seat == 1) {
  212. self.youpaipinviationBtn.userInteractionEnabled = NO;
  213. [self.youpaipinviationBtn setBackgroundImage:[LCTools ColorImage:CGSizeMake(56.0f, 22.0f) FromColors:@[HexColorFromRGB(0x4F4B5B),HexColorFromRGB(0x4F4B5B)] ByGradientType:GradientLeftToRight] forState:UIControlStateNormal];
  214. [self.youpaipinviationBtn setTitle:@"已上麦" forState:UIControlStateNormal];
  215. }else{
  216. self.youpaipinviationBtn.userInteractionEnabled = YES;
  217. [self.youpaipinviationBtn setBackgroundImage:[LCTools ColorImage:CGSizeMake(56.0f, 22.0f) FromColors:@[HexColorFromRGB(0xFF0084),HexColorFromRGB(0xFF3A00)] ByGradientType:GradientLeftToRight] forState:UIControlStateNormal];
  218. [self.youpaipinviationBtn setTitle:@"邀上麦" forState:UIControlStateNormal];
  219. }
  220. //1关注,0未关注 -1本身
  221. if (model.youpaipis_follow == 1){
  222. self.youpaipfollowBtn.selected = YES;
  223. }else if (model.youpaipis_follow == 0){
  224. self.youpaipfollowBtn.selected = NO;
  225. }else{
  226. self.youpaipfollowBtn.hidden = YES;
  227. }
  228. }
  229. - (void)youpaifinviationBtnClick{
  230. if (self.youpaipinviationBtnClickBlock != nil) {
  231. self.youpaipinviationBtnClickBlock(self.youpaipmodel);
  232. }
  233. }
  234. - (void)youpaiffollowBtnClick:(UIButton *)sender{
  235. sender.selected = !sender.selected;
  236. [LCCommonHttp followUserId:self.youpaipmodel.youpaipid];
  237. }
  238. @end