// // YMAudioVideoMatchingInfoPopupView.m // MSYOUPAI // // Created by YoMi on 2024/3/18. // Copyright © 2024 MS. All rights reserved. // #import "YMAudioVideoMatchingInfoPopupView.h" @interface YMAudioVideoMatchingInfoPopupView () /// 用户头像视图 @property (nonatomic, strong) UIImageView *userAvatarView; /// 用户昵称标签 @property (nonatomic, strong) UILabel *userNicknameLb; /// 用户匹配提示标签 @property (nonatomic, strong) UILabel *userMatchingTipsLb; /// 用户收益提示标签 @property (nonatomic, strong) UILabel *userEarningsTipsLb; /** 取消按钮*/ @property (nonatomic, strong) UIButton *cancelBtn; /** 确认按钮*/ @property (nonatomic, strong) UIButton *confirmBtn; @property (nonatomic, strong) YMAudioVideoMatchingInfoModel *model; @end @implementation YMAudioVideoMatchingInfoPopupView - (void)ym_setupViews{ self.backgroundColor = HexColorFromRGB(0xfd7bc5); self.frame = CGRectMake(0, 0, kFrameWidth, adapt(20) + adapt(60) + adapt(20)); [self addSubview:self.userAvatarView]; [self addSubview:self.userNicknameLb]; [self addSubview:self.userMatchingTipsLb]; [self addSubview:self.userEarningsTipsLb]; [self addSubview:self.cancelBtn]; [self addSubview:self.confirmBtn]; [self setNeedsUpdateConstraints]; [self updateConstraintsIfNeeded]; } - (void)updateConstraints{ [self.userAvatarView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self).offset(adapt(20)); make.left.equalTo(self).offset(adapt(20)); make.bottom.equalTo(self).offset(adapt(-20)); make.width.height.mas_equalTo(adapt(60)); }]; [self.userNicknameLb mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.userAvatarView.mas_top).offset(adapt(5)); make.left.equalTo(self.userAvatarView.mas_right).offset(adapt(10)); make.right.equalTo(self.cancelBtn.mas_left).offset(adapt(-10)); }]; [self.userMatchingTipsLb mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.userNicknameLb.mas_bottom).offset(adapt(5)); make.left.equalTo(self.userAvatarView.mas_right).offset(adapt(10)); make.right.equalTo(self.cancelBtn.mas_left).offset(adapt(-10)); }]; [self.userEarningsTipsLb mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.userMatchingTipsLb.mas_bottom).offset(adapt(5)); make.left.equalTo(self.userAvatarView.mas_right).offset(adapt(10)); make.right.equalTo(self.cancelBtn.mas_left).offset(adapt(-10)); }]; [self.cancelBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.centerY.equalTo(self.userAvatarView.mas_centerY); make.right.equalTo(self.confirmBtn.mas_left).offset(adapt(-15)); make.width.height.mas_equalTo(adapt(40)); }]; [self.confirmBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.centerY.equalTo(self.userAvatarView.mas_centerY); make.right.equalTo(self).offset(adapt(-20)); make.width.height.mas_equalTo(adapt(40)); }]; [super updateConstraints]; } - (void)configutationWithDictionary:(NSDictionary*)dic{ self.model = [YMAudioVideoMatchingInfoModel yy_modelWithJSON:dic]; [self.userAvatarView sd_setImageWithURL:[LCTools getImageUrlWithAddress:self.model.avatar?:@""]]; self.userNicknameLb.text = self.model.nickname?:@""; self.userMatchingTipsLb.text = stringFormat(@"邀你%@速配",[self.model.type isEqualToString:@"video"] ? @"视频" : @"语音"); self.userEarningsTipsLb.text = stringFormat(@"获得%@",self.model.price?:@""); } - (UIImageView *)userAvatarView{ if (!_userAvatarView) { _userAvatarView = [[UIImageView alloc]init]; _userAvatarView.contentMode = UIViewContentModeScaleAspectFill; _userAvatarView.clipsToBounds = YES; _userAvatarView.layer.cornerRadius = adapt(10); _userAvatarView.layer.masksToBounds = YES; } return _userAvatarView; } - (UILabel *)userNicknameLb{ if (!_userNicknameLb) { _userNicknameLb = [[UILabel alloc]init]; _userNicknameLb.font = LCBoldFont(15); _userNicknameLb.textColor = HexColorFromRGB(0xFFFFFF); _userNicknameLb.textAlignment = NSTextAlignmentLeft; _userNicknameLb.text = @"******"; } return _userNicknameLb; } - (UILabel *)userMatchingTipsLb{ if (!_userMatchingTipsLb) { _userMatchingTipsLb = [[UILabel alloc]init]; _userMatchingTipsLb.font = LCFont(12); _userMatchingTipsLb.textColor = HexColorFromRGB(0xFFFFFF); _userMatchingTipsLb.textAlignment = NSTextAlignmentLeft; _userMatchingTipsLb.text = @"邀请你速配"; } return _userMatchingTipsLb; } - (UILabel *)userEarningsTipsLb{ if (!_userEarningsTipsLb) { _userEarningsTipsLb = [[UILabel alloc]init]; _userEarningsTipsLb.font = LCFont(12); _userEarningsTipsLb.textColor = HexColorFromRGB(0xffd881); _userEarningsTipsLb.textAlignment = NSTextAlignmentLeft; _userEarningsTipsLb.text = @"******"; } return _userEarningsTipsLb; } - (UIButton *)cancelBtn { if(!_cancelBtn){ _cancelBtn = [UIButton buttonWithType:UIButtonTypeCustom]; [_cancelBtn setBackgroundImage:ImageByName(@"ym_audio_video_matching_rejecting_icon") forState:UIControlStateNormal]; WS(weakSelf) [[[_cancelBtn rac_signalForControlEvents:UIControlEventTouchUpInside] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id x) { if (weakSelf.buttonBlock) { weakSelf.buttonBlock(NO,@"",@""); } }]; } return _cancelBtn; } - (UIButton *)confirmBtn { if(!_confirmBtn){ _confirmBtn = [UIButton buttonWithType:UIButtonTypeCustom]; [_confirmBtn setBackgroundImage:ImageByName(@"ym_audio_video_matching_answering_icon") forState:UIControlStateNormal]; WS(weakSelf) [[[_confirmBtn rac_signalForControlEvents:UIControlEventTouchUpInside] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id x) { if (weakSelf.buttonBlock) { weakSelf.buttonBlock(YES,self.model.match_id,self.model.from_uid); } }]; } return _confirmBtn; } @end @implementation YMAudioVideoMatchingInfoModel + (NSDictionary *)modelCustomPropertyMapper { return @{@"nim_id":@"id",}; } @end