123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- //
- // 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
- }()
- }
|