Add option to focus the search bar when double tapping the search tab bar

- Enables double tap for tab bar(s)
- Hides double tap for me tab (as per previous comment)
- Adds search tab double tab option to focus the search bar
This commit is contained in:
Rizwan Mohamed Ibrahim 2023-11-17 14:46:00 +05:30
parent 6e149cd505
commit d1588dda98
No known key found for this signature in database
1 changed files with 20 additions and 16 deletions

View File

@ -292,12 +292,11 @@ extension MainTabBarController {
tabBarLongPressGestureRecognizer.delegate = self
tabBar.addGestureRecognizer(tabBarLongPressGestureRecognizer)
// todo: reconsider the "double tap to change account" feature -> https://github.com/mastodon/mastodon-ios/issues/628
// let tabBarDoubleTapGestureRecognizer = UITapGestureRecognizer()
// tabBarDoubleTapGestureRecognizer.numberOfTapsRequired = 2
// tabBarDoubleTapGestureRecognizer.addTarget(self, action: #selector(MainTabBarController.tabBarDoubleTapGestureRecognizerHandler(_:)))
// tabBarDoubleTapGestureRecognizer.delaysTouchesEnded = false
// tabBar.addGestureRecognizer(tabBarDoubleTapGestureRecognizer)
let tabBarDoubleTapGestureRecognizer = UITapGestureRecognizer()
tabBarDoubleTapGestureRecognizer.numberOfTapsRequired = 2
tabBarDoubleTapGestureRecognizer.addTarget(self, action: #selector(MainTabBarController.tabBarDoubleTapGestureRecognizerHandler(_:)))
tabBarDoubleTapGestureRecognizer.delaysTouchesEnded = false
tabBar.addGestureRecognizer(tabBarDoubleTapGestureRecognizer)
self.isReadyForWizardAvatarButton = authContext != nil
@ -359,17 +358,22 @@ extension MainTabBarController {
guard let tab = touchedTab(by: sender) else { return }
switch tab {
case .me:
guard let authContext = authContext else { return }
// todo: reconsider the "double tap to change account" feature -> https://github.com/mastodon/mastodon-ios/issues/628
// case .me:
// guard let authContext = authContext else { return }
// assert(Thread.isMainThread)
//
// guard let nextAccount = context.nextAccount(in: authContext) else { return }
//
// Task { @MainActor in
// let isActive = try await context.authenticationService.activeMastodonUser(domain: nextAccount.domain, userID: nextAccount.userID)
// guard isActive else { return }
// self.coordinator.setup()
// }
case .search:
assert(Thread.isMainThread)
guard let nextAccount = context.nextAccount(in: authContext) else { return }
Task { @MainActor in
let isActive = try await context.authenticationService.activeMastodonUser(domain: nextAccount.domain, userID: nextAccount.userID)
guard isActive else { return }
self.coordinator.setup()
}
// double tapping search tab opens the search bar without additional taps
searchViewController?.searchBarTapPublisher.send("")
default:
break
}