//
//  ElectronicAccountCardView.m
//  Open
//
//  Created by 雷俊博 on 2020/7/29.
//  Copyright © 2020 黄江涛 . All rights reserved.
//

#import "ElectronicAccountCardView.h"

@interface ElectronicAccountCardView ()



@end

@implementation ElectronicAccountCardView

- (instancetype)init
{
    self = [super init];
    if (self) {
        
        [self setupUI];
    }
    return self;
}

- (void)setupUI
{
    [self addSubview:self.cardView];
    [self.cardView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(10);
        make.right.offset(-10);
        make.top.offset(0);
        make.height.mas_greaterThanOrEqualTo(50);
        make.bottom.mas_equalTo(0);
    }];
    
   

    
    
   
    
}

#pragma mark - getters
- (UIView *)cardView
{
    if (!_cardView) {
        _cardView = [[UIView alloc]init];
        _cardView.backgroundColor = [UIColor colorWithHex:0x137ef6];
        [_cardView addSubview:self.lb_mark];
        [_cardView addSubview:self.lb_bankName];
        [_cardView addSubview:self.lb_message];
        [_lb_mark mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.offset(15);
            make.left.offset(20);
            make.height.offset(24);
            make.width.offset(24);
           
        }];
        [_lb_bankName mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self.lb_mark);
            make.left.equalTo(self.lb_mark.mas_right).offset(3);
        }];
        [_lb_message mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.lb_mark.mas_bottom).offset(10);
            make.left.offset(20);
            make.right.offset(-20);
            make.height.mas_greaterThanOrEqualTo(20);
            make.bottom.mas_equalTo(-20);
        }];
    }
    return _cardView;
}

- (MarkLabel *)lb_mark
{
    if (!_lb_mark) {
        _lb_mark = [[MarkLabel alloc]init];
        _lb_mark.text = @"乌";
        _lb_mark.textColor = [UIColor whiteColor];
        _lb_mark.textAlignment = NSTextAlignmentCenter;
        _lb_mark.font = [UIFont boldSystemFontOfSize:17];
        _lb_mark.layer.cornerRadius = 12;
        _lb_mark.layer.borderColor = [UIColor whiteColor].CGColor;
        _lb_mark.layer.borderWidth = 0.5;
        _lb_mark.edgeInsets = UIEdgeInsetsMake(2, 2, 2, 2);//设置内边距
        [_lb_mark sizeToFit];
    }
    return _lb_mark;
}

- (UILabel *)lb_bankName
{
    if (!_lb_bankName) {
        _lb_bankName = [[UILabel alloc]init];
        _lb_bankName.text = @"乌当农商银行";
        _lb_bankName.textColor = [UIColor whiteColor];
        _lb_bankName.font = [UIFont boldSystemFontOfSize:17];
    }
    return _lb_bankName;
}

- (UILabel *)lb_message
{
    if (!_lb_message) {
        _lb_message = [[UILabel alloc]init];
        _lb_message.attributedText = [self attributedStrWithFaultCode:@"仅需绑定一张银行卡并确认个人信息即可。通过电子账户与银行进行交易，资金安全有保障。"];
        _lb_message.textColor = [UIColor whiteColor];
        _lb_message.font = [UIFont systemFontOfSize:14];
        _lb_message.numberOfLines = 0;
    }
    return _lb_message;
}

- (NSAttributedString *) attributedStrWithFaultCode:(NSString *)faultCode {
    NSMutableAttributedString * faultCode_ = [[NSMutableAttributedString alloc] initWithString:faultCode];
    
    NSMutableParagraphStyle *paraStyle = [[NSMutableParagraphStyle alloc] init];
    paraStyle.lineSpacing = 8;
    
    NSDictionary * faultCodeAttributes = @{ NSFontAttributeName:[UIFont systemFontOfSize:14],NSParagraphStyleAttributeName:paraStyle,NSForegroundColorAttributeName:[UIColor whiteColor]};
    [faultCode_ setAttributes:faultCodeAttributes range:NSMakeRange(0,faultCode_.length)];
    
    
    
    return faultCode_;
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
