ResulteManifestCell.m 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. //
  2. // ResulteManifestCell.m
  3. // RA TradeFiling
  4. //
  5. // Created by Rui Zhang on 12/28/20.
  6. //
  7. #import "ResulteManifestCell.h"
  8. #import "const.h"
  9. #import "ResultAdditionView.h"
  10. #import "UIView+RAConstraint.h"
  11. @interface ResulteManifestCell ()
  12. @property (strong, nonatomic) IBOutlet UIView *bgView;
  13. @property (strong, nonatomic) IBOutlet UILabel *hbolLabel;
  14. @property (strong, nonatomic) IBOutlet UILabel *mbolLabel;
  15. @property (strong, nonatomic) IBOutlet UILabel *timeLabel;
  16. @property (strong, nonatomic) IBOutlet UIImageView *iconView;
  17. @property (strong, nonatomic) IBOutlet UILabel *cbolLabel;
  18. @property (strong, nonatomic) IBOutlet UILabel *logLabel;
  19. //@property (strong, nonatomic) IBOutlet UILabel *consigneeLabel;
  20. @property (weak, nonatomic) IBOutlet UIImageView *closeIcon;
  21. @property (nonatomic,strong) UIView *selectView;
  22. @property (nonatomic,assign) NSInteger additionCount;
  23. @property (nonatomic,strong) NSMutableArray<ResultAdditionView *> *additionArray;
  24. @end
  25. @implementation ResulteManifestCell
  26. #pragma mark - Override
  27. - (void)awakeFromNib {
  28. [super awakeFromNib];
  29. // Initialization code
  30. self.iconView.tintColor=UIColorFromRGB(0x1e7ffb);
  31. self.bgView.layer.cornerRadius = 10.0f;
  32. self.bgView.layer.borderColor = [UIColor darkGrayColor].CGColor;
  33. self.bgView.layer.borderWidth = 0.5f;
  34. self.bgView.layer.masksToBounds = YES;
  35. self.bgView.layer.shadowColor = [UIColor lightGrayColor].CGColor;
  36. self.hbolLabel.textColor = [UIColor colorWithRed:53 / 255.0 green:53 / 255.0 blue:55 / 255.0 alpha:1.0];
  37. self.cbolLabel.textColor = SecondaryTextColor;
  38. self.timeLabel.textColor = SecondaryTextColor;
  39. // self.lastactionLabel.textColor = [UIColor colorWithRed:53 / 255.0 green:53 / 255.0 blue:55 / 255.0 alpha:1.0];
  40. self.selectView = [UIView new];
  41. self.selectView.layer.cornerRadius = 5;
  42. self.selectView.layer.borderColor = [UIColor darkGrayColor].CGColor;
  43. self.selectView.layer.borderWidth = 0.3;
  44. self.selectView.backgroundColor = [UIColor colorWithWhite:0.7 alpha:0.8];
  45. self.selectedBackgroundView = self.selectView;
  46. self.additionArray = [NSMutableArray array];
  47. }
  48. - (void)layoutSubviews {
  49. [super layoutSubviews];
  50. self.selectView.frame = self.bgView.frame;
  51. }
  52. - (void)prepareForReuse {
  53. [super prepareForReuse];
  54. [[[[[[[[self setHBCCN:nil] setPrimaryCCN:nil] setTime:nil] setPreviousCCN:nil] setLog:nil] setIcon:nil] setIconSelect:NO] setInClose:NO];
  55. [self clearAdditionView];
  56. }
  57. #pragma mark - Getter
  58. + (NSString *)identifier {
  59. return NSStringFromClass(self);
  60. }
  61. #pragma mark - Setter
  62. - (instancetype)setHBCCN:(nullable NSString *)hbccn{
  63. self.hbolLabel.text = hbccn;
  64. return self;
  65. }
  66. - (instancetype)setPrimaryCCN:(nullable NSString *)primary_ccn{
  67. self.mbolLabel.text = primary_ccn;
  68. return self;
  69. }
  70. - (instancetype)setTime:(nullable NSString *)time {
  71. self.timeLabel.text = time;
  72. return self;
  73. }
  74. - (instancetype)setPreviousCCN:(nullable NSString *)previous_ccn {
  75. self.cbolLabel.text = previous_ccn;
  76. return self;
  77. }
  78. - (instancetype)setLog:(nullable NSString *)log {
  79. self.logLabel.text = [log stringByReplacingOccurrencesOfString:@"," withString:@", "];
  80. return self;
  81. }
  82. - (instancetype)setIcon:(nullable NSString *)icon {
  83. if (icon) {
  84. self.iconView.image = [[UIImage imageNamed:icon] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
  85. } else {
  86. self.iconView.image = nil;
  87. }
  88. return self;
  89. }
  90. - (instancetype)setInClose:(BOOL)inclose {
  91. if(inclose)
  92. {
  93. // self.closeIcon.image=[UIImage imageNamed:@"mark_closed"];
  94. self.iconView.backgroundColor=WarrningColor;//UIColor.redColor;
  95. }
  96. else
  97. {
  98. // self.closeIcon.image=[UIImage imageNamed:@"mark_inclose"];
  99. self.iconView.backgroundColor=UIColor.whiteColor;
  100. }
  101. return self;
  102. }
  103. - (instancetype)setIconSelect:(BOOL)select {
  104. if (select) {
  105. CGFloat w = CGRectGetWidth(self.iconView.bounds);
  106. CGFloat h = CGRectGetHeight(self.iconView.bounds);
  107. CGFloat r = MIN(w, h) * 0.5;
  108. UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:self.iconView.bounds cornerRadius:r];
  109. CAShapeLayer *mask = [CAShapeLayer layer];
  110. mask.lineWidth = 1.0f;
  111. mask.strokeColor = [UIColor redColor].CGColor;
  112. mask.fillColor = [UIColor clearColor].CGColor;
  113. mask.path = path.CGPath;
  114. mask.name = @"am_mask";
  115. [self.iconView.layer addSublayer:mask];
  116. } else {
  117. NSMutableArray *mArr = [self.iconView.layer.sublayers mutableCopy];
  118. for (CALayer *layer in mArr) {
  119. if ([layer isKindOfClass:[CAShapeLayer class]] && [layer.name isEqualToString:@"am_mask"]) {
  120. [layer removeFromSuperlayer];
  121. }
  122. }
  123. }
  124. return self;
  125. }
  126. //- (instancetype)setConsignee:(NSString *)consignee {
  127. // self.consigneeLabel.text = consignee;
  128. // return self;
  129. //}
  130. - (instancetype)addAdditionName:(NSString *)name value:(NSString *)value {
  131. ResultAdditionView *additionView;
  132. if (self.additionCount >= self.additionArray.count) {
  133. additionView = [ResultAdditionView additionView];
  134. [self.additionArray addObject:additionView];
  135. } else {
  136. additionView = [self.additionArray objectAtIndex:self.additionCount];
  137. }
  138. additionView.titleLabel.text = name;
  139. additionView.valueLabel.text = value;
  140. [self.bgView addSubview:additionView];
  141. __weak typeof(self) weakSelf = self;
  142. [additionView ra_applyConstraints:^(RAConstraintMaker *maker) {
  143. maker.left.ra_equalTo(weakSelf.bgView.left).ra_offset(10);
  144. maker.top.ra_equalTo(weakSelf.bgView.top).ra_offset(110.0f + 25.0f * weakSelf.additionCount);
  145. maker.right.ra_equalTo(weakSelf.bgView.right).ra_offset(-10);
  146. maker.height.ra_offset(25.0f);
  147. }];
  148. self.additionCount++;
  149. return self;
  150. }
  151. #pragma mark - Private
  152. - (void)clearAdditionView {
  153. for (ResultAdditionView *additionView in self.additionArray) {
  154. [additionView removeFromSuperview];
  155. }
  156. self.additionCount = 0;
  157. }
  158. @end