// // YOUPAILZChatRoomSeatView.m // VQU // // Created by CY on 2021/10/28. // Copyright © 2021 MS. All rights reserved. // #import "YOUPAILZChatRoomSeatView.h" #import "YOUPAILZChatRoomSeatAvatarView.h" @interface YOUPAILZChatRoomSeatView () @property (nonatomic,weak)YOUPAILZChatRoomSeatAvatarView *youpaipavatarView; @property (nonatomic,weak)UILabel *youpaipnameL; @property (nonatomic,weak)UIButton *youpaipprofitBtn; // 收益 @property (nonatomic,weak)UILabel *youpaipseatNumL; // 座位号 @property (nonatomic,assign)CGSize youpaipavatarSize; @end @implementation YOUPAILZChatRoomSeatView - (instancetype)initWithAvatarSize:(CGSize)youpaipavatarSize{ if (self = [super init]) { self.youpaipavatarSize = youpaipavatarSize; [self youpaifinitUI]; } return self; } - (void)youpaifinitUI{ YOUPAILZChatRoomSeatAvatarView *youpaipavatarView = [[YOUPAILZChatRoomSeatAvatarView alloc] initWithFrame:CGRectMake(0, 0, self.youpaipavatarSize.width, self.youpaipavatarSize.height)]; [self addSubview:youpaipavatarView]; self.youpaipavatarView = youpaipavatarView; [youpaipavatarView mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.equalTo(self); make.top.offset(0.0f); make.size.mas_offset(self.youpaipavatarSize); }]; UILabel *youpaipnameL = [[UILabel alloc] init]; youpaipnameL.font = LCFont(10.0f); youpaipnameL.textColor = HexColorFromRGB(0x9F9DA5); youpaipnameL.textAlignment = NSTextAlignmentCenter; [self addSubview:youpaipnameL]; self.youpaipnameL = youpaipnameL; [self layoutIfNeeded]; [youpaipnameL mas_makeConstraints:^(MASConstraintMaker *make) { // make.left.offset(0.0f); // make.right.offset(0.0f); make.centerX.equalTo(self); make.width.mas_lessThanOrEqualTo(self.mas_width); make.top.equalTo(youpaipavatarView.mas_bottom).offset(10.0f); make.height.offset(13.0f); }]; UILabel *youpaipseatNumL = [[UILabel alloc] init]; youpaipseatNumL.font = LCFont(9.0f); youpaipseatNumL.textColor = [UIColor whiteColor]; youpaipseatNumL.textAlignment = NSTextAlignmentCenter; youpaipseatNumL.layer.cornerRadius = 5.0f; youpaipseatNumL.clipsToBounds = YES; [youpaipnameL addSubview:youpaipseatNumL]; youpaipseatNumL.hidden = YES; self.youpaipseatNumL = youpaipseatNumL; [youpaipseatNumL mas_makeConstraints:^(MASConstraintMaker *make) { make.left.offset(0.0f); make.centerY.equalTo(youpaipnameL); make.size.mas_offset(CGSizeMake(10.0f, 10.0f)); }]; UIButton *youpaipprofitBtn = [UIButton buttonWithType:UIButtonTypeCustom]; youpaipprofitBtn.hidden = YES; youpaipprofitBtn.userInteractionEnabled = NO; [youpaipprofitBtn setImage:[UIImage imageNamed:@"vqu_images_chatroom_seat_cardiac_value"] forState:UIControlStateNormal]; [youpaipprofitBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; [youpaipprofitBtn setTitle:@"0" forState:UIControlStateNormal]; youpaipprofitBtn.titleLabel.font = LCFont(10.0f); [self addSubview:youpaipprofitBtn]; self.youpaipprofitBtn = youpaipprofitBtn; [youpaipprofitBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.left.right.offset(0.0f); make.top.equalTo(youpaipnameL.mas_bottom).offset(2.0f); make.height.offset(13.0f); }]; } -(void)setYoupaipmodel:(YOUPAILZChatRoomSeatModel *)youpaipmodel{ _youpaipmodel = youpaipmodel; self.youpaipnameL.attributedText = nil; self.youpaipnameL.textColor = HexColorFromRGB(0x9F9DA5); self.youpaipavatarView.youpaipmodel = youpaipmodel; [self.youpaipprofitBtn setTitle:youpaipmodel.youpaipuserInfo.youpaipscore forState:UIControlStateNormal]; self.youpaipprofitBtn.hidden = YES; self.youpaipseatNumL.hidden = YES; if (youpaipmodel.youpaipseatState == LZChatRoomSeatStateWithBusy) { self.youpaipnameL.text = youpaipmodel.youpaipuserInfo.youpaipnickname; }else{ self.youpaipnameL.text = youpaipmodel.youpaipseatName; } switch (youpaipmodel.youpaipplayType) { // 玩法类型 0、默认玩法,1、心动值玩法,2、相亲玩法 case 0:{ if (youpaipmodel.youpaipseatType == LZChatRoomSeatTypeWithGuest) { self.youpaipnameL.textColor = HexColorFromRGB(0xF8DF6F); }else{ self.youpaipnameL.textColor = [UIColor whiteColor]; } } break; case 1:{ if (youpaipmodel.youpaipseatType == LZChatRoomSeatTypeWithGuest) { self.youpaipnameL.textColor = HexColorFromRGB(0xF8DF6F); }else{ self.youpaipnameL.textColor = [UIColor whiteColor]; } if (youpaipmodel.youpaipseatState == LZChatRoomSeatStateWithBusy) { self.youpaipnameL.text = youpaipmodel.youpaipuserInfo.youpaipnickname; } if (youpaipmodel.youpaipseatState == LZChatRoomSeatStateWithBusy) { self.youpaipprofitBtn.hidden = NO; } } break; case 2:{ self.youpaipnameL.textColor = [UIColor whiteColor]; if (youpaipmodel.youpaipseatState == LZChatRoomSeatStateWithBusy) { self.youpaipprofitBtn.hidden = NO; } if (youpaipmodel.youpaipseatType != LZChatRoomSeatTypeWithHost) { [self youpaifhandleNameLabel]; } } break; default: break; } if (youpaipmodel.youpaipisSelected) { self.youpaipnameL.textColor = HexColorFromRGB(0xFFCF74); } if (youpaipmodel.youpaipplayType == 2) { if (youpaipmodel.youpaipisSelected) { self.youpaipnameL.textColor = HexColorFromRGB(0xFF7FDA); }else{ self.youpaipnameL.textColor = [UIColor whiteColor]; } } } - (void)youpaifhandleNameLabel{ self.youpaipnameL.textColor = [UIColor whiteColor]; self.youpaipseatNumL.hidden = NO; self.youpaipseatNumL.text = [NSString stringWithFormat:@"%@",@(self.youpaipmodel.youpaipseatIndex)]; NSString *noneStr = @""; if (self.youpaipmodel.youpaipseatIndex <= 4) { noneStr = @"女神位"; self.youpaipseatNumL.backgroundColor = HexColorFromRGB(0xFF3165); }else{ noneStr = @"男神位"; self.youpaipseatNumL.backgroundColor = HexColorFromRGB(0x368CFF); } NSString *nameText = @""; if (self.youpaipmodel.youpaipseatState == LZChatRoomSeatStateWithBusy) { nameText = self.youpaipmodel.youpaipuserInfo.youpaipnickname; }else{ nameText = noneStr; } if (self.youpaipmodel.youpaipseat_selected.length != 0) { nameText = self.youpaipmodel.youpaipseat_selected; } NSTextAttachment *attch = [[NSTextAttachment alloc] init]; attch.image = [UIImage new]; attch.bounds = CGRectMake(0.0f, 0.0f, 13.0f, 10.0f); NSAttributedString *imageAttachment = [NSAttributedString attributedStringWithAttachment:attch]; NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] init]; [attributedString appendAttributedString:imageAttachment]; [attributedString appendAttributedString:[[NSAttributedString alloc] initWithString:nameText]]; self.youpaipnameL.attributedText = attributedString; } @end