Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ final class PropertyListView: UIView {
tableView.dataSource = self
return tableView
}()

init() {

super.init(frame: .zero)
Expand All @@ -42,26 +42,26 @@ final class PropertyListView: UIView {
private extension PropertyListView {

func setupViews() {

self.backgroundColor = .white

self.configureSubviews()
self.configureSubviewsConstraints()
}

func configureSubviews() {

self.addSubview(self.tableView)
addSubview(self.tableView)

}

func configureSubviewsConstraints() {

NSLayoutConstraint.activate([

self.tableView.leadingAnchor.constraint(equalTo: self.leadingAnchor),
self.tableView.trailingAnchor.constraint(equalTo: self.trailingAnchor),
self.tableView.topAnchor.constraint(equalTo: self.topAnchor),
self.tableView.bottomAnchor.constraint(equalTo: self.bottomAnchor)

tableView.leadingAnchor.constraint(equalTo: self.leadingAnchor),
tableView.trailingAnchor.constraint(equalTo: self.trailingAnchor),
tableView.topAnchor.constraint(equalTo: self.topAnchor),
tableView.bottomAnchor.constraint(equalTo: self.bottomAnchor)

])
}
}
Expand All @@ -72,6 +72,7 @@ extension PropertyListView {

self.listItems = repositories
self.tableView.reloadData()

}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@

import UIKit

class PropertyListViewController: UIViewController {
class ResultsVC: UIViewController {

}

class PropertyListViewController: UIViewController, UISearchResultsUpdating {

let propertyListView: PropertyListView = {

Expand All @@ -16,22 +20,39 @@ class PropertyListViewController: UIViewController {
}()

let apiClient = RealEstateAPIClient()


let searchController = UISearchController(searchResultsController: ResultsVC())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tentar:

  1. utilizar no lugar da ResultsVC a propria ViewController (self)
  2. Outro caminho, implementar a navegacao/busca em outra Viewcontroller, que utiliza a PropertyListViewController como resultado - no lugar da ResultsVC, a PropertyListViewController.



override func viewDidLoad() {
super.viewDidLoad()

navigationController?.navigationBar.prefersLargeTitles = true
navigationItem.title = "Real Estate App 🏡"

self.view.backgroundColor = .white

configureSetupView()
fetchProperties()
}

override func loadView() {
self.view = propertyListView
}


func configureSetupView() {
navigationItem.title = "Real Estate App "
navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Settings", style: .plain, target: self, action: #selector(handleButton))
searchController.searchResultsUpdater = self
searchController.searchBar.placeholder = "Type a city or neighborhood "
navigationItem.searchController = searchController
self.view.backgroundColor = .white
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alinhar a linha com os de cima, dica: tente um CMD + A e CTRL + i

}

func updateSearchResults(for searchController: UISearchController) {
guard let text = searchController.searchBar.text else {
return
}

let vc = searchController.searchResultsController as? ResultsVC
vc?.view.backgroundColor = UIColor.lightGray.withAlphaComponent(0.3)
print(text)
}

func fetchProperties() {

apiClient.fetchProperties { properties in
Expand All @@ -42,5 +63,8 @@ class PropertyListViewController: UIViewController {
}
}
}
@objc func handleButton() {
print("click")
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ final class PropertyTableViewCell: UITableViewCell {

func configureViewConstraints() {
NSLayoutConstraint.activate([
announcementImageView.topAnchor.constraint(equalTo: topAnchor, constant: 10),
announcementImageView.topAnchor.constraint(equalTo: topAnchor, constant: 24),
announcementImageView.rightAnchor.constraint(equalTo: rightAnchor),
announcementImageView.leftAnchor.constraint(equalTo: leftAnchor),
announcementImageView.heightAnchor.constraint(equalToConstant: 200),
Expand Down