| | |
| | | |
| | | import UIKit |
| | | import JQTools |
| | | import RxSwift |
| | | import RxRelay |
| | | import CoreLocation |
| | | |
| | | class PavilionSearchVC: BaseVC { |
| | | |
| | | @IBOutlet weak var tf_search: UITextField! |
| | | @IBOutlet weak var collectionView: UICollectionView! |
| | | |
| | | var viewModel:PavilionViewModel? |
| | | |
| | | override func viewDidLoad() { |
| | | super.viewDidLoad() |
| | | title = "疗愈馆" |
| | | tf_search.delegate = self |
| | | tf_search.returnKeyType = .search |
| | | viewModel?.configure(collectionView) |
| | | } |
| | | |
| | | override func setUI() { |
| | |
| | | collectionView.contentInset = UIEdgeInsets(top: 0, left: 28.5, bottom: 0, right: 28.5) |
| | | collectionView.register(UINib(nibName: "PavilionItemCell", bundle: nil), forCellWithReuseIdentifier: "_PavilionItemCell") |
| | | } |
| | | |
| | | @IBAction func cancelAction(_ sender: UIButton) { |
| | | self.navigationController?.popViewController() |
| | | } |
| | | } |
| | | |
| | | extension PavilionSearchVC:UITextFieldDelegate{ |
| | | func textFieldShouldReturn(_ textField: UITextField) -> Bool { |
| | | textField.resignFirstResponder() |
| | | viewModel?.search.accept(textField.text!) |
| | | viewModel?.beginRefresh() |
| | | return true |
| | | } |
| | | } |
| | |
| | | extension PavilionSearchVC:UICollectionViewDataSource{ |
| | | |
| | | func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { |
| | | let detailVC = PavilionDetailVC() |
| | | let model = viewModel!.dataSource.value!.list[indexPath.row] |
| | | let detailVC = PavilionDetailVC(id: model.id) |
| | | push(vc: detailVC) |
| | | } |
| | | func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { |
| | | |
| | | let model = viewModel!.dataSource.value!.list[indexPath.row] |
| | | let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "_PavilionItemCell", for: indexPath) as! PavilionItemCell |
| | | cell.backgroundColor = .jq_randomColor |
| | | cell.jq_cornerRadius = 16 |
| | | cell.setPavilionDetailModel(model) |
| | | return cell |
| | | |
| | | } |
| | | |
| | | |
| | | func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { |
| | | return 10 |
| | | return viewModel?.dataSource.value?.list.count ?? 0 |
| | | } |
| | | } |
| | | |