// // YMMyEarningsBindAccountView.m // MSYOUPAI // // Created by YoMi on 2024/2/29. // Copyright © 2024 MS. All rights reserved. // #import "YMMyEarningsBindAccountView.h" #import "YMMyEarningsViewModel.h" @interface YMMyEarningsBindAccountView () /// 我的收益VM @property (nonatomic, strong) YMMyEarningsViewModel *viewModel; /// 收款账号提示标签 @property (nonatomic, strong) UILabel *payeeAccountTipsLb; /// 账号视图 @property (nonatomic, strong) UIView *accountView; /// 提现账号类型名称标签 @property (nonatomic, strong) UILabel *withdrawalAccountTypeNameLb; /// 提现账号信息标签 @property (nonatomic, strong) UILabel *withdrawalAccountInfoLb; /// 箭头图标 @property (nonatomic, strong) UIImageView *arrowIcon; @end @implementation YMMyEarningsBindAccountView - (void)ym_setupViews{ [self addSubview:self.payeeAccountTipsLb]; [self addSubview:self.accountView]; [self.accountView addSubview:self.withdrawalAccountTypeNameLb]; [self.accountView addSubview:self.withdrawalAccountInfoLb]; [self.accountView addSubview:self.arrowIcon]; [self setupConstraints]; } - (void)setupConstraints { [self.payeeAccountTipsLb mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self).offset(adapt(10)); make.left.equalTo(self).offset(adapt(18)); }]; [self.accountView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.payeeAccountTipsLb.mas_bottom).offset(adapt(12)); make.left.equalTo(self).offset(adapt(12)); make.right.equalTo(self).offset(adapt(-12)); make.bottom.equalTo(self).offset(adapt(-10)); make.height.mas_equalTo(adapt(48)); }]; [self.withdrawalAccountTypeNameLb mas_makeConstraints:^(MASConstraintMaker *make) { make.centerY.equalTo(self.accountView.mas_centerY); make.left.equalTo(self.accountView).offset(adapt(10)); }]; [self.withdrawalAccountInfoLb mas_makeConstraints:^(MASConstraintMaker *make) { make.centerY.equalTo(self.accountView.mas_centerY); make.left.equalTo(self.withdrawalAccountTypeNameLb.mas_right).offset(adapt(10)); }]; [self.arrowIcon mas_makeConstraints:^(MASConstraintMaker *make) { make.centerY.equalTo(self.accountView.mas_centerY); make.left.equalTo(self.withdrawalAccountInfoLb.mas_right).offset(adapt(10)); make.right.equalTo(self.accountView).offset(adapt(-10)); make.width.height.mas_equalTo(adapt(15)); }]; } - (void)ym_bindViewModel:(YMMyEarningsViewModel *)viewModel{ if (!viewModel) { return; } _viewModel = viewModel; RAC(self.withdrawalAccountTypeNameLb, text) = RACObserve(self.viewModel, withdrawalAccountTypeName); @weakify(self) [[[[[RACSignal combineLatest:@[ RACObserve(self.viewModel, withdrawalAccountHolder), RACObserve(self.viewModel, withdrawalAccount), ] reduce:^(NSString * withdrawalAccountHolder, NSString * withdrawalAccount){ if (OCStringIsEmpty(withdrawalAccountHolder)) { return stringFormat(@"%@",withdrawalAccount); } else { return stringFormat(@"%@(%@)",withdrawalAccount,withdrawalAccountHolder); } }] distinctUntilChanged] deliverOnMainThread] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(NSString * _Nullable withdrawalAccountInfo) { @strongify(self) self.withdrawalAccountInfoLb.text = withdrawalAccountInfo; }]; } - (UILabel *)payeeAccountTipsLb{ if (!_payeeAccountTipsLb) { _payeeAccountTipsLb = [[UILabel alloc]init]; _payeeAccountTipsLb.font = LCFont(13); _payeeAccountTipsLb.textColor = HexColorFromRGB(0x161330); _payeeAccountTipsLb.textAlignment = NSTextAlignmentLeft; _payeeAccountTipsLb.text = @"收款账号"; } return _payeeAccountTipsLb; } - (UIView *)accountView{ if (!_accountView) { _accountView = [[UIView alloc]init]; _accountView.backgroundColor = HexColorFromRGB(0xF2F5FF); _accountView.layer.cornerRadius = adapt(12); _accountView.layer.masksToBounds = YES; _accountView.userInteractionEnabled = YES; WS(weakSelf) UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] init]; [_accountView addGestureRecognizer:tap]; [[[tap rac_gestureSignal] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id x) { [weakSelf.viewModel gotoBindWithdrawalAccount]; }]; } return _accountView; } - (UILabel *)withdrawalAccountTypeNameLb { if (!_withdrawalAccountTypeNameLb) { _withdrawalAccountTypeNameLb = [[UILabel alloc]init]; _withdrawalAccountTypeNameLb.font = LCBoldFont(14); _withdrawalAccountTypeNameLb.textColor = HexColorFromRGB(0x333333); _withdrawalAccountTypeNameLb.textAlignment = NSTextAlignmentLeft; _withdrawalAccountTypeNameLb.text = @"支付宝账号"; /** *抗拉伸 setContentHuggingPriority(值越高,越不容易拉伸) */ [_withdrawalAccountTypeNameLb setContentHuggingPriority:UILayoutPriorityDefaultHigh forAxis:UILayoutConstraintAxisHorizontal]; /** *抗压缩 setContentCompressionResistancePriority(值越高,越不容易压缩) **/ [_withdrawalAccountTypeNameLb setContentCompressionResistancePriority:UILayoutPriorityDefaultHigh forAxis:UILayoutConstraintAxisHorizontal]; } return _withdrawalAccountTypeNameLb; } - (UILabel *)withdrawalAccountInfoLb{ if (!_withdrawalAccountInfoLb) { _withdrawalAccountInfoLb = [[UILabel alloc]init]; _withdrawalAccountInfoLb.font = LCFont(12); _withdrawalAccountInfoLb.textColor = HexColorFromRGB(0xB4BDD9); _withdrawalAccountInfoLb.textAlignment = NSTextAlignmentRight; _withdrawalAccountInfoLb.text = @"请绑定账号"; /** *抗拉伸 setContentHuggingPriority(值越高,越不容易拉伸) */ [_withdrawalAccountInfoLb setContentHuggingPriority:UILayoutPriorityDefaultLow forAxis:UILayoutConstraintAxisHorizontal]; /** *抗压缩 setContentCompressionResistancePriority(值越高,越不容易压缩) **/ [_withdrawalAccountInfoLb setContentCompressionResistancePriority:UILayoutPriorityDefaultLow forAxis:UILayoutConstraintAxisHorizontal]; } return _withdrawalAccountInfoLb; } - (UIImageView *)arrowIcon{ if (!_arrowIcon) { _arrowIcon = [[UIImageView alloc]init]; _arrowIcon.image = ImageByName(@"ym_my_earnings_arrow_icon"); /** *抗拉伸 setContentHuggingPriority(值越高,越不容易拉伸) */ [_arrowIcon setContentHuggingPriority:UILayoutPriorityDefaultHigh forAxis:UILayoutConstraintAxisHorizontal]; /** *抗压缩 setContentCompressionResistancePriority(值越高,越不容易压缩) **/ [_arrowIcon setContentCompressionResistancePriority:UILayoutPriorityDefaultHigh forAxis:UILayoutConstraintAxisHorizontal]; } return _arrowIcon; } @end