// // KBForgetPwdVC.m // keyBoard // // Created by Mac on 2025/12/3. // #import "KBForgetPwdVC.h" #import "KBForgetVerPwdVC.h" @interface KBForgetPwdVC () @property (nonatomic, strong) UILabel *titleLabel; // Reset Password @property (nonatomic, strong) UIView *emailFieldContainer; @property (nonatomic, strong) UITextField *emailTextField; @property (nonatomic, strong) UIButton *nextButton; // Next Step @end @implementation KBForgetPwdVC - (void)viewDidLoad { [super viewDidLoad]; self.view.backgroundColor = [UIColor whiteColor]; self.kb_titleLabel.text = KBLocalized(@"Reset Password"); [self setupUI]; } #pragma mark - UI - (void)setupUI { [self.view addSubview:self.titleLabel]; [self.view addSubview:self.emailFieldContainer]; [self.emailFieldContainer addSubview:self.emailTextField]; [self.view addSubview:self.nextButton]; // 标题:位于内容区域上方,距离自定义导航栏底部一定间距 [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.view).offset(24); make.top.equalTo(self.view).offset(KB_NAV_TOTAL_HEIGHT + 32); }]; // 邮箱输入容器 [self.emailFieldContainer mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.titleLabel.mas_bottom).offset(24); make.left.equalTo(self.view).offset(24); make.right.equalTo(self.view).offset(-24); make.height.mas_equalTo(52); }]; [self.emailTextField mas_makeConstraints:^(MASConstraintMaker *make) { make.edges.equalTo(self.emailFieldContainer).insets(UIEdgeInsetsMake(0, 16, 0, 16)); }]; // Next Step 按钮 [self.nextButton mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.emailFieldContainer.mas_bottom).offset(24); make.left.right.equalTo(self.emailFieldContainer); make.height.mas_equalTo(56); }]; } #pragma mark - Actions - (void)onTapNext { NSString *email = [self.emailTextField.text ?: @"" stringByTrimmingCharactersInSet: [NSCharacterSet whitespaceAndNewlineCharacterSet]]; if (email.length == 0) { [KBHUD showInfo:KBLocalized(@"Enter Email Address")]; return; } KBLOG(@"KBForgetPwdVC next step with email=%@", email); // TODO: 接 forgot password 接口 KBForgetVerPwdVC *vc = [[KBForgetVerPwdVC alloc] init]; UINavigationController *nav = KB_CURRENT_NAV; if ([nav isKindOfClass:[BaseNavigationController class]]) { [(BaseNavigationController *)nav kb_pushViewControllerRemovingSameClass:vc animated:YES]; } else { [nav pushViewController:vc animated:YES]; } } #pragma mark - UITextFieldDelegate - (BOOL)textFieldShouldReturn:(UITextField *)textField { if (textField == self.emailTextField) { [textField resignFirstResponder]; [self onTapNext]; } return YES; } #pragma mark - Lazy UI - (UILabel *)titleLabel { if (!_titleLabel) { _titleLabel = [UILabel new]; _titleLabel.text = KBLocalized(@"Reset Password"); _titleLabel.textColor = [UIColor colorWithHex:KBBlackValue]; _titleLabel.font = [KBFont bold:20]; _titleLabel.textAlignment = NSTextAlignmentLeft; } return _titleLabel; } - (UIView *)emailFieldContainer { if (!_emailFieldContainer) { _emailFieldContainer = [UIView new]; _emailFieldContainer.backgroundColor = [UIColor colorWithHex:0xF7F7F7]; _emailFieldContainer.layer.cornerRadius = 10.0; _emailFieldContainer.layer.masksToBounds = YES; } return _emailFieldContainer; } - (UITextField *)emailTextField { if (!_emailTextField) { _emailTextField = [[UITextField alloc] init]; _emailTextField.delegate = self; _emailTextField.keyboardType = UIKeyboardTypeEmailAddress; _emailTextField.autocapitalizationType = UITextAutocapitalizationTypeNone; _emailTextField.autocorrectionType = UITextAutocorrectionTypeNo; _emailTextField.clearButtonMode = UITextFieldViewModeWhileEditing; _emailTextField.textColor = [UIColor colorWithHex:KBBlackValue]; _emailTextField.font = [KBFont regular:14]; _emailTextField.returnKeyType = UIReturnKeyDone; NSString *ph = KBLocalized(@"Enter Email Address"); _emailTextField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:ph attributes:@{ NSForegroundColorAttributeName : [UIColor colorWithWhite:0.75 alpha:1.0], NSFontAttributeName : [KBFont regular:14] }]; } return _emailTextField; } - (UIButton *)nextButton { if (!_nextButton) { _nextButton = [UIButton buttonWithType:UIButtonTypeCustom]; [_nextButton setTitle:KBLocalized(@"Next Step") forState:UIControlStateNormal]; [_nextButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; _nextButton.titleLabel.font = [KBFont medium:16]; _nextButton.backgroundColor = [UIColor colorWithHex:KBColorValue]; _nextButton.layer.cornerRadius = 11.0; _nextButton.layer.masksToBounds = YES; [_nextButton addTarget:self action:@selector(onTapNext) forControlEvents:UIControlEventTouchUpInside]; } return _nextButton; } @end