Update logic for thread list bar button item

This commit is contained in:
ismailgulek
2021-12-02 14:30:30 +03:00
parent d5b5a2d785
commit 3e6637f5a8
2 changed files with 82 additions and 6 deletions
@@ -50,6 +50,13 @@ class BadgedBarButtonItem: UIBarButtonItem {
}
}
private var shouldHideBadge: Bool {
guard let text = badgeText else {
return true
}
return text.isEmpty || text == "0" || text == "nil" || text == "null"
}
init(withBaseButton baseButton: UIButton) {
self.baseButton = baseButton
badgeBackgroundColor = .gray
@@ -71,6 +78,7 @@ class BadgedBarButtonItem: UIBarButtonItem {
}
private func updateBadgeLabel() {
badgeLabel.isHidden = shouldHideBadge
badgeLabel.backgroundColor = badgeBackgroundColor
badgeLabel.font = badgeFont
badgeLabel.textColor = badgeTextColor