// // 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 { 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 { } } var suggestionInfo: BMKSuggestionInfo? { didSet { switch indexPath?.section { case 1: titleLabel.text = self.suggestionInfo!.district + self.suggestionInfo!.key default: break } } } var poiInfo: SwiftLocationPOIModel? { didSet { switch indexPath?.section { case 1: titleLabel.text = self.poiInfo?.name default: break } } } var locationAddress: String? { didSet { if locationAddress != "" && locationAddress != nil { titleLabel.text = locationAddress }else { titleLabel.text = LocationModel.shared().object()?.city ?? "西安市" } } } //MARK: - 设置view private func setupViews() { self.selectionStyle = .none addSubview(titleLabel) 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) } 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 bottomLineLabel: UILabel = { let bottomLineLabel = UILabel() bottomLineLabel.backgroundColor = kf5f5f5Color return bottomLineLabel }() }