2019-01-03 18:03:44 +08:00
//
// CRBoxInputView.h
// CRBoxInputView
//
// Created by Chobits on 2019/1/3.
// Copyright © 2019 Chobits. All rights reserved.
//
# import <UIKit / UIKit.h>
# import "CRBoxFlowLayout.h"
# import "CRBoxInputCellProperty.h"
2019-01-06 18:59:10 +08:00
# import "CRBoxInputCell.h"
2019-01-03 18:03:44 +08:00
@ class CRBoxInputView ;
2020-01-20 16:20:36 +08:00
typedef NS_ENUM ( NSInteger , CRTextEditStatus ) {
CRTextEditStatus_Idle ,
CRTextEditStatus_BeginEdit ,
CRTextEditStatus_EndEdit ,
} ;
2020-06-10 22:22:52 +08:00
typedef NS_ENUM ( NSInteger , CRInputType ) {
/// 数字
CRInputType_Number ,
/// 普通(不作任何处理)
CRInputType_Normal ,
2020-06-11 16:33:26 +08:00
/// 自定义正则( 此时需要设置customInputRegex)
2020-06-10 22:22:52 +08:00
CRInputType_Regex ,
} ;
2019-06-11 12:18:15 +08:00
typedef void ( ^ TextDidChangeblock ) ( NSString * _Nullable text , BOOL isFinished ) ;
2020-01-20 16:20:36 +08:00
typedef void ( ^ TextEditStatusChangeblock ) ( CRTextEditStatus editStatus ) ;
2019-01-03 18:03:44 +08:00
@ interface CRBoxInputView : UIView
/**
2019-06-11 12:18:15 +08:00
是 否 需 要 光 标
2019-01-09 11:34:31 +08:00
ifNeedCursor
2019-06-11 12:18:15 +08:00
default : YES
2019-01-03 18:03:44 +08:00
*/
@ property ( assign , nonatomic ) BOOL ifNeedCursor ;
/**
2019-06-11 12:18:15 +08:00
验 证 码 长 度
2019-01-09 11:34:31 +08:00
codeLength
2019-01-03 18:03:44 +08:00
default : 4
*/
2020-06-11 16:33:26 +08:00
@ property ( nonatomic , assign , readonly ) NSInteger codeLength ; //If you want to set codeLength, please use `- (instancetype)initWithCodeLength:(NSInteger)codeLength, or - (void)resetCodeLength:(NSInteger)codeLength beginEdit:(BOOL)beginEdit` in CRBoxInputView.
2019-01-03 18:03:44 +08:00
2019-01-03 19:44:13 +08:00
/**
2019-06-11 12:18:15 +08:00
是 否 开 启 密 文 模 式
2019-07-19 00:29:24 +08:00
描 述 : 你 可 以 在 任 何 时 候 修 改 该 属 性 , 并 且 已 经 存 在 的 文 字 会 自 动 刷 新 。
2019-01-09 11:34:31 +08:00
ifNeedSecurity
2019-07-19 00:29:24 +08:00
desc : You can change this property anytime . And the existing texts can be refreshed automatically .
2019-01-03 19:44:13 +08:00
default : NO
*/
@ property ( assign , nonatomic ) BOOL ifNeedSecurity ;
/**
2019-06-11 12:18:15 +08:00
显 示 密 文 的 延 时 时 间
securityDelay
desc : show security delay time
2019-01-03 19:44:13 +08:00
default : 0.3
*/
@ property ( assign , nonatomic ) CGFloat securityDelay ;
2019-01-07 12:23:58 +08:00
/**
2019-06-11 12:18:15 +08:00
键 盘 类 型
2019-01-09 11:34:31 +08:00
keyBoardType
2019-01-07 12:23:58 +08:00
default : UIKeyboardTypeNumberPad
*/
2019-01-03 19:44:13 +08:00
@ property ( assign , nonatomic ) UIKeyboardType keyBoardType ;
2019-01-07 12:23:58 +08:00
2020-06-10 22:22:52 +08:00
/**
输 入 样 式
inputType
default : CRInputType_Number
*/
@ property ( assign , nonatomic ) CRInputType inputType ;
/**
自 定 义 正 则 匹 配 输 入 内 容
customInputRegex
default : @ " "
当 inputType = = CRInputType_Regex时才会生效
*/
@ property ( copy , nonatomic ) NSString * _Nullable customInputRegex ;
2019-01-10 23:51:17 +08:00
/**
textContentType
2019-06-11 12:18:15 +08:00
描 述 : 你 可 以 设 置 为 ' nil ' 或 者 ' UITextContentTypeOneTimeCode ' 来 自 动 获 取 短 信 验 证 码
2019-01-10 23:52:50 +08:00
desc : You set this ' nil ' or ' UITextContentTypeOneTimeCode ' to auto fill verify code .
2019-01-10 23:51:17 +08:00
default : nil
*/
@ property ( null_unspecified , nonatomic , copy ) UITextContentType textContentType NS_AVAILABLE_IOS ( 10 _0 ) ;
2019-07-16 14:27:20 +08:00
/**
2019-07-16 15:07:08 +08:00
占 位 字 符 填 充 值
2019-07-16 14:27:20 +08:00
说 明 : 在 对 应 的 输 入 框 没 有 内 容 时 , 会 显 示 该 值 。
2019-07-16 15:07:08 +08:00
默 认 : nil
2019-07-16 14:27:20 +08:00
*/
@ property ( strong , nonatomic ) NSString * _Nullable placeholderText ;
2020-01-20 16:34:41 +08:00
/**
弹 出 键 盘 时 , 是 否 清 空 所 有 输 入
只 有 在 输 入 的 字 数 等 于 codeLength时 , 生 效
default : NO
*/
@ property ( assign , nonatomic ) BOOL ifClearAllInBeginEditing ;
2020-06-10 22:22:52 +08:00
2019-06-10 22:39:57 +08:00
@ property ( copy , nonatomic ) TextDidChangeblock _Nullable textDidChangeblock ;
2020-01-20 16:20:36 +08:00
@ property ( copy , nonatomic ) TextEditStatusChangeblock _Nullable textEditStatusChangeblock ;
2019-06-10 22:39:57 +08:00
@ property ( strong , nonatomic ) CRBoxFlowLayout * _Nullable boxFlowLayout ;
@ property ( strong , nonatomic ) CRBoxInputCellProperty * _Nullable customCellProperty ;
@ property ( strong , nonatomic , readonly ) NSString * _Nullable textValue ;
2019-07-01 11:22:29 +08:00
@ property ( strong , nonatomic ) UIView * _Nullable inputAccessoryView ;
2019-01-03 18:03:44 +08:00
2019-06-11 12:18:15 +08:00
/**
装 载 数 据 和 准 备 界 面
desc : Load and prepareView
beginEdit : 自 动 开 启 编 辑 模 式
default : YES
*/
2019-01-04 16:05:34 +08:00
- ( void ) loadAndPrepareView ;
2019-01-18 11:49:06 +08:00
- ( void ) loadAndPrepareViewWithBeginEdit : ( BOOL ) beginEdit ;
2020-01-20 16:48:05 +08:00
/**
重 载 输 入 的 数 据 ( 用 来 设 置 预 设 数 据 )
desc : Reload string . ( You can use this function to set deault value )
*/
2020-01-20 12:31:41 +08:00
- ( void ) reloadInputString : ( NSString * _Nullable ) value ;
2019-06-11 12:18:15 +08:00
/**
清 空 输 入
desc : Clear all
beginEdit : 自 动 开 启 编 辑 模 式
default : YES
*/
2019-01-04 16:05:34 +08:00
- ( void ) clearAll ;
2019-01-18 12:16:40 +08:00
- ( void ) clearAllWithBeginEdit : ( BOOL ) beginEdit ;
2019-06-10 22:39:57 +08:00
- ( UICollectionView * _Nullable ) mainCollectionView ;
2019-01-04 16:05:34 +08:00
2019-06-11 12:18:15 +08:00
// 快速设置
2019-01-04 16:05:34 +08:00
// Qiuck set
2019-06-10 22:39:57 +08:00
- ( void ) quickSetSecuritySymbol : ( NSString * _Nullable ) securitySymbol ;
2019-01-03 18:03:44 +08:00
2019-06-11 12:18:15 +08:00
// 你可以在继承的子类中调用父类方法
2019-01-09 11:34:31 +08:00
// You can inherit and call super
2019-01-06 19:40:28 +08:00
- ( void ) initDefaultValue ;
2019-06-11 12:18:15 +08:00
// 你可以在继承的子类中重写父类方法
2019-01-09 11:34:31 +08:00
// You can inherit and rewrite
2019-06-11 12:18:15 +08:00
- ( UICollectionViewCell * _Nullable ) customCollectionView : ( UICollectionView * _Nullable ) collectionView cellForItemAtIndexPath : ( NSIndexPath * _Nullable ) indexPath ;
2019-01-06 18:59:10 +08:00
2020-06-11 10:04:56 +08:00
// code Length 调整
- ( void ) resetCodeLength : ( NSInteger ) codeLength beginEdit : ( BOOL ) beginEdit ;
// Init
- ( instancetype _Nullable ) initWithCodeLength : ( NSInteger ) codeLength ;
2020-06-10 23:33:44 +08:00
2019-01-03 18:03:44 +08:00
@ end