//
//  OrderProgressCellContentView.m
//  Open
//
//  Created by 雷俊博 on 2019/10/18.
//  Copyright © 2019 黄江涛 . All rights reserved.
//
#define leftSpace 50
#define rightSpace 10
#import "OrderProgressCellContentView.h"
#import "UIView+frameAdjust.h"

@interface OrderProgressCellContentView ()

@property (nonatomic, strong)UIImageView *img_icon;

@property (nonatomic, strong)UILabel *lb_content;

@property (nonatomic, strong)UILabel *lb_date;

@end

@implementation OrderProgressCellContentView
#pragma mark - life cycle
- (instancetype)init {
    self = [super init];
    if (self) {
        [self setupUI];
    }
    return self;
}

- (void)setupUI
{
    self.backgroundColor = [UIColor whiteColor];
    
    UIImageView *img = [[UIImageView alloc]init];
    img.image = [UIImage imageNamed:@"提交icon"];
    [self addSubview:img];
    _img_icon = img;
    
    UILabel *content = [[UILabel alloc]init];
    content.font = [UIFont boldSystemFontOfSize:15];
   
    [self addSubview:content];
    _lb_content = content;
    
     UILabel *date = [[UILabel alloc]init];
    date.font = [UIFont systemFontOfSize:12];
    date.textColor = [UIColor colorWithHex:0x999999];

       [self addSubview:date];
       _lb_date = date;
    
    
    [img mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self);
        make.left.offset(leftSpace - 8.5);
        make.width.height.offset(17);
    }];
    
    [content mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(img).offset(-10);
        make.left.mas_equalTo(img.mas_right).offset(10);
        make.right.mas_equalTo(self).offset(-10);
        make.bottom.mas_equalTo(date.mas_top).offset(-4);
    }];
    
    [date mas_makeConstraints:^(MASConstraintMaker *make) {
           make.left.mas_equalTo(content);
           make.right.mas_equalTo(content);
           make.top.mas_equalTo(content.mas_bottom).offset(4);
           make.height.mas_equalTo(@12);
       }];
}

#pragma mark - public methods
- (void)reloadDataWithModel:(OrderModel *)model
{
     [self setNeedsDisplay];
    
    self.lb_content.text = model.dsc;
    self.lb_date.text = model.date;
    self.lb_content.textColor = model.textColor;
    self.img_icon.image = [UIImage imageNamed:model.imgName];
    
    
   
}


#pragma mark - getters and setters
- (void)setCurrented:(BOOL)currented {
    
    _currented = currented;
    if (currented) {
       
    } else {
       
    }
}




// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
    
    if (self.hasUpLine) {
        UIBezierPath *topBezier = [UIBezierPath bezierPath];
        [topBezier moveToPoint:CGPointMake(leftSpace, 0)];
        [topBezier addLineToPoint:CGPointMake(leftSpace, self.img_icon.minY)];
              
        topBezier.lineWidth = 1.0;
        if (self.currented) {
            UIColor *stroke = [UIColor colorWithHex:0xf98505];
            [stroke set];
        }else{
            UIColor *stroke = [UIColor colorWithHex:0x999999];
            [stroke set];
        }
        [topBezier stroke];
    }
    
    if (self.hasDownLine) {
           
           UIBezierPath *downBezier = [UIBezierPath bezierPath];
           [downBezier moveToPoint:CGPointMake(leftSpace, self.img_icon.maxY)];
           [downBezier addLineToPoint:CGPointMake(leftSpace, self.bounds.size.height)];
           
           downBezier.lineWidth = 1.0;
               UIColor *stroke = [UIColor colorWithHex:0xf98505];
               [stroke set];
          
           [downBezier stroke];
       }
}


@end
