From 868e86e0776a0fa40e39186a18cc6c4ab452e8af Mon Sep 17 00:00:00 2001 From: CMK Date: Thu, 4 Nov 2021 16:24:42 +0800 Subject: [PATCH] feat: make tabBar avatar button border highlighted when selected --- .../Scene/Root/MainTab/MainTabBarController.swift | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Mastodon/Scene/Root/MainTab/MainTabBarController.swift b/Mastodon/Scene/Root/MainTab/MainTabBarController.swift index 2cb96427..8688a8fa 100644 --- a/Mastodon/Scene/Root/MainTab/MainTabBarController.swift +++ b/Mastodon/Scene/Root/MainTab/MainTabBarController.swift @@ -252,6 +252,14 @@ extension MainTabBarController { tabBarLongPressGestureRecognizer.addTarget(self, action: #selector(MainTabBarController.tabBarLongPressGestureRecognizerHandler(_:))) tabBar.addGestureRecognizer(tabBarLongPressGestureRecognizer) + currentTab + .receive(on: DispatchQueue.main) + .sink { [weak self] tab in + guard let self = self else { return } + self.updateAvatarButtonAppearance() + } + .store(in: &disposeBag) + updateTabBarDisplay() #if DEBUG @@ -269,6 +277,7 @@ extension MainTabBarController { super.traitCollectionDidChange(previousTraitCollection) updateTabBarDisplay() + updateAvatarButtonAppearance() } } @@ -340,6 +349,11 @@ extension MainTabBarController { self.avatarButton.setContentHuggingPriority(.required - 1, for: .vertical) self.avatarButton.isUserInteractionEnabled = false } + + private func updateAvatarButtonAppearance() { + avatarButton.borderColor = currentTab.value == .me ? .label : .systemFill + avatarButton.setNeedsLayout() + } } extension MainTabBarController {