Browse Source

AddAddress

Chris 5 years ago
parent
commit
efc51c5266

+ 5 - 1
RainbowPlanet/RainbowPlanet.xcodeproj/project.pbxproj

@@ -433,6 +433,7 @@
 		BD13B6E022BA03BC008BB323 /* PublishTopicItemCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD13B6D522BA03BB008BB323 /* PublishTopicItemCell.swift */; };
 		BD13B6E122BA03BC008BB323 /* PublishSelTopicCollectionCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD13B6D622BA03BB008BB323 /* PublishSelTopicCollectionCell.swift */; };
 		BD13B6E222BA03BC008BB323 /* PublishTopicTypeCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD13B6D722BA03BB008BB323 /* PublishTopicTypeCell.swift */; };
+		BD13B6E422BA0546008BB323 /* PublishAddressPOICell.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD13B6E322BA0546008BB323 /* PublishAddressPOICell.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 */; };
@@ -981,6 +982,7 @@
 		BD13B6D522BA03BB008BB323 /* PublishTopicItemCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PublishTopicItemCell.swift; sourceTree = "<group>"; };
 		BD13B6D622BA03BB008BB323 /* PublishSelTopicCollectionCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PublishSelTopicCollectionCell.swift; sourceTree = "<group>"; };
 		BD13B6D722BA03BB008BB323 /* PublishTopicTypeCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PublishTopicTypeCell.swift; sourceTree = "<group>"; };
+		BD13B6E322BA0546008BB323 /* PublishAddressPOICell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PublishAddressPOICell.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>"; };
@@ -3765,8 +3767,9 @@
 			isa = PBXGroup;
 			children = (
 				BD13B6CC22BA03BB008BB323 /* PublishAddAddressController.swift */,
-				BD13B6CD22BA03BB008BB323 /* PublishAddressPOIView.swift */,
 				BD13B6CE22BA03BB008BB323 /* SearchAddrNavigationbarView.swift */,
+				BD13B6CD22BA03BB008BB323 /* PublishAddressPOIView.swift */,
+				BD13B6E322BA0546008BB323 /* PublishAddressPOICell.swift */,
 			);
 			path = PublishAddAddress;
 			sourceTree = "<group>";
@@ -4828,6 +4831,7 @@
 				A757C92E22744ACE00226355 /* AddressManagerListModel.swift in Sources */,
 				BDAA40F9228E9ADA00CF841D /* OrderApplyRefundReasonCell.swift in Sources */,
 				A7274C59228EE636000E3A07 /* LBXScanNetAnimation.swift in Sources */,
+				BD13B6E422BA0546008BB323 /* PublishAddressPOICell.swift in Sources */,
 				A7541502224C5ECB002480B5 /* BaiduMapManager.swift in Sources */,
 				A773D02F229FDC3B007A5751 /* DIYEmptyView.swift in Sources */,
 				A757C9342274882E00226355 /* UIScrollView+MJRefreshEX.m in Sources */,

+ 1 - 1
RainbowPlanet/RainbowPlanet/Modules/PublishModule/PublishAddAddress/PublishAddAddressController.swift

@@ -57,7 +57,7 @@ class PublishAddAddressController: BaseViewController {
         }
         navigationBarView.searchBlock = {
             [weak self] keyword in
-            print("----search")
+            self?.addressPOIView.searchPOI(keyword)
         }
         return navigationBarView
     }()

+ 136 - 0
RainbowPlanet/RainbowPlanet/Modules/PublishModule/PublishAddAddress/PublishAddressPOICell.swift

