feat: make tabBar avatar button border highlighted when selected
This commit is contained in:
parent
1cbc385253
commit
868e86e077
|
@ -252,6 +252,14 @@ extension MainTabBarController {
|
||||||
tabBarLongPressGestureRecognizer.addTarget(self, action: #selector(MainTabBarController.tabBarLongPressGestureRecognizerHandler(_:)))
|
tabBarLongPressGestureRecognizer.addTarget(self, action: #selector(MainTabBarController.tabBarLongPressGestureRecognizerHandler(_:)))
|
||||||
tabBar.addGestureRecognizer(tabBarLongPressGestureRecognizer)
|
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()
|
updateTabBarDisplay()
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
|
@ -269,6 +277,7 @@ extension MainTabBarController {
|
||||||
super.traitCollectionDidChange(previousTraitCollection)
|
super.traitCollectionDidChange(previousTraitCollection)
|
||||||
|
|
||||||
updateTabBarDisplay()
|
updateTabBarDisplay()
|
||||||
|
updateAvatarButtonAppearance()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -340,6 +349,11 @@ extension MainTabBarController {
|
||||||
self.avatarButton.setContentHuggingPriority(.required - 1, for: .vertical)
|
self.avatarButton.setContentHuggingPriority(.required - 1, for: .vertical)
|
||||||
self.avatarButton.isUserInteractionEnabled = false
|
self.avatarButton.isUserInteractionEnabled = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private func updateAvatarButtonAppearance() {
|
||||||
|
avatarButton.borderColor = currentTab.value == .me ? .label : .systemFill
|
||||||
|
avatarButton.setNeedsLayout()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension MainTabBarController {
|
extension MainTabBarController {
|
||||||
|
|
Loading…
Reference in New Issue