//
//  GMFaceSkinView.swift
//  Gengmei
//
//  Created by 刘鹿杰 on 2019/8/17.
//  Copyright © 2019 更美互动信息科技有限公司. All rights reserved.
//

import Foundation

import GMBaseSwift

class GMFaceSkinView : GMView {
    override func setup() {
        super.setup()
        let hudView = GMView()
        hudView.backgroundColor = UIColor(hex: 0, alpha: 0.5)
        self.addSubview(hudView)
        hudView.snp.makeConstraints { (make) in
            make.edges.equalToSuperview()
        }
        let noticeHudView = UIImageView(image: UIImage(named: "face_notice_hud"))
        self.addSubview(noticeHudView)
        noticeHudView.snp.makeConstraints { (make) in
            make.bottom.equalToSuperview().offset(-160 - UIView.safeAreaInsetsBottom)
            make.left.right.equalToSuperview()
            make.height.equalTo(144)
        }
        self.addSubview(noticeLabel)
        noticeLabel.snp.makeConstraints { (make) in
            make.size.equalTo(CGSize(width: 237, height: 104))
            make.bottom.equalToSuperview().offset(-187 - UIView.safeAreaInsetsBottom)
            make.centerX.equalTo(self)
        }
    }
    
    // 懒加载 懒加载说明文字
    lazy var noticeLabel: GMLabel = {
        let noticeLabel = GMLabel(textAlignment: .left, backgroundColor: .clear, textColor: .white, fontSize: 14)
        let text = "   · 请平视后置摄像头寻找合适距离\n   · 请跟随人声引导作出相应动作\n   · 听到闭眼提示后，请闭上眼睛 \n   · 此时相机会自动拍照哦"
        let attributedStr = NSMutableAttributedString(string: text)
        let style = NSMutableParagraphStyle()
        style.lineSpacing = 2
        attributedStr.addAttribute(NSAttributedString.Key.paragraphStyle, value: style, range: NSMakeRange(0, attributedStr.length))
        noticeLabel.attributedText = attributedStr
        noticeLabel.verticalAlignment = .middle
        noticeLabel.layer.shadowColor = UIColor.black.cgColor
        noticeLabel.layer.shadowOpacity = 0.1
        noticeLabel.layer.shadowRadius = 5
        noticeLabel.layer.cornerRadius = 4;
        noticeLabel.layer.masksToBounds = true
        noticeLabel.numberOfLines = 0;
        noticeLabel.backgroundColor = UIColor(hex: 0, alpha: 0.25)
        return noticeLabel
    }()
}
