YMBindWithdrawalAccountViewController.m 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. //
  2. // YMBindWithdrawalAccountViewController.m
  3. // MSYOUPAI
  4. //
  5. // Created by YoMi on 2024/3/5.
  6. // Copyright © 2024 MS. All rights reserved.
  7. //
  8. #import "YMBindWithdrawalAccountViewController.h"
  9. #import "YMBindWithdrawalAccountViewModel.h"
  10. #import "YMBindWithdrawalAccountInfoView.h"
  11. #import "YMBindWithdrawalAccountWarmTipsView.h"
  12. @interface YMBindWithdrawalAccountViewController ()<UIGestureRecognizerDelegate>
  13. /// 绑定提现账号VM
  14. @property (nonatomic, strong) YMBindWithdrawalAccountViewModel *viewModel;
  15. /// 容器滚动视图
  16. @property (nonatomic, strong) UIScrollView *contentScrollView;
  17. /// 容器视图
  18. @property (nonatomic, strong) UIView *contentView;
  19. /// 绑定账号信息视图
  20. @property (nonatomic, strong) YMBindWithdrawalAccountInfoView *accountInfoView;
  21. /// 绑定账号温馨提示视图
  22. @property (nonatomic, strong) YMBindWithdrawalAccountWarmTipsView *warmTipsView;
  23. /// 保存按钮
  24. @property (nonatomic, strong) UIButton *saveBtn;
  25. @end
  26. @implementation YMBindWithdrawalAccountViewController
  27. @dynamic viewModel;
  28. - (void)viewDidLoad {
  29. [super viewDidLoad];
  30. }
  31. - (void)ym_setupViews{
  32. [self.view addSubview:self.contentScrollView];
  33. [self.contentScrollView addSubview:self.contentView];
  34. [self.contentView addSubview:self.accountInfoView];
  35. [self.contentView addSubview:self.warmTipsView];
  36. [self.contentView addSubview:self.saveBtn];
  37. [self.view setNeedsUpdateConstraints];
  38. [self.view updateConstraintsIfNeeded];
  39. }
  40. - (void)updateViewConstraints{
  41. [self.contentScrollView mas_makeConstraints:^(MASConstraintMaker *make) {
  42. make.top.equalTo(self.view).offset(kYMNavHeight);
  43. make.left.equalTo(self.view);
  44. make.right.equalTo(self.view);
  45. make.bottom.equalTo(self.view);
  46. }];
  47. [self.contentView mas_makeConstraints:^(MASConstraintMaker *make) {
  48. make.edges.equalTo(self.contentScrollView);
  49. make.width.equalTo(self.contentScrollView.mas_width);
  50. }];
  51. [self.accountInfoView mas_makeConstraints:^(MASConstraintMaker *make) {
  52. make.top.equalTo(self.contentView);
  53. make.left.equalTo(self.contentView);
  54. make.right.equalTo(self.contentView);
  55. }];
  56. [self.warmTipsView mas_makeConstraints:^(MASConstraintMaker *make) {
  57. make.top.equalTo(self.accountInfoView.mas_bottom).offset(adapt(10));
  58. make.left.equalTo(self.contentView);
  59. make.right.equalTo(self.contentView);
  60. }];
  61. [self.saveBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  62. make.top.equalTo(self.warmTipsView.mas_bottom).offset(adapt(10));
  63. make.left.equalTo(self.contentView).offset(adapt(20));
  64. make.right.equalTo(self.contentView).offset(adapt(-20));
  65. make.bottom.equalTo(self.contentView).offset(Is_iPhoneX ? adapt(-32) : adapt(-12));
  66. make.height.mas_equalTo(adapt(50));
  67. }];
  68. [super updateViewConstraints];
  69. }
  70. - (void)ym_bindViewModel{
  71. [self.accountInfoView ym_bindViewModel:self.viewModel];
  72. [self.warmTipsView ym_bindViewModel:self.viewModel];
  73. RAC(self.saveBtn , enabled) = self.viewModel.validSaveSignal;
  74. [self.viewModel.validSaveSignal subscribeNext:^(id _Nullable value) {
  75. self.saveBtn.enabled = [value boolValue];
  76. if ([value boolValue]) {
  77. self.saveBtn.backgroundColor = HexColorFromRGB(0xfd7bc5);
  78. } else {
  79. self.saveBtn.backgroundColor = HexColorFromRGB(0xd3d0d7);
  80. }
  81. }];
  82. }
  83. - (UIScrollView *)contentScrollView{
  84. if (!_contentScrollView) {
  85. _contentScrollView = [[UIScrollView alloc]init];
  86. _contentScrollView.alwaysBounceVertical = YES;
  87. _contentScrollView.showsVerticalScrollIndicator = NO;
  88. _contentScrollView.showsHorizontalScrollIndicator = NO;
  89. _contentScrollView.backgroundColor = UIColor.clearColor;
  90. _contentScrollView.keyboardDismissMode = UIScrollViewKeyboardDismissModeOnDrag;
  91. }
  92. return _contentScrollView;
  93. }
  94. - (UIView *)contentView{
  95. if (!_contentView) {
  96. _contentView = [[UIView alloc]init];
  97. }
  98. return _contentView;
  99. }
  100. - (YMBindWithdrawalAccountInfoView *)accountInfoView{
  101. if (!_accountInfoView) {
  102. _accountInfoView = [[YMBindWithdrawalAccountInfoView alloc]init];
  103. }
  104. return _accountInfoView;
  105. }
  106. - (YMBindWithdrawalAccountWarmTipsView *)warmTipsView{
  107. if (!_warmTipsView) {
  108. _warmTipsView = [[YMBindWithdrawalAccountWarmTipsView alloc]init];
  109. }
  110. return _warmTipsView;
  111. }
  112. - (UIButton *)saveBtn{
  113. if (!_saveBtn) {
  114. _saveBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  115. _saveBtn.titleLabel.font = LCFont(15);
  116. [_saveBtn setTitle:@"保存" forState:UIControlStateNormal];
  117. [_saveBtn setTitleColor:MAINGRIDTitleC forState:UIControlStateNormal];
  118. [_saveBtn ym_setGradientBackgroundWithColors:kMainGradColors locations:kMainGradLocation startPoint:kMainGradStartP endPoint:kMainGradEndP];
  119. _saveBtn.layer.cornerRadius = adapt(8);
  120. _saveBtn.layer.masksToBounds = YES;
  121. WS(weakSelf)
  122. [[[_saveBtn rac_signalForControlEvents:UIControlEventTouchUpInside] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id x) {
  123. [weakSelf.viewModel submitBindWithdrawalAccount];
  124. }];
  125. }
  126. return _saveBtn;
  127. }
  128. @end