Files
keyboard/keyBoard/Class/Login/VC/KBForgetPwdVC.m

155 lines
5.4 KiB
Mathematica
Raw Normal View History

2025-12-03 16:05:00 +08:00
//
// KBForgetPwdVC.m
// keyBoard
//
// Created by Mac on 2025/12/3.
//
#import "KBForgetPwdVC.h"
2025-12-03 16:26:49 +08:00
#import "KBForgetVerPwdVC.h"
@interface KBForgetPwdVC () <UITextFieldDelegate>
2025-12-03 16:05:00 +08:00
2025-12-03 16:26:49 +08:00
@property (nonatomic, strong) UILabel *titleLabel; // Reset Password
@property (nonatomic, strong) UIView *emailFieldContainer;
@property (nonatomic, strong) UITextField *emailTextField;
@property (nonatomic, strong) UIButton *nextButton; // Next Step
2025-12-03 16:05:00 +08:00
@end
@implementation KBForgetPwdVC
- (void)viewDidLoad {
[super viewDidLoad];
2025-12-03 16:26:49 +08:00
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-03 16:05:00 +08:00
}
2025-12-03 16:26:49 +08:00
#pragma mark - UI
2025-12-03 16:05:00 +08:00
2025-12-03 16:26:49 +08:00
- (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];
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;
2025-12-03 16:05:00 +08:00
}
@end