//
//  GreenChannelImageView.m
//  Open
//
//  Created by 雷俊博 on 2019/7/11.
//  Copyright © 2019 黄江涛 . All rights reserved.
//

#import "GreenChannelImageView.h"
#import "Constants.h"


@interface GreenChannelImageView ()





@end

@implementation GreenChannelImageView
#pragma mark - life cycle
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        [self addSubview:self.leftView];
        [self addSubview:self.rightView];
        [self addSubview:self.img_leftImg];
        [self addSubview:self.img_rightImg];
        [self addSubview:self.btn_left];
        [self addSubview:self.btn_right];
        [self setupUI];
    }
    return self;
}
- (void)setupUI
{
    
    [self.leftView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.offset(10 * WIDTHRADIU);
        make.width.offset((self.frame.size.width - 30 * WIDTHRADIU) / 2.0);
        make.bottom.offset( - 10 * WIDTHRADIU);
    }];
    
    [self.rightView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.leftView.mas_right).offset( 10 * WIDTHRADIU);
        make.top.offset( 10 * WIDTHRADIU);
        make.right.offset( - 10 * WIDTHRADIU);
         make.bottom.offset( - 10 * WIDTHRADIU);
    }];
    [self.img_leftImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.equalTo(self.leftView);
    }];
    [self.img_rightImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.equalTo(self.rightView);
    }];
    
    [self.btn_left mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.width.height.equalTo(self.leftView);
    }];
    [self.btn_right mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.width.height.equalTo(self.rightView);
    }];
    
}



#pragma mark - getters and setters
- (UIView *)leftView
{
    if (!_leftView) {
        _leftView = [[UIView alloc]init];
        _leftView.backgroundColor = [UIColor colorWithHex:0xe6e6e6];
    }
    return _leftView;
}

- (UIView *)rightView
{
    if (!_rightView) {
        _rightView = [[UIView alloc]init];
        _rightView.backgroundColor = [UIColor colorWithHex:0xe6e6e6];
    }
    return _rightView;
}

- (UIImageView *)img_leftImg
{
    if (!_img_leftImg) {
        _img_leftImg = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"Greenchannel_addpictures_normal"]];
    }
    return _img_leftImg;
}
- (UIImageView *)img_rightImg
{
    if (!_img_rightImg) {
        _img_rightImg = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"Greenchannel_addpictures_normal"]];
    }
    return _img_rightImg;
}

- (UIButton *)btn_left
{
    if (!_btn_left) {
        _btn_left = [UIButton buttonWithType:UIButtonTypeCustom];
        _btn_left.tag = 200;
    }
    return _btn_left;
}

- (UIButton *)btn_right
{
    if (!_btn_right) {
        _btn_right = [UIButton buttonWithType:UIButtonTypeCustom];
        _btn_right.tag = 201;
    }
    return _btn_right;
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
