YOUPAILZChatRoomSeatView.m 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. //
  2. // YOUPAILZChatRoomSeatView.m
  3. // VQU
  4. //
  5. // Created by CY on 2021/10/28.
  6. // Copyright © 2021 MS. All rights reserved.
  7. //
  8. #import "YOUPAILZChatRoomSeatView.h"
  9. #import "YOUPAILZChatRoomSeatAvatarView.h"
  10. @interface YOUPAILZChatRoomSeatView ()
  11. @property (nonatomic,weak)YOUPAILZChatRoomSeatAvatarView *youpaipavatarView;
  12. @property (nonatomic,weak)UILabel *youpaipnameL;
  13. @property (nonatomic,weak)UIButton *youpaipprofitBtn; // 收益
  14. @property (nonatomic,weak)UILabel *youpaipseatNumL; // 座位号
  15. @property (nonatomic,assign)CGSize youpaipavatarSize;
  16. @end
  17. @implementation YOUPAILZChatRoomSeatView
  18. - (instancetype)initWithAvatarSize:(CGSize)youpaipavatarSize{
  19. if (self = [super init]) {
  20. self.youpaipavatarSize = youpaipavatarSize;
  21. [self youpaifinitUI];
  22. }
  23. return self;
  24. }
  25. - (void)youpaifinitUI{
  26. YOUPAILZChatRoomSeatAvatarView *youpaipavatarView = [[YOUPAILZChatRoomSeatAvatarView alloc] initWithFrame:CGRectMake(0, 0, self.youpaipavatarSize.width, self.youpaipavatarSize.height)];
  27. [self addSubview:youpaipavatarView];
  28. self.youpaipavatarView = youpaipavatarView;
  29. [youpaipavatarView mas_makeConstraints:^(MASConstraintMaker *make) {
  30. make.centerX.equalTo(self);
  31. make.top.offset(0.0f);
  32. make.size.mas_offset(self.youpaipavatarSize);
  33. }];
  34. UILabel *youpaipnameL = [[UILabel alloc] init];
  35. youpaipnameL.font = LCFont(10.0f);
  36. youpaipnameL.textColor = HexColorFromRGB(0x9F9DA5);
  37. youpaipnameL.textAlignment = NSTextAlignmentCenter;
  38. [self addSubview:youpaipnameL];
  39. self.youpaipnameL = youpaipnameL;
  40. [self layoutIfNeeded];
  41. [youpaipnameL mas_makeConstraints:^(MASConstraintMaker *make) {
  42. // make.left.offset(0.0f);
  43. // make.right.offset(0.0f);
  44. make.centerX.equalTo(self);
  45. make.width.mas_lessThanOrEqualTo(self.mas_width);
  46. make.top.equalTo(youpaipavatarView.mas_bottom).offset(10.0f);
  47. make.height.offset(13.0f);
  48. }];
  49. UILabel *youpaipseatNumL = [[UILabel alloc] init];
  50. youpaipseatNumL.font = LCFont(9.0f);
  51. youpaipseatNumL.textColor = [UIColor whiteColor];
  52. youpaipseatNumL.textAlignment = NSTextAlignmentCenter;
  53. youpaipseatNumL.layer.cornerRadius = 5.0f;
  54. youpaipseatNumL.clipsToBounds = YES;
  55. [youpaipnameL addSubview:youpaipseatNumL];
  56. youpaipseatNumL.hidden = YES;
  57. self.youpaipseatNumL = youpaipseatNumL;
  58. [youpaipseatNumL mas_makeConstraints:^(MASConstraintMaker *make) {
  59. make.left.offset(0.0f);
  60. make.centerY.equalTo(youpaipnameL);
  61. make.size.mas_offset(CGSizeMake(10.0f, 10.0f));
  62. }];
  63. UIButton *youpaipprofitBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  64. youpaipprofitBtn.hidden = YES;
  65. youpaipprofitBtn.userInteractionEnabled = NO;
  66. [youpaipprofitBtn setImage:[UIImage imageNamed:@"vqu_images_chatroom_seat_cardiac_value"] forState:UIControlStateNormal];
  67. [youpaipprofitBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  68. [youpaipprofitBtn setTitle:@"0" forState:UIControlStateNormal];
  69. youpaipprofitBtn.titleLabel.font = LCFont(10.0f);
  70. [self addSubview:youpaipprofitBtn];
  71. self.youpaipprofitBtn = youpaipprofitBtn;
  72. [youpaipprofitBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  73. make.left.right.offset(0.0f);
  74. make.top.equalTo(youpaipnameL.mas_bottom).offset(2.0f);
  75. make.height.offset(13.0f);
  76. }];
  77. }
  78. -(void)setYoupaipmodel:(YOUPAILZChatRoomSeatModel *)youpaipmodel{
  79. _youpaipmodel = youpaipmodel;
  80. self.youpaipnameL.attributedText = nil;
  81. self.youpaipnameL.textColor = HexColorFromRGB(0x9F9DA5);
  82. self.youpaipavatarView.youpaipmodel = youpaipmodel;
  83. [self.youpaipprofitBtn setTitle:youpaipmodel.youpaipuserInfo.youpaipscore forState:UIControlStateNormal];
  84. self.youpaipprofitBtn.hidden = YES;
  85. self.youpaipseatNumL.hidden = YES;
  86. if (youpaipmodel.youpaipseatState == LZChatRoomSeatStateWithBusy) {
  87. self.youpaipnameL.text = youpaipmodel.youpaipuserInfo.youpaipnickname;
  88. }else{
  89. self.youpaipnameL.text = youpaipmodel.youpaipseatName;
  90. }
  91. switch (youpaipmodel.youpaipplayType) { // 玩法类型 0、默认玩法,1、心动值玩法,2、相亲玩法
  92. case 0:{
  93. if (youpaipmodel.youpaipseatType == LZChatRoomSeatTypeWithGuest) {
  94. self.youpaipnameL.textColor = HexColorFromRGB(0xF8DF6F);
  95. }else{
  96. self.youpaipnameL.textColor = [UIColor whiteColor];
  97. }
  98. }
  99. break;
  100. case 1:{
  101. if (youpaipmodel.youpaipseatType == LZChatRoomSeatTypeWithGuest) {
  102. self.youpaipnameL.textColor = HexColorFromRGB(0xF8DF6F);
  103. }else{
  104. self.youpaipnameL.textColor = [UIColor whiteColor];
  105. }
  106. if (youpaipmodel.youpaipseatState == LZChatRoomSeatStateWithBusy) {
  107. self.youpaipnameL.text = youpaipmodel.youpaipuserInfo.youpaipnickname;
  108. }
  109. if (youpaipmodel.youpaipseatState == LZChatRoomSeatStateWithBusy) {
  110. self.youpaipprofitBtn.hidden = NO;
  111. }
  112. }
  113. break;
  114. case 2:{
  115. self.youpaipnameL.textColor = [UIColor whiteColor];
  116. if (youpaipmodel.youpaipseatState == LZChatRoomSeatStateWithBusy) {
  117. self.youpaipprofitBtn.hidden = NO;
  118. }
  119. if (youpaipmodel.youpaipseatType != LZChatRoomSeatTypeWithHost) {
  120. [self youpaifhandleNameLabel];
  121. }
  122. }
  123. break;
  124. default:
  125. break;
  126. }
  127. if (youpaipmodel.youpaipisSelected) {
  128. self.youpaipnameL.textColor = HexColorFromRGB(0xFFCF74);
  129. }
  130. if (youpaipmodel.youpaipplayType == 2) {
  131. if (youpaipmodel.youpaipisSelected) {
  132. self.youpaipnameL.textColor = HexColorFromRGB(0xFF7FDA);
  133. }else{
  134. self.youpaipnameL.textColor = [UIColor whiteColor];
  135. }
  136. }
  137. }
  138. - (void)youpaifhandleNameLabel{
  139. self.youpaipnameL.textColor = [UIColor whiteColor];
  140. self.youpaipseatNumL.hidden = NO;
  141. self.youpaipseatNumL.text = [NSString stringWithFormat:@"%@",@(self.youpaipmodel.youpaipseatIndex)];
  142. NSString *noneStr = @"";
  143. if (self.youpaipmodel.youpaipseatIndex <= 4) {
  144. noneStr = @"女神位";
  145. self.youpaipseatNumL.backgroundColor = HexColorFromRGB(0xFF3165);
  146. }else{
  147. noneStr = @"男神位";
  148. self.youpaipseatNumL.backgroundColor = HexColorFromRGB(0x368CFF);
  149. }
  150. NSString *nameText = @"";
  151. if (self.youpaipmodel.youpaipseatState == LZChatRoomSeatStateWithBusy) {
  152. nameText = self.youpaipmodel.youpaipuserInfo.youpaipnickname;
  153. }else{
  154. nameText = noneStr;
  155. }
  156. if (self.youpaipmodel.youpaipseat_selected.length != 0) {
  157. nameText = self.youpaipmodel.youpaipseat_selected;
  158. }
  159. NSTextAttachment *attch = [[NSTextAttachment alloc] init];
  160. attch.image = [UIImage new];
  161. attch.bounds = CGRectMake(0.0f, 0.0f, 13.0f, 10.0f);
  162. NSAttributedString *imageAttachment = [NSAttributedString attributedStringWithAttachment:attch];
  163. NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] init];
  164. [attributedString appendAttributedString:imageAttachment];
  165. [attributedString appendAttributedString:[[NSAttributedString alloc] initWithString:nameText]];
  166. self.youpaipnameL.attributedText = attributedString;
  167. }
  168. @end