feat: make tabBar avatar button border highlighted when selected

This commit is contained in:
CMK 2021-11-04 16:24:42 +08:00
parent 1cbc385253
commit 868e86e077
1 changed files with 14 additions and 0 deletions

View File

@ -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 {