2025-12-03 16:38:20 +08:00
//
// KBRegistVerEmailVC . m
// keyBoard
//
// Created by Mac on 2025 / 12 / 3.
//
# import "KBRegistVerEmailVC.h"
2025-12-03 16:45:58 +08:00
# import "CRBoxInputView.h"
2025-12-03 16:38:20 +08:00
@ interface KBRegistVerEmailVC ( )
2025-12-03 16:45:58 +08:00
@ 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
2025-12-03 16:38:20 +08:00
@ end
@ implementation KBRegistVerEmailVC
- ( void ) viewDidLoad {
[ super viewDidLoad ] ;
2025-12-03 16:45:58 +08:00
self . view . backgroundColor = [ UIColor whiteColor ] ;
self . kb_titleLabel . text = KBLocalized ( @ "Verify Email" ) ;
[ 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 . 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 ) ;
} ] ;
2025-12-03 16:38:20 +08:00
}
2025-12-03 16:45:58 +08:00
# 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 : 注 册 流 程 中 验 证 邮 箱 验 证 码 的 逻 辑
2025-12-03 16:51:46 +08:00
[ KBHUD showInfo : @ "验证通过后跳转邮箱登录页面" ] ;
2025-12-03 16:45:58 +08:00
}
# 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 : 0 xF7F7F7 ] ;
prop . cellBgColorSelected = [ UIColor colorWithHex : 0 xE0F5F2 ] ;
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 : 0 x717171 ] ;
_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." ) ;
2025-12-03 16:48:25 +08:00
// 使 用 上 个 页 面 传 入 的 邮 箱 ; 若 为 空 则 使 用 占 位 邮 箱
NSString * email = self . email . length > 0 ? self . email : @ "example@mail.com" ;
2025-12-03 16:45:58 +08:00
_descLabel . text = [ NSString stringWithFormat : template , email ] ;
}
return _descLabel ;
}
2025-12-03 16:38:20 +08:00
2025-12-03 16:45:58 +08:00
- ( 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 ;
2025-12-03 16:38:20 +08:00
}
@ end