123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202 |
- //
- // APPassForgetNewPassV.m
- // westkissMob
- //
- // Created by iOS on 2024/4/24.
- //
- #import "APPassForgetNewPassV.h"
- #import "KWTextField.h"
- @interface APPassForgetNewPassV ()
- @property (nonatomic, strong) KWTextField *passTf;
- @property (nonatomic, strong) KWTextField *conPassTf;
- @property (nonatomic, strong) UILabel *passTitleLb;
- @property (nonatomic, strong) UILabel *conpassTitleLb;
- @property (nonatomic, strong) UIButton *commitBtn;
- @end
- @implementation APPassForgetNewPassV
- - (void)clearPass {
- self.passTf.text = @"";
- self.conPassTf.text = @"";
- }
- - (void)commitBtnAction:(UIButton *)bt {
- [bt sleep:1];
- NSString *pass = self.passTf.text;
- NSString *conPass = self.conPassTf.text;
- if (pass == nil || pass.isEmpty || pass.length < 6) {
- [self makeToast:@"The Password Can't Less Than 6 Character"];
- return;
- }
- if (![pass isEqualToString:conPass]) {
- [self makeToast:@"The Confirm Password Mast Same to New Password"];
- return;
- }
- if (self.btnClick) {
- self.btnClick(pass);
- }
- }
- - (instancetype)initWithFrame:(CGRect)frame
- {
- self = [super initWithFrame:frame];
- if (self) {
- [self loadSubV];
- }
- return self;
- }
- - (void)loadSubV {
- UILabel *titileLab = [UILabel new];
- titileLab.text = @"RESET PASSWORD";
- titileLab.font = [UIFont boldSystemFontOfSize:16];
- titileLab.textAlignment = NSTextAlignmentCenter;
- titileLab.textColor = [UIColor colorWithHexString:@"#000000"];
- [self addSubview:titileLab];
-
- [titileLab mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(@30);
- make.leading.equalTo(self).offset(30);
- make.trailing.equalTo(self).offset(-30);
- }];
-
- [self addSubviews:@[self.passTitleLb, self.passTf, self.conpassTitleLb, self.conPassTf, self.commitBtn]];
-
-
- [self.passTitleLb mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(titileLab.mas_bottom).offset(40);
- make.height.equalTo(@14);
- make.leading.equalTo(@20);
- make.trailing.equalTo(@(-20));
- }];
- [self.passTf mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.passTitleLb.mas_bottom).offset(10);
- make.leading.equalTo(@20);
- make.trailing.equalTo(@(-20));
- make.height.equalTo(@45);
- }];
-
- [self.conpassTitleLb mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.passTf.mas_bottom).offset(30);
- make.height.equalTo(@14);
- make.leading.equalTo(@20);
- make.trailing.equalTo(@(-20));
- }];
- [self.conPassTf mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.conpassTitleLb.mas_bottom).offset(10);
- make.leading.equalTo(@20);
- make.trailing.equalTo(@(-20));
- make.height.equalTo(@45);
- }];
-
- [self.commitBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.conPassTf.mas_bottom).offset(31);
- make.height.equalTo(@45);
- make.leading.equalTo(@20);
- make.trailing.equalTo(@(-20));
- make.bottom.equalTo(self).offset(-30);
- }];
-
-
- }
- - (KWTextField *)passTf {
- if (!_passTf) {
- KWTextField *tf = [[KWTextField alloc] init];
- tf.placeholder = @"* Password";
- tf.rightView = [self getPassRightBt:800000];
- tf.rightViewMode = UITextFieldViewModeAlways;
- _passTf = tf;
- }
- return _passTf;
- }
- - (KWTextField *)conPassTf {
- if (!_conPassTf) {
- KWTextField *tf = [[KWTextField alloc] init];
- tf.placeholder = @"* Confirm Password";
- tf.rightView = [self getPassRightBt:800001];
- tf.rightViewMode = UITextFieldViewModeAlways;
- _conPassTf = tf;
- }
- return _conPassTf;
- }
- - (UILabel *)passTitleLb {
- if (!_passTitleLb) {
- UILabel *lb = [UILabel baseLb];
- lb.font = [UIFont fontWithName:Rob_Regular size:12];
- lb.text = @"New Password";
- lb.textColor = Col_000;
- _passTitleLb = lb;
- }
- return _passTitleLb;
- }
- - (UILabel *)conpassTitleLb {
- if (!_conpassTitleLb) {
- UILabel *lb = [UILabel baseLb];
- lb.font = [UIFont fontWithName:Rob_Regular size:12];
- lb.text = @"Confirm Password";
- lb.textColor = Col_000;
- _conpassTitleLb = lb;
- }
- return _conpassTitleLb;
- }
- - (UIButton *)commitBtn {
- if (!_commitBtn) {
- UIButton *bt = [UIButton buttonWithType:UIButtonTypeCustom];
- [bt setTitle:@"SUBMIT" forState:UIControlStateNormal];
- bt.titleLabel.font = [UIFont fontWithName:Rob_Regular size:14];
- [bt setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
- [bt setBackgroundColor:[UIColor colorWithHexString:@"#000000"]];
- bt.layer.cornerRadius = 4;
- bt.layer.masksToBounds = true;
- [bt addTarget:self action:@selector(commitBtnAction:) forControlEvents:UIControlEventTouchUpInside];
- _commitBtn = bt;
- }
- return _commitBtn;
- }
- - (UIView *)getPassRightBt:(NSInteger)tag {
- UIView *v = [UIView new];
- v.backgroundColor = UIColor.clearColor;
- UIButton *bt = [UIButton buttonWithType:UIButtonTypeCustom];
- [bt setImage:[UIImage imageNamed:@"login_password_secure"] forState:UIControlStateNormal];
- [bt setImage:[UIImage imageNamed:@"login_password_secure_display"] forState:UIControlStateSelected];
- [bt addTarget:self action:@selector(tfBtAction:) forControlEvents:UIControlEventTouchUpInside];
- bt.tag = tag;
- [v addSubview:bt];
- [bt mas_makeConstraints:^(MASConstraintMaker *make) {
- make.width.height.equalTo(@30);
- make.right.equalTo(v).offset(-17);
- make.centerY.equalTo(v);
- }];
- [v mas_makeConstraints:^(MASConstraintMaker *make) {
- make.width.equalTo(@50);
- make.height.equalTo(@43);
- }];
- return v;
- }
- - (void)tfBtAction:(UIButton *)bt {
- NSInteger tag = bt.tag - 800000;
- bt.selected = !bt.isSelected;
- if (tag == 0) {
- self.passTf.secureTextEntry = !bt.isSelected;
- } else {
- self.conPassTf.secureTextEntry = !bt.isSelected;
- }
- }
- @end
|