This commit is contained in:
2025-12-03 16:26:49 +08:00
parent 04a392e7c7
commit 49f730b609
11 changed files with 391 additions and 12 deletions

View File

@@ -7,7 +7,7 @@
#import "KBEmailLoginVC.h"
#import "KBEmailRegistVC.h"
#import "KBForgetPwdVC.h"
@interface KBEmailLoginVC () <UITextViewDelegate, UITextFieldDelegate>
//
@@ -222,6 +222,13 @@
- (void)onTapForgotPassword {
KBLOG(@"KBEmailLoginVC onTapForgotPassword");
KBForgetPwdVC *vc = [[KBForgetPwdVC 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];
}
}
- (void)onTapSignUp {

View File

@@ -0,0 +1,16 @@
//
// KBForgetPwdNewPwdVC.h
// keyBoard
//
// Created by Mac on 2025/12/3.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface KBForgetPwdNewPwdVC : UIViewController
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,31 @@
//
// KBForgetPwdNewPwdVC.m
// keyBoard
//
// Created by Mac on 2025/12/3.
//
#import "KBForgetPwdNewPwdVC.h"
@interface KBForgetPwdNewPwdVC ()
@end
@implementation KBForgetPwdNewPwdVC
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
@end

View File

@@ -5,11 +5,11 @@
// Created by Mac on 2025/12/3.
//
#import <UIKit/UIKit.h>
#import "BaseViewController.h"
NS_ASSUME_NONNULL_BEGIN
@interface KBForgetPwdVC : UIViewController
@interface KBForgetPwdVC : BaseViewController
@end

View File

@@ -6,8 +6,13 @@
//
#import "KBForgetPwdVC.h"
#import "KBForgetVerPwdVC.h"
@interface KBForgetPwdVC () <UITextFieldDelegate>
@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
@@ -15,17 +20,134 @@
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
self.view.backgroundColor = [UIColor whiteColor];
self.kb_titleLabel.text = KBLocalized(@"Reset Password");
[self setupUI];
}
/*
#pragma mark - Navigation
#pragma mark - UI
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
- (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 = 28.0;
_nextButton.layer.masksToBounds = YES;
[_nextButton addTarget:self action:@selector(onTapNext)
forControlEvents:UIControlEventTouchUpInside];
}
return _nextButton;
}
*/
@end

View File

@@ -0,0 +1,16 @@
//
// KBForgetVerPwdVC.h
// keyBoard
//
// Created by Mac on 2025/12/3.
//
#import "BaseViewController.h"
NS_ASSUME_NONNULL_BEGIN
@interface KBForgetVerPwdVC : BaseViewController
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,149 @@
//
// KBForgetVerPwdVC.m
// keyBoard
//
// Created by Mac on 2025/12/3.
//
#import "KBForgetVerPwdVC.h"
#import "CRBoxInputView.h"
@interface KBForgetVerPwdVC ()
@property (nonatomic, strong) UILabel *titleLabel; // Reset Password
@property (nonatomic, strong) UILabel *subTitleLabel; // Enter Email Verification Code
@property (nonatomic, strong) CRBoxInputView *codeInputView;
@property (nonatomic, strong) UIButton *nextButton; // Next Step
@end
@implementation KBForgetVerPwdVC
- (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.subTitleLabel];
[self.view addSubview:self.codeInputView];
[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.subTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.titleLabel);
make.top.equalTo(self.titleLabel.mas_bottom).offset(16);
}];
// CRBoxInputView
[self.codeInputView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.subTitleLabel.mas_bottom).offset(24);
make.left.equalTo(self.view).offset(24);
make.right.equalTo(self.view).offset(-24);
make.height.mas_equalTo(56);
}];
// Next Step
[self.nextButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.codeInputView.mas_bottom).offset(32);
make.left.equalTo(self.view).offset(24);
make.right.equalTo(self.view).offset(-24);
make.height.mas_equalTo(56);
}];
}
#pragma mark - Actions
- (void)onTapNext {
NSString *code = self.codeInputView.textValue ?: @"";
if (code.length == 0) {
[KBHUD showInfo:KBLocalized(@"Enter Email Verification Code")];
return;
}
KBLOG(@"KBVerPwdVC next step with code=%@", code);
// TODO:
}
#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;
}
- (UILabel *)subTitleLabel {
if (!_subTitleLabel) {
_subTitleLabel = [UILabel new];
_subTitleLabel.text = KBLocalized(@"Enter Email Verification Code");
_subTitleLabel.textColor = [UIColor colorWithHex:KBBlackValue];
_subTitleLabel.font = [KBFont regular:14];
_subTitleLabel.textAlignment = NSTextAlignmentLeft;
}
return _subTitleLabel;
}
- (CRBoxInputView *)codeInputView {
if (!_codeInputView) {
// 6
_codeInputView = [[CRBoxInputView alloc] initWithCodeLength:6];
_codeInputView.backgroundColor = [UIColor clearColor];
_codeInputView.ifNeedCursor = YES;
_codeInputView.keyBoardType = UIKeyboardTypeNumberPad;
_codeInputView.inputType = CRInputType_Number;
//
// CRBoxFlowLayout *layout = [[CRBoxFlowLayout alloc] init];
// layout.itemSize = CGSizeMake(40, 48);
// layout.minimumInteritemSpacing = 12;
// layout.minimumLineSpacing = 12;
// layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
// _codeInputView.boxFlowLayout = layout;
CRBoxInputCellProperty *prop = [[CRBoxInputCellProperty alloc] init];
prop.borderWidth = 0;
prop.cornerRadius = 8.0;
prop.cellBgColorNormal = [UIColor colorWithHex:0xF7F7F7];
prop.cellBgColorSelected = [UIColor colorWithHex:0xE0F5F2];
prop.cellFont = [KBFont bold:20];
prop.cellTextColor = [UIColor colorWithHex:KBBlackValue];
_codeInputView.customCellProperty = prop;
[_codeInputView loadAndPrepareView];
}
return _codeInputView;
}
- (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 = 28.0;
_nextButton.layer.masksToBounds = YES;
[_nextButton addTarget:self action:@selector(onTapNext)
forControlEvents:UIControlEventTouchUpInside];
}
return _nextButton;
}
@end

View File

@@ -11,6 +11,7 @@
#import "AppDelegate.h"
#import "KBEmailRegistVC.h"
#import "KBEmailLoginVC.h"
#import "KBForgetPwdVC.h"
@interface KBLoginVC () <UITextViewDelegate>
@@ -218,6 +219,13 @@
- (void)onTapForgotPassword {
//
KBLOG(@"onTapForgotPassword");
KBForgetPwdVC *vc = [[KBForgetPwdVC 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];
}
}
- (void)onTapBack {