123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316 |
- //
- // YMBindWithdrawalAccountInfoView.m
- // MSYOUPAI
- //
- // Created by YoMi on 2024/3/5.
- // Copyright © 2024 MS. All rights reserved.
- //
- #import "YMBindWithdrawalAccountInfoView.h"
- #import "YMBindWithdrawalAccountViewModel.h"
- @interface YMBindWithdrawalAccountInfoView ()
- /// 绑定提现账号VM
- @property (nonatomic, strong) YMBindWithdrawalAccountViewModel *viewModel;
- /// 账号信息标签
- @property (nonatomic, strong) UILabel *accountInfoLb;
- /// 账号信息视图
- @property (nonatomic, strong) UIView *accountInfoView;
- /// 账号类型视图
- @property (nonatomic, strong) UIView *accountTypeView;
- /// 账号类型标签
- @property (nonatomic, strong) UILabel *accountTypeLb;
- /// 账号类型按钮
- @property (nonatomic, strong) UIButton *accountTypeBtn;
- /// 账号视图
- @property (nonatomic, strong) UIView *accountView;
- /// 账号标签
- @property (nonatomic, strong) UILabel *accountLb;
- /// 账号输入框
- @property (nonatomic, strong) UITextField *accountInputBox;
- /// 账号持有人视图
- @property (nonatomic, strong) UIView *accountHolderView;
- /// 账号持有人标签
- @property (nonatomic, strong) UILabel *accountHolderLb;
- /// 账号持有人输入框
- @property (nonatomic, strong) UITextField *accountHolderInputBox;
- @end
- @implementation YMBindWithdrawalAccountInfoView
- - (void)ym_setupViews{
- [self addSubview:self.accountInfoLb];
- [self addSubview:self.accountInfoView];
-
- [self.accountInfoView addSubview:self.accountTypeView];
- [self.accountTypeView addSubview:self.accountTypeLb];
- [self.accountTypeView addSubview:self.accountTypeBtn];
-
- [self.accountInfoView addSubview:self.accountView];
- [self.accountView addSubview:self.accountLb];
- [self.accountView addSubview:self.accountInputBox];
-
- [self.accountInfoView addSubview:self.accountHolderView];
- [self.accountHolderView addSubview:self.accountHolderLb];
- [self.accountHolderView addSubview:self.accountHolderInputBox];
-
- [self setNeedsUpdateConstraints];
- [self updateConstraintsIfNeeded];
- }
- - (void)updateConstraints{
-
- [self.accountInfoLb mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self).offset(adapt(10));
- make.left.equalTo(self).offset(adapt(15));
- }];
-
- [self.accountInfoView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.accountInfoLb.mas_bottom).offset(adapt(10));
- make.left.equalTo(self).offset(adapt(15));
- make.right.equalTo(self).offset(adapt(-15));
- make.bottom.equalTo(self).offset(adapt(-15));
- }];
-
- [self.accountTypeView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.accountInfoView);
- make.left.equalTo(self.accountInfoView);
- make.right.equalTo(self.accountInfoView);
- }];
-
- [self.accountTypeLb mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerY.equalTo(self.accountTypeView.mas_centerY);
- make.left.equalTo(self.accountTypeView).offset(adapt(10));
- }];
-
- [self.accountTypeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.accountTypeView).offset(adapt(5));
- make.left.equalTo(self.accountTypeLb.mas_right).offset(adapt(10));
- make.right.equalTo(self.accountTypeView).offset(adapt(-10));
- make.bottom.equalTo(self.accountTypeView).offset(adapt(-5));
- make.height.mas_equalTo(adapt(30));
- }];
-
- [self.accountView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.accountTypeView.mas_bottom).offset(adapt(5));
- make.left.equalTo(self.accountTypeView.mas_left);
- make.right.equalTo(self.accountTypeView.mas_right);
- }];
-
- [self.accountLb mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerY.equalTo(self.accountView.mas_centerY);
- make.left.equalTo(self.accountView).offset(adapt(10));
- }];
-
- [self.accountInputBox mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.accountView).offset(adapt(5));
- make.left.equalTo(self.accountLb.mas_right).offset(adapt(10));
- make.right.equalTo(self.accountView).offset(adapt(-10));
- make.bottom.equalTo(self.accountView).offset(adapt(-5));
- make.height.mas_equalTo(adapt(30));
- }];
-
- [self.accountHolderView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.accountView.mas_bottom).offset(adapt(5));
- make.left.equalTo(self.accountTypeView.mas_left);
- make.right.equalTo(self.accountTypeView.mas_right);
- make.bottom.equalTo(self.accountInfoView);
- }];
-
- [self.accountHolderLb mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerY.equalTo(self.accountHolderView.mas_centerY);
- make.left.equalTo(self.accountHolderView).offset(adapt(10));
- }];
-
- [self.accountHolderInputBox mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.accountHolderView).offset(adapt(5));
- make.left.equalTo(self.accountHolderLb.mas_right).offset(adapt(10));
- make.right.equalTo(self.accountHolderView).offset(adapt(-10));
- make.bottom.equalTo(self.accountHolderView).offset(adapt(-5));
- make.height.mas_equalTo(adapt(30));
- }];
-
- [super updateConstraints];
- }
- - (void)ym_bindViewModel:(YMBindWithdrawalAccountViewModel *)viewModel{
- if (!viewModel) {
- return;
- }
-
- _viewModel = viewModel;
-
- switch (self.viewModel.bindWithdrawalAccountType) {
- case YMBindWithdrawalAccountTypeAdd:
- {
-
- }
- break;
- case YMBindWithdrawalAccountTypeEdit:
- {
- self.accountInputBox.text = self.viewModel.withdrawalAccount;
- self.accountHolderInputBox.text = self.viewModel.withdrawalAccountHolder;
- }
- break;
- default:
- break;
- }
-
-
- RAC(self.viewModel , withdrawalAccount) = [[RACSignal merge:@[RACObserve(self.accountInputBox, text),self.accountInputBox.rac_textSignal]] takeUntil:self.rac_willDeallocSignal];
-
- RAC(self.viewModel , withdrawalAccountHolder) = [[RACSignal merge:@[RACObserve(self.accountHolderInputBox, text),self.accountHolderInputBox.rac_textSignal]]takeUntil:self.rac_willDeallocSignal];
-
- @weakify(self)
- [[[[RACObserve(self.viewModel, accountTypeName) distinctUntilChanged] deliverOnMainThread] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(NSString * accountTypeName) {
- @strongify(self)
- [self.accountTypeBtn setTitle:accountTypeName forState:UIControlStateNormal];
- }];
-
- RAC(self.accountInputBox,attributedPlaceholder) = RACObserve(self.viewModel, accountPlaceholder);
-
- RAC(self.accountHolderInputBox,attributedPlaceholder) = RACObserve(self.viewModel, accountHolderPlaceholder);
-
- }
- - (UILabel *)accountInfoLb{
- if (!_accountInfoLb) {
- _accountInfoLb = [[UILabel alloc]init];
- _accountInfoLb.font = LCBoldFont(14);
- _accountInfoLb.textColor = HexColorFromRGB(0x333333);
- _accountInfoLb.textAlignment = NSTextAlignmentLeft;
- _accountInfoLb.text = @"账号信息";
- }
- return _accountInfoLb;
- }
- - (UIView *)accountInfoView{
- if (!_accountInfoView) {
- _accountInfoView = [[UIView alloc]init];
- _accountInfoView.backgroundColor = HexColorFromRGB(0xf6f6f6);
- _accountInfoView.layer.cornerRadius = adapt(10);
- _accountInfoView.layer.masksToBounds = YES;
- }
- return _accountInfoView;
- }
- - (UIView *)accountTypeView{
- if (!_accountTypeView) {
- _accountTypeView = [[UIView alloc]init];
- }
- return _accountTypeView;
- }
- - (UILabel *)accountTypeLb{
- if (!_accountTypeLb) {
- _accountTypeLb = [[UILabel alloc]init];
- _accountTypeLb.font = LCFont(12);
- _accountTypeLb.textColor = HexColorFromRGB(0x1B2739);
- _accountTypeLb.textAlignment = NSTextAlignmentLeft;
- _accountTypeLb.text = @"账号类型";
- }
- return _accountTypeLb;
- }
- - (UIButton *)accountTypeBtn{
- if (!_accountTypeBtn) {
- _accountTypeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- _accountTypeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- _accountTypeBtn.titleLabel.font = LCFont(12);
- [_accountTypeBtn setTitle:@"加载中" forState:UIControlStateNormal];
- [_accountTypeBtn setTitleColor:HexColorFromRGB(0x645E64) forState:UIControlStateNormal];
- [_accountTypeBtn setImage:ImageByName(@"ym_common_arrow_icon") forState:UIControlStateNormal];
- _accountTypeBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
- [_accountTypeBtn setSemanticContentAttribute:UISemanticContentAttributeForceRightToLeft];
- CGFloat margin = 3;
- _accountTypeBtn.imageEdgeInsets = UIEdgeInsetsMake(0, margin, 0, -margin);
- WS(weakSelf)
- [[[_accountTypeBtn rac_signalForControlEvents:UIControlEventTouchUpInside] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(__kindof UIButton * _Nullable sender) {
- [weakSelf.accountHolderInputBox resignFirstResponder];
- [weakSelf.accountInputBox resignFirstResponder];
- [weakSelf.viewModel openAccountTypeAlert];
- }];
- }
- return _accountTypeBtn;
- }
- - (UIView *)accountView{
- if (!_accountView) {
- _accountView = [[UIView alloc]init];
- }
- return _accountView;
- }
- - (UILabel *)accountLb{
- if (!_accountLb) {
- _accountLb = [[UILabel alloc]init];
- _accountLb.font = LCFont(12);
- _accountLb.textColor = HexColorFromRGB(0x1B2739);
- _accountLb.textAlignment = NSTextAlignmentLeft;
- _accountLb.text = @"提现账号";
- }
- return _accountLb;
- }
- - (UITextField *)accountInputBox{
- if (!_accountInputBox) {
- NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc]init];
- style.minimumLineHeight = 0;
- NSMutableAttributedString *placeholderAttributed = [[NSMutableAttributedString alloc]initWithString:@"请输入您的提现账号"];
- placeholderAttributed.yy_paragraphStyle = style;
- placeholderAttributed.yy_font = LCFont(12);
- placeholderAttributed.yy_color = HexColorFromRGB(0xADB0BC);
- _accountInputBox = [[UITextField alloc]init];
- _accountInputBox.font = LCFont(12);
- _accountInputBox.textAlignment = NSTextAlignmentRight;
- _accountInputBox.attributedPlaceholder = placeholderAttributed;
- _accountInputBox.clearButtonMode = UITextFieldViewModeWhileEditing;
- _accountInputBox.autocorrectionType = UITextAutocorrectionTypeDefault;
- _accountInputBox.autocapitalizationType = UITextAutocapitalizationTypeNone;
- _accountInputBox.keyboardType = UIKeyboardTypeDefault;
- }
- return _accountInputBox;
- }
- - (UIView *)accountHolderView{
- if (!_accountHolderView) {
- _accountHolderView = [[UIView alloc]init];
- }
- return _accountHolderView;
- }
- - (UILabel *)accountHolderLb{
- if (!_accountHolderLb) {
- _accountHolderLb = [[UILabel alloc]init];
- _accountHolderLb.font = LCFont(12);
- _accountHolderLb.textColor = HexColorFromRGB(0x1B2739);
- _accountHolderLb.textAlignment = NSTextAlignmentLeft;
- _accountHolderLb.text = @"提现姓名";
- }
- return _accountHolderLb;
- }
- - (UITextField *)accountHolderInputBox{
- if (!_accountHolderInputBox) {
- NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc]init];
- style.minimumLineHeight = 0;
- NSMutableAttributedString *placeholderAttributed = [[NSMutableAttributedString alloc]initWithString:@"请输入您的提现姓名"];
- placeholderAttributed.yy_paragraphStyle = style;
- placeholderAttributed.yy_font = LCFont(12);
- placeholderAttributed.yy_color = HexColorFromRGB(0xADB0BC);
- _accountHolderInputBox = [[UITextField alloc]init];
- _accountHolderInputBox.font = LCFont(12);
- _accountHolderInputBox.textAlignment = NSTextAlignmentRight;
- _accountHolderInputBox.attributedPlaceholder = placeholderAttributed;
- _accountHolderInputBox.clearButtonMode = UITextFieldViewModeWhileEditing;
- _accountHolderInputBox.autocorrectionType = UITextAutocorrectionTypeDefault;
- _accountHolderInputBox.autocapitalizationType = UITextAutocapitalizationTypeNone;
- _accountHolderInputBox.keyboardType = UIKeyboardTypeDefault;
- }
- return _accountHolderInputBox;
- }
- @end
|