Revert “Add a custom action for ‘switch accounts’”
This reverts commit f9daeea4d3
This commit is contained in:
parent
2ca6c2badf
commit
120065104c
|
@ -686,9 +686,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"account_list": {
|
"account_list": {
|
||||||
|
"tab_bar_hint": "Current selected profile: %s. Double tap then hold to show account switcher",
|
||||||
"dismiss_account_switcher": "Dismiss Account Switcher",
|
"dismiss_account_switcher": "Dismiss Account Switcher",
|
||||||
"add_account": "Add Account",
|
"add_account": "Add Account"
|
||||||
"switch_accounts": "Switch Accounts"
|
|
||||||
},
|
},
|
||||||
"wizard": {
|
"wizard": {
|
||||||
"new_in_mastodon": "New in Mastodon",
|
"new_in_mastodon": "New in Mastodon",
|
||||||
|
|
|
@ -33,7 +33,6 @@ final class ContentSplitViewController: UIViewController, NeedsDependency {
|
||||||
sidebarViewController.context = context
|
sidebarViewController.context = context
|
||||||
sidebarViewController.coordinator = coordinator
|
sidebarViewController.coordinator = coordinator
|
||||||
sidebarViewController.viewModel = SidebarViewModel(context: context, authContext: authContext)
|
sidebarViewController.viewModel = SidebarViewModel(context: context, authContext: authContext)
|
||||||
sidebarViewController.viewModel.delegate = sidebarViewController
|
|
||||||
sidebarViewController.delegate = self
|
sidebarViewController.delegate = self
|
||||||
return sidebarViewController
|
return sidebarViewController
|
||||||
}()
|
}()
|
||||||
|
|
|
@ -298,7 +298,6 @@ extension MainTabBarController {
|
||||||
}
|
}
|
||||||
.store(in: &disposeBag)
|
.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 {
|
if let user = authContext?.mastodonAuthenticationBox.authenticationRecord.object(in: context.managedObjectContext)?.user {
|
||||||
self.avatarURLObserver = user.publisher(for: \.avatar)
|
self.avatarURLObserver = user.publisher(for: \.avatar)
|
||||||
.sink { [weak self, weak user] _ in
|
.sink { [weak self, weak user] _ in
|
||||||
|
@ -307,19 +306,13 @@ extension MainTabBarController {
|
||||||
guard user.managedObjectContext != nil else { return }
|
guard user.managedObjectContext != nil else { return }
|
||||||
self.avatarURL = user.avatarImageURL()
|
self.avatarURL = user.avatarImageURL()
|
||||||
}
|
}
|
||||||
if let profileTabItem {
|
|
||||||
profileTabItem.accessibilityCustomActions = [
|
// a11y
|
||||||
UIAccessibilityCustomAction(name: L10n.Scene.AccountList.switchAccounts) { [weak self] _ in
|
let _profileTabItem = self.tabBar.items?.first { item in item.tag == Tab.me.tag }
|
||||||
self?.showAccountSwitcher()
|
guard let profileTabItem = _profileTabItem else { return }
|
||||||
return true
|
profileTabItem.accessibilityHint = L10n.Scene.AccountList.tabBarHint(user.displayNameWithFallback)
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
self.avatarURLObserver = nil
|
self.avatarURLObserver = nil
|
||||||
if let profileTabItem {
|
|
||||||
profileTabItem.accessibilityCustomActions = []
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let tabBarLongPressGestureRecognizer = UILongPressGestureRecognizer()
|
let tabBarLongPressGestureRecognizer = UILongPressGestureRecognizer()
|
||||||
|
@ -395,16 +388,12 @@ extension MainTabBarController {
|
||||||
|
|
||||||
switch tab {
|
switch tab {
|
||||||
case .me:
|
case .me:
|
||||||
showAccountSwitcher()
|
|
||||||
default:
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private func showAccountSwitcher() {
|
|
||||||
guard let authContext = self.authContext else { return }
|
guard let authContext = self.authContext else { return }
|
||||||
let accountListViewModel = AccountListViewModel(context: context, authContext: authContext)
|
let accountListViewModel = AccountListViewModel(context: context, authContext: authContext)
|
||||||
_ = coordinator.present(scene: .accountList(viewModel: accountListViewModel), from: self, transition: .panModal)
|
_ = coordinator.present(scene: .accountList(viewModel: accountListViewModel), from: self, transition: .panModal)
|
||||||
|
default:
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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 {
|
extension SidebarViewController {
|
||||||
@objc private func sidebarLongPressGestureRecognizerHandler(_ sender: UILongPressGestureRecognizer) {
|
@objc private func sidebarLongPressGestureRecognizerHandler(_ sender: UILongPressGestureRecognizer) {
|
||||||
guard sender.state == .began else { return }
|
guard sender.state == .began else { return }
|
||||||
|
|
|
@ -15,10 +15,6 @@ import MastodonAsset
|
||||||
import MastodonCore
|
import MastodonCore
|
||||||
import MastodonLocalization
|
import MastodonLocalization
|
||||||
|
|
||||||
protocol SidebarViewModelDelegate: AnyObject {
|
|
||||||
func sidebarViewModelDidSwitchAccounts(_ sidebarViewModel: SidebarViewModel)
|
|
||||||
}
|
|
||||||
|
|
||||||
final class SidebarViewModel {
|
final class SidebarViewModel {
|
||||||
|
|
||||||
var disposeBag = Set<AnyCancellable>()
|
var disposeBag = Set<AnyCancellable>()
|
||||||
|
@ -35,8 +31,6 @@ final class SidebarViewModel {
|
||||||
var secondaryDiffableDataSource: UICollectionViewDiffableDataSource<Section, Item>?
|
var secondaryDiffableDataSource: UICollectionViewDiffableDataSource<Section, Item>?
|
||||||
@Published private(set) var isReadyForWizardAvatarButton = false
|
@Published private(set) var isReadyForWizardAvatarButton = false
|
||||||
|
|
||||||
weak var delegate: SidebarViewModelDelegate?
|
|
||||||
|
|
||||||
init(context: AppContext, authContext: AuthContext?) {
|
init(context: AppContext, authContext: AuthContext?) {
|
||||||
self.context = context
|
self.context = context
|
||||||
self.authContext = authContext
|
self.authContext = authContext
|
||||||
|
@ -134,17 +128,9 @@ extension SidebarViewModel {
|
||||||
}
|
}
|
||||||
.store(in: &cell.disposeBag)
|
.store(in: &cell.disposeBag)
|
||||||
case .me:
|
case .me:
|
||||||
if self.authContext?.mastodonAuthenticationBox.authenticationRecord.object(in: self.context.managedObjectContext)?.user != nil {
|
guard let user = self.authContext?.mastodonAuthenticationBox.authenticationRecord.object(in: self.context.managedObjectContext)?.user else { return }
|
||||||
cell.accessibilityCustomActions = [
|
let currentUserDisplayName = user.displayNameWithFallback
|
||||||
UIAccessibilityCustomAction(name: L10n.Scene.AccountList.switchAccounts) { [weak self] _ in
|
cell.accessibilityHint = L10n.Scene.AccountList.tabBarHint(currentUserDisplayName)
|
||||||
guard let self, let delegate = self.delegate else { return false }
|
|
||||||
delegate.sidebarViewModelDidSwitchAccounts(self)
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
} else {
|
|
||||||
cell.accessibilityCustomActions = []
|
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue