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 @@ -22,6 +22,9 @@
54C4595928077D03004DD3DF /* UIViewController+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 54C4595828077D03004DD3DF /* UIViewController+Extensions.swift */; };
54E204C92804EB8C009FFEDC /* AccountView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 54E204C82804EB8C009FFEDC /* AccountView.swift */; };
54E204CB28051E0A009FFEDC /* AccountViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 54E204CA28051E0A009FFEDC /* AccountViewModel.swift */; };
8B5548A728061AB400714870 /* LoginModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8B5548A628061AB400714870 /* LoginModel.swift */; };
8B5548A928061B8000714870 /* LoginAPIClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8B5548A828061B8000714870 /* LoginAPIClient.swift */; };
8BD13BF3281868DF001756F4 /* PropertyInfoView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8BD13BF2281868DF001756F4 /* PropertyInfoView.swift */; };
980789CB275E8FAF00CED39A /* SettingsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 980789CA275E8FAF00CED39A /* SettingsViewController.swift */; };
980789CE275E943D00CED39A /* FavoritesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 980789CD275E943C00CED39A /* FavoritesViewController.swift */; };
980789D9275EA3C900CED39A /* AccountViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 980789D8275EA3C900CED39A /* AccountViewController.swift */; };
Expand Down Expand Up @@ -77,6 +80,9 @@
54C4595828077D03004DD3DF /* UIViewController+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIViewController+Extensions.swift"; sourceTree = "<group>"; };
54E204C82804EB8C009FFEDC /* AccountView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountView.swift; sourceTree = "<group>"; };
54E204CA28051E0A009FFEDC /* AccountViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountViewModel.swift; sourceTree = "<group>"; };
8B5548A628061AB400714870 /* LoginModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginModel.swift; sourceTree = "<group>"; };
8B5548A828061B8000714870 /* LoginAPIClient.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginAPIClient.swift; sourceTree = "<group>"; };
8BD13BF2281868DF001756F4 /* PropertyInfoView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PropertyInfoView.swift; sourceTree = "<group>"; };
980789CA275E8FAF00CED39A /* SettingsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsViewController.swift; sourceTree = "<group>"; };
980789CD275E943C00CED39A /* FavoritesViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FavoritesViewController.swift; sourceTree = "<group>"; };
980789D8275EA3C900CED39A /* AccountViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountViewController.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -141,6 +147,14 @@
path = Utils;
sourceTree = "<group>";
};
8BD13BF1281868C1001756F4 /* PropertyInfo */ = {
isa = PBXGroup;
children = (
8BD13BF2281868DF001756F4 /* PropertyInfoView.swift */,
);
path = PropertyInfo;
sourceTree = "<group>";
};
980789C9275E8F8E00CED39A /* Settings */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -183,13 +197,15 @@
children = (
980C0C0A2704F1C700F8100A /* RealEstateAPIClientProperty.swift */,
B0D7AA932805BFA8006177F8 /* RealEstateAPIFavorites.swift */,
8B5548A828061B8000714870 /* LoginAPIClient.swift */,
);
path = APIClient;
sourceTree = "<group>";
};
980C0C172704F1D500F8100A /* Screens */ = {
isa = PBXGroup;
children = (
8BD13BF1281868C1001756F4 /* PropertyInfo */,
54C4595528077B4B004DD3DF /* Utils */,
B0D7AA952805F05B006177F8 /* TabBar */,
980C0C182704F1DE00F8100A /* PropertyList */,
Expand Down Expand Up @@ -239,6 +255,7 @@
A50AC3F928089F4900873216 /* Address.swift */,
A50AC3FB28089FEA00873216 /* Pricing.swift */,
B0D7AA912805BBB7006177F8 /* Favorites.swift */,
8B5548A628061AB400714870 /* LoginModel.swift */,
);
path = Models;
sourceTree = "<group>";
Expand Down Expand Up @@ -466,17 +483,20 @@
543091792811EB4100BDC903 /* UIView+Extensions.swift in Sources */,
54309171281094F900BDC903 /* BaseView.swift in Sources */,
980789CE275E943D00CED39A /* FavoritesViewController.swift in Sources */,
8BD13BF3281868DF001756F4 /* PropertyInfoView.swift in Sources */,
986153D02704EE2B00838CA6 /* AppDelegate.swift in Sources */,
986153D22704EE2B00838CA6 /* SceneDelegate.swift in Sources */,
A50AC3FC28089FEA00873216 /* Pricing.swift in Sources */,
5498E3B52814DF14002BD1C4 /* PropertyListFactory.swift in Sources */,
54E204CB28051E0A009FFEDC /* AccountViewModel.swift in Sources */,
8B5548A728061AB400714870 /* LoginModel.swift in Sources */,
980789CB275E8FAF00CED39A /* SettingsViewController.swift in Sources */,
B0D7AA942805BFA8006177F8 /* RealEstateAPIFavorites.swift in Sources */,
980C0C1C2704F23E00F8100A /* PropertyDetailsViewController.swift in Sources */,
A50AC4062808BEC000873216 /* PropertyImageView.swift in Sources */,
E9FE07EC28076C6C00B2752F /* AccountFactory.swift in Sources */,
980C0C112704F1C700F8100A /* RealEstateAPIClientProperty.swift in Sources */,
8B5548A928061B8000714870 /* LoginAPIClient.swift in Sources */,
54E204C92804EB8C009FFEDC /* AccountView.swift in Sources */,
5446FD1128178A1200640269 /* Bindable.swift in Sources */,
980789D9275EA3C900CED39A /* AccountViewController.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import Foundation

protocol LoginAPIClientProtocol: AnyObject {
func fetchProperties(completion: @escaping (Result<[Property], ErrorRequest>) -> Void)
}

public final class LoginAPIClient {
func fetchProperties(completion: @escaping (Result<LoginModel, ErrorRequest>) -> Void) {
let urlString = ManagerGetURL.getLoginURL()
guard let url = URL(string: urlString) else {
completion(.failure(ErrorRequest.urlNotValid))
return
}

let task = URLSession.shared.dataTask(with: url) { data, response, error in
guard let response = response as? HTTPURLResponse, response.statusCode == 200, let data = data else {
completion(.failure(ErrorRequest.invalidJson))
return
}
do {
let decoder = JSONDecoder()
let result = try decoder.decode(LoginModel.self, from: data)
completion(.success(result))
} catch {
print(error)
completion(.failure(ErrorRequest.noData))
}
}

task.resume()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,4 @@ public final class RealEstateAPIClientProperty: RealEstateAPIPropertyProtocol {
task.resume()
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
public struct LoginModel: Decodable {
let success: Bool
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

import Foundation
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,12 @@ struct ManagerGetURL {
return urlString
}

public static func getLoginURL() -> String {

let baseURL = InfoPlistBaseURL.getStringValue(forKey: "BaseURL")
let login = InfoPlistBaseURL.getStringValue(forKey: "LoginRequestEndPoint")
let urlString = baseURL + login

return urlString
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
<string>favorites.json</string>
<key>PropertyRequestEndPoint</key>
<string>listings.json</string>
<key>LoginRequestEndPoint</key>
<string>login.json</string>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import UIKit

class PropertyDetailsViewController: UIViewController {

let propertyInfoView = PropertyInfoView()

private lazy var propertyDetailsView: PropertyDetailsView = {
let view = PropertyDetailsView()
view.sendContactButton.addTarget(self, action: #selector(sendContactForm), for: .touchUpInside)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import UIKit

class PropertyInfoView: BaseView, ViewCodable {

private lazy var priceLabel: UILabel = {
let label = UILabel()
label.text = " R$ 405.000"
label.font = .systemFont(ofSize: 20)
label.tintColor = .black
label.font = .boldSystemFont(ofSize: 20)
label.translatesAutoresizingMaskIntoConstraints = false
return label
}()

private lazy var buildingLabel: UILabel = {
let label = UILabel()
label.text = "Condomínio R$ 495 IPTU R$ 0"
label.tintColor = .black
label.translatesAutoresizingMaskIntoConstraints = false
return label
}()

private lazy var infoLabel: UILabel = {
let label = UILabel()
label.text = "69 m² 3 quartos 2 banheiros 1 vaga"
label.font = UIFont.systemFont(ofSize: 14)
label.textColor = UIColor.lightGray.withAlphaComponent(0.9)
label.translatesAutoresizingMaskIntoConstraints = false
return label
}()

private lazy var addressLabel: UILabel = {
let label = UILabel()
label.text = "Sem endereço"
label.font = UIFont.systemFont(ofSize: 14)
label.textColor = UIColor.lightGray.withAlphaComponent(0.9)
label.translatesAutoresizingMaskIntoConstraints = false
return label
}()

func setUpHierarchy() {
[priceLabel, buildingLabel, infoLabel, addressLabel].forEach {
addSubview($0)
}
}

func setUpConstraints() {
NSLayoutConstraint.activate([
priceLabel.topAnchor.constraint(equalTo: bottomAnchor, constant: 10),
priceLabel.rightAnchor.constraint(equalTo: rightAnchor, constant: -16),
priceLabel.leftAnchor.constraint(equalTo: leftAnchor, constant: 16),

buildingLabel.topAnchor.constraint(equalTo: priceLabel.bottomAnchor, constant: 10),
buildingLabel.rightAnchor.constraint(equalTo: rightAnchor, constant: -16),
buildingLabel.leftAnchor.constraint(equalTo: leftAnchor, constant: 16),

infoLabel.topAnchor.constraint(equalTo: buildingLabel.bottomAnchor, constant: 10),
infoLabel.rightAnchor.constraint(equalTo: rightAnchor, constant: -16),
infoLabel.leftAnchor.constraint(equalTo: leftAnchor, constant: 16),

addressLabel.topAnchor.constraint(equalTo: infoLabel.bottomAnchor, constant: 10),
addressLabel.rightAnchor.constraint(equalTo: rightAnchor, constant: -16),
addressLabel.leftAnchor.constraint(equalTo: leftAnchor, constant: 16),

bottomAnchor.constraint(equalTo: addressLabel.bottomAnchor, constant: 10)
])
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import UIKit
class PropertyListViewController: UIViewController {

private let viewModel: PropertyListViewModelProtocol

private let propertyListView: PropertyListView = {
let propertyListView = PropertyListView()
return propertyListView
Expand Down Expand Up @@ -52,4 +52,3 @@ class PropertyListViewController: UIViewController {
}
}
}