2025-12-03 16:26:49 +08:00
|
|
|
|
//
|
|
|
|
|
|
// KBForgetVerPwdVC.m
|
|
|
|
|
|
// keyBoard
|
|
|
|
|
|
//
|
|
|
|
|
|
// Created by Mac on 2025/12/3.
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
#import "KBForgetVerPwdVC.h"
|
|
|
|
|
|
#import "CRBoxInputView.h"
|
2025-12-03 16:38:20 +08:00
|
|
|
|
#import "KBForgetPwdNewPwdVC.h"
|
2025-12-03 16:26:49 +08:00
|
|
|
|
|
|
|
|
|
|
@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");
|
2025-12-03 18:02:20 +08:00
|
|
|
|
[self kb_addTapToDismissKeyboard];
|
2025-12-03 16:26:49 +08:00
|
|
|
|
|
|
|
|
|
|
[self setupUI];
|
2025-12-08 16:39:47 +08:00
|
|
|
|
NSString *reEmail = self.email ? self.email : @"";
|
|
|
|
|
|
[[KBLoginVM shared] sendVerifyMailWithEmail:reEmail withCompletion:^(BOOL success, NSError * _Nullable error) {
|
|
|
|
|
|
if (success) {
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}];
|
2025-12-03 16:26:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#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);
|
2025-12-08 16:39:47 +08:00
|
|
|
|
[[KBLoginVM shared] verifyEMailCode:self.email verifyCode:code withCompletion:^(BOOL success, NSError * _Nullable error) {
|
|
|
|
|
|
if (success) {
|
|
|
|
|
|
KBForgetPwdNewPwdVC *vc = [[KBForgetPwdNewPwdVC alloc] init];
|
|
|
|
|
|
vc.email = self.email;
|
|
|
|
|
|
UINavigationController *nav = KB_CURRENT_NAV;
|
|
|
|
|
|
if ([nav isKindOfClass:[BaseNavigationController class]]) {
|
|
|
|
|
|
[(BaseNavigationController *)nav kb_pushViewControllerRemovingSameClass:vc animated:YES];
|
|
|
|
|
|
} else {
|
|
|
|
|
|
[nav pushViewController:vc animated:YES];
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}];
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-12-03 16:26:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#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];
|
2025-12-03 16:38:20 +08:00
|
|
|
|
prop.cellCursorColor = [UIColor colorWithHex:KBBlackValue];
|
2025-12-03 16:26:49 +08:00
|
|
|
|
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];
|
2025-12-03 16:54:23 +08:00
|
|
|
|
_nextButton.layer.cornerRadius = 11.0;
|
2025-12-03 16:26:49 +08:00
|
|
|
|
_nextButton.layer.masksToBounds = YES;
|
|
|
|
|
|
[_nextButton addTarget:self action:@selector(onTapNext)
|
|
|
|
|
|
forControlEvents:UIControlEventTouchUpInside];
|
|
|
|
|
|
}
|
|
|
|
|
|
return _nextButton;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@end
|