94 lines
3.6 KiB
Swift
94 lines
3.6 KiB
Swift
//
|
|
// RamActionsView.swift
|
|
// Wallet
|
|
//
|
|
// Created by grigori on 12.11.2021.
|
|
// Copyright © 2021 AM. All rights reserved.
|
|
//
|
|
|
|
import Foundation
|
|
import UIKit
|
|
|
|
class RamActionsView: UIView {
|
|
|
|
let codeLabel = UILabel()
|
|
let arrowView = UIImageView()
|
|
let errorDescriptionLabel = UILabel()
|
|
let copyButton = CommonButtonAction()
|
|
|
|
override init(frame: CGRect) {
|
|
super.init(frame: frame)
|
|
|
|
setupViews()
|
|
}
|
|
|
|
required init?(coder: NSCoder) {
|
|
super.init(coder: coder)
|
|
|
|
setupViews()
|
|
}
|
|
|
|
private func setupViews() {
|
|
|
|
backgroundColor = Asset.marble.color
|
|
layer.cornerRadius = 10
|
|
|
|
codeLabel.attributedText = "Error code".attributed(named: "bold_14", color: Asset.textDeepWater.color)
|
|
arrowView.image = Asset.arrowTop.image
|
|
addSubview(codeLabel)
|
|
addSubview(arrowView)
|
|
addSubview(copyButton)
|
|
|
|
let separatorView1 = UIView()
|
|
separatorView1.backgroundColor = Asset.lightGray.color
|
|
separatorView1.alpha = 0.5
|
|
|
|
let separatorView2 = UIView()
|
|
separatorView2.backgroundColor = Asset.lightGray.color
|
|
separatorView2.alpha = 0.5
|
|
|
|
addSubview(separatorView1)
|
|
addSubview(separatorView2)
|
|
addSubview(errorDescriptionLabel)
|
|
|
|
|
|
copyButton.style = .secondary
|
|
copyButton.lzTitle = "Copy error code"
|
|
errorDescriptionLabel.numberOfLines = 0
|
|
|
|
translatesAutoresizingMaskIntoConstraints = false
|
|
subviews.forEach({ $0.translatesAutoresizingMaskIntoConstraints = false })
|
|
|
|
UIView.activate(constraints: [
|
|
heightAnchor.constraint(equalToConstant: 208),
|
|
codeLabel.topAnchor.constraint(equalTo: topAnchor, constant: 14),
|
|
codeLabel.leftAnchor.constraint(equalTo: leftAnchor, constant: 8),
|
|
arrowView.topAnchor.constraint(equalTo: topAnchor, constant: 17),
|
|
arrowView.rightAnchor.constraint(equalTo: rightAnchor, constant: -10),
|
|
separatorView1.heightAnchor.constraint(equalToConstant: 1),
|
|
separatorView1.topAnchor.constraint(equalTo: topAnchor, constant: 44),
|
|
separatorView1.leftAnchor.constraint(equalTo: leftAnchor, constant: 8),
|
|
separatorView1.centerXAnchor.constraint(equalTo: centerXAnchor),
|
|
separatorView2.heightAnchor.constraint(equalToConstant: 1),
|
|
separatorView2.bottomAnchor.constraint(equalTo: bottomAnchor, constant: -72),
|
|
separatorView2.leftAnchor.constraint(equalTo: leftAnchor, constant: 8),
|
|
separatorView2.centerXAnchor.constraint(equalTo: centerXAnchor),
|
|
errorDescriptionLabel.topAnchor.constraint(equalTo: separatorView1.topAnchor, constant: 12),
|
|
errorDescriptionLabel.leftAnchor.constraint(equalTo: leftAnchor, constant: 8),
|
|
errorDescriptionLabel.rightAnchor.constraint(equalTo: rightAnchor, constant: -8),
|
|
errorDescriptionLabel.bottomAnchor.constraint(equalTo: separatorView2.topAnchor, constant: -12),
|
|
copyButton.bottomAnchor.constraint(equalTo: bottomAnchor, constant: -12),
|
|
copyButton.heightAnchor.constraint(equalToConstant: 44),
|
|
copyButton.leftAnchor.constraint(equalTo: leftAnchor, constant: 8),
|
|
copyButton.rightAnchor.constraint(equalTo: rightAnchor, constant: -8),
|
|
])
|
|
}
|
|
|
|
func update(text: String) {
|
|
errorDescriptionLabel.attributedText = text.attributed()
|
|
copyButton.action = CommonMenuAction(action: { _ in
|
|
Alert.copy(text)
|
|
})
|
|
}
|
|
}
|