123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- //
- // YMAdolescentModelPasswordView.m
- // MSYOUPAI
- //
- // Created by YoMi on 2024/2/23.
- // Copyright © 2024 MS. All rights reserved.
- //
- #import "YMAdolescentModelPasswordView.h"
- #import "YMAdolescentModelViewModel.h"
- @interface YMAdolescentModelPasswordView ()
- /// 青少年模式VM
- @property (nonatomic, strong) YMAdolescentModelViewModel *viewModel;
- /// 青少年模式密码操作标签
- @property (nonatomic, strong) UILabel *adolescentModelPasswordOperationLb;
- /// 密码文本框
- @property (nonatomic, strong) YMCaptchaTextView *passwordTextView;
- @end
- @implementation YMAdolescentModelPasswordView
- - (void)ym_setupViews{
- [self addSubview:self.adolescentModelPasswordOperationLb];
- [self addSubview:self.passwordTextView];
- [self setNeedsUpdateConstraints];
- [self updateConstraintsIfNeeded];
- }
- - (void)updateConstraints{
-
- [self.adolescentModelPasswordOperationLb mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self).offset(adapt(30));
- make.left.equalTo(self).offset(adapt(15));
- make.right.equalTo(self).offset(adapt(-15));
- }];
-
- [self.passwordTextView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.adolescentModelPasswordOperationLb.mas_bottom).offset(adapt(20));
- make.left.equalTo(self).offset(adapt(15));
- make.right.equalTo(self).offset(adapt(-15));
- make.bottom.equalTo(self).offset(adapt(-30)).priorityHigh();
- make.height.mas_equalTo(adapt(60));
- }];
-
- [super updateConstraints];
- }
- - (void)ym_bindViewModel:(YMAdolescentModelViewModel *)viewModel{
- if (!viewModel) {
- return;
- }
-
- _viewModel = viewModel;
-
- RAC(self.adolescentModelPasswordOperationLb, text) = RACObserve(self.viewModel, adolescentModelPasswordOperationText);
-
- }
- - (UILabel *)adolescentModelPasswordOperationLb{
- if (!_adolescentModelPasswordOperationLb) {
- _adolescentModelPasswordOperationLb = [[UILabel alloc]init];
- _adolescentModelPasswordOperationLb.font = LCBoldFont(25);
- _adolescentModelPasswordOperationLb.textColor = HexColorFromRGB(0x333333);
- _adolescentModelPasswordOperationLb.textAlignment = NSTextAlignmentLeft;
- _adolescentModelPasswordOperationLb.text = @"密码操作";
- }
- return _adolescentModelPasswordOperationLb;
- }
- - (YMCaptchaTextView *)passwordTextView{
- if (!_passwordTextView) {
- YMCaptchaTextCellProperty *cellProperty = [[YMCaptchaTextCellProperty alloc]init];
- cellProperty.cellBgColorNormal = HexColorFromRGB(0xF6F6F6);
- cellProperty.cellBgColorSelected = HexColorFromRGB(0xF6F6F6);
- cellProperty.cellBgColorFilled = HexColorFromRGB(0xF6F6F6);
- cellProperty.cellCursorColor = HexColorFromRGB(0xfd7bc5);
- cellProperty.cellCursorWidth = 2;
- cellProperty.cellCursorHeight = adapt(18);
- cellProperty.cornerRadius = adapt(10);
- cellProperty.borderWidth = 0;
- cellProperty.cellFont = LCBoldFont(25);
- cellProperty.cellTextColor = HexColorFromRGB(0x000000);
- cellProperty.showLine = NO;
- cellProperty.customLineViewBlock = ^YMCaptchaTextLineView * _Nonnull{
- YMCaptchaTextLineView *lineView = [[YMCaptchaTextLineView alloc]init];
- lineView.underlineColorNormal = HexColorFromRGBA(0xCBCBCB, 0.72);
- lineView.underlineColorSelected = HexColorFromRGBA(0xCBCBCB, 0.72);
- lineView.underlineColorFilled = HexColorFromRGBA(0xCBCBCB, 0.72);
- [lineView.lineView mas_remakeConstraints:^(MASConstraintMaker *make) {
- make.height.mas_equalTo(adapt(1.5));
- make.left.right.bottom.offset(0);
- }];
- lineView.selectChangeBlock = ^(YMCaptchaTextLineView * _Nonnull lineView, BOOL selected) {
- if (selected) {
- [lineView.lineView mas_updateConstraints:^(MASConstraintMaker *make) {
- make.height.mas_equalTo(adapt(1.5));
- }];
- } else {
- [lineView.lineView mas_updateConstraints:^(MASConstraintMaker *make) {
- make.height.mas_equalTo(adapt(1.5));
- }];
- }
- };
-
- return lineView;
- };
- _passwordTextView = [[YMCaptchaTextView alloc] initWithCodeLength:4];
- _passwordTextView.captchaTextFlowLayout.itemSize = CGSizeMake(adapt(70), adapt(45));
- _passwordTextView.customCellProperty = cellProperty;
- @weakify(self)
- _passwordTextView.textDidChangeblock = ^(NSString *text, BOOL isFinished) {
- @strongify(self)
- switch (self.viewModel.adolescentModelType) {
- case YMAdolescentModelTypeTips:
- break;
- case YMAdolescentModelTypeSettingPassword:
- {
- self.viewModel.adolescentModelSettingPassword = text;
- }
- break;
- case YMAdolescentModelTypeConfirmPassword:
- {
- self.viewModel.adolescentModelConfirmPassword = text;
- }
- break;
- case YMAdolescentModelTypeClosePassword:
- {
- self.viewModel.adolescentModelConfirmPassword = text;
- }
- break;
- default:
- break;
- }
- };
- [_passwordTextView loadAndPrepareViewWithBeginEdit:NO];
- }
- return _passwordTextView;
- }
- @end
|