Переглянути джерело

MessageMain -- to be continued

Chris 5 роки тому
батько
коміт
cf64bd12c5

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

@@ -330,6 +330,7 @@
 		BD108C9722A60C2100837DAB /* HGImagePickerController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD108C9222A60C2100837DAB /* HGImagePickerController.swift */; };
 		BD108C9A22A60C3300837DAB /* HGImage.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = BD108C9822A60C3200837DAB /* HGImage.xcassets */; };
 		BD108C9B22A60C3300837DAB /* HGImage.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = BD108C9922A60C3300837DAB /* HGImage.storyboard */; };
+		BD12203122AF4A010051C7C2 /* MessageMainItemView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD12203022AF4A010051C7C2 /* MessageMainItemView.swift */; };
 		BD1DC6C5228CFD0B00B89C57 /* SwiftMoyaNetWorkServiceOrder.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD1DC6C3228CFD0B00B89C57 /* SwiftMoyaNetWorkServiceOrder.swift */; };
 		BD1DC6C6228CFD0B00B89C57 /* SwiftMoyaServiceOrderApi.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD1DC6C4228CFD0B00B89C57 /* SwiftMoyaServiceOrderApi.swift */; };
 		BD1DC6C9228D005000B89C57 /* OrderCreateParameterModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD1DC6C8228D005000B89C57 /* OrderCreateParameterModel.swift */; };
@@ -344,7 +345,6 @@
 		BD29A92E228F99780018CFC3 /* OrderCommentParameterModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD29A92D228F99780018CFC3 /* OrderCommentParameterModel.swift */; };
 		BD3474F522857B85000908C5 /* CommonPayHeader.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD3474F422857B85000908C5 /* CommonPayHeader.swift */; };
 		BD3AA45822AE63EC00EF4F20 /* MessageMainViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD3AA45722AE63EC00EF4F20 /* MessageMainViewController.swift */; };
-		BD3AA45B22AE64F000EF4F20 /* MessageMainView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD3AA45A22AE64F000EF4F20 /* MessageMainView.swift */; };
 		BD3AA45F22AE6F2500EF4F20 /* MessagePlanetTableCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD3AA45E22AE6F2500EF4F20 /* MessagePlanetTableCell.swift */; };
 		BD6EDF48229007EA009A20FE /* OrderApplyRefundModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD6EDF47229007EA009A20FE /* OrderApplyRefundModel.swift */; };
 		BD7AB83622841A8B0030646A /* ShoppingCartPayOrderItemCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD7AB83522841A8B0030646A /* ShoppingCartPayOrderItemCell.swift */; };
