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

#import "AddressBasicView.h"


@interface AddressBasicView ()


@end

@implementation AddressBasicView
#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.tf_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.tf_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.tf_content);
        make.bottom.equalTo(self.tf_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;
}
- (UITextField *)tf_content
{
    if (!_tf_content) {
        _tf_content = [[UITextField alloc]init];
        _tf_content.font = [UIFont systemFontOfSize:17];
        _tf_content.contentVerticalAlignment = UIControlContentVerticalAlignmentBottom;
        _tf_content.returnKeyType = UIReturnKeyDone;
    }
    
    return _tf_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