@@ -0,0 +1,136 @@
+//
+//  PublishAddressPOICell.swift
+//  RainbowPlanet
+//
+//  Created by Christopher on 2019/6/19.
+//  Copyright © 2019 RainbowPlanet. All rights reserved.
+//
+
+import UIKit
+import RxSwift
+import RxCocoa
+
+class PublishAddressPOICell: UITableViewCell {
+    
+    
+    typealias RefreshButtonBlock = () -> Void
+    var refreshButtonBlock : RefreshButtonBlock?
+    let disposeBag = DisposeBag()
+    
+    class func cellWith(tableView:UITableView,indexPath:IndexPath) -> PublishAddressPOICell {
+        let ID = "PublishAddressPOICell"
+        tableView.register(PublishAddressPOICell.self, forCellReuseIdentifier: ID)
+        let cell : PublishAddressPOICell = tableView.dequeueReusableCell(withIdentifier: ID, for: indexPath) as! PublishAddressPOICell
+        cell.indexPath = indexPath
+        return cell
+    }
+    
+    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
+        super.init(style: style, reuseIdentifier: reuseIdentifier)
+        setupViews()
+        setupLayouts()
+    }
+    
+    required init?(coder aDecoder: NSCoder) {
+        fatalError("init(coder:) has not been implemented")
+    }
+    
+    //MARK: - indexPath
+    var indexPath: IndexPath?{
+        didSet {
+            switch indexPath?.section {
+            case 0:
+                self.refreshButton.isHidden = false
+            default:
+                self.refreshButton.isHidden = true
+            }
+        }
+    }
+    
+    var suggestionInfo: BMKSuggestionInfo? {
+        didSet {
+            switch indexPath?.section {
+            case 1:
+                titleLabel.text = self.suggestionInfo!.district + self.suggestionInfo!.key
+            default:
+                break
+            }
+        }
+    }
+    
+    var locationAddress: String? {
+        didSet {
+            
+            if locationAddress != "" && locationAddress != nil {
+                titleLabel.text = locationAddress
+            }else {
+                titleLabel.text = LocationModel.shared().getLocationModel()?.city ?? "西安市"
+            }
+        }
+    }
+    
+    //MARK: - 设置view
+    private func setupViews() {
+        self.selectionStyle = .none
+        addSubview(titleLabel)
+        addSubview(refreshButton)
+        addSubview(bottomLineLabel)
+    }
+    
+    private func setupLayouts() {
+        titleLabel.snp.makeConstraints { (make) in
+            make.centerY.equalToSuperview()
+            make.left.equalTo(14)
+            make.right.equalTo(-14)
+            make.height.equalTo(21)
+        }
+        refreshButton.snp.makeConstraints { (make) in
+            make.top.equalTo(titleLabel)
+            make.right.equalToSuperview().offset(kScaleValue(value: -14))
+            make.width.equalTo(kScaleValue(value: 46))
+            
+        }
+        refreshButton.layoutButton(edgeInsetsStyle: ButtonEdgeInsetsStyle.left, imageTitleSpace: 2)
+        
+        bottomLineLabel.snp.makeConstraints { (make) in
+            make.bottom.equalToSuperview()
+            make.left.equalTo(titleLabel.snp_left)
+            make.right.equalTo(titleLabel.snp_right)
+            make.height.equalTo(0.5)
+        }
+        
+    }
+    
+    private lazy var titleLabel: UILabel = {
+        let titleLabel = UILabel()
+        titleLabel.textColor = k333333Color
+        titleLabel.font = kMediumFont15
+        titleLabel.textAlignment = .left
+        titleLabel.numberOfLines = 0
+        return titleLabel
+    }()
+    
+    private lazy var refreshButton : UIButton = {
+        let refreshButton = UIButton()
+        refreshButton.setImage(kImage(name: "navbar_refresh"), for: UIControl.State.normal)
+        refreshButton.setTitle("刷新", for: UIControl.State.normal)
+        refreshButton.setTitleColor(kFFA42FColor, for: UIControl.State.normal)
+        refreshButton.titleLabel?.font = kRegularFont14
+        refreshButton.isHidden = true
+        refreshButton.rx.tap.subscribe(onNext: { [weak self] (data) in
+            if self?.indexPath?.section == 0 {
+                if let refreshButtonBlock = self?.refreshButtonBlock {
+                    refreshButtonBlock()
+                }
+            }
+            
+        }).disposed(by: disposeBag)
+        return refreshButton
+    }()
+    
+    private lazy var bottomLineLabel: UILabel = {
+        let bottomLineLabel = UILabel()
+        bottomLineLabel.backgroundColor = kf5f5f5Color
+        return bottomLineLabel
+    }()
+}

+ 61 - 43
RainbowPlanet/RainbowPlanet/Modules/PublishModule/PublishAddAddress/PublishAddressPOIView.swift

