Files
CRBoxInputView/PodCode/Classes/CRBoxInputCellProperty.m

158 lines
4.5 KiB
Mathematica
Raw Permalink Normal View History

2019-01-03 18:03:44 +08:00
//
// CRBoxInputself.m
// CaiShenYe
//
// Created by Chobits on 2019/1/3.
// Copyright © 2019 Chobits. All rights reserved.
//
#import "CRBoxInputCellProperty.h"
2019-06-11 13:44:48 +08:00
#import <Masonry/Masonry.h>
2019-01-03 18:03:44 +08:00
2020-01-20 15:51:05 +08:00
@interface CRBoxInputCellProperty ()
@property (copy, nonatomic, readwrite) NSString *originValue;
@end
2019-01-03 18:03:44 +08:00
@implementation CRBoxInputCellProperty
- (instancetype)init
{
self = [super init];
if (self) {
2019-01-04 15:28:43 +08:00
__weak typeof(self) weakSelf = self;
2019-01-04 15:28:43 +08:00
// UI
2019-06-11 12:01:21 +08:00
self.borderWidth = (0.5);
2019-01-03 18:03:44 +08:00
self.cellBorderColorNormal = [UIColor colorWithRed:228/255.0 green:228/255.0 blue:228/255.0 alpha:1];
self.cellBorderColorSelected = [UIColor colorWithRed:255/255.0 green:70/255.0 blue:62/255.0 alpha:1];
self.cellBorderColorFilled = nil;
2019-01-07 12:56:47 +08:00
self.cellBgColorNormal = [UIColor whiteColor];
self.cellBgColorSelected = [UIColor whiteColor];
self.cellBgColorFilled = nil;
2019-01-03 18:03:44 +08:00
self.cellCursorColor = [UIColor colorWithRed:255/255.0 green:70/255.0 blue:62/255.0 alpha:1];
2019-01-07 12:30:15 +08:00
self.cellCursorWidth = 2;
self.cellCursorHeight = 32;
2019-01-03 18:03:44 +08:00
self.cornerRadius = 4;
2019-01-04 15:28:43 +08:00
2019-06-10 22:47:05 +08:00
// line
self.showLine = NO;
2019-01-04 15:28:43 +08:00
// label
2019-01-07 14:46:50 +08:00
self.cellFont = [UIFont systemFontOfSize:20];
self.cellTextColor = [UIColor blackColor];
2019-01-04 15:28:43 +08:00
// Security
self.ifShowSecurity = NO;
self.securitySymbol = @"✱";
self.originValue = @"";
2019-01-07 15:50:20 +08:00
self.securityType = CRBoxSecuritySymbolType;
2019-01-04 20:07:30 +08:00
2019-07-16 14:41:42 +08:00
// Placeholder
2019-07-16 14:59:37 +08:00
self.cellPlaceholderText = nil;
self.cellPlaceholderTextColor = [UIColor colorWithRed:114/255.0 green:116/255.0 blue:124/255.0 alpha:0.3];
self.cellPlaceholderFont = [UIFont systemFontOfSize:20];
2019-07-16 14:41:42 +08:00
2019-06-10 20:10:20 +08:00
// Block
self.customSecurityViewBlock = ^UIView * _Nonnull{
return [weakSelf defaultCustomSecurityView];
};
2019-06-10 22:39:57 +08:00
self.customLineViewBlock = ^CRLineView * _Nonnull{
return [CRLineView new];
};
2019-06-10 23:34:10 +08:00
self.configCellShadowBlock = nil;
2019-06-10 20:10:20 +08:00
// Test
2019-01-04 20:07:30 +08:00
self.index = 0;
2019-01-03 18:03:44 +08:00
}
return self;
}
2020-01-20 15:39:36 +08:00
#pragma mark - Copy
2019-01-04 15:28:43 +08:00
- (id)copyWithZone:(NSZone *)zone
{
CRBoxInputCellProperty *copy = [[self class] allocWithZone:zone];
// UI
2019-06-11 12:01:21 +08:00
copy.borderWidth = _borderWidth;
2019-01-04 15:28:43 +08:00
copy.cellBorderColorNormal = [_cellBorderColorNormal copy];
copy.cellBorderColorSelected = [_cellBorderColorSelected copy];
if (_cellBorderColorFilled) {
copy.cellBorderColorFilled = [_cellBorderColorFilled copy];
}
2019-01-07 12:56:47 +08:00
copy.cellBgColorNormal = [_cellBgColorNormal copy];
copy.cellBgColorSelected = [_cellBgColorSelected copy];
if (_cellBgColorFilled) {
copy.cellBgColorFilled = [_cellBgColorFilled copy];
}
2019-01-04 15:28:43 +08:00
copy.cellCursorColor = [_cellCursorColor copy];
2019-01-07 12:30:15 +08:00
copy.cellCursorWidth = _cellCursorWidth;
copy.cellCursorHeight = _cellCursorHeight;
2019-01-04 15:28:43 +08:00
copy.cornerRadius = _cornerRadius;
2019-06-10 22:47:05 +08:00
// line
copy.showLine = _showLine;
2019-01-04 15:28:43 +08:00
// label
2019-01-07 14:46:50 +08:00
copy.cellFont = [_cellFont copy];
copy.cellTextColor = [_cellTextColor copy];
2019-01-04 15:28:43 +08:00
// Security
copy.ifShowSecurity = _ifShowSecurity;
copy.securitySymbol = [_securitySymbol copy];
copy.originValue = [_originValue copy];
2019-01-04 16:51:30 +08:00
copy.securityType = _securityType;
2019-01-04 15:28:43 +08:00
2019-07-16 14:41:42 +08:00
// Placeholder
2019-07-16 14:59:37 +08:00
if (_cellPlaceholderText) {
copy.cellPlaceholderText = [_cellPlaceholderText copy];
2019-07-16 14:41:42 +08:00
}
2019-07-16 14:59:37 +08:00
copy.cellPlaceholderTextColor = [_cellPlaceholderTextColor copy];
copy.cellPlaceholderFont = [_cellPlaceholderFont copy];
2019-07-16 14:41:42 +08:00
2019-06-10 20:10:20 +08:00
// Block
copy.customSecurityViewBlock = [_customSecurityViewBlock copy];
2019-06-10 22:39:57 +08:00
copy.customLineViewBlock = [_customLineViewBlock copy];
2019-06-10 23:34:10 +08:00
if (_configCellShadowBlock) {
copy.configCellShadowBlock = [_configCellShadowBlock copy];
}
2019-01-04 15:28:43 +08:00
// Test
2019-01-04 20:07:30 +08:00
copy.index = _index;
2019-01-04 15:28:43 +08:00
return copy;
}
2020-01-20 15:39:36 +08:00
#pragma mark - Getter
- (UIView *)defaultCustomSecurityView
{
UIView *customSecurityView = [UIView new];
customSecurityView.backgroundColor = [UIColor clearColor];
// circleView
static CGFloat circleViewWidth = 20;
UIView *circleView = [UIView new];
2019-06-11 13:44:48 +08:00
circleView.backgroundColor = [UIColor blackColor];
circleView.layer.cornerRadius = 4;
[customSecurityView addSubview:circleView];
[circleView mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.height.mas_equalTo(circleViewWidth);
make.centerX.offset(0);
make.centerY.offset(0);
}];
return customSecurityView;
}
2020-01-20 15:51:05 +08:00
#pragma mark - Setter
- (void)setMyOriginValue:(NSString *)originValue {
_originValue = originValue;
}
2019-01-03 18:03:44 +08:00
@end