Commit 67723368 authored by pete谢兆麟's avatar pete谢兆麟

活动逻辑修改

parent a199fe52
...@@ -65,18 +65,18 @@ class YHCommunityViewController: YHBaseViewController { ...@@ -65,18 +65,18 @@ class YHCommunityViewController: YHBaseViewController {
return cleanBtn return cleanBtn
}() }()
lazy var friendsBtn:UIButton = { // lazy var friendsBtn:UIButton = {
let btn = UIButton() // let btn = UIButton()
btn.setImage(UIImage(named: "people_friends_btn"), for: .normal) // btn.setImage(UIImage(named: "people_friends_btn"), for: .normal)
btn.setTitle("好友", for: .normal) // btn.setTitle("好友", for: .normal)
btn.setTitleColor(UIColor.white, for: .normal) // btn.setTitleColor(UIColor.white, for: .normal)
btn.iconInLeft(spacing: 4.0) // btn.iconInLeft(spacing: 4.0)
btn.titleLabel?.font = UIFont.PFSC_R(ofSize:15) // btn.titleLabel?.font = UIFont.PFSC_R(ofSize:15)
btn.YH_clickEdgeInsets = UIEdgeInsets(top: 20, left: 20, bottom: 20, right: 20) // btn.YH_clickEdgeInsets = UIEdgeInsets(top: 20, left: 20, bottom: 20, right: 20)
btn.addTarget(self, action: #selector(didFriendsBtnClicked), for: .touchUpInside) // btn.addTarget(self, action: #selector(didFriendsBtnClicked), for: .touchUpInside)
return btn // return btn
}() // }()
//
let unreadHeight = 16.0 let unreadHeight = 16.0
lazy var unreadLabel:UILabel = { lazy var unreadLabel:UILabel = {
let label = UILabel() let label = UILabel()
...@@ -92,30 +92,30 @@ class YHCommunityViewController: YHBaseViewController { ...@@ -92,30 +92,30 @@ class YHCommunityViewController: YHBaseViewController {
var unreadCount:Int = 0 { var unreadCount:Int = 0 {
didSet { didSet {
self.updateUnreadCount(self.unreadCount) // self.updateUnreadCount(self.unreadCount)
} }
} }
func updateUnreadCount(_ count : Int) { // func updateUnreadCount(_ count : Int) {
self.unreadLabel.isHidden = (count <= 0) // self.unreadLabel.isHidden = (count <= 0)
if 0 < count && count < 100 { // if 0 < count && count < 100 {
self.unreadLabel.text = "\(count)" // self.unreadLabel.text = "\(count)"
} else if count >= 100 { // } 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 <= count && count < 100 { // if 10 <= count && count < 100 {
width = 22.0 // width = 22.0
} else if count >= 100 { // } else if count >= 100 {
width = 30.0 // width = 30.0
leftMargin = -14 // leftMargin = -14
} // }
self.unreadLabel.snp.updateConstraints { make in // self.unreadLabel.snp.updateConstraints { make in
make.width.equalTo(width) // make.width.equalTo(width)
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)
...@@ -197,20 +197,20 @@ class YHCommunityViewController: YHBaseViewController { ...@@ -197,20 +197,20 @@ class YHCommunityViewController: YHBaseViewController {
make.right.equalToSuperview().offset(-20) make.right.equalToSuperview().offset(-20)
} }
self.view.addSubview(friendsBtn) // self.view.addSubview(friendsBtn)
friendsBtn.snp.makeConstraints { make in // friendsBtn.snp.makeConstraints { make in
make.width.equalTo(54.0) // make.width.equalTo(54.0)
make.height.equalTo(21) // make.height.equalTo(21)
make.right.equalTo(-20) // make.right.equalTo(-20)
make.top.equalTo(12+k_Height_safeAreaInsetsTop()) // make.top.equalTo(12+k_Height_safeAreaInsetsTop())
} // }
//
self.friendsBtn.addSubview(self.unreadLabel) // self.friendsBtn.addSubview(self.unreadLabel)
self.unreadLabel.snp.makeConstraints { make in // self.unreadLabel.snp.makeConstraints { make in
make.width.height.equalTo(unreadHeight) // make.width.height.equalTo(unreadHeight)
make.left.equalTo(self.friendsBtn.snp.right).offset(-8) // make.left.equalTo(self.friendsBtn.snp.right).offset(-8)
make.top.equalTo(self.friendsBtn.snp.top).offset(-8) // make.top.equalTo(self.friendsBtn.snp.top).offset(-8)
} // }
segmentedView.snp.makeConstraints { make in segmentedView.snp.makeConstraints { make in
make.left.right.equalToSuperview() make.left.right.equalToSuperview()
...@@ -265,7 +265,7 @@ class YHCommunityViewController: YHBaseViewController { ...@@ -265,7 +265,7 @@ class YHCommunityViewController: YHBaseViewController {
self.friendViewModel.getMyFriendList { success, error in self.friendViewModel.getMyFriendList { success, error in
let unreadCount = self.friendViewModel.friendListModel.applyFriends.count let unreadCount = self.friendViewModel.friendListModel.applyFriends.count
self.unreadCount = unreadCount self.unreadCount = unreadCount
self.friendsBtn.isHidden = self.segmentedView.selectedIndex != 1 // self.friendsBtn.isHidden = self.segmentedView.selectedIndex != 1
} }
} else { } else {
self.unreadCount = 0 self.unreadCount = 0
...@@ -289,22 +289,22 @@ class YHCommunityViewController: YHBaseViewController { ...@@ -289,22 +289,22 @@ class YHCommunityViewController: YHBaseViewController {
extension YHCommunityViewController: JXSegmentedViewDelegate { extension YHCommunityViewController: JXSegmentedViewDelegate {
func segmentedView(_ segmentedView: JXSegmentedView, didSelectedItemAt index: Int) { func segmentedView(_ segmentedView: JXSegmentedView, didSelectedItemAt index: Int) {
navigationController?.interactivePopGestureRecognizer?.isEnabled = (segmentedView.selectedIndex == 0) navigationController?.interactivePopGestureRecognizer?.isEnabled = (segmentedView.selectedIndex == 0)
if segmentedView.selectedIndex == 1 { // 人脉 // if segmentedView.selectedIndex == 1 { // 人脉
bgImgV.isHidden = false // bgImgV.isHidden = false
friendsBtn.isHidden = false // friendsBtn.isHidden = false
cleanAllMsgBtn.isHidden = true // cleanAllMsgBtn.isHidden = true
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()
indicator.indicatorWidth = 16 // indicator.indicatorWidth = 16
indicator.indicatorHeight = 2 // indicator.indicatorHeight = 2
indicator.indicatorCornerRadius = 0.0 // indicator.indicatorCornerRadius = 0.0
indicator.indicatorColor = UIColor.white // indicator.indicatorColor = UIColor.white
segmentedView.indicators = [indicator] // segmentedView.indicators = [indicator]
//
} else { // 非人脉tab // } else { // 非人脉tab
bgImgV.isHidden = true bgImgV.isHidden = true
friendsBtn.isHidden = true // friendsBtn.isHidden = true
cleanAllMsgBtn.isHidden = segmentedView.selectedIndex != 0 cleanAllMsgBtn.isHidden = segmentedView.selectedIndex != 0
segmentedDataSource.titleNormalColor = UIColor.yhGreyColor segmentedDataSource.titleNormalColor = UIColor.yhGreyColor
segmentedDataSource.titleSelectedColor = UIColor.mainTextColor segmentedDataSource.titleSelectedColor = UIColor.mainTextColor
...@@ -314,7 +314,7 @@ extension YHCommunityViewController: JXSegmentedViewDelegate { ...@@ -314,7 +314,7 @@ extension YHCommunityViewController: JXSegmentedViewDelegate {
indicator.indicatorCornerRadius = 0.0 indicator.indicatorCornerRadius = 0.0
indicator.indicatorColor = UIColor.brandMainColor indicator.indicatorColor = UIColor.brandMainColor
segmentedView.indicators = [indicator] segmentedView.indicators = [indicator]
} // }
segmentedView.dataSource = segmentedDataSource segmentedView.dataSource = segmentedDataSource
self.segmentedView.reloadDataWithoutListContainer() self.segmentedView.reloadDataWithoutListContainer()
} }
......
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