From 2464e2530f8fe917855189a066fb1d57a32bc7f1 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Fri, 27 Oct 2023 17:14:55 -0500 Subject: [PATCH] Remove dead code --- Tusker.xcodeproj/project.pbxproj | 12 -- .../EnhancedTableViewController.swift | 92 ------------- .../Account Cell/AccountTableViewCell.swift | 130 ------------------ .../Account Cell/AccountTableViewCell.xib | 76 ---------- 4 files changed, 310 deletions(-) delete mode 100644 Tusker/Screens/Utilities/EnhancedTableViewController.swift delete mode 100644 Tusker/Views/Account Cell/AccountTableViewCell.swift delete mode 100644 Tusker/Views/Account Cell/AccountTableViewCell.xib diff --git a/Tusker.xcodeproj/project.pbxproj b/Tusker.xcodeproj/project.pbxproj index 6c6fafdb..a15de80a 100644 --- a/Tusker.xcodeproj/project.pbxproj +++ b/Tusker.xcodeproj/project.pbxproj @@ -214,8 +214,6 @@ D6A00B1D26379FC900316AD4 /* PollOptionsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6A00B1C26379FC900316AD4 /* PollOptionsView.swift */; }; D6A3A380295515550036B6EF /* ProfileHeaderButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6A3A37F295515550036B6EF /* ProfileHeaderButton.swift */; }; D6A3A3822956123A0036B6EF /* TimelinePosition.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6A3A3812956123A0036B6EF /* TimelinePosition.swift */; }; - D6A3BC8A2321F79B00FD64D5 /* AccountTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6A3BC882321F79B00FD64D5 /* AccountTableViewCell.swift */; }; - D6A3BC8B2321F79B00FD64D5 /* AccountTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = D6A3BC892321F79B00FD64D5 /* AccountTableViewCell.xib */; }; D6A4531629EF64BA00032932 /* ShareViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6A4531529EF64BA00032932 /* ShareViewController.swift */; }; D6A4531929EF64BA00032932 /* MainInterface.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = D6A4531729EF64BA00032932 /* MainInterface.storyboard */; }; D6A4531D29EF64BA00032932 /* ShareExtension.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = D6A4531329EF64BA00032932 /* ShareExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; @@ -258,7 +256,6 @@ D6B9366D2828445000237D0E /* SavedInstance.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6B9366C2828444F00237D0E /* SavedInstance.swift */; }; D6B9366F2828452F00237D0E /* SavedHashtag.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6B9366E2828452F00237D0E /* SavedHashtag.swift */; }; D6B936712829F72900237D0E /* NSManagedObjectContext+Helpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6B936702829F72900237D0E /* NSManagedObjectContext+Helpers.swift */; }; - D6BC8748219738E1006163F1 /* EnhancedTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6BC8747219738E1006163F1 /* EnhancedTableViewController.swift */; }; D6BC9DB1232C61BC002CA326 /* NotificationsPageViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6BC9DB0232C61BC002CA326 /* NotificationsPageViewController.swift */; }; D6BC9DB3232D4C07002CA326 /* WellnessPrefsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6BC9DB2232D4C07002CA326 /* WellnessPrefsView.swift */; }; D6BC9DD7232D7811002CA326 /* TimelinesPageViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6BC9DD6232D7811002CA326 /* TimelinesPageViewController.swift */; }; @@ -618,8 +615,6 @@ D6A00B1C26379FC900316AD4 /* PollOptionsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PollOptionsView.swift; sourceTree = ""; }; D6A3A37F295515550036B6EF /* ProfileHeaderButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProfileHeaderButton.swift; sourceTree = ""; }; D6A3A3812956123A0036B6EF /* TimelinePosition.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TimelinePosition.swift; sourceTree = ""; }; - D6A3BC882321F79B00FD64D5 /* AccountTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountTableViewCell.swift; sourceTree = ""; }; - D6A3BC892321F79B00FD64D5 /* AccountTableViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = AccountTableViewCell.xib; sourceTree = ""; }; D6A4531329EF64BA00032932 /* ShareExtension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = ShareExtension.appex; sourceTree = BUILT_PRODUCTS_DIR; }; D6A4531529EF64BA00032932 /* ShareViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareViewController.swift; sourceTree = ""; }; D6A4531829EF64BA00032932 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/MainInterface.storyboard; sourceTree = ""; }; @@ -661,7 +656,6 @@ D6B9366C2828444F00237D0E /* SavedInstance.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SavedInstance.swift; sourceTree = ""; }; D6B9366E2828452F00237D0E /* SavedHashtag.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SavedHashtag.swift; sourceTree = ""; }; D6B936702829F72900237D0E /* NSManagedObjectContext+Helpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSManagedObjectContext+Helpers.swift"; sourceTree = ""; }; - D6BC8747219738E1006163F1 /* EnhancedTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EnhancedTableViewController.swift; sourceTree = ""; }; D6BC9DB0232C61BC002CA326 /* NotificationsPageViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationsPageViewController.swift; sourceTree = ""; }; D6BC9DB2232D4C07002CA326 /* WellnessPrefsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WellnessPrefsView.swift; sourceTree = ""; }; D6BC9DD6232D7811002CA326 /* TimelinesPageViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TimelinesPageViewController.swift; sourceTree = ""; }; @@ -1296,8 +1290,6 @@ D6A3BC872321F78000FD64D5 /* Account Cell */ = { isa = PBXGroup; children = ( - D6A3BC882321F79B00FD64D5 /* AccountTableViewCell.swift */, - D6A3BC892321F79B00FD64D5 /* AccountTableViewCell.xib */, D6D12B55292D57E800D528E1 /* AccountCollectionViewCell.swift */, ); path = "Account Cell"; @@ -1427,7 +1419,6 @@ D693DE5623FE1A6A0061E07D /* EnhancedNavigationViewController.swift */, D6E77D0E286F773900D8B732 /* SplitNavigationController.swift */, D62D67C42A97D8CD00167EE2 /* MultiColumnNavigationController.swift */, - D6BC8747219738E1006163F1 /* EnhancedTableViewController.swift */, D693DE5823FE24300061E07D /* InteractivePushTransition.swift */, D6C693FB2162FE6F007D6A6D /* LoadingViewController.swift */, D6E0DC8D216EDF1E00369478 /* Previewing.swift */, @@ -1861,7 +1852,6 @@ D6E77D0D286E6B7300D8B732 /* TrendingLinkCardCollectionViewCell.xib in Resources */, D693A73025CF91C6003A14E2 /* FeaturedProfileCollectionViewCell.xib in Resources */, D61AC1D9232EA42D00C54D2D /* InstanceTableViewCell.xib in Resources */, - D6A3BC8B2321F79B00FD64D5 /* AccountTableViewCell.xib in Resources */, D6412B0B24B0D4C600F5412E /* ProfileHeaderView.xib in Resources */, D6D4DDDA212518A200E1C4BB /* LaunchScreen.storyboard in Resources */, D6E57FA325C26FAB00341037 /* Localizable.stringsdict in Resources */, @@ -1987,7 +1977,6 @@ D6ADB6F028ED1F25009924AB /* CachedImageView.swift in Sources */, D693DE5923FE24310061E07D /* InteractivePushTransition.swift in Sources */, D69693FA25859A8000F4E116 /* ComposeSceneDelegate.swift in Sources */, - D6A3BC8A2321F79B00FD64D5 /* AccountTableViewCell.swift in Sources */, D66A77BB233838DC0058F1EC /* UIFont+Traits.swift in Sources */, D65B4B682977769E00DABDFB /* StatusActionAccountListViewController.swift in Sources */, D61F759B29384F9C00C0B37F /* FilterMO.swift in Sources */, @@ -2227,7 +2216,6 @@ D6093F9B25BDD4B9004811E6 /* HashtagSearchResultsViewController.swift in Sources */, D6E77D09286D25FA00D8B732 /* TrendingHashtagCollectionViewCell.swift in Sources */, D667E5F12134D5050057A976 /* UIViewController+Delegates.swift in Sources */, - D6BC8748219738E1006163F1 /* EnhancedTableViewController.swift in Sources */, D6D79F292A0D596B00AB2315 /* StatusEditHistoryViewController.swift in Sources */, D6E426B325337C7000C02E1C /* CustomEmojiImageView.swift in Sources */, D6D4DDD0212518A000E1C4BB /* AppDelegate.swift in Sources */, diff --git a/Tusker/Screens/Utilities/EnhancedTableViewController.swift b/Tusker/Screens/Utilities/EnhancedTableViewController.swift deleted file mode 100644 index 6ea5e358..00000000 --- a/Tusker/Screens/Utilities/EnhancedTableViewController.swift +++ /dev/null @@ -1,92 +0,0 @@ -// -// EnhancedTableViewController.swift -// Tusker -// -// Created by Shadowfacts on 11/10/18. -// Copyright © 2018 Shadowfacts. All rights reserved. -// - -import UIKit -import SafariServices - -class EnhancedTableViewController: UITableViewController { - - var dragEnabled = false - - override func viewDidLoad() { - super.viewDidLoad() - - if dragEnabled { - tableView.dragDelegate = self - } - } - - // MARK: Table View Delegate - - override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { - if let cell = tableView.cellForRow(at: indexPath) as? SelectableTableViewCell { - cell.didSelectCell() - } - } - -} - -extension EnhancedTableViewController { - - override func tableView(_ tableView: UITableView, contextMenuConfigurationForRowAt indexPath: IndexPath, point: CGPoint) -> UIContextMenuConfiguration? { - if let cell = tableView.cellForRow(at: indexPath) as? UITableViewCell & MenuPreviewProvider { - let cellLocation = cell.convert(point, from: tableView) - guard let (previewProvider, actionsProvider) = cell.getPreviewProviders(for: cellLocation, sourceViewController: self) else { - return nil - } - let actionProvider: UIContextMenuActionProvider = { (_) in - let suggested = self.getSuggestedContextMenuActions(tableView: tableView, indexPath: indexPath, point: point) - return UIMenu(title: "", image: nil, identifier: nil, options: [], children: suggested + actionsProvider()) - } - return UIContextMenuConfiguration(identifier: nil, previewProvider: previewProvider, actionProvider: actionProvider) - } else { - return nil - } - } - - // todo: replace this with the UIKit suggested actions, if possible - @objc open func getSuggestedContextMenuActions(tableView: UITableView, indexPath: IndexPath, point: CGPoint) -> [UIAction] { - return [] - } - - override func tableView(_ tableView: UITableView, willPerformPreviewActionForMenuWith configuration: UIContextMenuConfiguration, animator: UIContextMenuInteractionCommitAnimating) { - if let viewController = animator.previewViewController { - animator.preferredCommitStyle = .pop - animator.addCompletion { - if let customPresenting = viewController as? CustomPreviewPresenting { - customPresenting.presentFromPreview(presenter: self) - } else { - self.show(viewController, sender: nil) - } - } - } - } - -} - -extension EnhancedTableViewController: UITableViewDragDelegate { - func tableView(_ tableView: UITableView, itemsForBeginning session: UIDragSession, at indexPath: IndexPath) -> [UIDragItem] { - guard let cell = tableView.cellForRow(at: indexPath) as? DraggableTableViewCell else { - return [] - } - return cell.dragItemsForBeginning(session: session) - } -} - -extension EnhancedTableViewController: TabBarScrollableViewController { - func tabBarScrollToTop() { - tableView.scrollToTop() - } -} - -extension EnhancedTableViewController: StatusBarTappableViewController { - func handleStatusBarTapped(xPosition: CGFloat) -> StatusBarTapActionResult { - tableView.scrollToTop() - return .stop - } -} diff --git a/Tusker/Views/Account Cell/AccountTableViewCell.swift b/Tusker/Views/Account Cell/AccountTableViewCell.swift deleted file mode 100644 index 67036ec0..00000000 --- a/Tusker/Views/Account Cell/AccountTableViewCell.swift +++ /dev/null @@ -1,130 +0,0 @@ -// -// AccountTableViewCell.swift -// Tusker -// -// Created by Shadowfacts on 9/5/19. -// Copyright © 2019 Shadowfacts. All rights reserved. -// - -import UIKit -import SwiftSoup - -class AccountTableViewCell: UITableViewCell { - - weak var delegate: (TuskerNavigationDelegate & MenuActionProvider)? - var mastodonController: MastodonController! { delegate?.apiController } - - @IBOutlet weak var avatarImageView: UIImageView! - @IBOutlet weak var displayNameLabel: AccountDisplayNameLabel! - @IBOutlet weak var usernameLabel: UILabel! - @IBOutlet weak var noteLabel: EmojiLabel! - - var accountID: String! - - private var avatarRequest: ImageCache.Request? - private var isGrayscale = false - - override func awakeFromNib() { - super.awakeFromNib() - - avatarImageView.layer.masksToBounds = true - avatarImageView.layer.cornerCurve = .continuous - - usernameLabel.font = UIFontMetrics(forTextStyle: .body).scaledFont(for: .systemFont(ofSize: 15, weight: .light)) - usernameLabel.adjustsFontForContentSizeCategory = true - - noteLabel.font = UIFontMetrics(forTextStyle: .body).scaledFont(for: .systemFont(ofSize: 15)) - noteLabel.adjustsFontForContentSizeCategory = true - - NotificationCenter.default.addObserver(self, selector: #selector(updateUIForPrefrences), name: .preferencesChanged, object: nil) - } - - @objc func updateUIForPrefrences() { - avatarImageView.layer.cornerRadius = Preferences.shared.avatarStyle.cornerRadius(for: avatarImageView) - - guard let account = mastodonController.persistentContainer.account(for: accountID) else { - // this table view cell could be cached in a table view (e.g., SearchResultsViewController) for an account that's since been purged - return - } - displayNameLabel.updateForAccountDisplayName(account: account) - - if isGrayscale != Preferences.shared.grayscaleImages { - updateGrayscaleableUI(account: account) - } - } - - func updateUI(accountID: String) { - self.accountID = accountID - guard let account = mastodonController.persistentContainer.account(for: accountID) else { - fatalError("Missing cached account \(accountID)") - } - - usernameLabel.text = "@\(account.acct)" - - updateGrayscaleableUI(account: account) - updateUIForPrefrences() - } - - private func updateGrayscaleableUI(account: AccountMO) { - isGrayscale = Preferences.shared.grayscaleImages - - let accountID = self.accountID - - avatarImageView.image = nil - if let avatarURL = account.avatar { - avatarRequest = ImageCache.avatars.get(avatarURL) { [weak self] (_, image) in - guard let self = self else { return } - self.avatarRequest = nil - - guard let image = image, - self.accountID == accountID, - let transformedImage = ImageGrayscalifier.convertIfNecessary(url: avatarURL, image: image) else { return } - - DispatchQueue.main.async { - self.avatarImageView.image = transformedImage - } - } - } - - let doc = try! SwiftSoup.parse(account.note) - noteLabel.text = try! doc.text() - noteLabel.setEmojis(account.emojis, identifier: account.id) - } - - override func prepareForReuse() { - super.prepareForReuse() - - avatarRequest?.cancel() - } - -} - -extension AccountTableViewCell: SelectableTableViewCell { - func didSelectCell() { - delegate?.selected(account: accountID) - } -} - -extension AccountTableViewCell: MenuPreviewProvider { - func getPreviewProviders(for location: CGPoint, sourceViewController: UIViewController) -> PreviewProviders? { - guard let mastodonController = mastodonController else { return nil } - return ( - content: { ProfileViewController(accountID: self.accountID, mastodonController: mastodonController) }, - actions: { self.delegate?.actionsForProfile(accountID: self.accountID, source: .view(self.avatarImageView)) ?? [] } - ) - } -} - -extension AccountTableViewCell: DraggableTableViewCell { - func dragItemsForBeginning(session: UIDragSession) -> [UIDragItem] { - guard let account = mastodonController.persistentContainer.account(for: accountID), - let currentAccountID = mastodonController.accountInfo?.id else { - return [] - } - let provider = NSItemProvider(object: account.url as NSURL) - let activity = UserActivityManager.showProfileActivity(id: account.id, accountID: currentAccountID) - activity.displaysAuxiliaryScene = true - provider.registerObject(activity, visibility: .all) - return [UIDragItem(itemProvider: provider)] - } -} diff --git a/Tusker/Views/Account Cell/AccountTableViewCell.xib b/Tusker/Views/Account Cell/AccountTableViewCell.xib deleted file mode 100644 index e2c188c0..00000000 --- a/Tusker/Views/Account Cell/AccountTableViewCell.xib +++ /dev/null @@ -1,76 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -