From cd5b4c1145bd28ca94066efb45aa3c3bc458c7de Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Mon, 2 Mar 2020 22:31:37 -0500 Subject: [PATCH] Remove old code --- .../Compose/ComposeViewController.swift | 10 +---- .../NotificationsTableViewController.swift | 6 ++- .../Preferences/SilentActionPrefs.swift | 37 +------------------ Tusker/Shortcuts/UserActivityManager.swift | 1 - .../ProfileHeaderTableViewCell.swift | 25 ------------- .../Status/BaseStatusTableViewCell.swift | 17 +-------- 6 files changed, 8 insertions(+), 88 deletions(-) diff --git a/Tusker/Screens/Compose/ComposeViewController.swift b/Tusker/Screens/Compose/ComposeViewController.swift index d3a749ae..6e3a05a7 100644 --- a/Tusker/Screens/Compose/ComposeViewController.swift +++ b/Tusker/Screens/Compose/ComposeViewController.swift @@ -217,15 +217,7 @@ class ComposeViewController: UIViewController { NotificationCenter.default.removeObserver(self, name: UIResponder.keyboardWillHideNotification, object: nil) NotificationCenter.default.removeObserver(self, name: UIResponder.keyboardWillChangeFrameNotification, object: nil) } - - override func viewDidLayoutSubviews() { - super.viewDidLayoutSubviews() - -// if inReplyToID != nil { -// scrollView.contentOffset = CGPoint(x: 0, y: stackView.arrangedSubviews.first!.frame.height) -// } - } - + override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) { super.traitCollectionDidChange(previousTraitCollection) diff --git a/Tusker/Screens/Notifications/NotificationsTableViewController.swift b/Tusker/Screens/Notifications/NotificationsTableViewController.swift index caa25201..c8a1a9a6 100644 --- a/Tusker/Screens/Notifications/NotificationsTableViewController.swift +++ b/Tusker/Screens/Notifications/NotificationsTableViewController.swift @@ -51,7 +51,7 @@ class NotificationsTableViewController: EnhancedTableViewController { tableView.register(UINib(nibName: "ActionNotificationGroupTableViewCell", bundle: .main), forCellReuseIdentifier: actionGroupCell) tableView.register(UINib(nibName: "FollowNotificationGroupTableViewCell", bundle: .main), forCellReuseIdentifier: followGroupCell) tableView.register(UINib(nibName: "FollowRequestNotificationTableViewCell", bundle: .main), forCellReuseIdentifier: followRequestCell) - tableView.register(UINib(nibName: "UnknownNotificationTableViewCell", bundle: .main), forCellReuseIdentifier: unknownCell) + tableView.register(UINib(nibName: "BasicTableViewCell", bundle: .main), forCellReuseIdentifier: unknownCell) tableView.prefetchDataSource = self @@ -120,7 +120,9 @@ class NotificationsTableViewController: EnhancedTableViewController { return cell case .unknown: - return tableView.dequeueReusableCell(withIdentifier: unknownCell, for: indexPath) + let cell = tableView.dequeueReusableCell(withIdentifier: unknownCell, for: indexPath) + cell.textLabel!.text = NSLocalizedString("Unknown Notification", comment: "unknown notification fallback cell text") + return cell } } diff --git a/Tusker/Screens/Preferences/SilentActionPrefs.swift b/Tusker/Screens/Preferences/SilentActionPrefs.swift index e2d1d9f0..dae1fff7 100644 --- a/Tusker/Screens/Preferences/SilentActionPrefs.swift +++ b/Tusker/Screens/Preferences/SilentActionPrefs.swift @@ -7,30 +7,7 @@ import SwiftUI -//struct SilentActionPermission: Identifiable { -// let application: String -// let permission: Preferences.Permission -// -// var id: String { -// return application -// } -// -// init(_ application: String, _ permission: Preferences.Permission) { -// self.application = application -// self.permission = permission -// } -//} - struct SilentActionPrefs : View { -// @MappedPreference(\.silentActions, fromPref: { -// var array = [SilentActionPermission]() -// for (application, permission) in $0 { -// array.append(SilentActionPermission(application, permission)) -// } -// return array -// }) -// var silentActionPermissions: [SilentActionPermission] -// @Preference(\.silentActions) var silentActions: [String: Preferences.Permission] @ObservedObject var preferences = Preferences.shared var body: some View { @@ -40,23 +17,13 @@ struct SilentActionPrefs : View { .listStyle(GroupedListStyle()) // .navigationBarTitle("Silent Action Permissions") // see FB6838291 -// List(Array(silentActions.keys).identified(by: \.self)) { application in -// Text(application) -//// Toggle(isOn: Binding(getValue: { self.silentActions[application] == .accepted }, setValue: { self.silentActions[application] = $0 ? .accepted : .rejected }), label: Text(application)) -// }.listStyle(.grouped) } } struct SilentActionPermissionCell: View { - @EnvironmentObject var preferences: Preferences + @ObservedObject var preferences = Preferences.shared let source: String -// var binding: Binding - - init(source: String) { - self.source = source -// self.binding = Binding(getValue: { self.preferences.silentActions[source] == .accepted }, setValue: { self.preferences.silentActions[source] = $0 ? .accepted : .rejected }) - } - + var body: some View { Toggle(isOn: Binding(get: { self.preferences.silentActions[self.source] == .accepted diff --git a/Tusker/Shortcuts/UserActivityManager.swift b/Tusker/Shortcuts/UserActivityManager.swift index 1259be04..c0792eb3 100644 --- a/Tusker/Shortcuts/UserActivityManager.swift +++ b/Tusker/Shortcuts/UserActivityManager.swift @@ -24,7 +24,6 @@ class UserActivityManager { let scene = UIApplication.shared.connectedScenes.compactMap { $0 as? UIWindowScene }.first! let window = scene.windows.first { $0.isKeyWindow }! return window.rootViewController as! MainTabBarViewController -// return (UIApplication.shared.delegate! as! AppDelegate).window!.rootViewController as! MainTabBarViewController } private static func present(_ vc: UIViewController, animated: Bool = true) { diff --git a/Tusker/Views/Profile Header/ProfileHeaderTableViewCell.swift b/Tusker/Views/Profile Header/ProfileHeaderTableViewCell.swift index 5fd7d9cd..9bbc03b1 100644 --- a/Tusker/Views/Profile Header/ProfileHeaderTableViewCell.swift +++ b/Tusker/Views/Profile Header/ProfileHeaderTableViewCell.swift @@ -157,28 +157,3 @@ class ProfileHeaderTableViewCell: UITableViewCell { } } - -//extension ProfileHeaderTableViewCell: MenuPreviewProvider { -// var navigationDelegate: TuskerNavigationDelegate? { return delegate } -// func getPreviewProviders(for location: CGPoint, sourceViewController: UIViewController) -> PreviewProviders? { -// let noteLabelPoint = noteLabel.convert(location, from: self) -// if noteLabel.bounds.contains(noteLabelPoint), -// let link = noteLabel.getLink(atPoint: noteLabelPoint) { -// return ( -// content: { self.noteLabel.getViewController(forLink: link.url, inRange: link.range) }, -// actions: { -// let text = (self.noteLabel.text! as NSString).substring(with: link.range) -// if let mention = self.noteLabel.getMention(for: link.url, text: text) { -// return self.actionsForProfile(accountID: mention.id, sourceView: self) -// } else if let hashtag = self.noteLabel.getHashtag(for: link.url, text: text) { -// return self.actionsForHashtag(hashtag, sourceView: self) -// } else { -// return self.actionsForURL(link.url, sourceView: self) -// } -// } -// ) -// } else { -// return nil -// } -// } -//} diff --git a/Tusker/Views/Status/BaseStatusTableViewCell.swift b/Tusker/Views/Status/BaseStatusTableViewCell.swift index 7e627885..55e20f63 100644 --- a/Tusker/Views/Status/BaseStatusTableViewCell.swift +++ b/Tusker/Views/Status/BaseStatusTableViewCell.swift @@ -339,22 +339,7 @@ extension BaseStatusTableViewCell: MenuPreviewProvider { actions: { [] } ) } - }/* else if contentLabel.frame.contains(location), - let link = contentLabel.getLink(atPoint: contentLabel.convert(location, from: self)) { - return ( - content: { self.contentLabel.getViewController(forLink: link.url, inRange: link.range) }, - actions: { - let text = (self.contentLabel.text! as NSString).substring(with: link.range) - if let mention = self.contentLabel.getMention(for: link.url, text: text) { - return self.actionsForProfile(accountID: mention.id, sourceView: self) - } else if let hashtag = self.contentLabel.getHashtag(for: link.url, text: text) { - return self.actionsForHashtag(hashtag, sourceView: self) - } else { - return self.actionsForURL(link.url, sourceView: self) - } - } - ) - }*/ + } return self.getStatusCellPreviewProviders(for: location, sourceViewController: sourceViewController) } }