YMAudioVideoMatchingInfoPopupView.m 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. //
  2. // YMAudioVideoMatchingInfoPopupView.m
  3. // MSYOUPAI
  4. //
  5. // Created by YoMi on 2024/3/18.
  6. // Copyright © 2024 MS. All rights reserved.
  7. //
  8. #import "YMAudioVideoMatchingInfoPopupView.h"
  9. @interface YMAudioVideoMatchingInfoPopupView ()
  10. /// 用户头像视图
  11. @property (nonatomic, strong) UIImageView *userAvatarView;
  12. /// 用户昵称标签
  13. @property (nonatomic, strong) UILabel *userNicknameLb;
  14. /// 用户匹配提示标签
  15. @property (nonatomic, strong) UILabel *userMatchingTipsLb;
  16. /// 用户收益提示标签
  17. @property (nonatomic, strong) UILabel *userEarningsTipsLb;
  18. /** 取消按钮*/
  19. @property (nonatomic, strong) UIButton *cancelBtn;
  20. /** 确认按钮*/
  21. @property (nonatomic, strong) UIButton *confirmBtn;
  22. @property (nonatomic, strong) YMAudioVideoMatchingInfoModel *model;
  23. @end
  24. @implementation YMAudioVideoMatchingInfoPopupView
  25. - (void)ym_setupViews{
  26. self.backgroundColor = HexColorFromRGB(0xfd7bc5);
  27. self.frame = CGRectMake(0, 0, kFrameWidth, adapt(20) + adapt(60) + adapt(20));
  28. [self addSubview:self.userAvatarView];
  29. [self addSubview:self.userNicknameLb];
  30. [self addSubview:self.userMatchingTipsLb];
  31. [self addSubview:self.userEarningsTipsLb];
  32. [self addSubview:self.cancelBtn];
  33. [self addSubview:self.confirmBtn];
  34. [self setNeedsUpdateConstraints];
  35. [self updateConstraintsIfNeeded];
  36. }
  37. - (void)updateConstraints{
  38. [self.userAvatarView mas_makeConstraints:^(MASConstraintMaker *make) {
  39. make.top.equalTo(self).offset(adapt(20));
  40. make.left.equalTo(self).offset(adapt(20));
  41. make.bottom.equalTo(self).offset(adapt(-20));
  42. make.width.height.mas_equalTo(adapt(60));
  43. }];
  44. [self.userNicknameLb mas_makeConstraints:^(MASConstraintMaker *make) {
  45. make.top.equalTo(self.userAvatarView.mas_top).offset(adapt(5));
  46. make.left.equalTo(self.userAvatarView.mas_right).offset(adapt(10));
  47. make.right.equalTo(self.cancelBtn.mas_left).offset(adapt(-10));
  48. }];
  49. [self.userMatchingTipsLb mas_makeConstraints:^(MASConstraintMaker *make) {
  50. make.top.equalTo(self.userNicknameLb.mas_bottom).offset(adapt(5));
  51. make.left.equalTo(self.userAvatarView.mas_right).offset(adapt(10));
  52. make.right.equalTo(self.cancelBtn.mas_left).offset(adapt(-10));
  53. }];
  54. [self.userEarningsTipsLb mas_makeConstraints:^(MASConstraintMaker *make) {
  55. make.top.equalTo(self.userMatchingTipsLb.mas_bottom).offset(adapt(5));
  56. make.left.equalTo(self.userAvatarView.mas_right).offset(adapt(10));
  57. make.right.equalTo(self.cancelBtn.mas_left).offset(adapt(-10));
  58. }];
  59. [self.cancelBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  60. make.centerY.equalTo(self.userAvatarView.mas_centerY);
  61. make.right.equalTo(self.confirmBtn.mas_left).offset(adapt(-15));
  62. make.width.height.mas_equalTo(adapt(40));
  63. }];
  64. [self.confirmBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  65. make.centerY.equalTo(self.userAvatarView.mas_centerY);
  66. make.right.equalTo(self).offset(adapt(-20));
  67. make.width.height.mas_equalTo(adapt(40));
  68. }];
  69. [super updateConstraints];
  70. }
  71. - (void)configutationWithDictionary:(NSDictionary*)dic{
  72. self.model = [YMAudioVideoMatchingInfoModel yy_modelWithJSON:dic];
  73. [self.userAvatarView sd_setImageWithURL:[LCTools getImageUrlWithAddress:self.model.avatar?:@""]];
  74. self.userNicknameLb.text = self.model.nickname?:@"";
  75. self.userMatchingTipsLb.text = stringFormat(@"邀你%@速配",[self.model.type isEqualToString:@"video"] ? @"视频" : @"语音");
  76. self.userEarningsTipsLb.text = stringFormat(@"获得%@",self.model.price?:@"");
  77. }
  78. - (UIImageView *)userAvatarView{
  79. if (!_userAvatarView) {
  80. _userAvatarView = [[UIImageView alloc]init];
  81. _userAvatarView.contentMode = UIViewContentModeScaleAspectFill;
  82. _userAvatarView.clipsToBounds = YES;
  83. _userAvatarView.layer.cornerRadius = adapt(10);
  84. _userAvatarView.layer.masksToBounds = YES;
  85. }
  86. return _userAvatarView;
  87. }
  88. - (UILabel *)userNicknameLb{
  89. if (!_userNicknameLb) {
  90. _userNicknameLb = [[UILabel alloc]init];
  91. _userNicknameLb.font = LCBoldFont(15);
  92. _userNicknameLb.textColor = HexColorFromRGB(0xFFFFFF);
  93. _userNicknameLb.textAlignment = NSTextAlignmentLeft;
  94. _userNicknameLb.text = @"******";
  95. }
  96. return _userNicknameLb;
  97. }
  98. - (UILabel *)userMatchingTipsLb{
  99. if (!_userMatchingTipsLb) {
  100. _userMatchingTipsLb = [[UILabel alloc]init];
  101. _userMatchingTipsLb.font = LCFont(12);
  102. _userMatchingTipsLb.textColor = HexColorFromRGB(0xFFFFFF);
  103. _userMatchingTipsLb.textAlignment = NSTextAlignmentLeft;
  104. _userMatchingTipsLb.text = @"邀请你速配";
  105. }
  106. return _userMatchingTipsLb;
  107. }
  108. - (UILabel *)userEarningsTipsLb{
  109. if (!_userEarningsTipsLb) {
  110. _userEarningsTipsLb = [[UILabel alloc]init];
  111. _userEarningsTipsLb.font = LCFont(12);
  112. _userEarningsTipsLb.textColor = HexColorFromRGB(0xffd881);
  113. _userEarningsTipsLb.textAlignment = NSTextAlignmentLeft;
  114. _userEarningsTipsLb.text = @"******";
  115. }
  116. return _userEarningsTipsLb;
  117. }
  118. - (UIButton *)cancelBtn {
  119. if(!_cancelBtn){
  120. _cancelBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  121. [_cancelBtn setBackgroundImage:ImageByName(@"ym_audio_video_matching_rejecting_icon") forState:UIControlStateNormal];
  122. WS(weakSelf)
  123. [[[_cancelBtn rac_signalForControlEvents:UIControlEventTouchUpInside] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id x) {
  124. if (weakSelf.buttonBlock) {
  125. weakSelf.buttonBlock(NO,@"",@"");
  126. }
  127. }];
  128. }
  129. return _cancelBtn;
  130. }
  131. - (UIButton *)confirmBtn {
  132. if(!_confirmBtn){
  133. _confirmBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  134. [_confirmBtn setBackgroundImage:ImageByName(@"ym_audio_video_matching_answering_icon") forState:UIControlStateNormal];
  135. WS(weakSelf)
  136. [[[_confirmBtn rac_signalForControlEvents:UIControlEventTouchUpInside] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id x) {
  137. if (weakSelf.buttonBlock) {
  138. weakSelf.buttonBlock(YES,self.model.match_id,self.model.from_uid);
  139. }
  140. }];
  141. }
  142. return _confirmBtn;
  143. }
  144. @end
  145. @implementation YMAudioVideoMatchingInfoModel
  146. + (NSDictionary *)modelCustomPropertyMapper {
  147. return @{@"nim_id":@"id",};
  148. }
  149. @end