123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 |
- //
- // 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 ()<UIGestureRecognizerDelegate>
- /// 绑定提现账号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
|