@@ -30,70 +30,85 @@ class PublishAddressPOIView: BaseView {
     
     
     override func setupViews() {
+        addSubview(disableShowBgView)
+        disableShowBgView.addSubview(disableShowLabel)
+        disableShowBgView.addSubview(disableShowImage)
+        disableShowBgView.addSubview(bottomLine)
+        disableShowBgView.addSubview(disableShowButton)
         
-        addSubview(searchBgView)
-        
-        searchBgView.addSubview(bottomLine)
-        searchBgView.addSubview(addressLabel)        
         addSubview(tableView)
         
     }
     
     override func setupLayouts() {
-        searchBgView.snp.makeConstraints { (make) in
+        disableShowBgView.snp.makeConstraints { (make) in
             make.top.left.right.equalToSuperview()
             make.height.equalTo(kScaleValue(value: 60))
         }
+        disableShowLabel.snp.makeConstraints { (make) in
+            make.left.equalTo(14)
+            make.centerY.equalToSuperview()
+            make.height.equalTo(21)
+        }
+        disableShowImage.snp.makeConstraints { (make) in
+            make.right.equalTo(-14)
+            make.centerY.equalToSuperview()
+            make.width.equalTo(16)
+            make.height.equalTo(11)
+        }
         bottomLine.snp.makeConstraints { (make) in
-            make.left.right.bottom.equalToSuperview()
+            make.left.equalTo(14)
+            make.right.equalTo(-14)
+            make.bottom.equalToSuperview()
             make.height.equalTo(0.5)
         }
-        
-        addressLabel.snp.remakeConstraints { (make) in
-            make.centerY.equalTo(searchBgView.snp.centerY)
-            make.left.equalTo(kScaleValue(value: 8))
+        disableShowButton.snp.makeConstraints { (make) in
+            make.edges.equalToSuperview()
         }
         
         tableView.snp.makeConstraints { (make) in
-            make.top.equalTo(searchBgView.snp.bottom)
+            make.top.equalTo(disableShowBgView.snp.bottom)
             make.left.right.bottom.equalToSuperview()
+        }        
+    }
+    
+    func searchPOI(_ searchText: String) {
+        BaiduMapManager.shared.suggestionSearchPoi(cityname:LocationModel.shared().getLocationModel()?.city ?? "西安市", keyword: searchText)
+        BaiduMapManager.shared.suggestionSearchSuccessBlock = {
+            [weak self] (suggestionList:Array<BMKSuggestionInfo>) in
+            self?.suggestionList = suggestionList
+            self?.tableView.reloadSections([1], with: UITableView.RowAnimation.fade)
         }
-        
     }
     
-    private lazy var searchBgView: UIView = {
-        let searchBgView = UIView()
-        searchBgView.backgroundColor = kffffffColor
-        return searchBgView
+    private lazy var disableShowBgView: UIView = {
+        let disableShowBgView = UIView()
+        disableShowBgView.backgroundColor = kffffffColor
+        return disableShowBgView
     }()
     
-    private lazy var addressLabel: UILabel = {
-        let addressLabel = UILabel()
-        addressLabel.text = LocationModel.shared().getLocationModel()?.city ?? "西安市"
-        addressLabel.textColor = k999999Color
-        addressLabel.font = kScaleRegularFont14
-        return addressLabel
+    private lazy var disableShowLabel: UILabel = {
+        let disableShowLabel = UILabel()
+        disableShowLabel.text = "不显示所在位置"
+        disableShowLabel.textColor = k333333Color
+        disableShowLabel.font = kMediumFont15
+        return disableShowLabel
+    }()
+    
+    private lazy var disableShowImage: UIImageView = {
+        let disableShowImage = UIImageView()
+        disableShowImage.image = kImage(name: "disableShowImage")
+        return disableShowImage
+    }()
+    
+    private lazy var disableShowButton: UIButton = {
+        let disableShowButton = UIButton(type: UIButton.ButtonType.custom)
+        disableShowButton.rx.tap.subscribe(onNext: { [weak self] in
+            print("----点击-不显示")
+        }).disposed(by: disposeBag)
+        return disableShowButton
     }()
     
-//    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.rx.text.orEmpty.changed.subscribe(onNext: { (text) in
-//
-//            BaiduMapManager.shared.suggestionSearchPoi(cityname:LocationModel.shared().getLocationModel()?.city ?? "西安市", keyword: text)
-//            BaiduMapManager.shared.suggestionSearchSuccessBlock = {
-//                [weak self] (suggestionList:Array<BMKSuggestionInfo>) in
-//                self?.suggestionList = suggestionList
-//                self?.tableView.reloadSections([1], with: UITableView.RowAnimation.fade)
-//            }
-//        }).disposed(by: disposeBag)
-//        return searchTextField
-//    }()
     
     private lazy var bottomLine: UILabel = {
         let bottomLine = UILabel()
@@ -106,7 +121,6 @@ class PublishAddressPOIView: BaseView {
         tableView.delegate = self
         tableView.dataSource = self
         tableView.backgroundColor = kffffffColor
-        tableView.estimatedRowHeight = kScaleValue(value: 48)
         tableView.separatorStyle = .none
         return tableView
     }()
@@ -136,7 +150,7 @@ extension PublishAddressPOIView:UITableViewDataSource,UITableViewDelegate {
     }
     
     func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
-        let cell = AddressPOITableViewCell.cellWith(tableView: tableView, indexPath: indexPath)
+        let cell = PublishAddressPOICell.cellWith(tableView: tableView, indexPath: indexPath)
         switch indexPath.section {
         case 0:
             cell.locationAddress = locationAddress
@@ -181,4 +195,8 @@ extension PublishAddressPOIView:UITableViewDataSource,UITableViewDelegate {
         }
     }
     
+    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
+        return 60
+    }
+    
 }

+ 4 - 8
RainbowPlanet/RainbowPlanet/Modules/PublishModule/PublishAddAddress/SearchAddrNavigationbarView.swift

@@ -82,14 +82,10 @@ class SearchAddrNavigationbarView: BaseView {
         searchTextField.returnKeyType = .search
         searchTextField.font = kScaleRegularFont14
         searchTextField.borderStyle = .none
-        searchTextField.rx.controlEvent([.editingDidEndOnExit]).asObservable().subscribe(onNext: {
-            [weak self] (text) in
-            
-            if searchTextField.text?.count ?? 0 > 0 {
-                self?.endEditing(true)
-            }else {
-                SwiftProgressHUD.shared().showText("搜索地址不能为空")
-            }                        
+        searchTextField.rx.text.orEmpty.changed.subscribe(onNext: { (text) in
+            if let searchBlock = self.searchBlock {
+                searchBlock(searchTextField.text ?? "")
+            }
         }).disposed(by: disposeBag)
         return searchTextField
     }()