Prechádzať zdrojové kódy

社区顶部栏完成

南鑫林 5 rokov pred
rodič
commit
b305a509c5

+ 4 - 0
RainbowPlanet/RainbowPlanet.xcodeproj/project.pbxproj

@@ -315,6 +315,7 @@
 		A7DF50D822A4FAFC00998908 /* ProductDetailEvaluationImageCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7DF50D722A4FAFC00998908 /* ProductDetailEvaluationImageCollectionViewCell.swift */; };
 		A7DF50DF22A5590200998908 /* BrowsePicturesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7DF50DE22A5590200998908 /* BrowsePicturesViewController.swift */; };
 		A7DF50E322A55AB600998908 /* BrowsePicturesPagerViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7DF50E222A55AB600998908 /* BrowsePicturesPagerViewCell.swift */; };
+		A7F2D6BD22B09F930093000B /* CommunityNavigationBarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7F2D6BC22B09F930093000B /* CommunityNavigationBarView.swift */; };
 		A7FF1555228AC27600A85748 /* ProductAllCommentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7FF1554228AC27600A85748 /* ProductAllCommentView.swift */; };
 		A7FF1557228AC3E800A85748 /* ProductAllCommentViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7FF1556228AC3E800A85748 /* ProductAllCommentViewController.swift */; };
 		A7FF1560228C693D00A85748 /* OrderViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7FF155F228C693D00A85748 /* OrderViewController.swift */; };
