Commit 032bc955 authored by Steven杜宇's avatar Steven杜宇

// 我的好友

parent 276b2a29
...@@ -78,17 +78,22 @@ class YHCommunityViewController: YHBaseViewController { ...@@ -78,17 +78,22 @@ class YHCommunityViewController: YHBaseViewController {
var unreadCount:Int = 0 { var unreadCount:Int = 0 {
didSet { didSet {
self.unreadLabel.isHidden = (self.unreadCount <= 0) self.updateUnreadCount(self.unreadCount)
if 0 < self.unreadCount && self.unreadCount < 100 { }
self.unreadLabel.text = "\(self.unreadCount)" }
} else if self.unreadCount >= 100 {
func updateUnreadCount(_ count : Int) {
self.unreadLabel.isHidden = (count <= 0)
if 0 < count && count < 100 {
self.unreadLabel.text = "\(count)"
} else if count >= 100 {
self.unreadLabel.text = "99+" self.unreadLabel.text = "99+"
} }
var width = unreadHeight var width = unreadHeight
var leftMargin = -8 var leftMargin = -8
if 10 <= self.unreadCount && self.unreadCount < 100 { if 10 <= count && count < 100 {
width = 22.0 width = 22.0
} else if self.unreadCount >= 100 { } else if count >= 100 {
width = 30.0 width = 30.0
leftMargin = -14 leftMargin = -14
} }
...@@ -97,7 +102,6 @@ class YHCommunityViewController: YHBaseViewController { ...@@ -97,7 +102,6 @@ class YHCommunityViewController: YHBaseViewController {
make.left.equalTo(self.friendsBtn.snp.right).offset(leftMargin) make.left.equalTo(self.friendsBtn.snp.right).offset(leftMargin)
} }
} }
}
@objc func didBackBtnClicked() { @objc func didBackBtnClicked() {
self.navigationController?.popViewController(animated: true) self.navigationController?.popViewController(animated: true)
...@@ -206,8 +210,7 @@ extension YHCommunityViewController: JXSegmentedViewDelegate { ...@@ -206,8 +210,7 @@ extension YHCommunityViewController: JXSegmentedViewDelegate {
if segmentedView.selectedIndex == 0 { if segmentedView.selectedIndex == 0 {
bgImgV.isHidden = false bgImgV.isHidden = false
friendsBtn.isHidden = false friendsBtn.isHidden = false
let count = self.unreadCount self.updateUnreadCount(self.unreadCount)
self.unreadCount = count
segmentedDataSource.titleNormalColor = UIColor(hex: 0xFFFFFF, alpha: 0.6) segmentedDataSource.titleNormalColor = UIColor(hex: 0xFFFFFF, alpha: 0.6)
segmentedDataSource.titleSelectedColor = .white segmentedDataSource.titleSelectedColor = .white
let indicator = JXSegmentedIndicatorLineView() let indicator = JXSegmentedIndicatorLineView()
...@@ -217,7 +220,7 @@ extension YHCommunityViewController: JXSegmentedViewDelegate { ...@@ -217,7 +220,7 @@ extension YHCommunityViewController: JXSegmentedViewDelegate {
} else { } else {
bgImgV.isHidden = true bgImgV.isHidden = true
friendsBtn.isHidden = true friendsBtn.isHidden = true
self.unreadCount = 0 self.updateUnreadCount(0)
segmentedDataSource.titleNormalColor = UIColor(hex: 0x94a3b8) segmentedDataSource.titleNormalColor = UIColor(hex: 0x94a3b8)
segmentedDataSource.titleSelectedColor = UIColor.mainTextColor segmentedDataSource.titleSelectedColor = UIColor.mainTextColor
let indicator = JXSegmentedIndicatorLineView() let indicator = JXSegmentedIndicatorLineView()
......
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