87 lines
2.7 KiB
Swift
87 lines
2.7 KiB
Swift
//
|
|
// AccountViewEmpty.swift
|
|
// Wallet
|
|
//
|
|
// Created by Igor on 12.10.2020.
|
|
// Copyright © 2020 List. All rights reserved.
|
|
//
|
|
|
|
import UIKit
|
|
|
|
extension CommonViewEmpty {
|
|
enum ActionButtonRelation {
|
|
case top
|
|
case bottom
|
|
}
|
|
}
|
|
|
|
class CommonViewEmpty: CommonViewCustom {
|
|
|
|
@IBOutlet private weak var titleLbl: UILabel!
|
|
@IBOutlet private weak var textLbl: UILabel!
|
|
@IBOutlet private weak var imgView: UIButton!
|
|
@IBOutlet private weak var button: CommonButtonAction!
|
|
@IBOutlet private var bottomButtonConstraint: NSLayoutConstraint!
|
|
@IBOutlet private var topButtonConstraint: NSLayoutConstraint!
|
|
|
|
@IBInspectable var image: UIImage? {
|
|
didSet { imgView.setImage(image, for: .normal) }
|
|
}
|
|
|
|
@IBInspectable var title: String? {
|
|
didSet { titleLbl.attributedText = title?.localized.attributed(style: .medium, size: 20, color: Asset.textCoal.color, alignment: .center) }
|
|
willSet {
|
|
self.titleLbl.isHidden = newValue?.isEmpty ?? true
|
|
}
|
|
}
|
|
|
|
@IBInspectable var text: String? {
|
|
didSet { textLbl.attributedText = text?.localized.attributed(style: .regular, size: 14, color: Asset.textGranite.color, alignment: .center) }
|
|
willSet {
|
|
self.textLbl.isHidden = newValue?.isEmpty ?? true
|
|
}
|
|
}
|
|
|
|
var action: CommonMenuAction? {
|
|
get { button.action }
|
|
set { button.action = newValue; button.isHidden = button.action == nil }
|
|
}
|
|
|
|
init(
|
|
title: String? = nil,
|
|
text: String? = nil,
|
|
image: UIImage? = nil,
|
|
backgroundColor: UIColor = .clear,
|
|
submit: String? = nil,
|
|
submitRealtion: ActionButtonRelation = .bottom,
|
|
action: (() -> Void)? = nil
|
|
) {
|
|
super.init(frame: .zero)
|
|
titleLbl.attributedText = title?.localized.attributed(style: .medium, size: 20, color: Asset.textCoal.color, alignment: .center)
|
|
textLbl.attributedText = text?.localized.attributed(style: .regular, size: 14, color: Asset.textGranite.color, alignment: .center)
|
|
self.textLbl.isHidden = text?.isEmpty ?? true
|
|
self.titleLbl.isHidden = title?.isEmpty ?? true
|
|
imgView.setImage(image, for: .normal)
|
|
if let submit = submit {
|
|
self.action = .action(title: submit) { _ in action?() }
|
|
} else {
|
|
button.isHidden = true
|
|
}
|
|
contentView.backgroundColor = backgroundColor
|
|
|
|
self.topButtonConstraint.isActive = submitRealtion == .top
|
|
self.bottomButtonConstraint.isActive = submitRealtion == .bottom
|
|
}
|
|
|
|
override func setup() {
|
|
super.setup()
|
|
titleLbl.text = nil
|
|
textLbl.text = nil
|
|
}
|
|
|
|
required init?(coder aDecoder: NSCoder) {
|
|
super.init(coder: aDecoder)
|
|
}
|
|
|
|
}
|