Commit 443ba274 authored by Steven杜宇's avatar Steven杜宇

// 红点逻辑

parent 49b497c6
...@@ -91,23 +91,28 @@ class YHTabBarViewController: ESTabBarController { ...@@ -91,23 +91,28 @@ class YHTabBarViewController: ESTabBarController {
if YHButlerServiceManager.shared.isUatAllowed() { if YHButlerServiceManager.shared.isUatAllowed() {
unreadCount = self.msgViewModel.unreadTotalCount + YHButlerServiceManager.shared.unreadCount unreadCount = self.msgViewModel.unreadTotalCount + YHButlerServiceManager.shared.unreadCount
} }
let isHaveUnreadMsg = unreadCount > 0
// 朋友tab小红点显示逻辑 // 朋友tab小红点显示逻辑
self.showFriendTabRedBadge(isHaveUnreadMsg) self.showFriendTabRedBadgeNumber(unreadCount)
} }
} }
} }
@objc func clearFriendTabBadge() { @objc func clearFriendTabBadge() {
showFriendTabRedBadge(false) showFriendTabRedBadgeNumber(0)
} }
func showFriendTabRedBadge(_ isShow: Bool) { func showFriendTabRedBadgeNumber(_ num: Int) {
if let vcs = self.viewControllers, vcs.count > 2 { if let vcs = self.viewControllers, vcs.count > 2 {
let friendVC = vcs[2] let friendVC = vcs[2]
if let tabBarItem = friendVC.tabBarItem as? ESTabBarItem { if let tabBarItem = friendVC.tabBarItem as? ESTabBarItem {
// badgeValue 空字符串会显示小红点 nil则隐藏 // badgeValue 空字符串会显示小红点 nil则隐藏
tabBarItem.badgeValue = isShow ? "" : nil var badge: String? = nil
if num > 99 {
badge = "99+"
} else if 0 < num, num <= 99 {
badge = "\(num)"
}
tabBarItem.badgeValue = badge
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment