YOUPAILZBlindDateSelectCell.m 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. //
  2. // YOUPAILZBlindDateSelectCell.m
  3. // YOUQU
  4. //
  5. // Created by CY on 2021/12/15.
  6. // Copyright © 2021 MS. All rights reserved.
  7. //
  8. #import "YOUPAILZBlindDateSelectCell.h"
  9. @interface YOUPAILZBlindDateSelectCell ()
  10. @property (nonatomic, weak) UIImageView *youpaipavatarImgV;
  11. @property (nonatomic,weak)UILabel *youpaipnameL;
  12. @property (nonatomic,weak)UILabel *youpaipseatNumL; // 座位号
  13. @property (nonatomic,weak) UIImageView *youpaipunmannedStateImgV; // 在没有人上麦的状态 空闲or锁定
  14. @end
  15. @implementation YOUPAILZBlindDateSelectCell
  16. - (instancetype)initWithFrame:(CGRect)frame{
  17. if (self = [super initWithFrame:frame]) {
  18. [self youpaifinitUI];
  19. }
  20. return self;
  21. }
  22. - (void)youpaifinitUI{
  23. UIImageView *youpaipavatarImgV = [[UIImageView alloc] init];
  24. youpaipavatarImgV.layer.cornerRadius = 27.0f;
  25. youpaipavatarImgV.clipsToBounds = YES;
  26. youpaipavatarImgV.layer.borderColor = HexColorFromRGB(0xFF7FDA).CGColor;
  27. youpaipavatarImgV.layer.borderWidth = 0.0f;
  28. youpaipavatarImgV.contentMode = UIViewContentModeScaleAspectFill;
  29. youpaipavatarImgV.hidden = YES;
  30. [self.contentView addSubview:youpaipavatarImgV];
  31. self.youpaipavatarImgV = youpaipavatarImgV;
  32. [youpaipavatarImgV mas_makeConstraints:^(MASConstraintMaker *make) {
  33. make.top.offset(0.0f);
  34. make.centerX.equalTo(self.contentView);
  35. make.size.mas_offset(CGSizeMake(54.0f, 54.0f));
  36. }];
  37. UIImageView *youpaipunmannedStateImgV = [[UIImageView alloc] init];
  38. youpaipunmannedStateImgV.hidden = YES;
  39. [self addSubview:youpaipunmannedStateImgV];
  40. self.youpaipunmannedStateImgV = youpaipunmannedStateImgV;
  41. [youpaipunmannedStateImgV mas_makeConstraints:^(MASConstraintMaker *make) {
  42. make.center.equalTo(youpaipavatarImgV);
  43. make.size.mas_offset(CGSizeMake(54.0f, 54.0f));
  44. }];
  45. UILabel *youpaipnameL = [[UILabel alloc] init];
  46. youpaipnameL.font = LCFont(10.0f);
  47. youpaipnameL.textColor = HexColorFromRGB(0x9F9DA5);
  48. youpaipnameL.textAlignment = NSTextAlignmentCenter;
  49. [self addSubview:youpaipnameL];
  50. self.youpaipnameL = youpaipnameL;
  51. [self layoutIfNeeded];
  52. [youpaipnameL mas_makeConstraints:^(MASConstraintMaker *make) {
  53. make.centerX.equalTo(self);
  54. make.bottom.offset(0.0f);
  55. make.width.mas_lessThanOrEqualTo(self.contentView.mas_width);
  56. make.height.offset(13.0f);
  57. }];
  58. UILabel *youpaipseatNumL = [[UILabel alloc] init];
  59. youpaipseatNumL.font = LCFont(9.0f);
  60. youpaipseatNumL.textColor = [UIColor whiteColor];
  61. youpaipseatNumL.textAlignment = NSTextAlignmentCenter;
  62. youpaipseatNumL.layer.cornerRadius = 5.0f;
  63. youpaipseatNumL.clipsToBounds = YES;
  64. [youpaipnameL addSubview:youpaipseatNumL];
  65. self.youpaipseatNumL = youpaipseatNumL;
  66. [youpaipseatNumL mas_makeConstraints:^(MASConstraintMaker *make) {
  67. make.left.offset(0.0f);
  68. make.centerY.equalTo(youpaipnameL);
  69. make.size.mas_offset(CGSizeMake(10.0f, 10.0f));
  70. }];
  71. }
  72. - (void)youpaifreloadWithModel:(YOUPAILZChatRoomSeatModel *)model{
  73. self.youpaipavatarImgV.hidden = YES;
  74. self.youpaipunmannedStateImgV.hidden = YES;
  75. switch (model.youpaipseatState) {
  76. case LZChatRoomSeatStateWithFree:{
  77. self.youpaipunmannedStateImgV.hidden = NO;
  78. NSString *imageName = @"";
  79. if (model.youpaipseatIndex <= 4) {
  80. imageName = @"vqu_image_chatroom_seat_woman";
  81. }else{
  82. imageName = @"vqu_image_chatroom_seat_man";
  83. }
  84. self.youpaipunmannedStateImgV.image = [UIImage imageNamed:imageName];
  85. }
  86. break;
  87. case LZChatRoomSeatStateWithLock:{
  88. self.youpaipunmannedStateImgV.hidden = NO;
  89. self.youpaipunmannedStateImgV.image = [UIImage imageNamed:@"vqu_images_chatroom_seat_lock"];
  90. }
  91. break;
  92. case LZChatRoomSeatStateWithBusy:{
  93. self.youpaipunmannedStateImgV.hidden = YES;
  94. self.youpaipavatarImgV.hidden = NO;
  95. [self.youpaipavatarImgV sd_setImageWithURL:[LCTools getImageUrlWithAddress:model.youpaipuserInfo.youpaipavatar]];
  96. }
  97. default:
  98. break;
  99. }
  100. self.youpaipseatNumL.text = [NSString stringWithFormat:@"%@",@(model.youpaipseatIndex)];
  101. NSString *noneStr = @"";
  102. if (model.youpaipseatIndex <= 4) {
  103. noneStr = @"女神位";
  104. self.youpaipseatNumL.backgroundColor = HexColorFromRGB(0xFF3165);
  105. }else{
  106. noneStr = @"男神位";
  107. self.youpaipseatNumL.backgroundColor = HexColorFromRGB(0x368CFF);
  108. }
  109. NSString *nameText = @"";
  110. if (model.youpaipseatState == LZChatRoomSeatStateWithBusy) {
  111. nameText = model.youpaipuserInfo.youpaipnickname;
  112. }else{
  113. nameText = noneStr;
  114. }
  115. NSMutableParagraphStyle *paraStyle = [[NSMutableParagraphStyle alloc] init];
  116. paraStyle.firstLineHeadIndent = 13.0f;//首行缩进
  117. NSAttributedString *attrText = [[NSAttributedString alloc] initWithString:nameText attributes:@{NSParagraphStyleAttributeName:paraStyle}];
  118. self.youpaipnameL.attributedText = attrText;
  119. if (model.youpaipisSelected) {
  120. self.youpaipnameL.textColor = HexColorFromRGB(0xFF7FDA);
  121. self.youpaipavatarImgV.layer.borderWidth = 2.0f;
  122. }else{
  123. self.youpaipnameL.textColor = [UIColor whiteColor];
  124. self.youpaipavatarImgV.layer.borderWidth = 0.0f;
  125. }
  126. }
  127. @end