Files
keyboard/keyBoard/Class/Vender/CRBoxInputView/CRBoxInputView.h

166 lines
4.6 KiB
C
Raw Normal View History

2025-12-02 18:29:04 +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"
#import "CRBoxInputCell.h"
@class CRBoxInputView;
typedef NS_ENUM(NSInteger, CRTextEditStatus) {
CRTextEditStatus_Idle,
CRTextEditStatus_BeginEdit,
CRTextEditStatus_EndEdit,
};
typedef NS_ENUM(NSInteger, CRInputType) {
/// 数字
CRInputType_Number,
/// 普通(不作任何处理)
CRInputType_Normal,
/// 自定义正则此时需要设置customInputRegex
CRInputType_Regex,
};
typedef void(^TextDidChangeblock)(NSString * _Nullable text, BOOL isFinished);
typedef void(^TextEditStatusChangeblock)(CRTextEditStatus editStatus);
typedef NSString *(^TextCustomProcessblock)(NSString * _Nullable text);
@interface CRBoxInputView : UIView
/**
ifNeedCursor
default: YES
*/
@property (assign, nonatomic) BOOL ifNeedCursor;
/**
codeLength
default: 4
*/
@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.
/**
ifNeedSecurity
desc: You can change this property anytime. And the existing texts can be refreshed automatically.
default: NO
*/
@property (assign, nonatomic) BOOL ifNeedSecurity;
/**
securityDelay
desc: show security delay time
default: 0.3
*/
@property (assign, nonatomic) CGFloat securityDelay;
/**
keyBoardType
default: UIKeyboardTypeNumberPad
*/
@property (assign, nonatomic) UIKeyboardType keyBoardType;
/**
inputType
default: CRInputType_Number
*/
@property (assign, nonatomic) CRInputType inputType;
/**
customInputRegex
default: @""
inputType == CRInputType_Regex时才会生效
*/
@property (copy, nonatomic) NSString * _Nullable customInputRegex;
/**
textContentType
: 'nil' 'UITextContentTypeOneTimeCode'
desc: You set this 'nil' or 'UITextContentTypeOneTimeCode' to auto fill verify code.
default: nil
*/
@property (null_unspecified,nonatomic,copy) UITextContentType textContentType NS_AVAILABLE_IOS(10_0);
/**
nil
*/
@property (strong, nonatomic) NSString * _Nullable placeholderText;
/**
codeLength时
default: NO
*/
@property (assign, nonatomic) BOOL ifClearAllInBeginEditing;
@property (copy, nonatomic) TextDidChangeblock _Nullable textDidChangeblock;
@property (copy, nonatomic) TextEditStatusChangeblock _Nullable textEditStatusChangeblock;
/// 文本自定义处理
@property (copy, nonatomic) TextCustomProcessblock _Nullable textCustomProcessblock;
@property (strong, nonatomic) CRBoxFlowLayout * _Nullable boxFlowLayout;
@property (strong, nonatomic) CRBoxInputCellProperty * _Nullable customCellProperty;
@property (strong, nonatomic, readonly) NSString * _Nullable textValue;
@property (strong, nonatomic) UIView * _Nullable inputAccessoryView;
/**
desc: Load and prepareView
beginEdit:
default: YES
*/
- (void)loadAndPrepareView;
- (void)loadAndPrepareViewWithBeginEdit:(BOOL)beginEdit;
/**
desc:Reload string. (You can use this function to set deault value)
*/
- (void)reloadInputString:(NSString *_Nullable)value;
/**
desc: Clear all
beginEdit:
default: YES
*/
- (void)clearAll;
- (void)clearAllWithBeginEdit:(BOOL)beginEdit;
- (UICollectionView *_Nullable)mainCollectionView;
// 快速设置
// Qiuck set
- (void)quickSetSecuritySymbol:(NSString *_Nullable)securitySymbol;
// 你可以在继承的子类中调用父类方法
// You can inherit and call super
- (void)initDefaultValue;
// 你可以在继承的子类中重写父类方法
// You can inherit and rewrite
- (UICollectionViewCell *_Nullable)customCollectionView:(UICollectionView *_Nullable)collectionView cellForItemAtIndexPath:(NSIndexPath *_Nullable)indexPath;
// code Length 调整
- (void)resetCodeLength:(NSInteger)codeLength beginEdit:(BOOL)beginEdit;
// Init
- (instancetype _Nullable )initWithCodeLength:(NSInteger)codeLength;
@end