An advanced Ethereum/EVM mobile wallet
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
alpha-wallet-ios/Trust/UI/EmptyView.swift

74 lines
2.3 KiB

// Copyright SIX DAY LLC. All rights reserved.
7 years ago
import Foundation
import UIKit
import StatefulViewController
7 years ago
class EmptyView: UIView {
let titleLabel = UILabel()
7 years ago
let imageView = UIImageView()
let button = Button(size: .normal, style: .solid)
let insets: UIEdgeInsets
7 years ago
var onRetry: (() -> Void)? = .none
init(
title: String = NSLocalizedString("Generic.Empty", value: "Empty", comment: ""),
image: UIImage? = R.image.no_transaction(),
insets: UIEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0),
onRetry: (() -> Void)? = .none
) {
self.insets = insets
self.onRetry = onRetry
7 years ago
super.init(frame: .zero)
7 years ago
backgroundColor = .white
titleLabel.translatesAutoresizingMaskIntoConstraints = false
titleLabel.text = title
titleLabel.font = UIFont.systemFont(ofSize: 18, weight: UIFontWeightMedium)
titleLabel.textColor = Colors.lightBlack
7 years ago
imageView.translatesAutoresizingMaskIntoConstraints = false
imageView.image = image
7 years ago
button.translatesAutoresizingMaskIntoConstraints = false
button.setTitle(NSLocalizedString("Generic.Refresh", value: "Refresh", comment: ""), for: .normal)
7 years ago
button.addTarget(self, action: #selector(retry), for: .touchUpInside)
let stackView = UIStackView(arrangedSubviews: [
imageView,
titleLabel,
button,
])
7 years ago
stackView.translatesAutoresizingMaskIntoConstraints = false
stackView.alignment = .center
stackView.axis = .vertical
stackView.spacing = 30
7 years ago
addSubview(stackView)
7 years ago
NSLayoutConstraint.activate([
stackView.trailingAnchor.constraint(equalTo: trailingAnchor),
stackView.leadingAnchor.constraint(equalTo: leadingAnchor),
stackView.centerXAnchor.constraint(equalTo: centerXAnchor),
stackView.centerYAnchor.constraint(equalTo: centerYAnchor),
button.widthAnchor.constraint(equalToConstant: 160),
7 years ago
])
}
7 years ago
func retry() {
onRetry?()
}
7 years ago
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
extension EmptyView: StatefulPlaceholderView {
func placeholderViewInsets() -> UIEdgeInsets {
return insets
}
}