@@ -744,6 +744,7 @@
 		BD108C9222A60C2100837DAB /* HGImagePickerController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HGImagePickerController.swift; sourceTree = "<group>"; };
 		BD108C9822A60C3200837DAB /* HGImage.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = HGImage.xcassets; sourceTree = "<group>"; };
 		BD108C9922A60C3300837DAB /* HGImage.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = HGImage.storyboard; sourceTree = "<group>"; };
+		BD12203022AF4A010051C7C2 /* MessageMainItemView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageMainItemView.swift; sourceTree = "<group>"; };
 		BD1DC6C3228CFD0B00B89C57 /* SwiftMoyaNetWorkServiceOrder.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwiftMoyaNetWorkServiceOrder.swift; sourceTree = "<group>"; };
 		BD1DC6C4228CFD0B00B89C57 /* SwiftMoyaServiceOrderApi.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwiftMoyaServiceOrderApi.swift; sourceTree = "<group>"; };
 		BD1DC6C8228D005000B89C57 /* OrderCreateParameterModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OrderCreateParameterModel.swift; sourceTree = "<group>"; };
@@ -758,7 +759,6 @@
 		BD29A92D228F99780018CFC3 /* OrderCommentParameterModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OrderCommentParameterModel.swift; sourceTree = "<group>"; };
 		BD3474F422857B85000908C5 /* CommonPayHeader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CommonPayHeader.swift; sourceTree = "<group>"; };
 		BD3AA45722AE63EC00EF4F20 /* MessageMainViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageMainViewController.swift; sourceTree = "<group>"; };
-		BD3AA45A22AE64F000EF4F20 /* MessageMainView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageMainView.swift; sourceTree = "<group>"; };
 		BD3AA45E22AE6F2500EF4F20 /* MessagePlanetTableCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessagePlanetTableCell.swift; sourceTree = "<group>"; };
 		BD6EDF47229007EA009A20FE /* OrderApplyRefundModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OrderApplyRefundModel.swift; sourceTree = "<group>"; };
 		BD7AB83522841A8B0030646A /* ShoppingCartPayOrderItemCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShoppingCartPayOrderItemCell.swift; sourceTree = "<group>"; };
@@ -3010,8 +3010,8 @@
 		BD3AA45922AE63FB00EF4F20 /* View */ = {
 			isa = PBXGroup;
 			children = (
-				BD3AA45A22AE64F000EF4F20 /* MessageMainView.swift */,
 				BD3AA45E22AE6F2500EF4F20 /* MessagePlanetTableCell.swift */,
+				BD12203022AF4A010051C7C2 /* MessageMainItemView.swift */,
 			);
 			path = View;
 			sourceTree = "<group>";
@@ -3414,6 +3414,7 @@
 				BDF47D7E22827C3F00941AB9 /* ProductSlidingTopBottomCollectionViewCell.swift in Sources */,
 				BD108C9522A60C2100837DAB /* HGImageCollectionViewCell.swift in Sources */,
 				A7FF1589228C854900A85748 /* OrderDetailBottomView.swift in Sources */,
+				BD12203122AF4A010051C7C2 /* MessageMainItemView.swift in Sources */,
 				BD1DC6C5228CFD0B00B89C57 /* SwiftMoyaNetWorkServiceOrder.swift in Sources */,
 				BD7AB83D228438020030646A /* OrderPayExpressInfoShowCell.swift in Sources */,
 				A72A72C422321DE000B21995 /* Extension+CAGradientLayer.swift in Sources */,
@@ -3696,7 +3697,6 @@
 				BDEF7791228571DC00ED0AC0 /* CommonPayView.swift in Sources */,
 				A71AF0A6226EDDC8001730FE /* SearchViewController.swift in Sources */,
 				BD20F1CF2283CE2300677D8E /* OrderFinishPayView.swift in Sources */,
-				BD3AA45B22AE64F000EF4F20 /* MessageMainView.swift in Sources */,
 				A7A98E4322804851005306E9 /* ShoppingMallSepcialFlowLayout.swift in Sources */,
 				A79057062276EA3D0037F823 /* OpenCityListModel.swift in Sources */,
 				BD7AB838228420310030646A /* ShoppingCartPayOrderHeader.swift in Sources */,

+ 1 - 0
RainbowPlanet/RainbowPlanet/Macro/FontMacro.swift

@@ -41,6 +41,7 @@ let kMediumFont27 = UIFont(name: "PingFang-SC-Medium", size: 27)
 let kMediumFont30 = UIFont(name: "PingFang-SC-Medium", size: 30)
 let kMediumFont35 = UIFont(name: "PingFang-SC-Medium", size: 35)
 
+let kRegularFont9  = UIFont(name: "PingFang-SC-Regular", size: 9)
 let kRegularFont10 = UIFont(name: "PingFang-SC-Regular", size: 10)
 let kRegularFont11 = UIFont(name: "PingFang-SC-Regular", size: 11)
 let kRegularFont12 = UIFont(name: "PingFang-SC-Regular", size: 12)

+ 9 - 0
RainbowPlanet/RainbowPlanet/Modules/MessageModule/MessageMain/View/MessageMainItemView.swift

@@ -0,0 +1,9 @@
+//
+//  MessageMainItemView.swift
+//  RainbowPlanet
+//
+//  Created by Christopher on 2019/6/11.
+//  Copyright © 2019 RainbowPlanet. All rights reserved.
+//  消息首页头部Item
+
+import UIKit

+ 0 - 123
RainbowPlanet/RainbowPlanet/Modules/MessageModule/MessageMain/View/MessageMainView.swift

@@ -1,123 +0,0 @@
-//
-//  MessageMainView.swift
-//  RainbowPlanet
-//
-//  Created by Christopher on 2019/6/10.
-//  Copyright © 2019 RainbowPlanet. All rights reserved.
-//
-
-import UIKit
-
-class MessageMainView: BaseView {
-    
-    typealias CommitOrderBlock = () -> Void
-    var commitOrderBlock : CommitOrderBlock?
-    
-    
-    override func setupViews() {
-        self.backgroundColor = kf7f8faColor
-        
-        addSubview(topView)
-        addSubview(tableView)
-    }
-    
-    override func setupLayouts() {
-        
-        topView.snp.makeConstraints { (make) in
-            make.top.left.right.equalToSuperview().offset(0)
-            make.height.equalTo(104)
-        }
-        
-        tableView.snp.makeConstraints { (make) in
-            make.top.equalTo(topView.snp_bottom).offset(10)
-            make.left.right.equalTo(0)
-            make.bottom.equalToSuperview()
-        }
-    }
-    
-    private lazy var topView: UIView = {
-        let topView = UIView()
-        topView.backgroundColor = UIColor.white
-        return topView
-    }()
-    
-    lazy var tableView: UITableView = {
-        let tableView = UITableView(frame: CGRect.zero, style: UITableView.Style.grouped)
-        tableView.separatorStyle = .none
-        tableView.backgroundColor = kf7f8faColor
-        tableView.dataSource = self
-        tableView.delegate = self
-        tableView.isScrollEnabled = false
-        tableView.estimatedRowHeight = 70
-        tableView.estimatedSectionFooterHeight = 0.000001
-        tableView.estimatedSectionHeaderHeight = 0.000001
-        return tableView
-    }()
-    
-    
-    
-    
-    private lazy var accountBtn: UIButton = {
-        let accountBtn = UIButton(type: UIButton.ButtonType.custom)
-        accountBtn.backgroundColor = kFFA42FColor
-        accountBtn.setTitle("提交订单", for: UIControl.State.normal)
-        accountBtn.setTitleColor(kffffffColor, for: UIControl.State.normal)
-        accountBtn.titleLabel?.font = kScaleRegularFont15
-        accountBtn.cornerRadius = 18
-        accountBtn.masksToBounds = true
-        accountBtn.rx.tap.subscribe(onNext: { [weak self] (data) in
-            if let commitOrderBlock = self?.commitOrderBlock {
-                commitOrderBlock()
-            }
-        }).disposed(by: disposeBag)
-        return accountBtn
-    }()
-    
-    private lazy var prePriceLabel: UILabel = {
-        let prePriceLabel = UILabel()
-        prePriceLabel.text = "合计"
-        prePriceLabel.textColor = k333333Color
-        prePriceLabel.font = kScaleRegularFont16
-        return prePriceLabel
-    }()
-    
-}
-
-// MARK: - tableView dataSource && delegate
-extension MessageMainView : UITableViewDelegate, UITableViewDataSource {
-    
-    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
-        return 2
-    }
-    
-    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
-        switch indexPath.row {
-        case 0:
-            // 星球通知
-            return UITableViewCell()
-        case 1:
-            // 星球活动
-            return UITableViewCell()
-        default:
-            return UITableViewCell()
-        }
-    }
-    
-    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
-        return 70
-    }
-    
-    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
-        switch indexPath.row {
-        case 0:
-            // 星球通知
-            print("点击--星球通知")
-        case 1:
-            // 星球活动
-            print("点击--星球活动")
-        default:
-            return
-        }
-    }
-
-}

