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

活动逻辑修改

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