From 904cafc02d59ac822e9af74066e709b8d73447bc Mon Sep 17 00:00:00 2001 From: kean Date: Thu, 19 Oct 2023 18:04:42 -0400 Subject: [PATCH 1/7] Remove unused code --- .../Pages/PageListViewController.swift | 24 +++---------------- 1 file changed, 3 insertions(+), 21 deletions(-) diff --git a/WordPress/Classes/ViewRelated/Pages/PageListViewController.swift b/WordPress/Classes/ViewRelated/Pages/PageListViewController.swift index 91d9634a1707..59880305f650 100644 --- a/WordPress/Classes/ViewRelated/Pages/PageListViewController.swift +++ b/WordPress/Classes/ViewRelated/Pages/PageListViewController.swift @@ -7,9 +7,7 @@ import UIKit class PageListViewController: AbstractPostListViewController, UIViewControllerRestoration { private struct Constant { struct Size { - static let pageSectionHeaderHeight = CGFloat(40.0) static let pageCellEstimatedRowHeight = CGFloat(44.0) - static let pageCellWithTagEstimatedRowHeight = CGFloat(60.0) static let pageListTableViewCellLeading = CGFloat(16.0) } @@ -20,7 +18,6 @@ class PageListViewController: AbstractPostListViewController, UIViewControllerRe static let restorePageCellIdentifier = "RestorePageCellIdentifier" static let restorePageCellNibName = "RestorePageTableViewCell" static let templatePageCellIdentifier = "TemplatePageCellIdentifier" - static let currentPageListStatusFilterKey = "CurrentPageListStatusFilterKey" } struct Events { @@ -32,12 +29,6 @@ class PageListViewController: AbstractPostListViewController, UIViewControllerRe static let editorUrl = "site-editor.php?canvas=edit" } - fileprivate lazy var sectionFooterSeparatorView: UIView = { - let footer = UIView() - footer.backgroundColor = .neutral(.shade10) - return footer - }() - private lazy var _tableViewHandler: PageListTableViewHandler = { let tableViewHandler = PageListTableViewHandler(tableView: self.tableView, blog: self.blog) tableViewHandler.cacheRowHeights = false @@ -55,8 +46,8 @@ class PageListViewController: AbstractPostListViewController, UIViewControllerRe } } - lazy var homepageSettingsService = { - return HomepageSettingsService(blog: blog, coreDataStack: ContextManager.shared) + private lazy var homepageSettingsService = { + HomepageSettingsService(blog: blog, coreDataStack: ContextManager.shared) }() private lazy var createButtonCoordinator: CreateButtonCoordinator = { @@ -108,7 +99,6 @@ class PageListViewController: AbstractPostListViewController, UIViewControllerRe return controllerWithBlog(restoredBlog) } - // MARK: - UIStateRestoring override func encodeRestorableState(with coder: NSCoder) { @@ -120,7 +110,6 @@ class PageListViewController: AbstractPostListViewController, UIViewControllerRe super.encodeRestorableState(with: coder) } - // MARK: - UIViewController override func viewDidLoad() { @@ -191,6 +180,7 @@ class PageListViewController: AbstractPostListViewController, UIViewControllerRe override func configureFooterView() { super.configureFooterView() + tableView.tableFooterView = UIView(frame: .zero) } @@ -279,7 +269,6 @@ class PageListViewController: AbstractPostListViewController, UIViewControllerRe } } - // MARK: - Model Interaction /// Retrieves the page object at the specified index path. @@ -344,14 +333,8 @@ class PageListViewController: AbstractPostListViewController, UIViewControllerRe return predicate } - // MARK: - Table View Handling - func sectionNameKeyPath() -> String { - let sortField = filterSettings.currentPostListFilter().sortField - return Page.sectionIdentifier(dateKeyPath: sortField.keyPath) - } - override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { tableView.deselectRow(at: indexPath, animated: true) @@ -991,5 +974,4 @@ private extension PageListViewController { static let noConnectionTitle: String = NSLocalizedString("Unable to load pages right now.", comment: "Title for No results full page screen displayedfrom pages list when there is no connection") static let noConnectionSubtitle: String = NSLocalizedString("Check your network connection and try again. Or draft a page.", comment: "Subtitle for No results full page screen displayed from pages list when there is no connection") } - } From 0e37d08ca69a619677a6d2df595e092a762baa01 Mon Sep 17 00:00:00 2001 From: kean Date: Thu, 19 Oct 2023 19:25:51 -0400 Subject: [PATCH 2/7] Add new page cell design --- .../ViewRelated/Pages/PageListCell.swift | 132 ++++++++++++++++++ .../Pages/PageListItemViewModel.swift | 68 +++++++++ .../ViewRelated/Pages/PageListTableViewCell.m | 9 -- .../Pages/PageListViewController.swift | 10 +- .../home.imageset/Contents.json | 15 ++ .../home.imageset/block-home.pdf | Bin 0 -> 1144 bytes .../posts.imageset/Contents.json | 15 ++ .../posts.imageset/site-menu-posts.pdf | Bin 0 -> 2587 bytes WordPress/WordPress.xcodeproj/project.pbxproj | 12 ++ 9 files changed, 248 insertions(+), 13 deletions(-) create mode 100644 WordPress/Classes/ViewRelated/Pages/PageListCell.swift create mode 100644 WordPress/Classes/ViewRelated/Pages/PageListItemViewModel.swift create mode 100644 WordPress/Resources/AppImages.xcassets/home.imageset/Contents.json create mode 100644 WordPress/Resources/AppImages.xcassets/home.imageset/block-home.pdf create mode 100644 WordPress/Resources/AppImages.xcassets/posts.imageset/Contents.json create mode 100644 WordPress/Resources/AppImages.xcassets/posts.imageset/site-menu-posts.pdf diff --git a/WordPress/Classes/ViewRelated/Pages/PageListCell.swift b/WordPress/Classes/ViewRelated/Pages/PageListCell.swift new file mode 100644 index 000000000000..11ca4db8529c --- /dev/null +++ b/WordPress/Classes/ViewRelated/Pages/PageListCell.swift @@ -0,0 +1,132 @@ +import Foundation +import UIKit +import Combine + +final class PageListCell: UITableViewCell, Reusable { + + // MARK: - Views + + private let titleLabel = UILabel() + private let badgeIconView = UIImageView() + private let badgesLabel = UILabel() + private let featuredImageView = CachedAnimatedImageView() + private let ellipsisButton = UIButton(type: .custom) + private var cancellables: [AnyCancellable] = [] + + // MARK: - Properties + + private lazy var imageLoader = ImageLoader(imageView: featuredImageView, loadingIndicator: SolidColorActivityIndicator()) + + // MARK: - Initializers + + override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { + super.init(style: style, reuseIdentifier: reuseIdentifier) + setupViews() + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + // MARK: - Public + + override func prepareForReuse() { + super.prepareForReuse() + + cancellables = [] + imageLoader.prepareForReuse() + } + + func configure(with viewModel: PageListItemViewModel) { + viewModel.$title.sink { [titleLabel] in + titleLabel.attributedText = $0 + }.store(in: &cancellables) + + badgeIconView.image = viewModel.badgeIcon + badgeIconView.isHidden = viewModel.badgeIcon == nil + badgesLabel.text = viewModel.badges + + imageLoader.prepareForReuse() + featuredImageView.isHidden = viewModel.imageURL == nil + if let imageURL = viewModel.imageURL { + let host = MediaHost(with: viewModel.page) { error in + WordPressAppDelegate.crashLogging?.logError(error) + } + imageLoader.loadImage(with: imageURL, from: host, preferredSize: Constants.imageSize) + } + } + + // MARK: - Setup + + private func setupViews() { + setupLabels() + setupFeaturedImageView() + setupEllipsisButton() + + let badgesStackView = UIStackView(arrangedSubviews: [ + badgeIconView, badgesLabel, UIView() + ]) + badgesStackView.alignment = .bottom + badgesStackView.spacing = 2 + + let labelsStackView = UIStackView(arrangedSubviews: [ + titleLabel, badgesStackView + ]) + labelsStackView.spacing = 4 + labelsStackView.axis = .vertical + + let contentStackView = UIStackView(arrangedSubviews: [ + labelsStackView, featuredImageView, ellipsisButton + ]) + contentStackView.spacing = 8 + contentStackView.alignment = .center + contentStackView.isLayoutMarginsRelativeArrangement = true + contentStackView.directionalLayoutMargins = NSDirectionalEdgeInsets(top: 12, leading: 16, bottom: 12, trailing: 16) + + NSLayoutConstraint.activate([ + badgeIconView.heightAnchor.constraint(equalToConstant: 18), + badgeIconView.heightAnchor.constraint(equalTo: badgeIconView.widthAnchor, multiplier: 1) + ]) + + contentView.addSubview(contentStackView) + contentStackView.translatesAutoresizingMaskIntoConstraints = false + contentView.pinSubviewToAllEdges(contentStackView) + } + + private func setupLabels() { + titleLabel.translatesAutoresizingMaskIntoConstraints = false + titleLabel.adjustsFontForContentSizeCategory = true + titleLabel.numberOfLines = 1 + + badgeIconView.tintColor = UIColor.secondaryLabel + + badgesLabel.font = WPStyleGuide.fontForTextStyle(.footnote) + badgesLabel.textColor = UIColor.secondaryLabel + } + + private func setupFeaturedImageView() { + featuredImageView.translatesAutoresizingMaskIntoConstraints = false + featuredImageView.contentMode = .scaleAspectFill + featuredImageView.layer.masksToBounds = true + featuredImageView.layer.cornerRadius = 5 + + NSLayoutConstraint.activate([ + featuredImageView.widthAnchor.constraint(equalToConstant: Constants.imageSize.width), + featuredImageView.heightAnchor.constraint(equalToConstant: Constants.imageSize.height), + ]) + } + + private func setupEllipsisButton() { + ellipsisButton.translatesAutoresizingMaskIntoConstraints = false + ellipsisButton.setImage(UIImage(named: "more-horizontal-mobile"), for: .normal) + ellipsisButton.tintColor = .listIcon + + NSLayoutConstraint.activate([ + ellipsisButton.widthAnchor.constraint(equalToConstant: 24) + ]) + } +} + +private enum Constants { + static let imageSize = CGSize(width: 44, height: 44) +} diff --git a/WordPress/Classes/ViewRelated/Pages/PageListItemViewModel.swift b/WordPress/Classes/ViewRelated/Pages/PageListItemViewModel.swift new file mode 100644 index 000000000000..18d8e180356d --- /dev/null +++ b/WordPress/Classes/ViewRelated/Pages/PageListItemViewModel.swift @@ -0,0 +1,68 @@ +import Foundation + +final class PageListItemViewModel { + let page: Page + @Published var title: NSAttributedString + let badgeIcon: UIImage? + let badges: String + let imageURL: URL? + let accessibilityIdentifier: String? + + init(page: Page) { + self.page = page + self.title = makeContentAttributedString(for: page) + self.badgeIcon = makeBadgeIcon(for: page) + self.badges = makeBadgesString(for: page) + self.imageURL = page.featuredImageURL + self.accessibilityIdentifier = page.slugForDisplay() + } +} + +private func makeContentAttributedString(for page: Page) -> NSAttributedString { + let page = page.hasRevision() ? page.revision : page + let title = page?.titleForDisplay() ?? "" + return NSAttributedString(string: title, attributes: [ + .font: WPStyleGuide.fontForTextStyle(.callout, fontWeight: .semibold), + .foregroundColor: UIColor.text + ]) +} + +private func makeBadgeIcon(for page: Page) -> UIImage? { + if page.isSiteHomepage { + return UIImage(named: "home") + } + if page.isSitePostsPage { + return UIImage(named: "posts") + } + return nil +} + +private func makeBadgesString(for page: Page) -> String { + var badges: [String] = [] + if page.isSiteHomepage { + badges.append(Strings.badgeHomepage) + } else if page.isSitePostsPage { + badges.append(Strings.badgePosts) + } + if let displayDate = page.displayDate() { + badges.append(displayDate.capitalized) + } + if page.hasPrivateState { + badges.append(Strings.badgePrivatePage) + } + if page.hasPendingReviewState { + badges.append(Strings.badgePendingReview) + } + if page.hasLocalChanges() { + badges.append(Strings.badgeLocalChanges) + } + return badges.joined(separator: " · ") +} + +private enum Strings { + static let badgeHomepage = NSLocalizedString("pageList.badgeHomepage", value: "Homepage", comment: "Badge for page cells") + static let badgePosts = NSLocalizedString("pageList.badgePosts", value: "Posts page", comment: "Badge for page cells") + static let badgePrivatePage = NSLocalizedString("pageList.badgePrivate", value: "Private", comment: "Badge for page cells") + static let badgePendingReview = NSLocalizedString("pageList.badgePendingReview", value: "Pending review", comment: "Badge for page cells") + static let badgeLocalChanges = NSLocalizedString("pageList.badgeLocalChanges", value: "Local changes", comment: "Badge for page cells") +} diff --git a/WordPress/Classes/ViewRelated/Pages/PageListTableViewCell.m b/WordPress/Classes/ViewRelated/Pages/PageListTableViewCell.m index 3497f942ba5a..1d4b4cff659a 100644 --- a/WordPress/Classes/ViewRelated/Pages/PageListTableViewCell.m +++ b/WordPress/Classes/ViewRelated/Pages/PageListTableViewCell.m @@ -47,15 +47,6 @@ - (void)prepareForReuse [self setNeedsDisplay]; } -- (ImageLoader *)featuredImageLoader -{ - if (_featuredImageLoader == nil) { - _featuredImageLoader = [[ImageLoader alloc] initWithImageView:self.featuredImageView - gifStrategy:GIFStrategyLargeGIFs]; - } - return _featuredImageLoader; -} - - (NSDateFormatter *)dateFormatter { if (_dateFormatter == nil) { diff --git a/WordPress/Classes/ViewRelated/Pages/PageListViewController.swift b/WordPress/Classes/ViewRelated/Pages/PageListViewController.swift index 59880305f650..5c21e7b6cfa3 100644 --- a/WordPress/Classes/ViewRelated/Pages/PageListViewController.swift +++ b/WordPress/Classes/ViewRelated/Pages/PageListViewController.swift @@ -14,7 +14,6 @@ class PageListViewController: AbstractPostListViewController, UIViewControllerRe struct Identifiers { static let pagesViewControllerRestorationKey = "PagesViewControllerRestorationKey" static let pageCellIdentifier = "PageCellIdentifier" - static let pageCellNibName = "PageListTableViewCell" static let restorePageCellIdentifier = "RestorePageCellIdentifier" static let restorePageCellNibName = "RestorePageTableViewCell" static let templatePageCellIdentifier = "TemplatePageCellIdentifier" @@ -169,8 +168,7 @@ class PageListViewController: AbstractPostListViewController, UIViewControllerRe let bundle = Bundle.main // Register the cells - let pageCellNib = UINib(nibName: Constant.Identifiers.pageCellNibName, bundle: bundle) - tableView.register(pageCellNib, forCellReuseIdentifier: Constant.Identifiers.pageCellIdentifier) + tableView.register(PageListCell.self, forCellReuseIdentifier: Constant.Identifiers.pageCellIdentifier) let restorePageCellNib = UINib(nibName: Constant.Identifiers.restorePageCellNibName, bundle: bundle) tableView.register(restorePageCellNib, forCellReuseIdentifier: Constant.Identifiers.restorePageCellIdentifier) @@ -372,12 +370,15 @@ class PageListViewController: AbstractPostListViewController, UIViewControllerRe let cell = tableView.dequeueReusableCell(withIdentifier: identifier, for: indexPath) configureCell(cell, at: indexPath) + if let cell = cell as? PageListCell { + cell.configure(with: PageListItemViewModel(page: page)) + } return cell } override func configureCell(_ cell: UITableViewCell, at indexPath: IndexPath) { guard let cell = cell as? BasePageListCell else { - preconditionFailure("The cell should be of class \(String(describing: BasePageListCell.self))") + return } cell.accessoryType = .none @@ -385,6 +386,7 @@ class PageListViewController: AbstractPostListViewController, UIViewControllerRe let page = pageAtIndexPath(indexPath) let filterType = filterSettings.currentPostListFilter().filterType + // TODO: Implement indenting for child pages (#21818) if cell.reuseIdentifier == Constant.Identifiers.pageCellIdentifier { cell.indentationWidth = Constant.Size.pageListTableViewCellLeading cell.indentationLevel = filterType != .published ? 0 : page.hierarchyIndex diff --git a/WordPress/Resources/AppImages.xcassets/home.imageset/Contents.json b/WordPress/Resources/AppImages.xcassets/home.imageset/Contents.json new file mode 100644 index 000000000000..346fd4f0038b --- /dev/null +++ b/WordPress/Resources/AppImages.xcassets/home.imageset/Contents.json @@ -0,0 +1,15 @@ +{ + "images" : [ + { + "filename" : "block-home.pdf", + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + }, + "properties" : { + "template-rendering-intent" : "template" + } +} diff --git a/WordPress/Resources/AppImages.xcassets/home.imageset/block-home.pdf b/WordPress/Resources/AppImages.xcassets/home.imageset/block-home.pdf new file mode 100644 index 0000000000000000000000000000000000000000..ebbcad2cdae7ee84d3f2f2408b2f298624300f8d GIT binary patch literal 1144 zcmZvcO>dkq5QgvbE9SCNQYnBjA3=&DHM>n!wNBZzd;1ixG-|T1xLJ>xIGT)BSe7^d6wjq`G3&Y8U&Z&;0Pjfl^C`j z6mcMAUPys0T)LBUPD?!}wf;$l9JKIiAKvGng@Y$l1nKE6NND0>h9q=`A`nHE#K}Tv z5=fcI)I!b@-pLud;+|06^jPl3rGl*aRp@0O;NcBu_zKo0lLwq(tT#?ZN~4r*lrSZG zg>SVsLy!00$!@g5Z-0L&47b%@P2jWIHPwxI!u#1YtS)AY%#o{9s@^;m2l2QqfLOqU*CZkCZE3=ri(VH~H3C9GEOzTEx; DWz_k8 literal 0 HcmV?d00001 diff --git a/WordPress/Resources/AppImages.xcassets/posts.imageset/Contents.json b/WordPress/Resources/AppImages.xcassets/posts.imageset/Contents.json new file mode 100644 index 000000000000..7ac3a4229e83 --- /dev/null +++ b/WordPress/Resources/AppImages.xcassets/posts.imageset/Contents.json @@ -0,0 +1,15 @@ +{ + "images" : [ + { + "filename" : "site-menu-posts.pdf", + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + }, + "properties" : { + "template-rendering-intent" : "template" + } +} diff --git a/WordPress/Resources/AppImages.xcassets/posts.imageset/site-menu-posts.pdf b/WordPress/Resources/AppImages.xcassets/posts.imageset/site-menu-posts.pdf new file mode 100644 index 0000000000000000000000000000000000000000..d702263b23ed78cf9d42351abb9919755b0355fc GIT binary patch literal 2587 zcmd^AOHbQC5WerP*b5RIu)U7gu_Y7<5{Rl6L6aVkP!GmgLa1Y>wo^fWeP_H+m?EfB1T)J{6ySM>jtu(Fq(uMsq?m3r z!uykARKrmByfa~L&R+2K)~m=5O# z#ST|npu6Vp7{x`gu($E$OFLh-Su48pOV<4@ue0V`C&@*Euf1#EZil|)&nb?V+AsaH z!J7|@<-FKEW$#n#AN8ARZ4Bhv98cxZ5u;r z#RcEeR6$Oi5Rw^SM}6F^AXJJOEU1onTJ6D>4dQPAahMp4fv4sQ!^HQYFtl84ooxzH6D;qC85H-pskY*T9&c7Bvc&$Ps-V7DzV3VZ%gs-LwSeL_ SZC1Bkb;2--$ literal 0 HcmV?d00001 diff --git a/WordPress/WordPress.xcodeproj/project.pbxproj b/WordPress/WordPress.xcodeproj/project.pbxproj index 248080cc2312..c7b5e409a7b5 100644 --- a/WordPress/WordPress.xcodeproj/project.pbxproj +++ b/WordPress/WordPress.xcodeproj/project.pbxproj @@ -423,6 +423,10 @@ 0C6C4CD42A4F0AD90049E762 /* blaze-search-page-1.json in Resources */ = {isa = PBXBuildFile; fileRef = 0C6C4CD32A4F0AD80049E762 /* blaze-search-page-1.json */; }; 0C6C4CD62A4F0AEE0049E762 /* blaze-search-page-2.json in Resources */ = {isa = PBXBuildFile; fileRef = 0C6C4CD52A4F0AEE0049E762 /* blaze-search-page-2.json */; }; 0C6C4CD82A4F0F2C0049E762 /* Bundle+TestExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0C6C4CD72A4F0F2C0049E762 /* Bundle+TestExtensions.swift */; }; + 0C700B862AE1E1300085C2EE /* PageListCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0C700B852AE1E1300085C2EE /* PageListCell.swift */; }; + 0C700B872AE1E1300085C2EE /* PageListCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0C700B852AE1E1300085C2EE /* PageListCell.swift */; }; + 0C700B892AE1E1940085C2EE /* PageListItemViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0C700B882AE1E1940085C2EE /* PageListItemViewModel.swift */; }; + 0C700B8A2AE1E1940085C2EE /* PageListItemViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0C700B882AE1E1940085C2EE /* PageListItemViewModel.swift */; }; 0C7073952A65CB2E00F325CE /* MemoryCache.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0C7073942A65CB2E00F325CE /* MemoryCache.swift */; }; 0C7073962A65CB2E00F325CE /* MemoryCache.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0C7073942A65CB2E00F325CE /* MemoryCache.swift */; }; 0C71959B2A3CA582002EA18C /* SiteSettingsRelatedPostsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0C71959A2A3CA582002EA18C /* SiteSettingsRelatedPostsView.swift */; }; @@ -6135,6 +6139,8 @@ 0C6C4CD32A4F0AD80049E762 /* blaze-search-page-1.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = "blaze-search-page-1.json"; sourceTree = ""; }; 0C6C4CD52A4F0AEE0049E762 /* blaze-search-page-2.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = "blaze-search-page-2.json"; sourceTree = ""; }; 0C6C4CD72A4F0F2C0049E762 /* Bundle+TestExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Bundle+TestExtensions.swift"; sourceTree = ""; }; + 0C700B852AE1E1300085C2EE /* PageListCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PageListCell.swift; sourceTree = ""; }; + 0C700B882AE1E1940085C2EE /* PageListItemViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PageListItemViewModel.swift; sourceTree = ""; }; 0C7073942A65CB2E00F325CE /* MemoryCache.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MemoryCache.swift; sourceTree = ""; }; 0C71959A2A3CA582002EA18C /* SiteSettingsRelatedPostsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SiteSettingsRelatedPostsView.swift; sourceTree = ""; }; 0C748B4A2A9D71A000809E1A /* SiteMediaCollectionViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SiteMediaCollectionViewController.swift; sourceTree = ""; }; @@ -12606,6 +12612,8 @@ 5DFA7EBE1AF7CB3A0072023B /* Views */ = { isa = PBXGroup; children = ( + 0C700B852AE1E1300085C2EE /* PageListCell.swift */, + 0C700B882AE1E1940085C2EE /* PageListItemViewModel.swift */, 59A3CADB1CD2FF0C009BFA1B /* BasePageListCell.h */, 59A3CADC1CD2FF0C009BFA1B /* BasePageListCell.m */, 8B93856D22DC08060010BF02 /* PageListSectionHeaderView.swift */, @@ -21074,6 +21082,7 @@ 7E4123BE20F4097B00DF8486 /* NotificationContentRangeFactory.swift in Sources */, FA332AD429C1FC7A00182FBB /* MovedToJetpackViewModel.swift in Sources */, FA3FBF8B2A2772340012FC90 /* DashboardActivityLogViewModel.swift in Sources */, + 0C700B892AE1E1940085C2EE /* PageListItemViewModel.swift in Sources */, E6D170371EF9D8D10046D433 /* SiteInfo.swift in Sources */, E16A76F31FC4766900A661E3 /* CredentialsService.swift in Sources */, F9B862C92478170A008B093C /* EncryptedLogTableViewController.swift in Sources */, @@ -22462,6 +22471,7 @@ 0CA1C8C12A940EE300F691EE /* AvatarMenuController.swift in Sources */, 931215E8267F52A6008C3B69 /* ReferrerDetailsHeaderRow.swift in Sources */, F17A2A1E23BFBD72001E96AC /* UIView+ExistingConstraints.swift in Sources */, + 0C700B862AE1E1300085C2EE /* PageListCell.swift in Sources */, F1450CF32437DA3E00A28BFE /* MediaRequestAuthenticator.swift in Sources */, 0C391E5E2A2FE5350040EA91 /* DashboardBlazeCampaignView.swift in Sources */, 9881296E219CF1310075FF33 /* StatsCellHeader.swift in Sources */, @@ -24633,6 +24643,7 @@ 3FFDEF7829177D7500B625CE /* MigrationNotificationsViewModel.swift in Sources */, FABB23372602FC2C00C8785C /* WebNavigationDelegate.swift in Sources */, FAFC065227D27241002F0483 /* BlogDetailsViewController+Dashboard.swift in Sources */, + 0C700B8A2AE1E1940085C2EE /* PageListItemViewModel.swift in Sources */, 8B55FAAD2614FC87007D618E /* Text+BoldSubString.swift in Sources */, FABB23382602FC2C00C8785C /* WordPress-22-23.xcmappingmodel in Sources */, FED65D79293511E4008071BF /* SharedDataIssueSolver.swift in Sources */, @@ -25156,6 +25167,7 @@ F4D9188729D78C9100974A71 /* BlogDetailsViewController+Strings.swift in Sources */, FABB24B82602FC2C00C8785C /* DynamicHeightCollectionView.swift in Sources */, FABB24B92602FC2C00C8785C /* RegisterDomainDetailsViewModel+RowList.swift in Sources */, + 0C700B872AE1E1300085C2EE /* PageListCell.swift in Sources */, FEDA8D9D2A5AA7050081314F /* PrepublishingViewController+JetpackSocial.swift in Sources */, FABB24BA2602FC2C00C8785C /* TenorGIF.swift in Sources */, FABB24BB2602FC2C00C8785C /* ThemeBrowserViewController.swift in Sources */, From b800ee38005887521df51a977aeaec674c525f5b Mon Sep 17 00:00:00 2001 From: kean Date: Fri, 20 Oct 2023 09:29:39 -0400 Subject: [PATCH 3/7] Remove PageListTableViewCell --- .../System/WordPress-Bridging-Header.h | 1 - .../ViewRelated/Pages/PageListTableViewCell.h | 6 - .../ViewRelated/Pages/PageListTableViewCell.m | 206 ------------------ .../Pages/PageListTableViewCell.xib | 138 ------------ WordPress/WordPress.xcodeproj/project.pbxproj | 14 -- 5 files changed, 365 deletions(-) delete mode 100644 WordPress/Classes/ViewRelated/Pages/PageListTableViewCell.h delete mode 100644 WordPress/Classes/ViewRelated/Pages/PageListTableViewCell.m delete mode 100644 WordPress/Classes/ViewRelated/Pages/PageListTableViewCell.xib diff --git a/WordPress/Classes/System/WordPress-Bridging-Header.h b/WordPress/Classes/System/WordPress-Bridging-Header.h index 1a69dbe6bdff..b88bb353230f 100644 --- a/WordPress/Classes/System/WordPress-Bridging-Header.h +++ b/WordPress/Classes/System/WordPress-Bridging-Header.h @@ -38,7 +38,6 @@ #import "NSObject+Helpers.h" -#import "PageListTableViewCell.h" #import "PageSettingsViewController.h" #import "PostContentProvider.h" #import "PostCategory.h" diff --git a/WordPress/Classes/ViewRelated/Pages/PageListTableViewCell.h b/WordPress/Classes/ViewRelated/Pages/PageListTableViewCell.h deleted file mode 100644 index 964094bb5561..000000000000 --- a/WordPress/Classes/ViewRelated/Pages/PageListTableViewCell.h +++ /dev/null @@ -1,6 +0,0 @@ -#import -#import "BasePageListCell.h" - -@interface PageListTableViewCell : BasePageListCell - -@end diff --git a/WordPress/Classes/ViewRelated/Pages/PageListTableViewCell.m b/WordPress/Classes/ViewRelated/Pages/PageListTableViewCell.m deleted file mode 100644 index 1d4b4cff659a..000000000000 --- a/WordPress/Classes/ViewRelated/Pages/PageListTableViewCell.m +++ /dev/null @@ -1,206 +0,0 @@ -#import "PageListTableViewCell.h" -#import "WPStyleGuide+Pages.h" -#import "WordPress-Swift.h" - -@import Gridicons; - - -static CGFloat const PageListTableViewCellTagLabelRadius = 2.0; -static CGFloat const FeaturedImageSize = 120.0; - -@interface PageListTableViewCell() - -@property (nonatomic, strong) IBOutlet UILabel *titleLabel; -@property (nonatomic, strong) IBOutlet UILabel *timestampLabel; -@property (nonatomic, strong) IBOutlet UILabel *badgesLabel; -@property (nonatomic, strong) IBOutlet UILabel *typeLabel; -@property (nonatomic, strong) IBOutlet UIImageView *typeIcon; -@property (strong, nonatomic) IBOutlet CachedAnimatedImageView *featuredImageView; -@property (nonatomic, strong) IBOutlet UIButton *menuButton; -@property (nonatomic, strong) IBOutlet NSLayoutConstraint *labelsContainerTrailing; -@property (nonatomic, strong) IBOutlet NSLayoutConstraint *leadingContentConstraint; - -@property (nonatomic, strong) ImageLoader *featuredImageLoader; -@property (nonatomic, strong) NSDateFormatter *dateFormatter; - -@end - -@implementation PageListTableViewCell { - CGFloat _indentationWidth; - NSInteger _indentationLevel; -} - -- (void)awakeFromNib -{ - [super awakeFromNib]; - self.contentView.autoresizingMask = UIViewAutoresizingFlexibleHeight; - [self applyStyles]; - [self setupAccessibility]; -} - -- (void)prepareForReuse -{ - [super prepareForReuse]; - - [self applyStyles]; - [self.featuredImageLoader prepareForReuse]; - [self setNeedsDisplay]; -} - -- (NSDateFormatter *)dateFormatter -{ - if (_dateFormatter == nil) { - _dateFormatter = [NSDateFormatter new]; - _dateFormatter.doesRelativeDateFormatting = YES; - _dateFormatter.dateStyle = NSDateFormatterNoStyle; - _dateFormatter.timeStyle = NSDateFormatterShortStyle; - } - return _dateFormatter; -} - -- (CGFloat)indentationWidth -{ - return _indentationWidth; -} - -- (NSInteger)indentationLevel -{ - return _indentationLevel; -} - -- (void)setIndentationWidth:(CGFloat)indentationWidth -{ - _indentationWidth = indentationWidth; - [self updateLeadingContentConstraint]; -} - -- (void)setIndentationLevel:(NSInteger)indentationLevel -{ - _indentationLevel = indentationLevel; - [self updateLeadingContentConstraint]; -} - - -#pragma mark - Accessors - -- (void)setPost:(AbstractPost *)post -{ - [super setPost:post]; - [self configureTitle]; - [self configureForStatus]; - [self configureBadges]; - [self configureFeaturedImage]; - self.accessibilityIdentifier = post.slugForDisplay; -} - -#pragma mark - Configuration - -- (void)applyStyles -{ - [WPStyleGuide configureTableViewCell:self]; - [WPStyleGuide configureLabel:self.timestampLabel textStyle:UIFontTextStyleSubheadline]; - [WPStyleGuide configureLabel:self.badgesLabel textStyle:UIFontTextStyleSubheadline]; - [WPStyleGuide configureLabel:self.typeLabel textStyle:UIFontTextStyleSubheadline]; - - self.titleLabel.font = [WPStyleGuide notoBoldFontForTextStyle:UIFontTextStyleHeadline]; - self.titleLabel.adjustsFontForContentSizeCategory = YES; - - self.titleLabel.textColor = [UIColor murielText]; - self.badgesLabel.textColor = [UIColor murielTextSubtle]; - self.typeLabel.textColor = [UIColor murielTextSubtle]; - self.menuButton.tintColor = [UIColor murielTextSubtle]; - [self.menuButton setImage:[UIImage gridiconOfType:GridiconTypeEllipsis] forState:UIControlStateNormal]; - - self.typeIcon.tintColor = [UIColor murielTextSubtle]; - - self.backgroundColor = [UIColor murielNeutral5]; - self.contentView.backgroundColor = [UIColor murielNeutral5]; - - self.featuredImageView.layer.cornerRadius = PageListTableViewCellTagLabelRadius; -} - -- (void)configureTitle -{ - AbstractPost *post = [self.post hasRevision] ? [self.post revision] : self.post; - self.titleLabel.text = [post titleForDisplay] ?: [NSString string]; -} - -- (void)configureForStatus -{ - if (self.post.isFailed && !self.post.hasLocalChanges) { - self.titleLabel.textColor = [UIColor murielError]; - self.menuButton.tintColor = [UIColor murielError]; - } -} - -- (void)updateLeadingContentConstraint -{ - self.leadingContentConstraint.constant = (CGFloat)_indentationLevel * _indentationWidth; -} - -- (void)configureBadges -{ - Page *page = (Page *)self.post; - - NSMutableArray *badges = [NSMutableArray new]; - - [self.typeLabel setText:@""]; - [self.typeIcon setImage:nil]; - - if (self.post.dateCreated != nil) { - NSString *timestamp = [self.post isScheduled] ? [self.dateFormatter stringFromDate:self.post.dateCreated] : [self.post.dateCreated mediumString]; - [badges addObject:timestamp]; - } - - if (page.isSiteHomepage) { - [badges addObject:@""]; - [self.typeLabel setText:NSLocalizedString(@"Homepage", @"Title of the Homepage Badge")]; - [self.typeIcon setImage:[UIImage gridiconOfType:GridiconTypeHouse]]; - } - - if (page.isSitePostsPage) { - [badges addObject:@""]; - [self.typeLabel setText:NSLocalizedString(@"Posts page", @"Title of the Posts Page Badge")]; - [self.typeIcon setImage:[UIImage gridiconOfType:GridiconTypePosts]]; - } - - if (page.hasPrivateState) { - [badges addObject:NSLocalizedString(@"Private", @"Title of the Private Badge")]; - } else if (page.hasPendingReviewState) { - [badges addObject:NSLocalizedString(@"Pending review", @"Title of the Pending Review Badge")]; - } - - if (page.hasLocalChanges) { - [badges addObject:NSLocalizedString(@"Local changes", @"Title of the Local Changes Badge")]; - } - - self.badgesLabel.text = [badges componentsJoinedByString:@" · "]; -} - -- (void)configureFeaturedImage -{ - Page *page = (Page *)self.post; - - BOOL hideFeaturedImage = page.featuredImage == nil; - self.featuredImageView.hidden = hideFeaturedImage; - self.labelsContainerTrailing.active = !hideFeaturedImage; - BOOL isBlogAtomic = [page.featuredImage.blog isAtomic]; - - if (!hideFeaturedImage) { - [self.featuredImageLoader loadImageFromMedia:page.featuredImage - preferredSize:CGSizeMake(FeaturedImageSize, FeaturedImageSize) - placeholder:nil - isBlogAtomic:isBlogAtomic - success:nil - error:^(NSError *error) { - DDLogError(@"Failed to load the media: %@", error); - }]; - - } -} - -- (void)setupAccessibility { - self.menuButton.accessibilityLabel = NSLocalizedString(@"More", @"Accessibility label for the More button in Page List."); -} - -@end diff --git a/WordPress/Classes/ViewRelated/Pages/PageListTableViewCell.xib b/WordPress/Classes/ViewRelated/Pages/PageListTableViewCell.xib deleted file mode 100644 index e42c25955b09..000000000000 --- a/WordPress/Classes/ViewRelated/Pages/PageListTableViewCell.xib +++ /dev/null @@ -1,138 +0,0 @@ - - - - - - - - - - - NotoSerif-Bold - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/WordPress/WordPress.xcodeproj/project.pbxproj b/WordPress/WordPress.xcodeproj/project.pbxproj index c7b5e409a7b5..4f66287392b0 100644 --- a/WordPress/WordPress.xcodeproj/project.pbxproj +++ b/WordPress/WordPress.xcodeproj/project.pbxproj @@ -1409,8 +1409,6 @@ 5DF7F7781B223916003A05C8 /* PostToPost30To31.m in Sources */ = {isa = PBXBuildFile; fileRef = 5DF7F7771B223916003A05C8 /* PostToPost30To31.m */; }; 5DF8D26119E82B1000A2CD95 /* ReaderCommentsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 5DF8D26019E82B1000A2CD95 /* ReaderCommentsViewController.m */; }; 5DFA7EC31AF7CB910072023B /* Pages.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 5DFA7EC21AF7CB910072023B /* Pages.storyboard */; }; - 5DFA7EC71AF814E40072023B /* PageListTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 5DFA7EC51AF814E40072023B /* PageListTableViewCell.m */; }; - 5DFA7EC81AF814E40072023B /* PageListTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 5DFA7EC61AF814E40072023B /* PageListTableViewCell.xib */; }; 6E5BA46926A59D620043A6F2 /* SupportScreenTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E5BA46826A59D620043A6F2 /* SupportScreenTests.swift */; }; 730354BA21C867E500CD18C2 /* SiteCreatorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 730354B921C867E500CD18C2 /* SiteCreatorTests.swift */; }; 7305138321C031FC006BD0A1 /* AssembledSiteView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7305138221C031FC006BD0A1 /* AssembledSiteView.swift */; }; @@ -4030,7 +4028,6 @@ FABB20112602FC2C00C8785C /* SpaceMono-Bold.ttf in Resources */ = {isa = PBXBuildFile; fileRef = F5A34D0825DF2F7700C9654B /* SpaceMono-Bold.ttf */; }; FABB20142602FC2C00C8785C /* CommentsList.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 9835F16D25E492EE002EFF23 /* CommentsList.storyboard */; }; FABB20162602FC2C00C8785C /* TabbedTotalsCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 98563DDC21BF30C40006F5E9 /* TabbedTotalsCell.xib */; }; - FABB20172602FC2C00C8785C /* PageListTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 5DFA7EC61AF814E40072023B /* PageListTableViewCell.xib */; }; FABB20182602FC2C00C8785C /* NoteBlockImageTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = B5C66B771ACF073900F68370 /* NoteBlockImageTableViewCell.xib */; }; FABB201B2602FC2C00C8785C /* SignupEpilogue.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B59F34A0207678480069992D /* SignupEpilogue.storyboard */; }; FABB201D2602FC2C00C8785C /* PostStatsTitleCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 98FCFC222231DF43006ECDD4 /* PostStatsTitleCell.xib */; }; @@ -4382,7 +4379,6 @@ FABB21D02602FC2C00C8785C /* SiteStatsPeriodTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 984B138D21F65F860004B6A2 /* SiteStatsPeriodTableViewController.swift */; }; FABB21D12602FC2C00C8785C /* TextBundleWrapper.m in Sources */ = {isa = PBXBuildFile; fileRef = 43EE90EE223B1028006A33E9 /* TextBundleWrapper.m */; }; FABB21D22602FC2C00C8785C /* WPCategoryTree.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2F605FA925145F7200F99544 /* WPCategoryTree.swift */; }; - FABB21D32602FC2C00C8785C /* PageListTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 5DFA7EC51AF814E40072023B /* PageListTableViewCell.m */; }; FABB21D42602FC2C00C8785C /* PageSettingsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 5D62BAD618AA88210044E5F7 /* PageSettingsViewController.m */; }; FABB21D52602FC2C00C8785C /* SiteDesignContentCollectionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 46241C3A2540D483002B8A12 /* SiteDesignContentCollectionViewController.swift */; }; FABB21D62602FC2C00C8785C /* PlanComparisonViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17D2FDC11C6A468A00944265 /* PlanComparisonViewController.swift */; }; @@ -7072,9 +7068,6 @@ 5DF8D25F19E82B1000A2CD95 /* ReaderCommentsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ReaderCommentsViewController.h; sourceTree = ""; }; 5DF8D26019E82B1000A2CD95 /* ReaderCommentsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = ReaderCommentsViewController.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; 5DFA7EC21AF7CB910072023B /* Pages.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Pages.storyboard; sourceTree = ""; }; - 5DFA7EC41AF814E40072023B /* PageListTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PageListTableViewCell.h; sourceTree = ""; }; - 5DFA7EC51AF814E40072023B /* PageListTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PageListTableViewCell.m; sourceTree = ""; }; - 5DFA7EC61AF814E40072023B /* PageListTableViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = PageListTableViewCell.xib; sourceTree = ""; }; 5E48AA7F709A5B0F2318A7E3 /* Pods-JetpackDraftActionExtension.release-internal.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-JetpackDraftActionExtension.release-internal.xcconfig"; path = "../Pods/Target Support Files/Pods-JetpackDraftActionExtension/Pods-JetpackDraftActionExtension.release-internal.xcconfig"; sourceTree = ""; }; 67832AB9D81652460A80BE66 /* Pods-Apps-Jetpack.release-internal.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Apps-Jetpack.release-internal.xcconfig"; path = "../Pods/Target Support Files/Pods-Apps-Jetpack/Pods-Apps-Jetpack.release-internal.xcconfig"; sourceTree = ""; }; 6C1B070FAD875CA331772B57 /* Pods-JetpackStatsWidgets.release-alpha.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-JetpackStatsWidgets.release-alpha.xcconfig"; path = "../Pods/Target Support Files/Pods-JetpackStatsWidgets/Pods-JetpackStatsWidgets.release-alpha.xcconfig"; sourceTree = ""; }; @@ -12618,9 +12611,6 @@ 59A3CADC1CD2FF0C009BFA1B /* BasePageListCell.m */, 8B93856D22DC08060010BF02 /* PageListSectionHeaderView.swift */, 5D13FA561AF99C2100F06492 /* PageListSectionHeaderView.xib */, - 5DFA7EC41AF814E40072023B /* PageListTableViewCell.h */, - 5DFA7EC51AF814E40072023B /* PageListTableViewCell.m */, - 5DFA7EC61AF814E40072023B /* PageListTableViewCell.xib */, 5D18FE9C1AFBB17400EFEED0 /* RestorePageTableViewCell.h */, 5D18FE9D1AFBB17400EFEED0 /* RestorePageTableViewCell.m */, 5D18FE9E1AFBB17400EFEED0 /* RestorePageTableViewCell.xib */, @@ -19216,7 +19206,6 @@ 1761F17A26209AEE000815EF /* wordpress-dark-icon-app-60x60@3x.png in Resources */, 80535DBC294ABBF000873161 /* JetpackAllFeaturesLogosAnimation_ltr.json in Resources */, 98563DDE21BF30C40006F5E9 /* TabbedTotalsCell.xib in Resources */, - 5DFA7EC81AF814E40072023B /* PageListTableViewCell.xib in Resources */, B5C66B781ACF073900F68370 /* NoteBlockImageTableViewCell.xib in Resources */, FEA088032696E81F00193358 /* ListTableHeaderView.xib in Resources */, B59F34A1207678480069992D /* SignupEpilogue.storyboard in Resources */, @@ -19750,7 +19739,6 @@ F46597B328E6605E00D5F49A /* neu-green-icon-app-60@2x.png in Resources */, F46597E728E6698D00D5F49A /* spectrum-on-black-icon-app-76@2x.png in Resources */, FABB20162602FC2C00C8785C /* TabbedTotalsCell.xib in Resources */, - FABB20172602FC2C00C8785C /* PageListTableViewCell.xib in Resources */, 8BE6F92E27EE27E10008BDC7 /* BlogDashboardPostCardGhostCell.xib in Resources */, FABB20182602FC2C00C8785C /* NoteBlockImageTableViewCell.xib in Resources */, FABB201B2602FC2C00C8785C /* SignupEpilogue.storyboard in Resources */, @@ -21321,7 +21309,6 @@ 984B138E21F65F870004B6A2 /* SiteStatsPeriodTableViewController.swift in Sources */, 433ADC1D223B2A7F00ED9DE1 /* TextBundleWrapper.m in Sources */, 2F605FAA25145F7200F99544 /* WPCategoryTree.swift in Sources */, - 5DFA7EC71AF814E40072023B /* PageListTableViewCell.m in Sources */, 5D62BAD718AA88210044E5F7 /* PageSettingsViewController.m in Sources */, 46241C3C2540D483002B8A12 /* SiteDesignContentCollectionViewController.swift in Sources */, 17D2FDC21C6A468A00944265 /* PlanComparisonViewController.swift in Sources */, @@ -24144,7 +24131,6 @@ FABB21D12602FC2C00C8785C /* TextBundleWrapper.m in Sources */, FABB21D22602FC2C00C8785C /* WPCategoryTree.swift in Sources */, 019D69A12A5EBF47003B676D /* WordPressAuthenticatorProtocol.swift in Sources */, - FABB21D32602FC2C00C8785C /* PageListTableViewCell.m in Sources */, FABB21D42602FC2C00C8785C /* PageSettingsViewController.m in Sources */, FA73D7E62798765B00DF24B3 /* SitePickerViewController.swift in Sources */, FABB21D52602FC2C00C8785C /* SiteDesignContentCollectionViewController.swift in Sources */, From e07fef1387fcf759eca941b25f508231c219697b Mon Sep 17 00:00:00 2001 From: kean Date: Fri, 20 Oct 2023 09:47:29 -0400 Subject: [PATCH 4/7] Remove the Undo button --- .../ViewRelated/Pages/BasePageListCell.h | 36 ----------------- .../ViewRelated/Pages/BasePageListCell.m | 22 ----------- .../Pages/PageListViewController.swift | 39 ++++--------------- .../Pages/RestorePageTableViewCell.h | 3 +- .../Pages/RestorePageTableViewCell.m | 11 +----- .../Pages/RestorePageTableViewCell.xib | 28 ++----------- WordPress/WordPress.xcodeproj/project.pbxproj | 8 ---- 7 files changed, 14 insertions(+), 133 deletions(-) delete mode 100644 WordPress/Classes/ViewRelated/Pages/BasePageListCell.h delete mode 100644 WordPress/Classes/ViewRelated/Pages/BasePageListCell.m diff --git a/WordPress/Classes/ViewRelated/Pages/BasePageListCell.h b/WordPress/Classes/ViewRelated/Pages/BasePageListCell.h deleted file mode 100644 index 6c33eb6a56b7..000000000000 --- a/WordPress/Classes/ViewRelated/Pages/BasePageListCell.h +++ /dev/null @@ -1,36 +0,0 @@ -#import - -@class AbstractPost; -@class BasePageListCell; - -NS_ASSUME_NONNULL_BEGIN - -/// A block that represents an action triggered by tapping on a button in a cell. -/// -/// @param cell The cell that contains the button that was tapped. -/// @param button The button that was tapped. -/// @param post The post represented by the cell that was tapped. -/// -typedef void(^BasePageListCellActionBlock)(BasePageListCell* cell, - UIButton* button, - AbstractPost* post); - -/// A base cell to represent a page object. -/// -@interface BasePageListCell : UITableViewCell - -/// The post represented by this cell. -/// -@property (nonatomic, strong, readwrite, nullable) AbstractPost *post; - -/// The block that will be executed when the main button inside this cell is tapped. -/// -@property (nonatomic, copy, readwrite, nullable) BasePageListCellActionBlock onAction; - -/// Configure the cell to represent the specified post. -/// -- (void)configureCell:(AbstractPost *)post; - -@end - -NS_ASSUME_NONNULL_END diff --git a/WordPress/Classes/ViewRelated/Pages/BasePageListCell.m b/WordPress/Classes/ViewRelated/Pages/BasePageListCell.m deleted file mode 100644 index 5ccee46b4b92..000000000000 --- a/WordPress/Classes/ViewRelated/Pages/BasePageListCell.m +++ /dev/null @@ -1,22 +0,0 @@ -#import "BasePageListCell.h" -#import "AbstractPost.h" - -@implementation BasePageListCell - -- (void)configureCell:(AbstractPost *)post -{ - self.post = post; -} - - -#pragma mark - Action - -- (IBAction)onAction:(UIButton *)sender -{ - if (self.onAction) { - NSAssert(self.post != nil, @"Expected the post to be set here."); - self.onAction(self, sender, self.post); - } -} - -@end diff --git a/WordPress/Classes/ViewRelated/Pages/PageListViewController.swift b/WordPress/Classes/ViewRelated/Pages/PageListViewController.swift index 5c21e7b6cfa3..51ed553f7d42 100644 --- a/WordPress/Classes/ViewRelated/Pages/PageListViewController.swift +++ b/WordPress/Classes/ViewRelated/Pages/PageListViewController.swift @@ -377,32 +377,15 @@ class PageListViewController: AbstractPostListViewController, UIViewControllerRe } override func configureCell(_ cell: UITableViewCell, at indexPath: IndexPath) { - guard let cell = cell as? BasePageListCell else { - return - } - - cell.accessoryType = .none - - let page = pageAtIndexPath(indexPath) - let filterType = filterSettings.currentPostListFilter().filterType - // TODO: Implement indenting for child pages (#21818) - if cell.reuseIdentifier == Constant.Identifiers.pageCellIdentifier { - cell.indentationWidth = Constant.Size.pageListTableViewCellLeading - cell.indentationLevel = filterType != .published ? 0 : page.hierarchyIndex - cell.onAction = { [weak self] cell, button, page in - self?.handleMenuAction(fromCell: cell, fromButton: button, forPage: page) - } - } else if cell.reuseIdentifier == Constant.Identifiers.restorePageCellIdentifier { - cell.selectionStyle = .none - cell.onAction = { [weak self] cell, _, page in - self?.handleRestoreAction(fromCell: cell, forPage: page) - } - } - - cell.contentView.backgroundColor = UIColor.listForeground - - cell.configureCell(page) + // TODO: Implement cntext menus (#21717) +// if cell.reuseIdentifier == Constant.Identifiers.pageCellIdentifier { +// cell.indentationWidth = Constant.Size.pageListTableViewCellLeading +// cell.indentationLevel = filterType != .published ? 0 : page.hierarchyIndex +// cell.onAction = { [weak self] cell, button, page in +// self?.handleMenuAction(fromCell: cell, fromButton: button, forPage: page) +// } +// } } fileprivate func cellIdentifierForPage(_ page: Page) -> String { @@ -778,12 +761,6 @@ class PageListViewController: AbstractPostListViewController, UIViewControllerRe return page } - fileprivate func handleRestoreAction(fromCell cell: UITableViewCell, forPage page: AbstractPost) { - restorePost(page) { [weak self] in - self?._tableViewHandler.refreshTableView(at: self?.tableView.indexPath(for: cell)) - } - } - private func addSetHomepageAction(to controller: UIAlertController, for page: AbstractPost, at index: IndexPath?) { let objectID = page.objectID diff --git a/WordPress/Classes/ViewRelated/Pages/RestorePageTableViewCell.h b/WordPress/Classes/ViewRelated/Pages/RestorePageTableViewCell.h index 1710b0acb21e..7590d85f01a4 100644 --- a/WordPress/Classes/ViewRelated/Pages/RestorePageTableViewCell.h +++ b/WordPress/Classes/ViewRelated/Pages/RestorePageTableViewCell.h @@ -1,6 +1,5 @@ #import -#import "BasePageListCell.h" -@interface RestorePageTableViewCell : BasePageListCell +@interface RestorePageTableViewCell : UITableViewCell @end diff --git a/WordPress/Classes/ViewRelated/Pages/RestorePageTableViewCell.m b/WordPress/Classes/ViewRelated/Pages/RestorePageTableViewCell.m index c05e0d4ce98c..58768db25591 100644 --- a/WordPress/Classes/ViewRelated/Pages/RestorePageTableViewCell.m +++ b/WordPress/Classes/ViewRelated/Pages/RestorePageTableViewCell.m @@ -1,12 +1,9 @@ #import "RestorePageTableViewCell.h" #import "WPStyleGuide+Pages.h" -@import Gridicons; - @interface RestorePageTableViewCell() @property (nonatomic, strong) IBOutlet UILabel *restoreLabel; -@property (nonatomic, strong) IBOutlet UIButton *restoreButton; @end @@ -17,6 +14,8 @@ @implementation RestorePageTableViewCell - (void)awakeFromNib { [super awakeFromNib]; + self.selectionStyle = UITableViewCellSelectionStyleNone; + [self configureView]; [self applyStyles]; } @@ -26,17 +25,11 @@ - (void)awakeFromNib { - (void)applyStyles { [WPStyleGuide applyRestorePageLabelStyle:self.restoreLabel]; - [WPStyleGuide applyRestorePageButtonStyle:self.restoreButton]; } - (void)configureView { self.restoreLabel.text = NSLocalizedString(@"Page moved to trash.", @"A short message explaining that a page was moved to the trash bin."); - NSString *buttonTitle = NSLocalizedString(@"Undo", @"The title of an 'undo' button. Tapping the button moves a trashed page out of the trash folder."); - [self.restoreButton setTitle:buttonTitle forState:UIControlStateNormal]; - [self.restoreButton setImage:[UIImage gridiconOfType:GridiconTypeUndo - withSize:CGSizeMake(18.0, 18.0)] - forState:UIControlStateNormal]; } @end diff --git a/WordPress/Classes/ViewRelated/Pages/RestorePageTableViewCell.xib b/WordPress/Classes/ViewRelated/Pages/RestorePageTableViewCell.xib index 2904556a70cb..50b2bc830ca1 100644 --- a/WordPress/Classes/ViewRelated/Pages/RestorePageTableViewCell.xib +++ b/WordPress/Classes/ViewRelated/Pages/RestorePageTableViewCell.xib @@ -1,9 +1,9 @@ - + - + @@ -12,7 +12,7 @@ - + @@ -25,37 +25,15 @@ - - - - - - - diff --git a/WordPress/WordPress.xcodeproj/project.pbxproj b/WordPress/WordPress.xcodeproj/project.pbxproj index 4f66287392b0..4ead76c282e3 100644 --- a/WordPress/WordPress.xcodeproj/project.pbxproj +++ b/WordPress/WordPress.xcodeproj/project.pbxproj @@ -1354,7 +1354,6 @@ 596C03601B84F24000899EEB /* ThemeBrowser.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 596C035F1B84F24000899EEB /* ThemeBrowser.storyboard */; }; 5981FE051AB8A89A0009E080 /* WPUserAgentTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5981FE041AB8A89A0009E080 /* WPUserAgentTests.m */; }; 598DD1711B97985700146967 /* ThemeBrowserCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 598DD1701B97985700146967 /* ThemeBrowserCell.swift */; }; - 59A3CADD1CD2FF0C009BFA1B /* BasePageListCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 59A3CADC1CD2FF0C009BFA1B /* BasePageListCell.m */; }; 59A9AB351B4C33A500A433DC /* ThemeService.m in Sources */ = {isa = PBXBuildFile; fileRef = 59A9AB341B4C33A500A433DC /* ThemeService.m */; }; 59B48B621B99E132008EBB84 /* JSONObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = 59B48B611B99E132008EBB84 /* JSONObject.swift */; }; 59DCA5211CC68AF3000F245F /* PageListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 59DCA5201CC68AF3000F245F /* PageListViewController.swift */; }; @@ -4774,7 +4773,6 @@ FABB23802602FC2C00C8785C /* ReaderCommentsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 5DF8D26019E82B1000A2CD95 /* ReaderCommentsViewController.m */; }; FABB23812602FC2C00C8785C /* MySiteViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1716AEFB25F2927600CF49EC /* MySiteViewController.swift */; }; FABB23822602FC2C00C8785C /* FooterContentGroup.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7E3E7A5F20E44E490075D159 /* FooterContentGroup.swift */; }; - FABB23832602FC2C00C8785C /* BasePageListCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 59A3CADC1CD2FF0C009BFA1B /* BasePageListCell.m */; }; FABB23852602FC2C00C8785C /* WPError.m in Sources */ = {isa = PBXBuildFile; fileRef = E114D799153D85A800984182 /* WPError.m */; }; FABB23862602FC2C00C8785C /* ContentRouter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7E53AB0120FE5EAE005796FE /* ContentRouter.swift */; }; FABB23872602FC2C00C8785C /* BlogToBlog32to33.swift in Sources */ = {isa = PBXBuildFile; fileRef = E16273E01B2ACEB600088AF7 /* BlogToBlog32to33.swift */; }; @@ -6971,8 +6969,6 @@ 597421B01CEB6874005D5F38 /* ConfigurablePostView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ConfigurablePostView.h; sourceTree = ""; }; 5981FE041AB8A89A0009E080 /* WPUserAgentTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WPUserAgentTests.m; sourceTree = ""; }; 598DD1701B97985700146967 /* ThemeBrowserCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ThemeBrowserCell.swift; sourceTree = ""; }; - 59A3CADB1CD2FF0C009BFA1B /* BasePageListCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BasePageListCell.h; sourceTree = ""; }; - 59A3CADC1CD2FF0C009BFA1B /* BasePageListCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BasePageListCell.m; sourceTree = ""; }; 59A9AB331B4C33A500A433DC /* ThemeService.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ThemeService.h; sourceTree = ""; }; 59A9AB341B4C33A500A433DC /* ThemeService.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ThemeService.m; sourceTree = ""; }; 59A9AB391B4C3ECD00A433DC /* LocalCoreDataServiceTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LocalCoreDataServiceTests.m; sourceTree = ""; }; @@ -12607,8 +12603,6 @@ children = ( 0C700B852AE1E1300085C2EE /* PageListCell.swift */, 0C700B882AE1E1940085C2EE /* PageListItemViewModel.swift */, - 59A3CADB1CD2FF0C009BFA1B /* BasePageListCell.h */, - 59A3CADC1CD2FF0C009BFA1B /* BasePageListCell.m */, 8B93856D22DC08060010BF02 /* PageListSectionHeaderView.swift */, 5D13FA561AF99C2100F06492 /* PageListSectionHeaderView.xib */, 5D18FE9C1AFBB17400EFEED0 /* RestorePageTableViewCell.h */, @@ -21905,7 +21899,6 @@ F18CB8962642E58700B90794 /* FixedSizeImageView.swift in Sources */, 7E3E7A6020E44E490075D159 /* FooterContentGroup.swift in Sources */, 46F584B82624E6380010A723 /* BlockEditorSettings+GutenbergEditorSettings.swift in Sources */, - 59A3CADD1CD2FF0C009BFA1B /* BasePageListCell.m in Sources */, E114D79A153D85A800984182 /* WPError.m in Sources */, 7E53AB0220FE5EAE005796FE /* ContentRouter.swift in Sources */, E16273E11B2ACEB600088AF7 /* BlogToBlog32to33.swift in Sources */, @@ -24733,7 +24726,6 @@ F4D829622930E9F300038726 /* MigrationDeleteWordPressViewController.swift in Sources */, 4AA33F05299A1F93005B6E23 /* ReaderTagTopic+Lookup.swift in Sources */, FABB23822602FC2C00C8785C /* FooterContentGroup.swift in Sources */, - FABB23832602FC2C00C8785C /* BasePageListCell.m in Sources */, F163541726DE2ECE008B625B /* NotificationEventTracker.swift in Sources */, 0A9610FA28B2E56300076EBA /* UserSuggestion+Comparable.swift in Sources */, 80C740FC2989FC4600199027 /* PostStatsTableViewController+JetpackBannerViewController.swift in Sources */, From 37a4a3b5e010c75a1bd3f3383b3bf57e5471dce0 Mon Sep 17 00:00:00 2001 From: kean Date: Fri, 20 Oct 2023 10:06:11 -0400 Subject: [PATCH 5/7] Fix crash --- .../Classes/ViewRelated/Pages/PageListViewController.swift | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/WordPress/Classes/ViewRelated/Pages/PageListViewController.swift b/WordPress/Classes/ViewRelated/Pages/PageListViewController.swift index 51ed553f7d42..adfec9afc3e9 100644 --- a/WordPress/Classes/ViewRelated/Pages/PageListViewController.swift +++ b/WordPress/Classes/ViewRelated/Pages/PageListViewController.swift @@ -333,6 +333,11 @@ class PageListViewController: AbstractPostListViewController, UIViewControllerRe // MARK: - Table View Handling + func sectionNameKeyPath() -> String { + let sortField = filterSettings.currentPostListFilter().sortField + return Page.sectionIdentifier(dateKeyPath: sortField.keyPath) + } + override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { tableView.deselectRow(at: indexPath, animated: true) From cebcffac5cbc49a8a183f206653000f694cc460b Mon Sep 17 00:00:00 2001 From: kean Date: Fri, 20 Oct 2023 10:09:39 -0400 Subject: [PATCH 6/7] Update Homepage template cell design --- .../ViewRelated/Pages/TemplatePageTableViewCell.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/WordPress/Classes/ViewRelated/Pages/TemplatePageTableViewCell.swift b/WordPress/Classes/ViewRelated/Pages/TemplatePageTableViewCell.swift index 62cbac0ff17f..4e68d84350f6 100644 --- a/WordPress/Classes/ViewRelated/Pages/TemplatePageTableViewCell.swift +++ b/WordPress/Classes/ViewRelated/Pages/TemplatePageTableViewCell.swift @@ -37,11 +37,11 @@ private struct TemplatePageView: View { private var text: some View { VStack(alignment: .leading, spacing: 2.0) { Text(Constants.title) - .font(Font(WPStyleGuide.notoBoldFontForTextStyle(.headline))) - .foregroundColor(Color(UIColor.text)) + .font(Font(WPStyleGuide.fontForTextStyle(.callout, fontWeight: .semibold))) + .foregroundColor(Color(UIColor.label)) Text(Constants.subtitle) - .font(.subheadline) - .foregroundColor(Color(UIColor.textSubtle)) + .font(.footnote) + .foregroundColor(Color(UIColor.secondaryLabel)) } .frame(maxWidth: .infinity, alignment: .leading) } From a69c864a2c1556be576df76e34be836b4b7d060a Mon Sep 17 00:00:00 2001 From: kean Date: Mon, 23 Oct 2023 09:19:24 -0400 Subject: [PATCH 7/7] Fix margins and separator insets --- WordPress/Classes/ViewRelated/Pages/PageListCell.swift | 2 ++ .../ViewRelated/Pages/TemplatePageTableViewCell.swift | 5 ++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/WordPress/Classes/ViewRelated/Pages/PageListCell.swift b/WordPress/Classes/ViewRelated/Pages/PageListCell.swift index 11ca4db8529c..3935dd4be11c 100644 --- a/WordPress/Classes/ViewRelated/Pages/PageListCell.swift +++ b/WordPress/Classes/ViewRelated/Pages/PageListCell.swift @@ -59,6 +59,8 @@ final class PageListCell: UITableViewCell, Reusable { // MARK: - Setup private func setupViews() { + separatorInset = UIEdgeInsets(top: 0, left: 16, bottom: 0, right: 0) + setupLabels() setupFeaturedImageView() setupEllipsisButton() diff --git a/WordPress/Classes/ViewRelated/Pages/TemplatePageTableViewCell.swift b/WordPress/Classes/ViewRelated/Pages/TemplatePageTableViewCell.swift index 4e68d84350f6..da6a05ec790a 100644 --- a/WordPress/Classes/ViewRelated/Pages/TemplatePageTableViewCell.swift +++ b/WordPress/Classes/ViewRelated/Pages/TemplatePageTableViewCell.swift @@ -19,9 +19,8 @@ class TemplatePageTableViewCell: UITableViewCell { private func applyStyles() { backgroundColor = .neutral(.shade5) - separatorInset = .zero + separatorInset = UIEdgeInsets(top: 0, left: 16, bottom: 0, right: 0) } - } private struct TemplatePageView: View { @@ -30,7 +29,7 @@ private struct TemplatePageView: View { text icon } - .padding(EdgeInsets(top: 4.0, leading: 16.0, bottom: 8.0, trailing: 16.0)) + .padding(EdgeInsets(top: 12.0, leading: 16.0, bottom: 12.0, trailing: 16.0)) .background(Color(UIColor.listForeground)) }