YMMyEarningsBindAccountView.m 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. //
  2. // YMMyEarningsBindAccountView.m
  3. // MSYOUPAI
  4. //
  5. // Created by YoMi on 2024/2/29.
  6. // Copyright © 2024 MS. All rights reserved.
  7. //
  8. #import "YMMyEarningsBindAccountView.h"
  9. #import "YMMyEarningsViewModel.h"
  10. @interface YMMyEarningsBindAccountView ()
  11. /// 我的收益VM
  12. @property (nonatomic, strong) YMMyEarningsViewModel *viewModel;
  13. /// 收款账号提示标签
  14. @property (nonatomic, strong) UILabel *payeeAccountTipsLb;
  15. /// 账号视图
  16. @property (nonatomic, strong) UIView *accountView;
  17. /// 提现账号类型名称标签
  18. @property (nonatomic, strong) UILabel *withdrawalAccountTypeNameLb;
  19. /// 提现账号信息标签
  20. @property (nonatomic, strong) UILabel *withdrawalAccountInfoLb;
  21. /// 箭头图标
  22. @property (nonatomic, strong) UIImageView *arrowIcon;
  23. @end
  24. @implementation YMMyEarningsBindAccountView
  25. - (void)ym_setupViews{
  26. [self addSubview:self.payeeAccountTipsLb];
  27. [self addSubview:self.accountView];
  28. [self.accountView addSubview:self.withdrawalAccountTypeNameLb];
  29. [self.accountView addSubview:self.withdrawalAccountInfoLb];
  30. [self.accountView addSubview:self.arrowIcon];
  31. [self setupConstraints];
  32. }
  33. - (void)setupConstraints {
  34. [self.payeeAccountTipsLb mas_makeConstraints:^(MASConstraintMaker *make) {
  35. make.top.equalTo(self).offset(adapt(10));
  36. make.left.equalTo(self).offset(adapt(18));
  37. }];
  38. [self.accountView mas_makeConstraints:^(MASConstraintMaker *make) {
  39. make.top.equalTo(self.payeeAccountTipsLb.mas_bottom).offset(adapt(12));
  40. make.left.equalTo(self).offset(adapt(12));
  41. make.right.equalTo(self).offset(adapt(-12));
  42. make.bottom.equalTo(self).offset(adapt(-10));
  43. make.height.mas_equalTo(adapt(48));
  44. }];
  45. [self.withdrawalAccountTypeNameLb mas_makeConstraints:^(MASConstraintMaker *make) {
  46. make.centerY.equalTo(self.accountView.mas_centerY);
  47. make.left.equalTo(self.accountView).offset(adapt(10));
  48. }];
  49. [self.withdrawalAccountInfoLb mas_makeConstraints:^(MASConstraintMaker *make) {
  50. make.centerY.equalTo(self.accountView.mas_centerY);
  51. make.left.equalTo(self.withdrawalAccountTypeNameLb.mas_right).offset(adapt(10));
  52. }];
  53. [self.arrowIcon mas_makeConstraints:^(MASConstraintMaker *make) {
  54. make.centerY.equalTo(self.accountView.mas_centerY);
  55. make.left.equalTo(self.withdrawalAccountInfoLb.mas_right).offset(adapt(10));
  56. make.right.equalTo(self.accountView).offset(adapt(-10));
  57. make.width.height.mas_equalTo(adapt(15));
  58. }];
  59. }
  60. - (void)ym_bindViewModel:(YMMyEarningsViewModel *)viewModel{
  61. if (!viewModel) {
  62. return;
  63. }
  64. _viewModel = viewModel;
  65. RAC(self.withdrawalAccountTypeNameLb, text) = RACObserve(self.viewModel, withdrawalAccountTypeName);
  66. @weakify(self)
  67. [[[[[RACSignal combineLatest:@[
  68. RACObserve(self.viewModel, withdrawalAccountHolder),
  69. RACObserve(self.viewModel, withdrawalAccount),
  70. ] reduce:^(NSString * withdrawalAccountHolder, NSString * withdrawalAccount){
  71. if (OCStringIsEmpty(withdrawalAccountHolder)) {
  72. return stringFormat(@"%@",withdrawalAccount);
  73. } else {
  74. return stringFormat(@"%@(%@)",withdrawalAccount,withdrawalAccountHolder);
  75. }
  76. }] distinctUntilChanged] deliverOnMainThread] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(NSString * _Nullable withdrawalAccountInfo) {
  77. @strongify(self)
  78. self.withdrawalAccountInfoLb.text = withdrawalAccountInfo;
  79. }];
  80. }
  81. - (UILabel *)payeeAccountTipsLb{
  82. if (!_payeeAccountTipsLb) {
  83. _payeeAccountTipsLb = [[UILabel alloc]init];
  84. _payeeAccountTipsLb.font = LCFont(13);
  85. _payeeAccountTipsLb.textColor = HexColorFromRGB(0x161330);
  86. _payeeAccountTipsLb.textAlignment = NSTextAlignmentLeft;
  87. _payeeAccountTipsLb.text = @"收款账号";
  88. }
  89. return _payeeAccountTipsLb;
  90. }
  91. - (UIView *)accountView{
  92. if (!_accountView) {
  93. _accountView = [[UIView alloc]init];
  94. _accountView.backgroundColor = HexColorFromRGB(0xF2F5FF);
  95. _accountView.layer.cornerRadius = adapt(12);
  96. _accountView.layer.masksToBounds = YES;
  97. _accountView.userInteractionEnabled = YES;
  98. WS(weakSelf)
  99. UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] init];
  100. [_accountView addGestureRecognizer:tap];
  101. [[[tap rac_gestureSignal] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id x) {
  102. [weakSelf.viewModel gotoBindWithdrawalAccount];
  103. }];
  104. }
  105. return _accountView;
  106. }
  107. - (UILabel *)withdrawalAccountTypeNameLb {
  108. if (!_withdrawalAccountTypeNameLb) {
  109. _withdrawalAccountTypeNameLb = [[UILabel alloc]init];
  110. _withdrawalAccountTypeNameLb.font = LCBoldFont(14);
  111. _withdrawalAccountTypeNameLb.textColor = HexColorFromRGB(0x333333);
  112. _withdrawalAccountTypeNameLb.textAlignment = NSTextAlignmentLeft;
  113. _withdrawalAccountTypeNameLb.text = @"支付宝账号";
  114. /**
  115. *抗拉伸 setContentHuggingPriority(值越高,越不容易拉伸)
  116. */
  117. [_withdrawalAccountTypeNameLb setContentHuggingPriority:UILayoutPriorityDefaultHigh forAxis:UILayoutConstraintAxisHorizontal];
  118. /**
  119. *抗压缩 setContentCompressionResistancePriority(值越高,越不容易压缩)
  120. **/
  121. [_withdrawalAccountTypeNameLb setContentCompressionResistancePriority:UILayoutPriorityDefaultHigh forAxis:UILayoutConstraintAxisHorizontal];
  122. }
  123. return _withdrawalAccountTypeNameLb;
  124. }
  125. - (UILabel *)withdrawalAccountInfoLb{
  126. if (!_withdrawalAccountInfoLb) {
  127. _withdrawalAccountInfoLb = [[UILabel alloc]init];
  128. _withdrawalAccountInfoLb.font = LCFont(12);
  129. _withdrawalAccountInfoLb.textColor = HexColorFromRGB(0xB4BDD9);
  130. _withdrawalAccountInfoLb.textAlignment = NSTextAlignmentRight;
  131. _withdrawalAccountInfoLb.text = @"请绑定账号";
  132. /**
  133. *抗拉伸 setContentHuggingPriority(值越高,越不容易拉伸)
  134. */
  135. [_withdrawalAccountInfoLb setContentHuggingPriority:UILayoutPriorityDefaultLow forAxis:UILayoutConstraintAxisHorizontal];
  136. /**
  137. *抗压缩 setContentCompressionResistancePriority(值越高,越不容易压缩)
  138. **/
  139. [_withdrawalAccountInfoLb setContentCompressionResistancePriority:UILayoutPriorityDefaultLow forAxis:UILayoutConstraintAxisHorizontal];
  140. }
  141. return _withdrawalAccountInfoLb;
  142. }
  143. - (UIImageView *)arrowIcon{
  144. if (!_arrowIcon) {
  145. _arrowIcon = [[UIImageView alloc]init];
  146. _arrowIcon.image = ImageByName(@"ym_my_earnings_arrow_icon");
  147. /**
  148. *抗拉伸 setContentHuggingPriority(值越高,越不容易拉伸)
  149. */
  150. [_arrowIcon setContentHuggingPriority:UILayoutPriorityDefaultHigh forAxis:UILayoutConstraintAxisHorizontal];
  151. /**
  152. *抗压缩 setContentCompressionResistancePriority(值越高,越不容易压缩)
  153. **/
  154. [_arrowIcon setContentCompressionResistancePriority:UILayoutPriorityDefaultHigh forAxis:UILayoutConstraintAxisHorizontal];
  155. }
  156. return _arrowIcon;
  157. }
  158. @end