// // PublicTimelineDescriptionTableViewCell.swift // PublicTimelineDescriptionTableViewCell // // Created by Shadowfacts on 8/7/21. // Copyright © 2021 Shadowfacts. All rights reserved. // import UIKit class PublicTimelineDescriptionTableViewCell: UITableViewCell { weak var mastodonController: MastodonController! var local = false { didSet { updateLabel() } } var didDismiss: (() -> Void)? @IBOutlet private weak var descriptionLabel: UILabel! override func awakeFromNib() { super.awakeFromNib() contentView.backgroundColor = .tintColor } private func updateLabel() { let str = NSMutableAttributedString() let instanceStr = NSAttributedString(string: mastodonController.instanceURL.host!, attributes: [ .font: UIFont(descriptor: .preferredFontDescriptor(withTextStyle: .body).withSymbolicTraits(.traitBold)!, size: 0) ]) if local { str.append(NSAttributedString(string: "The local timeline shows public posts from only ")) str.append(instanceStr) str.append(NSAttributedString(string: ".")) } else { str.append(NSAttributedString(string: "The federated timeline shows public posts from all users that ")) str.append(instanceStr) str.append(NSAttributedString(string: " knows about.")) } descriptionLabel.attributedText = str } } extension PublicTimelineDescriptionTableViewCell: SelectableTableViewCell { func didSelectCell() { didDismiss?() } }