diff --git a/solutions/devsprint-andre-nogueira-1/RealEstateApp/Screens/PropertyList/PropertyListView.swift b/solutions/devsprint-andre-nogueira-1/RealEstateApp/Screens/PropertyList/PropertyListView.swift index 611b03c..194cd8d 100644 --- a/solutions/devsprint-andre-nogueira-1/RealEstateApp/Screens/PropertyList/PropertyListView.swift +++ b/solutions/devsprint-andre-nogueira-1/RealEstateApp/Screens/PropertyList/PropertyListView.swift @@ -26,7 +26,7 @@ final class PropertyListView: UIView { tableView.dataSource = self return tableView }() - + init() { super.init(frame: .zero) @@ -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) + ]) } } @@ -72,6 +72,7 @@ extension PropertyListView { self.listItems = repositories self.tableView.reloadData() + } } diff --git a/solutions/devsprint-andre-nogueira-1/RealEstateApp/Screens/PropertyList/PropertyListViewController.swift b/solutions/devsprint-andre-nogueira-1/RealEstateApp/Screens/PropertyList/PropertyListViewController.swift index 200d563..d9b16c8 100644 --- a/solutions/devsprint-andre-nogueira-1/RealEstateApp/Screens/PropertyList/PropertyListViewController.swift +++ b/solutions/devsprint-andre-nogueira-1/RealEstateApp/Screens/PropertyList/PropertyListViewController.swift @@ -7,7 +7,11 @@ import UIKit -class PropertyListViewController: UIViewController { +class ResultsVC: UIViewController { + +} + +class PropertyListViewController: UIViewController, UISearchResultsUpdating { let propertyListView: PropertyListView = { @@ -16,22 +20,39 @@ class PropertyListViewController: UIViewController { }() let apiClient = RealEstateAPIClient() - + + let searchController = UISearchController(searchResultsController: ResultsVC()) + + 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 + } + + 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 @@ -42,5 +63,8 @@ class PropertyListViewController: UIViewController { } } } + @objc func handleButton() { + print("click") + } } diff --git a/solutions/devsprint-andre-nogueira-1/RealEstateApp/Screens/PropertyList/PropertyTableViewCell.swift b/solutions/devsprint-andre-nogueira-1/RealEstateApp/Screens/PropertyList/PropertyTableViewCell.swift index f92ac50..b1a7dfa 100644 --- a/solutions/devsprint-andre-nogueira-1/RealEstateApp/Screens/PropertyList/PropertyTableViewCell.swift +++ b/solutions/devsprint-andre-nogueira-1/RealEstateApp/Screens/PropertyList/PropertyTableViewCell.swift @@ -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),