123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155 |
- //
- // YOUPAILZChatRoomBlindDateProgressView.m
- // YOUQU
- //
- // Created by CY on 2021/12/14.
- // Copyright © 2021 MS. All rights reserved.
- //
- #import "YOUPAILZChatRoomBlindDateProgressView.h"
- #import "LOTAnimationView.h"
- @interface YOUPAILZChatRoomBlindDateProgressView ()
- @property (nonatomic,strong)YOUPAILZChatRoomModel *youpaipmodel;
- @end
- @implementation YOUPAILZChatRoomBlindDateProgressView
- - (void)youpaifreloadWithModel:(YOUPAILZChatRoomModel *)model{
- if (model.youpaipplayType != LZChatRoomPlayTypeWithBlindDate || model.youpaiptalk_played_status.count == 0) {
- return;
- }
- self.youpaipmodel = model;
- for (UIView *subV in self.subviews) {
- [subV removeFromSuperview];
- }
- NSMutableArray <UIButton *>*btns = [NSMutableArray array];
- for (NSInteger i = 0; i < model.youpaiptalk_played_status.count; i ++) {
- YOUPAILZChatRoomTalkPlayedStatusModel *statusModel = model.youpaiptalk_played_status[i];
- UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
- btn.layer.cornerRadius = 11.0f;
- btn.clipsToBounds = YES;
- [btn setBackgroundColor:[[UIColor whiteColor] colorWithAlphaComponent:0.29f]];
- if (statusModel.youpaipselected) {
- [btn setBackgroundColor:[UIColor clearColor]];
- [btn setBackgroundImage:[LCTools ColorImage:CGSizeMake(ScaleSize(64.0f), 22.0f) FromColors:@[HexColorFromRGB(0xFF7FDA),HexColorFromRGB(0xFF48B3)] ByGradientType:GradientTopToBottom] forState:UIControlStateNormal];
- }
- [btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
- [btn setTitle:statusModel.youpaiptitle forState:UIControlStateNormal];
- btn.titleLabel.font = LCFont(ScaleSize(12.0f));
- btn.tag = i;
- [btn addTarget:self action:@selector(youpaifbtnClick:) forControlEvents:UIControlEventTouchUpInside];
- [self addSubview:btn];
- [btns addObject:btn];
- }
- [btns mas_distributeViewsAlongAxis:MASAxisTypeHorizontal withFixedItemLength:ScaleSize(64.0f) leadSpacing:ScaleSize(25.0f) tailSpacing:ScaleSize(25.0f)];
- [btns mas_makeConstraints:^(MASConstraintMaker *make) {
- make.bottom.offset(0.0f);
- make.height.offset(22.0f);
- }];
- for (NSInteger i = 0; i < btns.count - 1; i ++) {
- UIButton *startBtn = btns[i];
- UIButton *endBtn = btns[i + 1];
- UIView *line = [[UIView alloc] init];
- line.backgroundColor = [[UIColor whiteColor] colorWithAlphaComponent:0.3f];
- [self addSubview:line];
- [line mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(startBtn.mas_right);
- make.right.equalTo(endBtn.mas_left);
- make.centerY.equalTo(startBtn);
- make.height.offset(1.0f);
- }];
- }
- if (model.youpaiptalk_played_status.count != 0) {
- if (!model.youpaiptalk_played_status.firstObject.youpaipselected && [model.youpaipuserInfo.youpaipid isEqual:model.youpaiphostSeat.youpaipuserInfo.youpaipid]) {
- LOTAnimationView *tipAnV = [LOTAnimationView animationWithFilePath:[[NSBundle mainBundle] pathForResource:@"ic_chatroom_blinddate_start_tip" ofType:@"json"]];
- tipAnV.frame = CGRectMake(0.0f, 0.0f, 77.0f, 23.0f);
- tipAnV.loopAnimation = YES;
- tipAnV.contentMode = UIViewContentModeScaleAspectFill;
- [tipAnV play];
-
- UITapGestureRecognizer *tapG = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(youpaifopenBlindDateProcess)];
- [tipAnV addGestureRecognizer:tapG];
- [self addSubview:tipAnV];
- [tipAnV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.bottom.equalTo(btns.firstObject.top).offset(-3.0f);
- make.centerX.equalTo(btns.firstObject);
- make.size.mas_offset(CGSizeMake(77.0f, 23.0f));
- }];
- }
-
-
- YOUPAILZChatRoomSeatModel *localSeatModel = nil;
- for (YOUPAILZChatRoomSeatModel *seatModel in model.youpaipnormalSeats) {
- if ([seatModel.youpaipuserInfo.youpaipid isEqual:model.youpaipuserInfo.youpaipid]) {
- localSeatModel = seatModel;
- break;
- }
- }
- if (model.youpaiptalk_played_status[1].youpaipselected && !model.youpaiptalk_played_status[2].youpaipselected && localSeatModel != nil) {
- LOTAnimationView *tipAnV = [LOTAnimationView animationWithFilePath:[[NSBundle mainBundle] pathForResource:@"ic_chatroom_blinddate_selected_object_tip" ofType:@"json"]];
- tipAnV.frame = CGRectMake(0.0f, 0.0f, 77.0f, 23.0f);
- tipAnV.loopAnimation = YES;
- tipAnV.contentMode = UIViewContentModeScaleAspectFill;
- [tipAnV play];
-
- UITapGestureRecognizer *tapG = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(youpaifblindDateSelected)];
- [tipAnV addGestureRecognizer:tapG];
- [self addSubview:tipAnV];
- [tipAnV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.bottom.equalTo(btns[1].top).offset(-3.0f);
- make.centerX.equalTo(btns[1]);
- make.size.mas_offset(CGSizeMake(77.0f, 23.0f));
- }];
- }
-
- }
- }
- - (void)youpaifbtnClick:(UIButton *)sender{
- if (self.youpaipmodel.youpaiptalk_played_status.count != 0) {
- /// 主持点击
- if (!self.youpaipmodel.youpaiptalk_played_status[sender.tag].youpaipselected && [self.youpaipmodel.youpaipuserInfo.youpaipid isEqual:self.youpaipmodel.youpaiphostSeat.youpaipuserInfo.youpaipid]) {
- if (self.blindDateProgressBlock != nil) {
- self.blindDateProgressBlock(sender.tag);
- }
- return;
- }
-
- // 扑通麦位点击
- if (sender.tag == 1) {
- [self youpaifblindDateSelected];
- }
- }
- }
- - (void)youpaifopenBlindDateProcess{
- if (self.youpaipmodel.youpaiptalk_played_status.count != 0) {
- /// 主持点击
- if (!self.youpaipmodel.youpaiptalk_played_status.firstObject.youpaipselected && [self.youpaipmodel.youpaipuserInfo.youpaipid isEqual:self.youpaipmodel.youpaiphostSeat.youpaipuserInfo.youpaipid]) {
- if (self.blindDateProgressBlock != nil) {
- self.blindDateProgressBlock(0);
- }
- }
- }
- }
- - (void)youpaifblindDateSelected{
- if (self.youpaipmodel.youpaiptalk_played_status.count != 0) {
- // 扑通麦位点击
- YOUPAILZChatRoomSeatModel *localSeatModel = nil;
- for (YOUPAILZChatRoomSeatModel *seatModel in self.youpaipmodel.youpaipnormalSeats) {
- if ([seatModel.youpaipuserInfo.youpaipid isEqual:self.youpaipmodel.youpaipuserInfo.youpaipid]) {
- localSeatModel = seatModel;
- break;
- }
- }
- if (self.youpaipmodel.youpaiptalk_played_status[1].youpaipselected && !self.youpaipmodel.youpaiptalk_played_status[2].youpaipselected && localSeatModel != nil) {
- if (self.blindDateSelectedBlock != nil) {
- self.blindDateSelectedBlock();
- }
- }
- }
- }
- @end
|