+ 32 - 20
RainbowPlanet/RainbowPlanet/Modules/MessageModule/MessageMain/View/MessagePlanetTableCell.swift

@@ -10,6 +10,21 @@ import UIKit
 
 class MessagePlanetTableCell: UITableViewCell {
     
+    var cellRow: Int? {
+        didSet{
+            switch self.cellRow {
+            case 0:
+                iconImageView.image = kImage(name: "page05")
+                titleLabel.text = "星球通知"
+            case 1:
+                iconImageView.image = kImage(name: "page05")
+                titleLabel.text = "星球活动"
+            default:
+                return
+            }
+        }
+    }
+    
     class func cellWith(tableView:UITableView,indexPath:IndexPath) -> MessagePlanetTableCell {
         let ID = "MessagePlanetTableCell"
         tableView.register(MessagePlanetTableCell.self, forCellReuseIdentifier: ID)
@@ -55,55 +70,52 @@ class MessagePlanetTableCell: UITableViewCell {
         titleLabel.snp.makeConstraints { (make) in
             make.top.equalTo(12)
             make.left.equalTo(iconImageView.snp_right).offset(8)
-            make.left.equalToSuperview().offset(30)
-            make.right.equalToSuperview().offset(-30)
+            make.width.equalTo(67)
+            make.height.equalTo(23)
         }
         
         subLabel.snp.makeConstraints { (make) in
-            make.top.equalTo(iconImageView.snp.bottom).offset(16)
-            make.centerX.equalToSuperview()
-            make.left.equalToSuperview().offset(30)
+            make.top.equalTo(titleLabel.snp.bottom).offset(4)
+            make.left.equalTo(titleLabel.snp_left)
             make.right.equalToSuperview().offset(-30)
+            make.height.equalTo(19)
         }
         
         timeLabel.snp.makeConstraints { (make) in
-            make.top.equalTo(iconImageView.snp.bottom).offset(16)
-            make.centerX.equalToSuperview()
-            make.left.equalToSuperview().offset(30)
-            make.right.equalToSuperview().offset(-30)
+            make.top.equalToSuperview().offset(17)
+            make.right.equalToSuperview().offset(-14)
+            make.height.equalTo(13)
         }
         
     }
     
     lazy var iconImageView : UIImageView = {
         let iconImageView = UIImageView()
-        iconImageView.image = kImage(name: "page05")
         return iconImageView
     }()
     
     private lazy var titleLabel: UILabel = {
         let titleLabel = UILabel()
-        titleLabel.text = "购物车内无商品"
         titleLabel.textColor = k333333Color
-        titleLabel.font = kRegularFont14
-        titleLabel.textAlignment = .center
+        titleLabel.font = kRegularFont16
+        titleLabel.textAlignment = .left
         return titleLabel
     }()
     
     private lazy var subLabel: UILabel = {
         let subLabel = UILabel()
-        subLabel.text = "购物车内无商品"
-        subLabel.textColor = k333333Color
-        subLabel.font = kRegularFont14
-        subLabel.textAlignment = .center
+        subLabel.text = "我就是一个消息用来测一测"
+        subLabel.textColor = k999999Color
+        subLabel.font = kRegularFont12
+        subLabel.textAlignment = .left
         return subLabel
     }()
     
     private lazy var timeLabel: UILabel = {
         let timeLabel = UILabel()
-        timeLabel.text = "购物车内无商品"
-        timeLabel.textColor = k333333Color
-        timeLabel.font = kRegularFont14
+        timeLabel.text = "15:00"
+        timeLabel.textColor = k999999Color
+        timeLabel.font = kRegularFont9
         timeLabel.textAlignment = .center
         return timeLabel
     }()

+ 79 - 9
RainbowPlanet/RainbowPlanet/Modules/MessageModule/MessageMain/ViewController/MessageMainViewController.swift

@@ -19,14 +19,23 @@ class MessageMainViewController: BaseViewController {
     
     override func setupViews() {
         navigationBar.title = "消息"
-        view.addSubview(messageMainView)
+        view.backgroundColor = kf7f8faColor
+        
+        view.addSubview(topView)
+        view.addSubview(tableView)
     }
     
     override func setupLayouts() {
-        messageMainView.snp.makeConstraints { (make) in
-            make.left.right.equalToSuperview()
-            make.top.equalTo(kNavBarTotalHeight)
-            make.height.equalTo(kScreenHeight - kNavBarTotalHeight - kTabBarTotalHeight)
+        topView.snp.makeConstraints { (make) in
+            make.top.equalToSuperview().offset(kNavBarTotalHeight)
+            make.left.right.equalToSuperview().offset(0)
+            make.height.equalTo(104)
+        }
+        
+        tableView.snp.makeConstraints { (make) in
+            make.top.equalTo(topView.snp_bottom).offset(10)
+            make.left.right.equalTo(0)
+            make.bottom.equalToSuperview()
         }
     }
     
@@ -34,10 +43,71 @@ class MessageMainViewController: BaseViewController {
         
     }
     
-    private lazy var messageMainView: MessageMainView = {
-        let messageMainView = MessageMainView()
-        
-        return messageMainView
+    
+    private lazy var topView: UIView = {
+        let topView = UIView()
+        topView.backgroundColor = UIColor.white
+        return topView
     }()
     
+    lazy var tableView: UITableView = {
+        let tableView = UITableView(frame: CGRect.zero, style: UITableView.Style.grouped)
+        tableView.separatorStyle = .none
+        tableView.backgroundColor = kf7f8faColor
+        tableView.dataSource = self
+        tableView.delegate = self
+        tableView.isScrollEnabled = false
+        tableView.estimatedRowHeight = 70
+        tableView.estimatedSectionFooterHeight = 0.000001
+        tableView.estimatedSectionHeaderHeight = 0.000001
+        return tableView
+    }()
+    
+}
+
+// MARK: - tableView dataSource && delegate
+extension MessageMainViewController: UITableViewDataSource, UITableViewDelegate {
+    
+    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
+        return 2
+    }
+    
+    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
+        switch indexPath.row {
+        case 0:
+            // 星球通知
+            let cell = MessagePlanetTableCell.cellWith(tableView: tableView, indexPath: indexPath)
+            cell.cellRow = 0
+            return cell
+        case 1:
+            // 星球活动
+            let cell = MessagePlanetTableCell.cellWith(tableView: tableView, indexPath: indexPath)
+            cell.cellRow = 1
+            return cell
+        default:
+            return UITableViewCell()
+        }
+    }
+    
+    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
+        return 70
+    }
+    
+    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
+        switch indexPath.row {
+        case 0:
+            // 星球通知
+            print("点击--星球通知")
+        case 1:
+            // 星球活动
+            print("点击--星球活动")
+        default:
+            return
+        }
+    }
+    
+    func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
+        return 0
+    }
+    
 }