//
//  AddressBasic2View.m
//  Open
//
//  Created by 雷俊博 on 2019/12/9.
//  Copyright © 2019 黄江涛 . All rights reserved.
//

#import "AddressBasic2View.h"

@implementation AddressBasic2View
#pragma mark - life cycle
- (instancetype)initWithFrame:(CGRect)frame leftName:(NSString *)leftName
{
    self = [super initWithFrame:frame];
    if (self) {
        [self addSubview:self.lb_leftName];
        [self addSubview:self.tv_content];
        [self addSubview:self.line];
        
        
        self.lb_leftName.text = leftName;
        
        [self setupUI];
        
    }
    return self;
}
- (void)setupUI
{
    [self.lb_leftName mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self);
        make.left.offset(20);
        make.width.offset(80);
    }];
    
    
    [self.tv_content mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self);
        make.left.equalTo(self.lb_leftName.mas_right).offset(4);
        make.height.equalTo(self);
        make.right.offset(-20);
    }];
    
    
    [self.line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(self.tv_content);
        make.bottom.equalTo(self.tv_content.mas_bottom).offset(-0.5);
        make.height.offset(0.5);
    }];
    
}

#pragma mark - getters and setters
- (UILabel *)lb_leftName
{
    if (!_lb_leftName) {
        _lb_leftName = [[UILabel alloc]init];
        _lb_leftName.textColor = [UIColor colorWithHex:0x666666];
        _lb_leftName.font = [UIFont systemFontOfSize:17];
    }
    return _lb_leftName;
}
- (UITextView *)tv_content
{
    if (!_tv_content) {
        _tv_content = [[UITextView alloc]init];
        _tv_content.font = [UIFont systemFontOfSize:17];
        _tv_content.contentInset = UIEdgeInsetsMake(7, 0, 0, 0);
        _tv_content.returnKeyType = UIReturnKeyDone;
    }
    
    return _tv_content;
}

- (UIView *)line
{
    if (!_line) {
        _line = [[UIView alloc]init];
        _line.backgroundColor = [UIColor colorWithHex:0xcccccc];
    }
    return _line;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