@@ -757,6 +758,7 @@
 		A7DF50DE22A5590200998908 /* BrowsePicturesViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BrowsePicturesViewController.swift; sourceTree = "<group>"; };
 		A7DF50E222A55AB600998908 /* BrowsePicturesPagerViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BrowsePicturesPagerViewCell.swift; sourceTree = "<group>"; };
 		A7E03A30F40582782EC5DA89 /* Pods_RainbowPlanetTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_RainbowPlanetTests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
+		A7F2D6BC22B09F930093000B /* CommunityNavigationBarView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CommunityNavigationBarView.swift; sourceTree = "<group>"; };
 		A7FF1554228AC27600A85748 /* ProductAllCommentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProductAllCommentView.swift; sourceTree = "<group>"; };
 		A7FF1556228AC3E800A85748 /* ProductAllCommentViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProductAllCommentViewController.swift; sourceTree = "<group>"; };
 		A7FF155F228C693D00A85748 /* OrderViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OrderViewController.swift; sourceTree = "<group>"; };
@@ -1277,6 +1279,7 @@
 		A719EE6922AF43EE001AAC98 /* View */ = {
 			isa = PBXGroup;
 			children = (
+				A7F2D6BC22B09F930093000B /* CommunityNavigationBarView.swift */,
 			);
 			path = View;
 			sourceTree = "<group>";
@@ -3848,6 +3851,7 @@
 				A7BB685922696B9200AB07A2 /* SelfRecommendationCollectionViewCell.swift in Sources */,
 				A7636AC822682BAF00374F9E /* LocationView.swift in Sources */,
 				A738D205225AF90D00EEE860 /* WeChatpayOrderModel.swift in Sources */,
+				A7F2D6BD22B09F930093000B /* CommunityNavigationBarView.swift in Sources */,
 				A7274C5C228EE636000E3A07 /* LBXScanLineAnimation.swift in Sources */,
 				A739121A229F75F50033177E /* JXPagingMainTableView.swift in Sources */,
 				A7CC7524227190FB003C4F38 /* AccountSecurityView.swift in Sources */,

+ 111 - 0
RainbowPlanet/RainbowPlanet/Modules/CommunityModule/Community/View/CommunityNavigationBarView.swift

@@ -0,0 +1,111 @@
+//
+//  CommunityNavigationBarView.swift
+//  RainbowPlanet
+//
+//  Created by 南鑫林 on 2019/6/12.
+//  Copyright © 2019 RainbowPlanet. All rights reserved.
+//
+
+import UIKit
+
+class CommunityNavigationBarView: BaseView {
+    
+    typealias SearchClosure = () -> Void
+    var searchClosure:SearchClosure?
+    
+    override func setupViews() {
+        addSubview(leftButton)
+        addSubview(rightButton)
+        addSubview(searchBgView)
+        searchBgView.addSubview(searchIconImageView)
+        searchBgView.addSubview(searchTextField)
+    }
+    
+    override func setupLayouts() {
+        
+        leftButton.snp.makeConstraints { (make) in
+            make.centerY.equalToSuperview()
+            make.left.equalToSuperview().offset(16)
+            make.size.equalTo(20)
+        }
+        
+        rightButton.snp.makeConstraints { (make) in
+            make.centerY.equalToSuperview()
+            make.right.equalToSuperview().offset(-14)
+            make.height.equalTo(20)
+            make.width.greaterThanOrEqualTo(20)
+        }
+        rightButton.layoutButton(edgeInsetsStyle: ButtonEdgeInsetsStyle.left, imageTitleSpace: 2)
+        
+        searchBgView.snp.makeConstraints { (make) in
+            make.centerY.equalToSuperview()
+            make.height.equalTo(30)
+            make.right.equalTo(rightButton.snp.left).offset(-10)
+            make.left.equalTo(leftButton.snp.right).offset(10)
+        }
+        
+        searchIconImageView.snp.makeConstraints { (make) in
+            make.centerY.equalToSuperview()
+            make.left.equalToSuperview().offset(15)
+            make.size.equalTo(17)
+        }
+
+        searchTextField.snp.makeConstraints { (make) in
+            make.centerY.equalToSuperview()
+            make.left.equalTo(searchIconImageView.snp.right).offset(6)
+            make.height.equalTo(30)
+        }
+        
+    }
+    
+    lazy var leftButton: UIButton = {
+        let leftButton = UIButton(type: UIButton.ButtonType.custom)
+        leftButton.setImage(kImage(name: "navbar_address"), for: UIControl.State.normal)
+        return leftButton
+    }()
+    
+    lazy var rightButton: UIButton = {
+        let rightButton = UIButton(type: UIButton.ButtonType.custom)
+        rightButton.setImage(kImage(name: "navbar_class"), for: UIControl.State.normal)
+        rightButton.setTitle("999", for: UIControl.State.normal)
+        rightButton.setTitleColor(kFFA42FColor, for: UIControl.State.normal)
+        rightButton.titleLabel?.font = kMediumFont16
+        return rightButton
+    }()
+    
+    private lazy var searchBgView: UIView = {
+        let searchBgView = UIView()
+        searchBgView.backgroundColor = kf7f8faColor
+        searchBgView.cornerRadius = 15
+        searchBgView.masksToBounds = true
+        searchBgView.addTapGesture(1, target: self, action: #selector(searchClick))
+        return searchBgView
+    }()
+    
+    private lazy var searchIconImageView: UIImageView = {
+        let searchIconImageView = UIImageView()
+        searchIconImageView.image = kImage(name: "navbar_search")
+        return searchIconImageView
+    }()
+    
+    private lazy var searchTextField: UITextField = {
+        let searchTextField = UITextField()
+        searchTextField.placeholder = "大家都在搜"
+        searchTextField.tintColor = kFFA42FColor
+        searchTextField.textColor = k333333Color
+        searchTextField.returnKeyType = .done
+        searchTextField.font = kScaleRegularFont14
+        searchTextField.borderStyle = .none
+        searchTextField.isEnabled = false
+        return searchTextField
+    }()
+    
+    
+    /// 搜索点击
+    @objc func searchClick() {
+        if let searchClosure = searchClosure {
+            searchClosure()
+        }
+    }
+
+}

+ 46 - 14
RainbowPlanet/RainbowPlanet/Modules/CommunityModule/Community/ViewController/CommunityViewController.swift

@@ -15,31 +15,63 @@ class CommunityViewController: BaseViewController {
         super.viewDidLoad()
         setupViews()
         setupLayouts()
+        setupData()
     }
     
     override func setupViews() {
+        navigationBar.isHidden = true
         view.addSubview(segmentedView)
         view.addSubview(listContainerView)
+        view.addSubview(communityNavigationBarView)
+        
     }
     
     override func setupLayouts() {
         
+        communityNavigationBarView.snp.makeConstraints { (make) in
+            make.top.equalTo(kSafeStatusBarHeight)
+            make.left.right.equalToSuperview()
+            make.height.equalTo(kNavBarHeight)
+        }
+        
         segmentedView.snp.makeConstraints { (make) in
-            make.left.equalToSuperview().offset(100 * kScaleWidth)
-            make.right.equalToSuperview().offset(-100 * kScaleWidth)
-            make.height.equalTo(48 * kScaleWidth)
+            make.left.equalToSuperview().offset(100)
+            make.right.equalToSuperview().offset(-100)
+            make.height.equalTo(48)
             make.top.equalTo(kNavBarTotalHeight)
-            
         }
+        
         listContainerView.snp.makeConstraints { (make) in
             make.top.equalTo(segmentedView.snp.bottom)
             make.left.right.bottom.equalToSuperview()
         }
     }
+    
+    override func setupData() {
+        //发布
+        communityNavigationBarView.leftButton.rx.tap.subscribe(onNext: { (data) in
+            
+        }).disposed(by: disposeBag)
+        //搜索
+        communityNavigationBarView.searchClosure = {
+            
+        }
+        //彩虹豆
+        communityNavigationBarView.rightButton.rx.tap.subscribe(onNext: { (data) in
+            
+        }).disposed(by: disposeBag)
+    }
+    
+    
+    /// navigationBar
+    private lazy var communityNavigationBarView: CommunityNavigationBarView = {
+        let communityNavigationBarView = CommunityNavigationBarView()
+        return communityNavigationBarView
+    }()
 
     
     //1.初始化JXSegmentedViewx
-    lazy var segmentedView: JXSegmentedView = {
+    private lazy var segmentedView: JXSegmentedView = {
         let segmentedView = JXSegmentedView()
         segmentedView.delegate = self
         segmentedView.dataSource = segmentedDataSource
@@ -47,13 +79,13 @@ class CommunityViewController: BaseViewController {
         segmentedView.contentScrollView = listContainerView.scrollView
         segmentedView.selectItemAt(index: 0)
         segmentedView.defaultSelectedIndex = 0
-        segmentedView.contentEdgeInsetLeft = 4 * kScaleWidth
-        segmentedView.contentEdgeInsetRight = 4 * kScaleWidth
+        segmentedView.contentEdgeInsetLeft = 4
+        segmentedView.contentEdgeInsetRight = 4
         return segmentedView
     }()
     
     //2.初始化dataSource
-    lazy var segmentedDataSource: JXSegmentedTitleDataSource = {
+    private lazy var segmentedDataSource: JXSegmentedTitleDataSource = {
         let segmentedDataSource = JXSegmentedTitleDataSource()
         segmentedDataSource.titles = ["关注","推荐","星球"]
         segmentedDataSource.isTitleColorGradientEnabled = true
@@ -61,8 +93,8 @@ class CommunityViewController: BaseViewController {
         segmentedDataSource.isTitleZoomEnabled = true
         segmentedDataSource.titleNormalColor = kbbbbbbColor
         segmentedDataSource.titleSelectedColor = k333333Color
-        segmentedDataSource.titleNormalFont = kScaleRegularFont14!
-        segmentedDataSource.titleSelectedFont = kScaleBoldFont22
+        segmentedDataSource.titleNormalFont = kRegularFont14!
+        segmentedDataSource.titleSelectedFont = kBoldFont22
         
         //reloadData(selectedIndex:)方法一定要调用,方法内部会刷新数据源数组
         segmentedDataSource.reloadData(selectedIndex: 0)
@@ -70,16 +102,16 @@ class CommunityViewController: BaseViewController {
         return segmentedDataSource
     }()
     //3.初始化指示器indicator
-    lazy var indicator: JXSegmentedIndicatorLineView = {
+    private lazy var indicator: JXSegmentedIndicatorLineView = {
         let indicator = JXSegmentedIndicatorLineView()
         indicator.indicatorColor = k333333Color
-        indicator.indicatorHeight = 4 * kScaleWidth
-        indicator.indicatorWidth = 20 * kScaleWidth
+        indicator.indicatorHeight = 4
+        indicator.indicatorWidth = 20
         return indicator
     }()
     
     //4.初始化JXSegmentedListContainerView
-    lazy var listContainerView: JXSegmentedListContainerView = {
+    private lazy var listContainerView: JXSegmentedListContainerView = {
         let listContainerView = JXSegmentedListContainerView(dataSource: self)
         listContainerView.didAppearPercent = 0.01
         listContainerView.defaultSelectedIndex = 0