diff --git a/WordPress/Classes/ViewRelated/Reader/Cards/ReaderRecommendedSiteCardCell.swift b/WordPress/Classes/ViewRelated/Reader/Cards/ReaderRecommendedSiteCardCell.swift deleted file mode 100644 index 52bbd98c2202..000000000000 --- a/WordPress/Classes/ViewRelated/Reader/Cards/ReaderRecommendedSiteCardCell.swift +++ /dev/null @@ -1,95 +0,0 @@ -import UIKit - -class ReaderRecommendedSiteCardCell: UITableViewCell { - @IBOutlet weak var iconImageView: UIImageView! - @IBOutlet weak var blogNameLabel: UILabel! - @IBOutlet weak var hostNameLabel: UILabel! - @IBOutlet weak var followButton: UIButton! - @IBOutlet weak var descriptionLabel: UILabel? - @IBOutlet weak var headerStackView: UIStackView! - - weak var delegate: ReaderRecommendedSitesCardCellDelegate? - - override func awakeFromNib() { - super.awakeFromNib() - - applyStyles() - } - - func configure(_ topic: ReaderSiteTopic) { - separatorInset = UIEdgeInsets.zero - - followButton.isSelected = topic.following - blogNameLabel.text = topic.title - hostNameLabel.text = URL(string: topic.siteURL)?.host - descriptionLabel?.text = topic.siteDescription - descriptionLabel?.isHidden = topic.siteDescription.isEmpty - - configureSiteIcon(topic) - configureFollowButtonVisibility() - - applyStyles() - } - - @IBAction func didTapFollowButton(_ sender: Any) { - // Optimistically change the value - followButton.isSelected = !followButton.isSelected - - applyFollowButtonStyles() - configureFollowButtonVisibility() - - delegate?.handleFollowActionForCell(self) - } - - private func configureFollowButtonVisibility() { - let isLoggedIn = ReaderHelpers.isLoggedIn() - followButton.isHidden = !isLoggedIn - } - - private func configureSiteIcon(_ topic: ReaderSiteTopic) { - let placeholder = UIImage.siteIconPlaceholder - - guard - !topic.siteBlavatar.isEmpty, - let url = URL(string: topic.siteBlavatar) - else { - iconImageView.image = placeholder - return - } - - iconImageView.downloadImage(from: url, placeholderImage: placeholder) - } - - override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) { - configureFollowButtonVisibility() - - if traitCollection.hasDifferentColorAppearance(comparedTo: previousTraitCollection) { - applyFollowButtonStyles() - } - } - - private func applyStyles() { - backgroundColor = .secondarySystemGroupedBackground - - // Blog Name - blogNameLabel.font = WPStyleGuide.fontForTextStyle(.subheadline, fontWeight: .semibold) - blogNameLabel.textColor = .label - - // Host Label - hostNameLabel.font = WPStyleGuide.fontForTextStyle(.footnote) - hostNameLabel.textColor = .secondaryLabel - - applyFollowButtonStyles() - headerStackView.spacing = 12.0 - } - - private func applyFollowButtonStyles() { - let contentInsets = NSDirectionalEdgeInsets(top: 8.0, leading: 16.0, bottom: 8.0, trailing: 16.0) - WPStyleGuide.applyReaderFollowButtonStyle(followButton, contentInsets: contentInsets) - } - -} - -protocol ReaderRecommendedSitesCardCellDelegate: AnyObject { - func handleFollowActionForCell(_ cell: ReaderRecommendedSiteCardCell) -} diff --git a/WordPress/Classes/ViewRelated/Reader/Cards/ReaderRecommendedSiteCardCell.xib b/WordPress/Classes/ViewRelated/Reader/Cards/ReaderRecommendedSiteCardCell.xib deleted file mode 100644 index 17fa5f550dff..000000000000 --- a/WordPress/Classes/ViewRelated/Reader/Cards/ReaderRecommendedSiteCardCell.xib +++ /dev/null @@ -1,116 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/WordPress/Classes/ViewRelated/Reader/Controllers/ReaderSitesCardCell.swift b/WordPress/Classes/ViewRelated/Reader/Controllers/ReaderSitesCardCell.swift index d2803f619daa..333118170cb6 100644 --- a/WordPress/Classes/ViewRelated/Reader/Controllers/ReaderSitesCardCell.swift +++ b/WordPress/Classes/ViewRelated/Reader/Controllers/ReaderSitesCardCell.swift @@ -51,23 +51,3 @@ class ReaderSitesCardCell: ReaderTopicsTableCardCell { protocol ReaderSitesCardCellDelegate: ReaderTopicsTableCardCellDelegate { func handleFollowActionForTopic(_ topic: ReaderAbstractTopic, for cell: ReaderSitesCardCell) } - -extension ReaderSitesCardCell: ReaderRecommendedSitesCardCellDelegate { - func handleFollowActionForCell(_ cell: ReaderRecommendedSiteCardCell) { - guard - let indexPath = self.tableView.indexPath(for: cell), - let topic = data[indexPath.row] as? ReaderSiteTopic - else { - return - } - - (delegate as? ReaderSitesCardCellDelegate)?.handleFollowActionForTopic(topic, for: self) - - // Track Follow Action - var properties = [String: Any]() - properties[WPAppAnalyticsKeyFollowAction] = !topic.following - properties[WPAppAnalyticsKeyBlogID] = topic.siteID - - WPAnalytics.trackReader(.readerSuggestedSiteToggleFollow, properties: properties) - } -}