Commit 06b601d7 authored by Steven杜宇's avatar Steven杜宇

// 好友未读消息

parent fffea899
...@@ -11,7 +11,7 @@ import JXSegmentedView ...@@ -11,7 +11,7 @@ import JXSegmentedView
class YHCommunityViewController: YHBaseViewController { class YHCommunityViewController: YHBaseViewController {
var defaltIndex: Int = 0 var defaltIndex: Int = 0
let friendViewModel = YHMatchUserViewModel()
let arrItemTitles = ["人脉","活动"] let arrItemTitles = ["人脉","活动"]
var arrItemVCs : [YHBaseViewController] = [] var arrItemVCs : [YHBaseViewController] = []
...@@ -56,16 +56,58 @@ class YHCommunityViewController: YHBaseViewController { ...@@ -56,16 +56,58 @@ class YHCommunityViewController: YHBaseViewController {
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.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.addTarget(self, action: #selector(didFriendsBtnClicked), for: .touchUpInside) btn.addTarget(self, action: #selector(didFriendsBtnClicked), for: .touchUpInside)
return btn return btn
}() }()
let unreadHeight = 16.0
lazy var unreadLabel:UILabel = {
let label = UILabel()
label.textColor = .white
label.textAlignment = .center
label.backgroundColor = .failColor
label.font = .PFSC_M(ofSize: 10)
label.layer.cornerRadius = unreadHeight/2.0
label.clipsToBounds = true
label.isHidden = true
return label
}()
var unreadCount:Int = 0 {
didSet {
self.unreadLabel.isHidden = (self.unreadCount <= 0)
if 0 < self.unreadCount && self.unreadCount < 100 {
self.unreadLabel.text = "\(self.unreadCount)"
} else if self.unreadCount >= 100 {
self.unreadLabel.text = "99+"
}
var width = unreadHeight
var leftMargin = -8
if 10 <= self.unreadCount && self.unreadCount < 100 {
width = 22.0
} else if self.unreadCount >= 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() { @objc func didBackBtnClicked() {
self.navigationController?.popViewController(animated: true) self.navigationController?.popViewController(animated: true)
} }
@objc func didFriendsBtnClicked() { @objc func didFriendsBtnClicked() {
if !YHLoginManager.shared.isLogin() {
YHOneKeyLoginManager.shared.oneKeyLogin()
return
}
let vc = YHMyGoodFriendsVC() let vc = YHMyGoodFriendsVC()
self.navigationController?.pushViewController(vc) self.navigationController?.pushViewController(vc)
} }
...@@ -111,16 +153,23 @@ class YHCommunityViewController: YHBaseViewController { ...@@ -111,16 +153,23 @@ class YHCommunityViewController: YHBaseViewController {
self.view.addSubview(friendsBtn) self.view.addSubview(friendsBtn)
friendsBtn.snp.makeConstraints { make in friendsBtn.snp.makeConstraints { make in
make.width.equalTo(82.0) make.width.equalTo(54.0)
make.height.equalTo(48) make.height.equalTo(21)
make.right.equalToSuperview() make.right.equalTo(-20)
make.top.equalTo(k_Height_safeAreaInsetsTop()) make.top.equalTo(12+k_Height_safeAreaInsetsTop())
}
self.view.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)
} }
} }
override func viewWillAppear(_ animated: Bool) { override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated) super.viewWillAppear(animated)
requestFriendRequest()
//处于第一个item的时候,才允许屏幕边缘手势返回 //处于第一个item的时候,才允许屏幕边缘手势返回
navigationController?.interactivePopGestureRecognizer?.isEnabled = (segmentedView.selectedIndex == 0) navigationController?.interactivePopGestureRecognizer?.isEnabled = (segmentedView.selectedIndex == 0)
} }
...@@ -138,6 +187,17 @@ class YHCommunityViewController: YHBaseViewController { ...@@ -138,6 +187,17 @@ class YHCommunityViewController: YHBaseViewController {
segmentedView.frame = CGRect(x: 0, y: k_Height_safeAreaInsetsTop(), width: view.bounds.size.width, height: 48) segmentedView.frame = CGRect(x: 0, y: k_Height_safeAreaInsetsTop(), width: view.bounds.size.width, height: 48)
listContainerView.frame = CGRect(x: 0, y: k_Height_safeAreaInsetsTop() + 48, width: view.bounds.size.width, height: view.bounds.size.height - 48 - k_Height_safeAreaInsetsTop()) listContainerView.frame = CGRect(x: 0, y: k_Height_safeAreaInsetsTop() + 48, width: view.bounds.size.width, height: view.bounds.size.height - 48 - k_Height_safeAreaInsetsTop())
} }
func requestFriendRequest() {
if YHLoginManager.shared.isLogin() {
self.friendViewModel.getMyFriendList { success, error in
let unreadCount = self.friendViewModel.friendListModel.applyFriends.count
self.unreadCount = unreadCount
}
} else {
self.unreadCount = 0
}
}
} }
extension YHCommunityViewController: JXSegmentedViewDelegate { extension YHCommunityViewController: JXSegmentedViewDelegate {
......
...@@ -170,6 +170,10 @@ class YHPeopleViewController: YHBaseViewController { ...@@ -170,6 +170,10 @@ class YHPeopleViewController: YHBaseViewController {
@objc func didMatchBtnClicked() { @objc func didMatchBtnClicked() {
if !YHLoginManager.shared.isLogin() {
YHOneKeyLoginManager.shared.oneKeyLogin()
return
}
if informationAuthorizeViewModel.model.is_fillin == 1 { if informationAuthorizeViewModel.model.is_fillin == 1 {
startMatchUsers() startMatchUsers()
} else { } else {
......
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