YMBindWithdrawalAccountInfoView.m 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. //
  2. // YMBindWithdrawalAccountInfoView.m
  3. // MSYOUPAI
  4. //
  5. // Created by YoMi on 2024/3/5.
  6. // Copyright © 2024 MS. All rights reserved.
  7. //
  8. #import "YMBindWithdrawalAccountInfoView.h"
  9. #import "YMBindWithdrawalAccountViewModel.h"
  10. @interface YMBindWithdrawalAccountInfoView ()
  11. /// 绑定提现账号VM
  12. @property (nonatomic, strong) YMBindWithdrawalAccountViewModel *viewModel;
  13. /// 账号信息标签
  14. @property (nonatomic, strong) UILabel *accountInfoLb;
  15. /// 账号信息视图
  16. @property (nonatomic, strong) UIView *accountInfoView;
  17. /// 账号类型视图
  18. @property (nonatomic, strong) UIView *accountTypeView;
  19. /// 账号类型标签
  20. @property (nonatomic, strong) UILabel *accountTypeLb;
  21. /// 账号类型按钮
  22. @property (nonatomic, strong) UIButton *accountTypeBtn;
  23. /// 账号视图
  24. @property (nonatomic, strong) UIView *accountView;
  25. /// 账号标签
  26. @property (nonatomic, strong) UILabel *accountLb;
  27. /// 账号输入框
  28. @property (nonatomic, strong) UITextField *accountInputBox;
  29. /// 账号持有人视图
  30. @property (nonatomic, strong) UIView *accountHolderView;
  31. /// 账号持有人标签
  32. @property (nonatomic, strong) UILabel *accountHolderLb;
  33. /// 账号持有人输入框
  34. @property (nonatomic, strong) UITextField *accountHolderInputBox;
  35. @end
  36. @implementation YMBindWithdrawalAccountInfoView
  37. - (void)ym_setupViews{
  38. [self addSubview:self.accountInfoLb];
  39. [self addSubview:self.accountInfoView];
  40. [self.accountInfoView addSubview:self.accountTypeView];
  41. [self.accountTypeView addSubview:self.accountTypeLb];
  42. [self.accountTypeView addSubview:self.accountTypeBtn];
  43. [self.accountInfoView addSubview:self.accountView];
  44. [self.accountView addSubview:self.accountLb];
  45. [self.accountView addSubview:self.accountInputBox];
  46. [self.accountInfoView addSubview:self.accountHolderView];
  47. [self.accountHolderView addSubview:self.accountHolderLb];
  48. [self.accountHolderView addSubview:self.accountHolderInputBox];
  49. [self setNeedsUpdateConstraints];
  50. [self updateConstraintsIfNeeded];
  51. }
  52. - (void)updateConstraints{
  53. [self.accountInfoLb mas_makeConstraints:^(MASConstraintMaker *make) {
  54. make.top.equalTo(self).offset(adapt(10));
  55. make.left.equalTo(self).offset(adapt(15));
  56. }];
  57. [self.accountInfoView mas_makeConstraints:^(MASConstraintMaker *make) {
  58. make.top.equalTo(self.accountInfoLb.mas_bottom).offset(adapt(10));
  59. make.left.equalTo(self).offset(adapt(15));
  60. make.right.equalTo(self).offset(adapt(-15));
  61. make.bottom.equalTo(self).offset(adapt(-15));
  62. }];
  63. [self.accountTypeView mas_makeConstraints:^(MASConstraintMaker *make) {
  64. make.top.equalTo(self.accountInfoView);
  65. make.left.equalTo(self.accountInfoView);
  66. make.right.equalTo(self.accountInfoView);
  67. }];
  68. [self.accountTypeLb mas_makeConstraints:^(MASConstraintMaker *make) {
  69. make.centerY.equalTo(self.accountTypeView.mas_centerY);
  70. make.left.equalTo(self.accountTypeView).offset(adapt(10));
  71. }];
  72. [self.accountTypeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  73. make.top.equalTo(self.accountTypeView).offset(adapt(5));
  74. make.left.equalTo(self.accountTypeLb.mas_right).offset(adapt(10));
  75. make.right.equalTo(self.accountTypeView).offset(adapt(-10));
  76. make.bottom.equalTo(self.accountTypeView).offset(adapt(-5));
  77. make.height.mas_equalTo(adapt(30));
  78. }];
  79. [self.accountView mas_makeConstraints:^(MASConstraintMaker *make) {
  80. make.top.equalTo(self.accountTypeView.mas_bottom).offset(adapt(5));
  81. make.left.equalTo(self.accountTypeView.mas_left);
  82. make.right.equalTo(self.accountTypeView.mas_right);
  83. }];
  84. [self.accountLb mas_makeConstraints:^(MASConstraintMaker *make) {
  85. make.centerY.equalTo(self.accountView.mas_centerY);
  86. make.left.equalTo(self.accountView).offset(adapt(10));
  87. }];
  88. [self.accountInputBox mas_makeConstraints:^(MASConstraintMaker *make) {
  89. make.top.equalTo(self.accountView).offset(adapt(5));
  90. make.left.equalTo(self.accountLb.mas_right).offset(adapt(10));
  91. make.right.equalTo(self.accountView).offset(adapt(-10));
  92. make.bottom.equalTo(self.accountView).offset(adapt(-5));
  93. make.height.mas_equalTo(adapt(30));
  94. }];
  95. [self.accountHolderView mas_makeConstraints:^(MASConstraintMaker *make) {
  96. make.top.equalTo(self.accountView.mas_bottom).offset(adapt(5));
  97. make.left.equalTo(self.accountTypeView.mas_left);
  98. make.right.equalTo(self.accountTypeView.mas_right);
  99. make.bottom.equalTo(self.accountInfoView);
  100. }];
  101. [self.accountHolderLb mas_makeConstraints:^(MASConstraintMaker *make) {
  102. make.centerY.equalTo(self.accountHolderView.mas_centerY);
  103. make.left.equalTo(self.accountHolderView).offset(adapt(10));
  104. }];
  105. [self.accountHolderInputBox mas_makeConstraints:^(MASConstraintMaker *make) {
  106. make.top.equalTo(self.accountHolderView).offset(adapt(5));
  107. make.left.equalTo(self.accountHolderLb.mas_right).offset(adapt(10));
  108. make.right.equalTo(self.accountHolderView).offset(adapt(-10));
  109. make.bottom.equalTo(self.accountHolderView).offset(adapt(-5));
  110. make.height.mas_equalTo(adapt(30));
  111. }];
  112. [super updateConstraints];
  113. }
  114. - (void)ym_bindViewModel:(YMBindWithdrawalAccountViewModel *)viewModel{
  115. if (!viewModel) {
  116. return;
  117. }
  118. _viewModel = viewModel;
  119. switch (self.viewModel.bindWithdrawalAccountType) {
  120. case YMBindWithdrawalAccountTypeAdd:
  121. {
  122. }
  123. break;
  124. case YMBindWithdrawalAccountTypeEdit:
  125. {
  126. self.accountInputBox.text = self.viewModel.withdrawalAccount;
  127. self.accountHolderInputBox.text = self.viewModel.withdrawalAccountHolder;
  128. }
  129. break;
  130. default:
  131. break;
  132. }
  133. RAC(self.viewModel , withdrawalAccount) = [[RACSignal merge:@[RACObserve(self.accountInputBox, text),self.accountInputBox.rac_textSignal]] takeUntil:self.rac_willDeallocSignal];
  134. RAC(self.viewModel , withdrawalAccountHolder) = [[RACSignal merge:@[RACObserve(self.accountHolderInputBox, text),self.accountHolderInputBox.rac_textSignal]]takeUntil:self.rac_willDeallocSignal];
  135. @weakify(self)
  136. [[[[RACObserve(self.viewModel, accountTypeName) distinctUntilChanged] deliverOnMainThread] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(NSString * accountTypeName) {
  137. @strongify(self)
  138. [self.accountTypeBtn setTitle:accountTypeName forState:UIControlStateNormal];
  139. }];
  140. RAC(self.accountInputBox,attributedPlaceholder) = RACObserve(self.viewModel, accountPlaceholder);
  141. RAC(self.accountHolderInputBox,attributedPlaceholder) = RACObserve(self.viewModel, accountHolderPlaceholder);
  142. }
  143. - (UILabel *)accountInfoLb{
  144. if (!_accountInfoLb) {
  145. _accountInfoLb = [[UILabel alloc]init];
  146. _accountInfoLb.font = LCBoldFont(14);
  147. _accountInfoLb.textColor = HexColorFromRGB(0x333333);
  148. _accountInfoLb.textAlignment = NSTextAlignmentLeft;
  149. _accountInfoLb.text = @"账号信息";
  150. }
  151. return _accountInfoLb;
  152. }
  153. - (UIView *)accountInfoView{
  154. if (!_accountInfoView) {
  155. _accountInfoView = [[UIView alloc]init];
  156. _accountInfoView.backgroundColor = HexColorFromRGB(0xf6f6f6);
  157. _accountInfoView.layer.cornerRadius = adapt(10);
  158. _accountInfoView.layer.masksToBounds = YES;
  159. }
  160. return _accountInfoView;
  161. }
  162. - (UIView *)accountTypeView{
  163. if (!_accountTypeView) {
  164. _accountTypeView = [[UIView alloc]init];
  165. }
  166. return _accountTypeView;
  167. }
  168. - (UILabel *)accountTypeLb{
  169. if (!_accountTypeLb) {
  170. _accountTypeLb = [[UILabel alloc]init];
  171. _accountTypeLb.font = LCFont(12);
  172. _accountTypeLb.textColor = HexColorFromRGB(0x1B2739);
  173. _accountTypeLb.textAlignment = NSTextAlignmentLeft;
  174. _accountTypeLb.text = @"账号类型";
  175. }
  176. return _accountTypeLb;
  177. }
  178. - (UIButton *)accountTypeBtn{
  179. if (!_accountTypeBtn) {
  180. _accountTypeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  181. _accountTypeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  182. _accountTypeBtn.titleLabel.font = LCFont(12);
  183. [_accountTypeBtn setTitle:@"加载中" forState:UIControlStateNormal];
  184. [_accountTypeBtn setTitleColor:HexColorFromRGB(0x645E64) forState:UIControlStateNormal];
  185. [_accountTypeBtn setImage:ImageByName(@"ym_common_arrow_icon") forState:UIControlStateNormal];
  186. _accountTypeBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
  187. [_accountTypeBtn setSemanticContentAttribute:UISemanticContentAttributeForceRightToLeft];
  188. CGFloat margin = 3;
  189. _accountTypeBtn.imageEdgeInsets = UIEdgeInsetsMake(0, margin, 0, -margin);
  190. WS(weakSelf)
  191. [[[_accountTypeBtn rac_signalForControlEvents:UIControlEventTouchUpInside] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(__kindof UIButton * _Nullable sender) {
  192. [weakSelf.accountHolderInputBox resignFirstResponder];
  193. [weakSelf.accountInputBox resignFirstResponder];
  194. [weakSelf.viewModel openAccountTypeAlert];
  195. }];
  196. }
  197. return _accountTypeBtn;
  198. }
  199. - (UIView *)accountView{
  200. if (!_accountView) {
  201. _accountView = [[UIView alloc]init];
  202. }
  203. return _accountView;
  204. }
  205. - (UILabel *)accountLb{
  206. if (!_accountLb) {
  207. _accountLb = [[UILabel alloc]init];
  208. _accountLb.font = LCFont(12);
  209. _accountLb.textColor = HexColorFromRGB(0x1B2739);
  210. _accountLb.textAlignment = NSTextAlignmentLeft;
  211. _accountLb.text = @"提现账号";
  212. }
  213. return _accountLb;
  214. }
  215. - (UITextField *)accountInputBox{
  216. if (!_accountInputBox) {
  217. NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc]init];
  218. style.minimumLineHeight = 0;
  219. NSMutableAttributedString *placeholderAttributed = [[NSMutableAttributedString alloc]initWithString:@"请输入您的提现账号"];
  220. placeholderAttributed.yy_paragraphStyle = style;
  221. placeholderAttributed.yy_font = LCFont(12);
  222. placeholderAttributed.yy_color = HexColorFromRGB(0xADB0BC);
  223. _accountInputBox = [[UITextField alloc]init];
  224. _accountInputBox.font = LCFont(12);
  225. _accountInputBox.textAlignment = NSTextAlignmentRight;
  226. _accountInputBox.attributedPlaceholder = placeholderAttributed;
  227. _accountInputBox.clearButtonMode = UITextFieldViewModeWhileEditing;
  228. _accountInputBox.autocorrectionType = UITextAutocorrectionTypeDefault;
  229. _accountInputBox.autocapitalizationType = UITextAutocapitalizationTypeNone;
  230. _accountInputBox.keyboardType = UIKeyboardTypeDefault;
  231. }
  232. return _accountInputBox;
  233. }
  234. - (UIView *)accountHolderView{
  235. if (!_accountHolderView) {
  236. _accountHolderView = [[UIView alloc]init];
  237. }
  238. return _accountHolderView;
  239. }
  240. - (UILabel *)accountHolderLb{
  241. if (!_accountHolderLb) {
  242. _accountHolderLb = [[UILabel alloc]init];
  243. _accountHolderLb.font = LCFont(12);
  244. _accountHolderLb.textColor = HexColorFromRGB(0x1B2739);
  245. _accountHolderLb.textAlignment = NSTextAlignmentLeft;
  246. _accountHolderLb.text = @"提现姓名";
  247. }
  248. return _accountHolderLb;
  249. }
  250. - (UITextField *)accountHolderInputBox{
  251. if (!_accountHolderInputBox) {
  252. NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc]init];
  253. style.minimumLineHeight = 0;
  254. NSMutableAttributedString *placeholderAttributed = [[NSMutableAttributedString alloc]initWithString:@"请输入您的提现姓名"];
  255. placeholderAttributed.yy_paragraphStyle = style;
  256. placeholderAttributed.yy_font = LCFont(12);
  257. placeholderAttributed.yy_color = HexColorFromRGB(0xADB0BC);
  258. _accountHolderInputBox = [[UITextField alloc]init];
  259. _accountHolderInputBox.font = LCFont(12);
  260. _accountHolderInputBox.textAlignment = NSTextAlignmentRight;
  261. _accountHolderInputBox.attributedPlaceholder = placeholderAttributed;
  262. _accountHolderInputBox.clearButtonMode = UITextFieldViewModeWhileEditing;
  263. _accountHolderInputBox.autocorrectionType = UITextAutocorrectionTypeDefault;
  264. _accountHolderInputBox.autocapitalizationType = UITextAutocapitalizationTypeNone;
  265. _accountHolderInputBox.keyboardType = UIKeyboardTypeDefault;
  266. }
  267. return _accountHolderInputBox;
  268. }
  269. @end