From 120065104ccbf0d4516af618adcab97e3f432759 Mon Sep 17 00:00:00 2001 From: Jed Fox Date: Mon, 14 Nov 2022 08:45:10 -0500 Subject: [PATCH] =?UTF-8?q?Revert=20=E2=80=9CAdd=20a=20custom=20action=20f?= =?UTF-8?q?or=20=E2=80=98switch=20accounts=E2=80=99=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit f9daeea4d3ad66a5387493b67682c4e27396d2bf --- Localization/app.json | 6 ++--- .../Root/ContentSplitViewController.swift | 1 - .../Root/MainTab/MainTabBarController.swift | 27 ++++++------------- .../Root/Sidebar/SidebarViewController.swift | 13 --------- .../Scene/Root/Sidebar/SidebarViewModel.swift | 20 +++----------- 5 files changed, 14 insertions(+), 53 deletions(-) diff --git a/Localization/app.json b/Localization/app.json index 4c64d28f3..8fb7933c4 100644 --- a/Localization/app.json +++ b/Localization/app.json @@ -686,9 +686,9 @@ } }, "account_list": { + "tab_bar_hint": "Current selected profile: %s. Double tap then hold to show account switcher", "dismiss_account_switcher": "Dismiss Account Switcher", - "add_account": "Add Account", - "switch_accounts": "Switch Accounts" + "add_account": "Add Account" }, "wizard": { "new_in_mastodon": "New in Mastodon", @@ -699,4 +699,4 @@ "title": "Bookmarks" } } -} +} \ No newline at end of file diff --git a/Mastodon/Scene/Root/ContentSplitViewController.swift b/Mastodon/Scene/Root/ContentSplitViewController.swift index 4ae7204ca..3f4758e8e 100644 --- a/Mastodon/Scene/Root/ContentSplitViewController.swift +++ b/Mastodon/Scene/Root/ContentSplitViewController.swift @@ -33,7 +33,6 @@ final class ContentSplitViewController: UIViewController, NeedsDependency { sidebarViewController.context = context sidebarViewController.coordinator = coordinator sidebarViewController.viewModel = SidebarViewModel(context: context, authContext: authContext) - sidebarViewController.viewModel.delegate = sidebarViewController sidebarViewController.delegate = self return sidebarViewController }() diff --git a/Mastodon/Scene/Root/MainTab/MainTabBarController.swift b/Mastodon/Scene/Root/MainTab/MainTabBarController.swift index 0eea7288e..e2510071e 100644 --- a/Mastodon/Scene/Root/MainTab/MainTabBarController.swift +++ b/Mastodon/Scene/Root/MainTab/MainTabBarController.swift @@ -298,7 +298,6 @@ extension MainTabBarController { } .store(in: &disposeBag) - let profileTabItem = self.tabBar.items?.first { item in item.tag == Tab.me.tag } if let user = authContext?.mastodonAuthenticationBox.authenticationRecord.object(in: context.managedObjectContext)?.user { self.avatarURLObserver = user.publisher(for: \.avatar) .sink { [weak self, weak user] _ in @@ -307,19 +306,13 @@ extension MainTabBarController { guard user.managedObjectContext != nil else { return } self.avatarURL = user.avatarImageURL() } - if let profileTabItem { - profileTabItem.accessibilityCustomActions = [ - UIAccessibilityCustomAction(name: L10n.Scene.AccountList.switchAccounts) { [weak self] _ in - self?.showAccountSwitcher() - return true - } - ] - } + + // a11y + let _profileTabItem = self.tabBar.items?.first { item in item.tag == Tab.me.tag } + guard let profileTabItem = _profileTabItem else { return } + profileTabItem.accessibilityHint = L10n.Scene.AccountList.tabBarHint(user.displayNameWithFallback) } else { self.avatarURLObserver = nil - if let profileTabItem { - profileTabItem.accessibilityCustomActions = [] - } } let tabBarLongPressGestureRecognizer = UILongPressGestureRecognizer() @@ -395,17 +388,13 @@ extension MainTabBarController { switch tab { case .me: - showAccountSwitcher() + guard let authContext = self.authContext else { return } + let accountListViewModel = AccountListViewModel(context: context, authContext: authContext) + _ = coordinator.present(scene: .accountList(viewModel: accountListViewModel), from: self, transition: .panModal) default: break } } - - private func showAccountSwitcher() { - guard let authContext = self.authContext else { return } - let accountListViewModel = AccountListViewModel(context: context, authContext: authContext) - _ = coordinator.present(scene: .accountList(viewModel: accountListViewModel), from: self, transition: .panModal) - } } extension MainTabBarController { diff --git a/Mastodon/Scene/Root/Sidebar/SidebarViewController.swift b/Mastodon/Scene/Root/Sidebar/SidebarViewController.swift index 28e205047..70e1239b6 100644 --- a/Mastodon/Scene/Root/Sidebar/SidebarViewController.swift +++ b/Mastodon/Scene/Root/Sidebar/SidebarViewController.swift @@ -162,19 +162,6 @@ extension SidebarViewController { } -extension SidebarViewController: SidebarViewModelDelegate { - func sidebarViewModelDidSwitchAccounts(_ sidebarViewModel: SidebarViewModel) { - guard let diffableDataSource = viewModel.diffableDataSource else { return } - guard let indexPath = diffableDataSource.indexPath(for: .tab(.me)) else { return } - guard let cell = collectionView.cellForItem(at: indexPath) else { return } - delegate?.sidebarViewController( - self, - didLongPressItem: .tab(.me), - sourceView: cell - ) - } -} - extension SidebarViewController { @objc private func sidebarLongPressGestureRecognizerHandler(_ sender: UILongPressGestureRecognizer) { guard sender.state == .began else { return } diff --git a/Mastodon/Scene/Root/Sidebar/SidebarViewModel.swift b/Mastodon/Scene/Root/Sidebar/SidebarViewModel.swift index 2a8082e47..c3f9e3e36 100644 --- a/Mastodon/Scene/Root/Sidebar/SidebarViewModel.swift +++ b/Mastodon/Scene/Root/Sidebar/SidebarViewModel.swift @@ -15,10 +15,6 @@ import MastodonAsset import MastodonCore import MastodonLocalization -protocol SidebarViewModelDelegate: AnyObject { - func sidebarViewModelDidSwitchAccounts(_ sidebarViewModel: SidebarViewModel) -} - final class SidebarViewModel { var disposeBag = Set() @@ -35,8 +31,6 @@ final class SidebarViewModel { var secondaryDiffableDataSource: UICollectionViewDiffableDataSource? @Published private(set) var isReadyForWizardAvatarButton = false - weak var delegate: SidebarViewModelDelegate? - init(context: AppContext, authContext: AuthContext?) { self.context = context self.authContext = authContext @@ -134,17 +128,9 @@ extension SidebarViewModel { } .store(in: &cell.disposeBag) case .me: - if self.authContext?.mastodonAuthenticationBox.authenticationRecord.object(in: self.context.managedObjectContext)?.user != nil { - cell.accessibilityCustomActions = [ - UIAccessibilityCustomAction(name: L10n.Scene.AccountList.switchAccounts) { [weak self] _ in - guard let self, let delegate = self.delegate else { return false } - delegate.sidebarViewModelDidSwitchAccounts(self) - return true - } - ] - } else { - cell.accessibilityCustomActions = [] - } + guard let user = self.authContext?.mastodonAuthenticationBox.authenticationRecord.object(in: self.context.managedObjectContext)?.user else { return } + let currentUserDisplayName = user.displayNameWithFallback + cell.accessibilityHint = L10n.Scene.AccountList.tabBarHint(currentUserDisplayName) default: break }