|
@@ -11,6 +11,10 @@ import JXSegmentedView
|
|
import SwiftyMediator
|
|
import SwiftyMediator
|
|
import Kingfisher
|
|
import Kingfisher
|
|
|
|
|
|
|
|
+var communityNavigationBarIsHidden: Bool = false
|
|
|
|
+
|
|
|
|
+var communityIndex: Int = 1
|
|
|
|
+
|
|
enum CommunityModuleTopType : String {
|
|
enum CommunityModuleTopType : String {
|
|
case communityModuleFollowTop = "CommunityModuleFollowTop"
|
|
case communityModuleFollowTop = "CommunityModuleFollowTop"
|
|
case communityModuleRecommendTop = "CommunityModuleRecommendTop"
|
|
case communityModuleRecommendTop = "CommunityModuleRecommendTop"
|
|
@@ -51,35 +55,35 @@ class CommunityViewController: BaseViewController {
|
|
}
|
|
}
|
|
|
|
|
|
override func setupLayouts() {
|
|
override func setupLayouts() {
|
|
-
|
|
|
|
- navigationBarbgView.snp.makeConstraints { (make) in
|
|
|
|
- make.top.equalTo(kNavBarTotalHeight+48)
|
|
|
|
- make.left.right.equalToSuperview()
|
|
|
|
- make.height.equalTo(62)
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+
|
|
communityNavigationBarView.snp.makeConstraints { (make) in
|
|
communityNavigationBarView.snp.makeConstraints { (make) in
|
|
make.top.equalTo(kSafeStatusBarHeight)
|
|
make.top.equalTo(kSafeStatusBarHeight)
|
|
make.left.right.equalToSuperview()
|
|
make.left.right.equalToSuperview()
|
|
make.height.equalTo(kNavBarHeight)
|
|
make.height.equalTo(kNavBarHeight)
|
|
}
|
|
}
|
|
-
|
|
|
|
segmentedView.snp.makeConstraints { (make) in
|
|
segmentedView.snp.makeConstraints { (make) in
|
|
make.left.equalToSuperview()
|
|
make.left.equalToSuperview()
|
|
make.right.equalToSuperview()
|
|
make.right.equalToSuperview()
|
|
make.height.equalTo(48)
|
|
make.height.equalTo(48)
|
|
make.top.equalTo(kNavBarTotalHeight)
|
|
make.top.equalTo(kNavBarTotalHeight)
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
listContainerView.snp.makeConstraints { (make) in
|
|
listContainerView.snp.makeConstraints { (make) in
|
|
make.top.equalTo(segmentedView.snp.bottom)
|
|
make.top.equalTo(segmentedView.snp.bottom)
|
|
make.left.right.bottom.equalToSuperview()
|
|
make.left.right.bottom.equalToSuperview()
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ navigationBarbgView.snp.makeConstraints { (make) in
|
|
|
|
+ make.top.equalTo(segmentedView.snp.bottom)
|
|
|
|
+ make.left.right.equalToSuperview()
|
|
|
|
+ make.height.equalTo(62)
|
|
|
|
+ }
|
|
linebgImageView.snp.makeConstraints { (make) in
|
|
linebgImageView.snp.makeConstraints { (make) in
|
|
make.top.equalTo(segmentedView.snp.bottom)
|
|
make.top.equalTo(segmentedView.snp.bottom)
|
|
make.left.right.equalToSuperview()
|
|
make.left.right.equalToSuperview()
|
|
make.height.equalTo(20)
|
|
make.height.equalTo(20)
|
|
}
|
|
}
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
override func setupData() {
|
|
override func setupData() {
|
|
@@ -199,6 +203,36 @@ class CommunityViewController: BaseViewController {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // 滚动
|
|
|
|
+ observe = NotificationCenter.default.addObserver(forName: NSNotification.Name("CommunityViewControllerScrollView"), object: nil, queue: OperationQueue.main) {[weak self] (notification) in
|
|
|
|
+ let navigationBarIsHidden = notification.object as? Bool
|
|
|
|
+
|
|
|
|
+ if communityNavigationBarIsHidden { //隐藏
|
|
|
|
+ if !(navigationBarIsHidden!) {
|
|
|
|
+ self?.communityNavigationBarView.snp.updateConstraints { (make) in
|
|
|
|
+ make.top.equalTo(kSafeStatusBarHeight)
|
|
|
|
+ }
|
|
|
|
+ self?.segmentedView.snp.updateConstraints { (make) in
|
|
|
|
+ make.top.equalTo(kNavBarTotalHeight)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }else {
|
|
|
|
+ if (navigationBarIsHidden!) {
|
|
|
|
+ self?.communityNavigationBarView.snp.updateConstraints { (make) in
|
|
|
|
+ make.top.equalTo(-kNavBarTotalHeight)
|
|
|
|
+ }
|
|
|
|
+ self?.segmentedView.snp.updateConstraints { (make) in
|
|
|
|
+ make.top.equalTo(kSafeStatusBarHeight)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ communityNavigationBarIsHidden = navigationBarIsHidden!
|
|
|
|
+ UIView.animate(withDuration: 0.5, animations: { [weak self] in
|
|
|
|
+ self?.view.layoutIfNeeded()
|
|
|
|
+ self?.listContainerView.layoutSubviews()
|
|
|
|
+ }) { (complete) in}
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
// 分享
|
|
// 分享
|
|
@@ -359,10 +393,6 @@ class CommunityViewController: BaseViewController {
|
|
|
|
|
|
var index : Int?
|
|
var index : Int?
|
|
|
|
|
|
-// override func didReceiveMemoryWarning() {
|
|
|
|
-// super.didReceiveMemoryWarning()
|
|
|
|
-// }
|
|
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
extension CommunityViewController : JXSegmentedViewDelegate {
|
|
extension CommunityViewController : JXSegmentedViewDelegate {
|
|
@@ -373,11 +403,24 @@ extension CommunityViewController : JXSegmentedViewDelegate {
|
|
}
|
|
}
|
|
if index == 1 {
|
|
if index == 1 {
|
|
communityModuleTopType = .communityModuleRecommendTop
|
|
communityModuleTopType = .communityModuleRecommendTop
|
|
-
|
|
|
|
}
|
|
}
|
|
if index == 2 {
|
|
if index == 2 {
|
|
communityModuleTopType = .communityModulePlanetTop
|
|
communityModuleTopType = .communityModulePlanetTop
|
|
|
|
+ if (communityNavigationBarIsHidden) {
|
|
|
|
+ self.communityNavigationBarView.snp.updateConstraints { (make) in
|
|
|
|
+ make.top.equalTo(kSafeStatusBarHeight)
|
|
|
|
+ }
|
|
|
|
+ self.segmentedView.snp.updateConstraints { (make) in
|
|
|
|
+ make.top.equalTo(kNavBarTotalHeight)
|
|
|
|
+ }
|
|
|
|
+ communityNavigationBarIsHidden = false
|
|
|
|
+ UIView.animate(withDuration: 0.5, animations: { [weak self] in
|
|
|
|
+ self?.view.layoutIfNeeded()
|
|
|
|
+ self?.listContainerView.layoutSubviews()
|
|
|
|
+ }) { (complete) in}
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+ communityIndex = index
|
|
listContainerView.didClickSelectedItem(at: index)
|
|
listContainerView.didClickSelectedItem(at: index)
|
|
|
|
|
|
self.index = index
|
|
self.index = index
|