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.

48 lines
1.4 KiB

1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
  1. //
  2. import UIKit
  3. class AllRecipientTableViewCell: UITableViewCell {
  4. @IBOutlet weak var logoLabel: UILabel! {
  5. didSet {
  6. self.logoLabel.clipsToBounds = true
  7. self.logoLabel.layer.cornerRadius = self.logoLabel.frame.width/2
  8. }
  9. }
  10. @IBOutlet weak var usernameLabel: UILabel!
  11. var nameInitials: String? {
  12. guard let name = self.usernameLabel.text?.components(separatedBy: " "), name.count > 1 else {
  13. let _name = self.usernameLabel
  14. if (_name?.text?.count ?? 0) >= 2 {
  15. let first2 = String(_name?.text?.prefix(2) ?? "")
  16. return first2.uppercased()
  17. }
  18. else {
  19. return (_name?.text ?? "").uppercased()
  20. }
  21. }
  22. let first1 = String(name[0].prefix(1))
  23. let second1 = String(name[1].prefix(1))
  24. return first1.uppercased() + second1.uppercased()
  25. }
  26. override func awakeFromNib() {
  27. super.awakeFromNib()
  28. // Initialization code
  29. }
  30. override func setSelected(_ selected: Bool, animated: Bool) {
  31. super.setSelected(selected, animated: animated)
  32. // Configure the view for the selected state
  33. }
  34. func setUp(model: Recipient?) {
  35. self.usernameLabel.text = model?.fullName ?? ""
  36. self.logoLabel.text = nameInitials
  37. }
  38. }