diff --git a/Shared/Localization/en.lproj/Localizable.strings b/Shared/Localization/en.lproj/Localizable.strings index ea15ccf..e067871 100644 --- a/Shared/Localization/en.lproj/Localizable.strings +++ b/Shared/Localization/en.lproj/Localizable.strings @@ -41,6 +41,8 @@ "Reset Password" = "Reset Password"; "Next Step" = "Next Step"; "Enter Email Verification Code" = "Enter Email Verification Code"; +"Verify Email" = "Verify Email"; +"We have already sent it to the email address %@. Please enter the 6-digit verification code from the email to verify your mailbox." = "We have already sent it to the email address %@. Please enter the 6-digit verification code from the email to verify your mailbox."; // Language switching prompt diff --git a/Shared/Localization/zh-Hans.lproj/Localizable.strings b/Shared/Localization/zh-Hans.lproj/Localizable.strings index e78f25b..401fc10 100644 --- a/Shared/Localization/zh-Hans.lproj/Localizable.strings +++ b/Shared/Localization/zh-Hans.lproj/Localizable.strings @@ -41,6 +41,8 @@ "Reset Password" = "重置密码"; "Next Step" = "下一步"; "Enter Email Verification Code" = "请输入邮箱验证码"; +"Verify Email" = "验证邮箱"; +"We have already sent it to the email address %@. Please enter the 6-digit verification code from the email to verify your mailbox." = "我们已将验证码发送至邮箱 %@,请在邮件中查看并输入 6 位验证码完成验证。"; // 语言切换提示 diff --git a/keyBoard/Class/Login/VC/KBEmailRegistVC.m b/keyBoard/Class/Login/VC/KBEmailRegistVC.m index 57bf2de..4364ce5 100644 --- a/keyBoard/Class/Login/VC/KBEmailRegistVC.m +++ b/keyBoard/Class/Login/VC/KBEmailRegistVC.m @@ -10,6 +10,7 @@ #import #import "KBLoginVM.h" #import "AppDelegate.h" +#import "KBRegistVerEmailVC.h" @interface KBEmailRegistVC () @@ -262,6 +263,13 @@ KBLOG(@"onTapSubmit email=%@, password length=%zd", self.emailTextField.text, self.passwordTextField.text.length); + KBRegistVerEmailVC *vc = [[KBRegistVerEmailVC 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)onTapForgotPassword { diff --git a/keyBoard/Class/Login/VC/KBRegistVerEmailVC.h b/keyBoard/Class/Login/VC/KBRegistVerEmailVC.h index f309cf8..67c2241 100644 --- a/keyBoard/Class/Login/VC/KBRegistVerEmailVC.h +++ b/keyBoard/Class/Login/VC/KBRegistVerEmailVC.h @@ -5,11 +5,11 @@ // Created by Mac on 2025/12/3. // 注册验证邮箱 -#import +#import "BaseViewController.h" NS_ASSUME_NONNULL_BEGIN -@interface KBRegistVerEmailVC : UIViewController +@interface KBRegistVerEmailVC : BaseViewController @end diff --git a/keyBoard/Class/Login/VC/KBRegistVerEmailVC.m b/keyBoard/Class/Login/VC/KBRegistVerEmailVC.m index fe8ec96..89166dd 100644 --- a/keyBoard/Class/Login/VC/KBRegistVerEmailVC.m +++ b/keyBoard/Class/Login/VC/KBRegistVerEmailVC.m @@ -6,26 +6,169 @@ // #import "KBRegistVerEmailVC.h" +#import "CRBoxInputView.h" @interface KBRegistVerEmailVC () +@property (nonatomic, strong) UILabel *titleLabel; // Verify Email +@property (nonatomic, strong) UILabel *subTitleLabel; // Enter Email Verification Code +@property (nonatomic, strong) CRBoxInputView *codeInputView; +@property (nonatomic, strong) UILabel *descLabel; // 多行提示文案 +@property (nonatomic, strong) UIButton *confirmButton; // Confirm + @end @implementation KBRegistVerEmailVC - (void)viewDidLoad { [super viewDidLoad]; - // Do any additional setup after loading the view. + self.view.backgroundColor = [UIColor whiteColor]; + self.kb_titleLabel.text = KBLocalized(@"Verify Email"); + + [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.subTitleLabel]; + [self.view addSubview:self.codeInputView]; + [self.view addSubview:self.descLabel]; + [self.view addSubview:self.confirmButton]; + + // 标题 + [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); + }]; + + // 验证码输入 + [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); + }]; + + // 描述文案 + [self.descLabel mas_makeConstraints:^(MASConstraintMaker *make) { + make.top.equalTo(self.codeInputView.mas_bottom).offset(24); + make.left.equalTo(self.view).offset(24); + make.right.equalTo(self.view).offset(-24); + }]; + + // Confirm 按钮 + [self.confirmButton mas_makeConstraints:^(MASConstraintMaker *make) { + make.top.equalTo(self.descLabel.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)onTapConfirm { + NSString *code = self.codeInputView.textValue ?: @""; + if (code.length == 0) { + [KBHUD showInfo:KBLocalized(@"Enter Email Verification Code")]; + return; + } + KBLOG(@"KBRegistVerEmailVC confirm with code=%@", code); + // TODO: 注册流程中验证邮箱验证码的逻辑 +} + +#pragma mark - Lazy UI + +- (UILabel *)titleLabel { + if (!_titleLabel) { + _titleLabel = [UILabel new]; + _titleLabel.text = KBLocalized(@"Verify Email"); + _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) { + _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.cellCursorColor = [UIColor colorWithHex:KBBlackValue]; + prop.cellFont = [KBFont bold:20]; + prop.cellTextColor = [UIColor colorWithHex:KBBlackValue]; + _codeInputView.customCellProperty = prop; + + [_codeInputView loadAndPrepareView]; + } + return _codeInputView; +} + +- (UILabel *)descLabel { + if (!_descLabel) { + _descLabel = [UILabel new]; + _descLabel.textColor = [UIColor colorWithHex:0x717171]; + _descLabel.font = [KBFont regular:12]; + _descLabel.numberOfLines = 0; + _descLabel.textAlignment = NSTextAlignmentLeft; + + // 这里用 %@ 预留邮箱地址占位 + NSString *template = KBLocalized(@"We have already sent it to the email address %@. Please enter the 6-digit verification code from the email to verify your mailbox."); + // 默认先用一个占位邮箱,外部可以根据真实邮箱重新设置 + NSString *email = @"example@mail.com"; + _descLabel.text = [NSString stringWithFormat:template, email]; + } + return _descLabel; +} + +- (UIButton *)confirmButton { + if (!_confirmButton) { + _confirmButton = [UIButton buttonWithType:UIButtonTypeCustom]; + [_confirmButton setTitle:KBLocalized(@"Confirm") forState:UIControlStateNormal]; + [_confirmButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; + _confirmButton.titleLabel.font = [KBFont medium:16]; + _confirmButton.backgroundColor = [UIColor colorWithHex:KBColorValue]; + _confirmButton.layer.cornerRadius = 28.0; + _confirmButton.layer.masksToBounds = YES; + [_confirmButton addTarget:self action:@selector(onTapConfirm) + forControlEvents:UIControlEventTouchUpInside]; + } + return _confirmButton; } -*/ @end