tokenary/Tokenary iOS/Screens/Accounts/AccountTableViewCell.swift

30 lines
872 B
Swift
Raw Normal View History

2021-12-09 15:59:47 +03:00
// Copyright © 2021 Tokenary. All rights reserved.
import UIKit
import BlockiesSwift
2021-12-09 16:25:30 +03:00
protocol AccountTableViewCellDelegate: AnyObject {
func didTapMoreButton(accountCell: AccountTableViewCell)
}
2021-12-09 15:59:47 +03:00
class AccountTableViewCell: UITableViewCell {
2021-12-09 16:25:30 +03:00
private weak var cellDelegate: AccountTableViewCellDelegate?
2021-12-09 15:59:47 +03:00
@IBOutlet weak var avatarImageView: UIImageView!
@IBOutlet weak var titleLabel: UILabel!
2021-12-09 16:25:30 +03:00
func setup(address: String, delegate: AccountTableViewCellDelegate) {
cellDelegate = delegate
2021-12-09 15:59:47 +03:00
avatarImageView.image = Blockies(seed: address.lowercased()).createImage()
let without0x = address.dropFirst(2)
titleLabel.text = without0x.prefix(4) + "..." + without0x.suffix(4)
}
2021-12-09 16:25:30 +03:00
@IBAction func moreButtonTapped(_ sender: Any) {
cellDelegate?.didTapMoreButton(accountCell: self)
}
2021-12-09 15:59:47 +03:00
}