| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192 |
- //
- // ResultISFCell.m
- // RA TradeFiling
- //
- // Created by Rui Zhang on 12/17/20.
- //
- #import "ResultISFCell.h"
- #import "const.h"
- #import "ResultAdditionView.h"
- #import "UIView+RAConstraint.h"
- @interface ResultISFCell ()
- @property (strong, nonatomic) IBOutlet UIView *bgView;
- @property (strong, nonatomic) IBOutlet UILabel *bolLabel;
- @property (strong, nonatomic) IBOutlet UILabel *transactionnoLabel;
- @property (strong, nonatomic) IBOutlet UILabel *isftypeLabel;
- @property (strong, nonatomic) IBOutlet UIImageView *iconView;
- @property (weak, nonatomic) IBOutlet UILabel *importnoLabel;
- @property (strong, nonatomic) IBOutlet UILabel *logLabel;
- @property (strong, nonatomic) IBOutlet UILabel *consigneeLabel;
- @property (nonatomic,strong) UIView *selectView;
- @property (nonatomic,assign) NSInteger additionCount;
- @property (nonatomic,strong) NSMutableArray<ResultAdditionView *> *additionArray;
- @end
- @implementation ResultISFCell
- #pragma mark - Override
- - (void)awakeFromNib {
- [super awakeFromNib];
- // Initialization code
-
- self.iconView.tintColor=UIColorFromRGB(0x1e7ffb);
-
- self.bgView.layer.cornerRadius = 10.0f;
- self.bgView.layer.borderColor = [UIColor darkGrayColor].CGColor;
- self.bgView.layer.borderWidth = 0.5f;
- self.bgView.layer.masksToBounds = YES;
- self.bgView.layer.shadowColor = [UIColor lightGrayColor].CGColor;
-
- self.bolLabel.textColor = [UIColor colorWithRed:53 / 255.0 green:53 / 255.0 blue:55 / 255.0 alpha:1.0];
- self.isftypeLabel.textColor = SecondaryTextColor;
- self.importnoLabel.textColor = SecondaryTextColor;
- // self.consigneeLabel.textColor = SecondaryTextColor;
- self.transactionnoLabel.textColor = [UIColor colorWithRed:53 / 255.0 green:53 / 255.0 blue:55 / 255.0 alpha:1.0];
-
- self.selectView = [UIView new];
- self.selectView.layer.cornerRadius = 5;
- self.selectView.layer.borderColor = [UIColor darkGrayColor].CGColor;
- self.selectView.layer.borderWidth = 0.3;
- self.selectView.backgroundColor = [UIColor colorWithWhite:0.7 alpha:0.8];
- self.selectedBackgroundView = self.selectView;
-
- self.additionArray = [NSMutableArray array];
- }
- - (void)layoutSubviews {
- [super layoutSubviews];
-
- self.selectView.frame = self.bgView.frame;
- }
- - (void)prepareForReuse {
- [super prepareForReuse];
-
- [[[[[[[[self setBOL:nil] setISFType:nil] setTransactionNo:nil] setLog:nil] setIcon:nil] setIconSelect:NO] setConsignee:nil] setImportNo:nil];
- [self clearAdditionView];
- }
- #pragma mark - Getter
- + (NSString *)identifier {
- return NSStringFromClass(self);
- }
- #pragma mark - Setter
- - (instancetype)setBOL:(NSString *)bol{
- self.bolLabel.text = bol;
- return self;
- }
- - (instancetype)setISFType:(NSString *)isftype{
- self.isftypeLabel.text = isftype;
- return self;
- }
- - (instancetype)setImportNo:(NSString *)import_no
- {
- self.importnoLabel.text = import_no;
- return self;
- }
- - (instancetype)setTransactionNo:(NSString *)transactionno{
- self.transactionnoLabel.text = transactionno;
- return self;
- }
- - (instancetype)setLog:(NSString *)log {
- self.logLabel.text = [log stringByReplacingOccurrencesOfString:@"," withString:@", "];
- return self;
- }
- - (instancetype)setIcon:(NSString *)icon {
-
- if (icon) {
- self.iconView.image = [[UIImage imageNamed:icon] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
- } else {
- self.iconView.image = nil;
- }
-
- return self;
- }
- - (instancetype)setIconSelect:(BOOL)select {
- if (select) {
-
- CGFloat w = CGRectGetWidth(self.iconView.bounds);
- CGFloat h = CGRectGetHeight(self.iconView.bounds);
- CGFloat r = MIN(w, h) * 0.5;
- UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:self.iconView.bounds cornerRadius:r];
- CAShapeLayer *mask = [CAShapeLayer layer];
- mask.lineWidth = 1.0f;
- mask.strokeColor = [UIColor redColor].CGColor;
- mask.fillColor = [UIColor clearColor].CGColor;
- mask.path = path.CGPath;
- mask.name = @"am_mask";
- [self.iconView.layer addSublayer:mask];
-
- } else {
- NSMutableArray *mArr = [self.iconView.layer.sublayers mutableCopy];
- for (CALayer *layer in mArr) {
- if ([layer isKindOfClass:[CAShapeLayer class]] && [layer.name isEqualToString:@"am_mask"]) {
- [layer removeFromSuperlayer];
- }
- }
- }
- return self;
- }
- - (instancetype)setConsignee:(NSString *)consignee {
- self.consigneeLabel.text = consignee;
- return self;
- }
- - (instancetype)addAdditionName:(NSString *)name value:(NSString *)value {
-
- ResultAdditionView *additionView;
- if (self.additionCount >= self.additionArray.count) {
-
- additionView = [ResultAdditionView additionView];
-
- [self.additionArray addObject:additionView];
-
- } else {
-
- additionView = [self.additionArray objectAtIndex:self.additionCount];
- }
- additionView.titleLabel.text = name;
- additionView.valueLabel.text = value;
-
- [self.bgView addSubview:additionView];
- __weak typeof(self) weakSelf = self;
- [additionView ra_applyConstraints:^(RAConstraintMaker *maker) {
-
- maker.left.ra_equalTo(weakSelf.bgView.left).ra_offset(10);
- maker.top.ra_equalTo(weakSelf.bgView.top).ra_offset(110.0f + 25.0f * weakSelf.additionCount);
- maker.right.ra_equalTo(weakSelf.bgView.right).ra_offset(-10);
- maker.height.ra_offset(25.0f);
- }];
-
- self.additionCount++;
-
- return self;
- }
- #pragma mark - Private
- - (void)clearAdditionView {
- for (ResultAdditionView *additionView in self.additionArray) {
- [additionView removeFromSuperview];
- }
- self.additionCount = 0;
- }
- @end
|