// // CommonViewWarning.swift // Wallet // // Created by Igor on 10.02.2021. // Copyright © 2021 AM. All rights reserved. // import UIKit class CommonViewWarning: CommonViewCustom { @IBOutlet private weak var imageInfo: UIImageView! @IBOutlet weak var textLbl: UILabel! @IBInspectable var text: String? { get { textLbl.attributedText?.string } set { textLbl.attributedText = newValue?.attributed(style: .regular, size: 12, color: Asset.textBrick.color, alignment: .center) } } @IBInspectable var lzText: String? { get { textLbl.attributedText?.string } set { textLbl.attributedText = newValue?.localized.attributed(style: .regular, size: 12, color: Asset.textBrick.color, alignment: .left) } } override func setup() { super.setup() contentView.backgroundColor = Asset.brick.color.withAlphaComponent(0.1) } func makeCritical() { contentView.backgroundColor = Asset.brick.color textLbl.textColor = Asset.textSnow.color if #available(iOS 13.0, *) { imageInfo.tintColor = Asset.snow.color imageInfo.image = Asset.commonInfo.image .withRenderingMode(.alwaysTemplate) .withTintColor(Asset.snow.color) } else { imageInfo.tintColor = Asset.snow.color imageInfo.image = Asset.commonInfo.image .withRenderingMode(.alwaysTemplate) } } } extension UIView { static func warning(text: String) -> CommonViewWarning { view { $0.lzText = text } } static func criticalWarning(text: String) -> CommonViewWarning { view { $0.lzText = text $0.makeCritical() } } }