YOUPAILZChatRoomBlindDateProgressView.m 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. //
  2. // YOUPAILZChatRoomBlindDateProgressView.m
  3. // YOUQU
  4. //
  5. // Created by CY on 2021/12/14.
  6. // Copyright © 2021 MS. All rights reserved.
  7. //
  8. #import "YOUPAILZChatRoomBlindDateProgressView.h"
  9. #import "LOTAnimationView.h"
  10. @interface YOUPAILZChatRoomBlindDateProgressView ()
  11. @property (nonatomic,strong)YOUPAILZChatRoomModel *youpaipmodel;
  12. @end
  13. @implementation YOUPAILZChatRoomBlindDateProgressView
  14. - (void)youpaifreloadWithModel:(YOUPAILZChatRoomModel *)model{
  15. if (model.youpaipplayType != LZChatRoomPlayTypeWithBlindDate || model.youpaiptalk_played_status.count == 0) {
  16. return;
  17. }
  18. self.youpaipmodel = model;
  19. for (UIView *subV in self.subviews) {
  20. [subV removeFromSuperview];
  21. }
  22. NSMutableArray <UIButton *>*btns = [NSMutableArray array];
  23. for (NSInteger i = 0; i < model.youpaiptalk_played_status.count; i ++) {
  24. YOUPAILZChatRoomTalkPlayedStatusModel *statusModel = model.youpaiptalk_played_status[i];
  25. UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
  26. btn.layer.cornerRadius = 11.0f;
  27. btn.clipsToBounds = YES;
  28. [btn setBackgroundColor:[[UIColor whiteColor] colorWithAlphaComponent:0.29f]];
  29. if (statusModel.youpaipselected) {
  30. [btn setBackgroundColor:[UIColor clearColor]];
  31. [btn setBackgroundImage:[LCTools ColorImage:CGSizeMake(ScaleSize(64.0f), 22.0f) FromColors:@[HexColorFromRGB(0xFF7FDA),HexColorFromRGB(0xFF48B3)] ByGradientType:GradientTopToBottom] forState:UIControlStateNormal];
  32. }
  33. [btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  34. [btn setTitle:statusModel.youpaiptitle forState:UIControlStateNormal];
  35. btn.titleLabel.font = LCFont(ScaleSize(12.0f));
  36. btn.tag = i;
  37. [btn addTarget:self action:@selector(youpaifbtnClick:) forControlEvents:UIControlEventTouchUpInside];
  38. [self addSubview:btn];
  39. [btns addObject:btn];
  40. }
  41. [btns mas_distributeViewsAlongAxis:MASAxisTypeHorizontal withFixedItemLength:ScaleSize(64.0f) leadSpacing:ScaleSize(25.0f) tailSpacing:ScaleSize(25.0f)];
  42. [btns mas_makeConstraints:^(MASConstraintMaker *make) {
  43. make.bottom.offset(0.0f);
  44. make.height.offset(22.0f);
  45. }];
  46. for (NSInteger i = 0; i < btns.count - 1; i ++) {
  47. UIButton *startBtn = btns[i];
  48. UIButton *endBtn = btns[i + 1];
  49. UIView *line = [[UIView alloc] init];
  50. line.backgroundColor = [[UIColor whiteColor] colorWithAlphaComponent:0.3f];
  51. [self addSubview:line];
  52. [line mas_makeConstraints:^(MASConstraintMaker *make) {
  53. make.left.equalTo(startBtn.mas_right);
  54. make.right.equalTo(endBtn.mas_left);
  55. make.centerY.equalTo(startBtn);
  56. make.height.offset(1.0f);
  57. }];
  58. }
  59. if (model.youpaiptalk_played_status.count != 0) {
  60. if (!model.youpaiptalk_played_status.firstObject.youpaipselected && [model.youpaipuserInfo.youpaipid isEqual:model.youpaiphostSeat.youpaipuserInfo.youpaipid]) {
  61. LOTAnimationView *tipAnV = [LOTAnimationView animationWithFilePath:[[NSBundle mainBundle] pathForResource:@"ic_chatroom_blinddate_start_tip" ofType:@"json"]];
  62. tipAnV.frame = CGRectMake(0.0f, 0.0f, 77.0f, 23.0f);
  63. tipAnV.loopAnimation = YES;
  64. tipAnV.contentMode = UIViewContentModeScaleAspectFill;
  65. [tipAnV play];
  66. UITapGestureRecognizer *tapG = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(youpaifopenBlindDateProcess)];
  67. [tipAnV addGestureRecognizer:tapG];
  68. [self addSubview:tipAnV];
  69. [tipAnV mas_makeConstraints:^(MASConstraintMaker *make) {
  70. make.bottom.equalTo(btns.firstObject.top).offset(-3.0f);
  71. make.centerX.equalTo(btns.firstObject);
  72. make.size.mas_offset(CGSizeMake(77.0f, 23.0f));
  73. }];
  74. }
  75. YOUPAILZChatRoomSeatModel *localSeatModel = nil;
  76. for (YOUPAILZChatRoomSeatModel *seatModel in model.youpaipnormalSeats) {
  77. if ([seatModel.youpaipuserInfo.youpaipid isEqual:model.youpaipuserInfo.youpaipid]) {
  78. localSeatModel = seatModel;
  79. break;
  80. }
  81. }
  82. if (model.youpaiptalk_played_status[1].youpaipselected && !model.youpaiptalk_played_status[2].youpaipselected && localSeatModel != nil) {
  83. LOTAnimationView *tipAnV = [LOTAnimationView animationWithFilePath:[[NSBundle mainBundle] pathForResource:@"ic_chatroom_blinddate_selected_object_tip" ofType:@"json"]];
  84. tipAnV.frame = CGRectMake(0.0f, 0.0f, 77.0f, 23.0f);
  85. tipAnV.loopAnimation = YES;
  86. tipAnV.contentMode = UIViewContentModeScaleAspectFill;
  87. [tipAnV play];
  88. UITapGestureRecognizer *tapG = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(youpaifblindDateSelected)];
  89. [tipAnV addGestureRecognizer:tapG];
  90. [self addSubview:tipAnV];
  91. [tipAnV mas_makeConstraints:^(MASConstraintMaker *make) {
  92. make.bottom.equalTo(btns[1].top).offset(-3.0f);
  93. make.centerX.equalTo(btns[1]);
  94. make.size.mas_offset(CGSizeMake(77.0f, 23.0f));
  95. }];
  96. }
  97. }
  98. }
  99. - (void)youpaifbtnClick:(UIButton *)sender{
  100. if (self.youpaipmodel.youpaiptalk_played_status.count != 0) {
  101. /// 主持点击
  102. if (!self.youpaipmodel.youpaiptalk_played_status[sender.tag].youpaipselected && [self.youpaipmodel.youpaipuserInfo.youpaipid isEqual:self.youpaipmodel.youpaiphostSeat.youpaipuserInfo.youpaipid]) {
  103. if (self.blindDateProgressBlock != nil) {
  104. self.blindDateProgressBlock(sender.tag);
  105. }
  106. return;
  107. }
  108. // 扑通麦位点击
  109. if (sender.tag == 1) {
  110. [self youpaifblindDateSelected];
  111. }
  112. }
  113. }
  114. - (void)youpaifopenBlindDateProcess{
  115. if (self.youpaipmodel.youpaiptalk_played_status.count != 0) {
  116. /// 主持点击
  117. if (!self.youpaipmodel.youpaiptalk_played_status.firstObject.youpaipselected && [self.youpaipmodel.youpaipuserInfo.youpaipid isEqual:self.youpaipmodel.youpaiphostSeat.youpaipuserInfo.youpaipid]) {
  118. if (self.blindDateProgressBlock != nil) {
  119. self.blindDateProgressBlock(0);
  120. }
  121. }
  122. }
  123. }
  124. - (void)youpaifblindDateSelected{
  125. if (self.youpaipmodel.youpaiptalk_played_status.count != 0) {
  126. // 扑通麦位点击
  127. YOUPAILZChatRoomSeatModel *localSeatModel = nil;
  128. for (YOUPAILZChatRoomSeatModel *seatModel in self.youpaipmodel.youpaipnormalSeats) {
  129. if ([seatModel.youpaipuserInfo.youpaipid isEqual:self.youpaipmodel.youpaipuserInfo.youpaipid]) {
  130. localSeatModel = seatModel;
  131. break;
  132. }
  133. }
  134. if (self.youpaipmodel.youpaiptalk_played_status[1].youpaipselected && !self.youpaipmodel.youpaiptalk_played_status[2].youpaipselected && localSeatModel != nil) {
  135. if (self.blindDateSelectedBlock != nil) {
  136. self.blindDateSelectedBlock();
  137. }
  138. }
  139. }
  140. }
  141. @end