// // YMBindWithdrawalAccountViewController.m // MSYOUPAI // // Created by YoMi on 2024/3/5. // Copyright © 2024 MS. All rights reserved. // #import "YMBindWithdrawalAccountViewController.h" #import "YMBindWithdrawalAccountViewModel.h" #import "YMBindWithdrawalAccountInfoView.h" #import "YMBindWithdrawalAccountWarmTipsView.h" @interface YMBindWithdrawalAccountViewController () /// 绑定提现账号VM @property (nonatomic, strong) YMBindWithdrawalAccountViewModel *viewModel; /// 容器滚动视图 @property (nonatomic, strong) UIScrollView *contentScrollView; /// 容器视图 @property (nonatomic, strong) UIView *contentView; /// 绑定账号信息视图 @property (nonatomic, strong) YMBindWithdrawalAccountInfoView *accountInfoView; /// 绑定账号温馨提示视图 @property (nonatomic, strong) YMBindWithdrawalAccountWarmTipsView *warmTipsView; /// 保存按钮 @property (nonatomic, strong) UIButton *saveBtn; @end @implementation YMBindWithdrawalAccountViewController @dynamic viewModel; - (void)viewDidLoad { [super viewDidLoad]; } - (void)ym_setupViews{ [self.view addSubview:self.contentScrollView]; [self.contentScrollView addSubview:self.contentView]; [self.contentView addSubview:self.accountInfoView]; [self.contentView addSubview:self.warmTipsView]; [self.contentView addSubview:self.saveBtn]; [self.view setNeedsUpdateConstraints]; [self.view updateConstraintsIfNeeded]; } - (void)updateViewConstraints{ [self.contentScrollView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.view).offset(kYMNavHeight); make.left.equalTo(self.view); make.right.equalTo(self.view); make.bottom.equalTo(self.view); }]; [self.contentView mas_makeConstraints:^(MASConstraintMaker *make) { make.edges.equalTo(self.contentScrollView); make.width.equalTo(self.contentScrollView.mas_width); }]; [self.accountInfoView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.contentView); make.left.equalTo(self.contentView); make.right.equalTo(self.contentView); }]; [self.warmTipsView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.accountInfoView.mas_bottom).offset(adapt(10)); make.left.equalTo(self.contentView); make.right.equalTo(self.contentView); }]; [self.saveBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.warmTipsView.mas_bottom).offset(adapt(10)); make.left.equalTo(self.contentView).offset(adapt(20)); make.right.equalTo(self.contentView).offset(adapt(-20)); make.bottom.equalTo(self.contentView).offset(Is_iPhoneX ? adapt(-32) : adapt(-12)); make.height.mas_equalTo(adapt(50)); }]; [super updateViewConstraints]; } - (void)ym_bindViewModel{ [self.accountInfoView ym_bindViewModel:self.viewModel]; [self.warmTipsView ym_bindViewModel:self.viewModel]; RAC(self.saveBtn , enabled) = self.viewModel.validSaveSignal; [self.viewModel.validSaveSignal subscribeNext:^(id _Nullable value) { self.saveBtn.enabled = [value boolValue]; if ([value boolValue]) { self.saveBtn.backgroundColor = HexColorFromRGB(0xfd7bc5); } else { self.saveBtn.backgroundColor = HexColorFromRGB(0xd3d0d7); } }]; } - (UIScrollView *)contentScrollView{ if (!_contentScrollView) { _contentScrollView = [[UIScrollView alloc]init]; _contentScrollView.alwaysBounceVertical = YES; _contentScrollView.showsVerticalScrollIndicator = NO; _contentScrollView.showsHorizontalScrollIndicator = NO; _contentScrollView.backgroundColor = UIColor.clearColor; _contentScrollView.keyboardDismissMode = UIScrollViewKeyboardDismissModeOnDrag; } return _contentScrollView; } - (UIView *)contentView{ if (!_contentView) { _contentView = [[UIView alloc]init]; } return _contentView; } - (YMBindWithdrawalAccountInfoView *)accountInfoView{ if (!_accountInfoView) { _accountInfoView = [[YMBindWithdrawalAccountInfoView alloc]init]; } return _accountInfoView; } - (YMBindWithdrawalAccountWarmTipsView *)warmTipsView{ if (!_warmTipsView) { _warmTipsView = [[YMBindWithdrawalAccountWarmTipsView alloc]init]; } return _warmTipsView; } - (UIButton *)saveBtn{ if (!_saveBtn) { _saveBtn = [UIButton buttonWithType:UIButtonTypeCustom]; _saveBtn.titleLabel.font = LCFont(15); [_saveBtn setTitle:@"保存" forState:UIControlStateNormal]; [_saveBtn setTitleColor:MAINGRIDTitleC forState:UIControlStateNormal]; [_saveBtn ym_setGradientBackgroundWithColors:kMainGradColors locations:kMainGradLocation startPoint:kMainGradStartP endPoint:kMainGradEndP]; _saveBtn.layer.cornerRadius = adapt(8); _saveBtn.layer.masksToBounds = YES; WS(weakSelf) [[[_saveBtn rac_signalForControlEvents:UIControlEventTouchUpInside] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id x) { [weakSelf.viewModel submitBindWithdrawalAccount]; }]; } return _saveBtn; } @end