diff --git a/solutions/devsprint-pedro-alvarez-2/.vscode/settings.json b/solutions/devsprint-pedro-alvarez-2/.vscode/settings.json new file mode 100644 index 0000000..9892690 --- /dev/null +++ b/solutions/devsprint-pedro-alvarez-2/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "editor.quickSuggestions": { + "comments": "off", + "strings": "off", + "other": "off" + } +} \ No newline at end of file diff --git a/solutions/devsprint-pedro-alvarez-2/FinanceApp.xcodeproj/project.pbxproj b/solutions/devsprint-pedro-alvarez-2/FinanceApp.xcodeproj/project.pbxproj index d7e0c0e..11f549f 100644 --- a/solutions/devsprint-pedro-alvarez-2/FinanceApp.xcodeproj/project.pbxproj +++ b/solutions/devsprint-pedro-alvarez-2/FinanceApp.xcodeproj/project.pbxproj @@ -51,6 +51,9 @@ 98C8A4E327C819DE00A630ED /* Contact.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98C8A4E227C819DE00A630ED /* Contact.swift */; }; 98C8A4E527C81A3F00A630ED /* TransferResult.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98C8A4E427C81A3F00A630ED /* TransferResult.swift */; }; 98C8A4E727C81A9C00A630ED /* UserProfile.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98C8A4E627C81A9C00A630ED /* UserProfile.swift */; }; + + FBD92BE1294C005D0005A98E /* ContactListViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = FBD92BE0294C005D0005A98E /* ContactListViewModel.swift */; }; + FBECEFF22943E4E40027C8A2 /* ContactListModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = FBECEFF12943E4E40027C8A2 /* ContactListModel.swift */; }; F6162AF429420120008FCF6C /* UIColor+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = F6162AF329420120008FCF6C /* UIColor+Extensions.swift */; }; F6162AF829420167008FCF6C /* CustomUIButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = F6162AF729420167008FCF6C /* CustomUIButton.swift */; }; FBB56216294777360060278D /* BaseViewHierarchy.swift in Sources */ = {isa = PBXBuildFile; fileRef = FBB56215294777360060278D /* BaseViewHierarchy.swift */; }; @@ -124,6 +127,9 @@ 98C8A4E227C819DE00A630ED /* Contact.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Contact.swift; sourceTree = ""; }; 98C8A4E427C81A3F00A630ED /* TransferResult.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TransferResult.swift; sourceTree = ""; }; 98C8A4E627C81A9C00A630ED /* UserProfile.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserProfile.swift; sourceTree = ""; }; + FBD92BE0294C005D0005A98E /* ContactListViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContactListViewModel.swift; sourceTree = ""; }; + FBECEFF12943E4E40027C8A2 /* ContactListModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContactListModel.swift; sourceTree = ""; }; + F6162AF329420120008FCF6C /* UIColor+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIColor+Extensions.swift"; sourceTree = ""; }; F6162AF729420167008FCF6C /* CustomUIButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomUIButton.swift; sourceTree = ""; }; FBB56215294777360060278D /* BaseViewHierarchy.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseViewHierarchy.swift; sourceTree = ""; }; @@ -285,7 +291,6 @@ 98C8A4E227C819DE00A630ED /* Contact.swift */, 98C8A4E427C81A3F00A630ED /* TransferResult.swift */, 98C8A4E627C81A9C00A630ED /* UserProfile.swift */, - FBB56215294777360060278D /* BaseViewHierarchy.swift */, ); path = Models; sourceTree = ""; @@ -329,8 +334,10 @@ 98584B08277E602C0028DBEA /* ContactList */ = { isa = PBXGroup; children = ( + FBD92BDF294C00280005A98E /* ViewModel */, 98584B19277E60740028DBEA /* ContactListView.swift */, 98584B1A277E60740028DBEA /* ContactListViewController.swift */, + FBECEFF12943E4E40027C8A2 /* ContactListModel.swift */, ); path = ContactList; sourceTree = ""; @@ -338,7 +345,6 @@ 98906BEC29392209001D1975 /* Components */ = { isa = PBXGroup; children = ( - FBB56217294778170060278D /* Base */, 98906BED2939221B001D1975 /* AccountSummaryView.swift */, 98906BEF2939223C001D1975 /* ActivityCellView.swift */, 98906BF129392248001D1975 /* ActivityListView.swift */, @@ -366,6 +372,7 @@ path = Extensions; sourceTree = ""; }; + FBD92BDF294C00280005A98E /* ViewModel */ = { F6162AF529420146008FCF6C /* Commons */ = { isa = PBXGroup; children = ( @@ -385,9 +392,9 @@ FBB56217294778170060278D /* Base */ = { isa = PBXGroup; children = ( - FBB56218294778320060278D /* BaseView.swift */, + FBD92BE0294C005D0005A98E /* ContactListViewModel.swift */, ); - path = Base; + path = ViewModel; sourceTree = ""; }; /* End PBXGroup section */ @@ -540,11 +547,11 @@ 98C8A4E327C819DE00A630ED /* Contact.swift in Sources */, 98C8A4E527C81A3F00A630ED /* TransferResult.swift in Sources */, 98584AE8277E50430028DBEA /* TransfersViewController.swift in Sources */, - FBB56216294777360060278D /* BaseViewHierarchy.swift in Sources */, 98906BF42939225B001D1975 /* ContactCellView.swift in Sources */, 98584B14277E605F0028DBEA /* ActivityDetailsView.swift in Sources */, 98584AE7277E50430028DBEA /* TransfersView.swift in Sources */, 98906BF62939226B001D1975 /* UserProfileHeaderView.swift in Sources */, + FBD92BE1294C005D0005A98E /* ContactListViewModel.swift in Sources */, 98C8A4DB27C815C000A630ED /* UITableViewCell+Extensions.swift in Sources */, 98584AF3277E50430028DBEA /* ConfirmationView.swift in Sources */, 98584AEE277E50430028DBEA /* UserProfileViewController.swift in Sources */, @@ -558,9 +565,9 @@ 989627E027ADC2F60009A07F /* DebugViewController.swift in Sources */, 98584AA5277E35E90028DBEA /* HomeViewController.swift in Sources */, 98906BF229392248001D1975 /* ActivityListView.swift in Sources */, - FBB56219294778320060278D /* BaseView.swift in Sources */, 98584AED277E50430028DBEA /* UserProfileView.swift in Sources */, 98C8A4E127C8196100A630ED /* ActivityDetails.swift in Sources */, + FBECEFF22943E4E40027C8A2 /* ContactListModel.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/solutions/devsprint-pedro-alvarez-2/FinanceApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/solutions/devsprint-pedro-alvarez-2/FinanceApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved deleted file mode 100644 index e4cad68..0000000 --- a/solutions/devsprint-pedro-alvarez-2/FinanceApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ /dev/null @@ -1,14 +0,0 @@ -{ - "pins" : [ - { - "identity" : "swift-snapshot-testing", - "kind" : "remoteSourceControl", - "location" : "https://github.com/pointfreeco/swift-snapshot-testing", - "state" : { - "revision" : "f8a9c997c3c1dab4e216a8ec9014e23144cbab37", - "version" : "1.9.0" - } - } - ], - "version" : 2 -} diff --git a/solutions/devsprint-pedro-alvarez-2/FinanceApp/Resources/Assets.xcassets/img.imageset/Contents.json b/solutions/devsprint-pedro-alvarez-2/FinanceApp/Resources/Assets.xcassets/img.imageset/Contents.json new file mode 100644 index 0000000..aca8f0c --- /dev/null +++ b/solutions/devsprint-pedro-alvarez-2/FinanceApp/Resources/Assets.xcassets/img.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "img.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/solutions/devsprint-pedro-alvarez-2/FinanceApp/Resources/Assets.xcassets/img.imageset/img.png b/solutions/devsprint-pedro-alvarez-2/FinanceApp/Resources/Assets.xcassets/img.imageset/img.png new file mode 100644 index 0000000..7ccbeb1 Binary files /dev/null and b/solutions/devsprint-pedro-alvarez-2/FinanceApp/Resources/Assets.xcassets/img.imageset/img.png differ diff --git a/solutions/devsprint-pedro-alvarez-2/FinanceApp/Resources/Assets.xcassets/img2.imageset/Contents.json b/solutions/devsprint-pedro-alvarez-2/FinanceApp/Resources/Assets.xcassets/img2.imageset/Contents.json new file mode 100644 index 0000000..e83c564 --- /dev/null +++ b/solutions/devsprint-pedro-alvarez-2/FinanceApp/Resources/Assets.xcassets/img2.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "img2.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/solutions/devsprint-pedro-alvarez-2/FinanceApp/Resources/Assets.xcassets/img2.imageset/img2.png b/solutions/devsprint-pedro-alvarez-2/FinanceApp/Resources/Assets.xcassets/img2.imageset/img2.png new file mode 100644 index 0000000..cedbf07 Binary files /dev/null and b/solutions/devsprint-pedro-alvarez-2/FinanceApp/Resources/Assets.xcassets/img2.imageset/img2.png differ diff --git a/solutions/devsprint-pedro-alvarez-2/FinanceApp/Resources/Assets.xcassets/img3.imageset/Contents.json b/solutions/devsprint-pedro-alvarez-2/FinanceApp/Resources/Assets.xcassets/img3.imageset/Contents.json new file mode 100644 index 0000000..0a9a17f --- /dev/null +++ b/solutions/devsprint-pedro-alvarez-2/FinanceApp/Resources/Assets.xcassets/img3.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "img3.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/solutions/devsprint-pedro-alvarez-2/FinanceApp/Resources/Assets.xcassets/img3.imageset/img3.png b/solutions/devsprint-pedro-alvarez-2/FinanceApp/Resources/Assets.xcassets/img3.imageset/img3.png new file mode 100644 index 0000000..49e775b Binary files /dev/null and b/solutions/devsprint-pedro-alvarez-2/FinanceApp/Resources/Assets.xcassets/img3.imageset/img3.png differ diff --git a/solutions/devsprint-pedro-alvarez-2/FinanceApp/Resources/Assets.xcassets/img4.imageset/Contents.json b/solutions/devsprint-pedro-alvarez-2/FinanceApp/Resources/Assets.xcassets/img4.imageset/Contents.json new file mode 100644 index 0000000..2e42959 --- /dev/null +++ b/solutions/devsprint-pedro-alvarez-2/FinanceApp/Resources/Assets.xcassets/img4.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "img4.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/solutions/devsprint-pedro-alvarez-2/FinanceApp/Resources/Assets.xcassets/img4.imageset/img4.png b/solutions/devsprint-pedro-alvarez-2/FinanceApp/Resources/Assets.xcassets/img4.imageset/img4.png new file mode 100644 index 0000000..74a3025 Binary files /dev/null and b/solutions/devsprint-pedro-alvarez-2/FinanceApp/Resources/Assets.xcassets/img4.imageset/img4.png differ diff --git a/solutions/devsprint-pedro-alvarez-2/FinanceApp/Resources/Assets.xcassets/img5.imageset/Contents.json b/solutions/devsprint-pedro-alvarez-2/FinanceApp/Resources/Assets.xcassets/img5.imageset/Contents.json new file mode 100644 index 0000000..0270947 --- /dev/null +++ b/solutions/devsprint-pedro-alvarez-2/FinanceApp/Resources/Assets.xcassets/img5.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "img5.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/solutions/devsprint-pedro-alvarez-2/FinanceApp/Resources/Assets.xcassets/img5.imageset/img5.png b/solutions/devsprint-pedro-alvarez-2/FinanceApp/Resources/Assets.xcassets/img5.imageset/img5.png new file mode 100644 index 0000000..bdb63a7 Binary files /dev/null and b/solutions/devsprint-pedro-alvarez-2/FinanceApp/Resources/Assets.xcassets/img5.imageset/img5.png differ diff --git a/solutions/devsprint-pedro-alvarez-2/FinanceApp/Resources/Assets.xcassets/img6.imageset/Contents.json b/solutions/devsprint-pedro-alvarez-2/FinanceApp/Resources/Assets.xcassets/img6.imageset/Contents.json new file mode 100644 index 0000000..2ac2bc8 --- /dev/null +++ b/solutions/devsprint-pedro-alvarez-2/FinanceApp/Resources/Assets.xcassets/img6.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "img6.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/solutions/devsprint-pedro-alvarez-2/FinanceApp/Resources/Assets.xcassets/img6.imageset/img6.png b/solutions/devsprint-pedro-alvarez-2/FinanceApp/Resources/Assets.xcassets/img6.imageset/img6.png new file mode 100644 index 0000000..5c951ce Binary files /dev/null and b/solutions/devsprint-pedro-alvarez-2/FinanceApp/Resources/Assets.xcassets/img6.imageset/img6.png differ diff --git a/solutions/devsprint-pedro-alvarez-2/FinanceApp/Resources/Assets.xcassets/img7.imageset/Contents.json b/solutions/devsprint-pedro-alvarez-2/FinanceApp/Resources/Assets.xcassets/img7.imageset/Contents.json new file mode 100644 index 0000000..86b3f5b --- /dev/null +++ b/solutions/devsprint-pedro-alvarez-2/FinanceApp/Resources/Assets.xcassets/img7.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "img7.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/solutions/devsprint-pedro-alvarez-2/FinanceApp/Resources/Assets.xcassets/img7.imageset/img7.png b/solutions/devsprint-pedro-alvarez-2/FinanceApp/Resources/Assets.xcassets/img7.imageset/img7.png new file mode 100644 index 0000000..71e2797 Binary files /dev/null and b/solutions/devsprint-pedro-alvarez-2/FinanceApp/Resources/Assets.xcassets/img7.imageset/img7.png differ diff --git a/solutions/devsprint-pedro-alvarez-2/FinanceApp/Screens/Components/ContactCellView.swift b/solutions/devsprint-pedro-alvarez-2/FinanceApp/Screens/Components/ContactCellView.swift index f0bd3ee..85aaf20 100644 --- a/solutions/devsprint-pedro-alvarez-2/FinanceApp/Screens/Components/ContactCellView.swift +++ b/solutions/devsprint-pedro-alvarez-2/FinanceApp/Screens/Components/ContactCellView.swift @@ -7,6 +7,47 @@ import UIKit -class ContactCellView { +class ContactCellView: UITableViewCell { + + + static let identifier = "ContactCellView" + + private let contactCell: ContactListView = { + let contactCell = ContactListView() + contactCell.translatesAutoresizingMaskIntoConstraints = false + return contactCell + }() + + override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { + super.init(style: style, reuseIdentifier: reuseIdentifier) + backgroundColor = .clear + confighierarchy() + configConstraints() + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + func configureCell(with contactList: ContactListModel) { + contactCell.getPopularView(image: contactList.image, name: contactList.name, phone: contactList.phone) + } } + +extension ContactCellView { + private func confighierarchy() { + addSubview(contactCell) + } + + private func configConstraints() { + NSLayoutConstraint.activate([ + + contactCell.topAnchor.constraint(equalTo: self.topAnchor), + contactCell.bottomAnchor.constraint(equalTo: self.bottomAnchor), + contactCell.leadingAnchor.constraint(equalTo: self.leadingAnchor, constant: 20), + contactCell.trailingAnchor.constraint(equalTo: self.trailingAnchor, constant: -20), + ]) + } +} + diff --git a/solutions/devsprint-pedro-alvarez-2/FinanceApp/Screens/ContactList/ContactListModel.swift b/solutions/devsprint-pedro-alvarez-2/FinanceApp/Screens/ContactList/ContactListModel.swift new file mode 100644 index 0000000..b8f66c3 --- /dev/null +++ b/solutions/devsprint-pedro-alvarez-2/FinanceApp/Screens/ContactList/ContactListModel.swift @@ -0,0 +1,17 @@ +// +// ContactListModel.swift +// FinanceApp +// +// Created by Kleiton Mendes on 09/12/22. +// + +import Foundation +import UIKit + +public struct ContactListModel { + let name: String + let phone: String + let image: String +} + + diff --git a/solutions/devsprint-pedro-alvarez-2/FinanceApp/Screens/ContactList/ContactListView.swift b/solutions/devsprint-pedro-alvarez-2/FinanceApp/Screens/ContactList/ContactListView.swift index 06a4708..b2669b6 100644 --- a/solutions/devsprint-pedro-alvarez-2/FinanceApp/Screens/ContactList/ContactListView.swift +++ b/solutions/devsprint-pedro-alvarez-2/FinanceApp/Screens/ContactList/ContactListView.swift @@ -8,5 +8,90 @@ import UIKit class ContactListView: UIView { - + + // MARK: - Private Properties UI + lazy var imagePerson: UIImageView = { + let image = UIImageView() + image.translatesAutoresizingMaskIntoConstraints = false + image.layer.cornerRadius = 30 + image.clipsToBounds = true + image.layer.masksToBounds = true + image.backgroundColor = .gray + image.contentMode = .scaleToFill + return image + }() + + lazy var nameLabel: UILabel = { + let label = UILabel() + label.translatesAutoresizingMaskIntoConstraints = false + label.numberOfLines = 0 + label.textColor = .black + label.font = .boldSystemFont(ofSize: 15) + label.textAlignment = .left + return label + }() + + lazy var phoneLabel: UILabel = { + let label = UILabel() + label.translatesAutoresizingMaskIntoConstraints = false + label.numberOfLines = 0 + label.textColor = .gray + label.font = .boldSystemFont(ofSize: 13) + label.textAlignment = .left + return label + }() + + private lazy var stackView: UIStackView = { + let stackView = UIStackView() + stackView.translatesAutoresizingMaskIntoConstraints = false + stackView.axis = .vertical + return stackView + }() + + // MARK: - Init + init() { + super.init(frame: .zero) + confighierarchy() + configConstraints() + } + + @available(*, unavailable) + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + + } + + func getPopularView(image: String, name: String, phone: String) { + imagePerson.image = UIImage(named: image) + nameLabel.text = name + phoneLabel.text = phone + } } + + + extension ContactListView { + // MARK: - Private Methods + private func confighierarchy() { + addSubview(imagePerson) + addSubview(stackView) + stackView.addArrangedSubview(nameLabel) + stackView.addArrangedSubview(phoneLabel) + } + + + private func configConstraints() { + NSLayoutConstraint.activate([ + + imagePerson.topAnchor.constraint(equalTo: self.topAnchor, constant: 16), + imagePerson.bottomAnchor.constraint(equalTo: self.bottomAnchor, constant: -16), + imagePerson.leadingAnchor.constraint(equalTo: self.leadingAnchor), + imagePerson.heightAnchor.constraint(equalToConstant: 60.0), + imagePerson.widthAnchor.constraint(equalToConstant: 60.0), + + stackView.centerYAnchor.constraint(equalTo: self.centerYAnchor), + stackView.leadingAnchor.constraint(equalTo: imagePerson.trailingAnchor, constant: 20.0), + stackView.trailingAnchor.constraint(equalTo: trailingAnchor, constant: -20.0), + ]) + } + + } diff --git a/solutions/devsprint-pedro-alvarez-2/FinanceApp/Screens/ContactList/ContactListViewController.swift b/solutions/devsprint-pedro-alvarez-2/FinanceApp/Screens/ContactList/ContactListViewController.swift index 19efab5..8d2a607 100644 --- a/solutions/devsprint-pedro-alvarez-2/FinanceApp/Screens/ContactList/ContactListViewController.swift +++ b/solutions/devsprint-pedro-alvarez-2/FinanceApp/Screens/ContactList/ContactListViewController.swift @@ -8,8 +8,64 @@ import UIKit class ContactListViewController: UIViewController { + + private let viewModel = ContactListViewModel() + + // MARK: - Private Properties UI + private lazy var contactTableView: UITableView = { + let tableView = UITableView(frame: .zero, style: .plain) + tableView.translatesAutoresizingMaskIntoConstraints = false + tableView.dataSource = self + tableView.backgroundColor = .clear + tableView.register(ContactCellView.self, forCellReuseIdentifier: ContactCellView.identifier) + return tableView + }() + + override func viewDidLoad() { + super.viewDidLoad() + view.backgroundColor = .white + title = "Contact List" + + } + + override func viewWillAppear(_ animated: Bool) { + super.viewWillAppear(animated) + confighierarchy() + configConstraints() + DispatchQueue.main.async { + self.contactTableView.reloadData() + } + } + +} - override func loadView() { - self.view = ContactListView() + extension ContactListViewController { + // MARK: - Private Methods + private func confighierarchy() { + view.addSubview(contactTableView) + } + + private func configConstraints() { + NSLayoutConstraint.activate([ + + contactTableView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor), + contactTableView.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor), + contactTableView.leadingAnchor.constraint(equalTo: view.leadingAnchor), + contactTableView.trailingAnchor.constraint(equalTo: view.trailingAnchor) + ]) + } + } + +extension ContactListViewController: UITableViewDataSource { + func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + guard let cell = tableView.dequeueReusableCell(withIdentifier: ContactCellView.identifier, for: indexPath) as? ContactCellView else { return UITableViewCell() } + let contactList = viewModel.contactList[indexPath.row] + cell.configureCell(with: contactList) + return cell + } + + func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + return viewModel.contactList.count } } + diff --git a/solutions/devsprint-pedro-alvarez-2/FinanceApp/Screens/ContactList/ViewModel/ContactListViewModel.swift b/solutions/devsprint-pedro-alvarez-2/FinanceApp/Screens/ContactList/ViewModel/ContactListViewModel.swift new file mode 100644 index 0000000..6c2a27a --- /dev/null +++ b/solutions/devsprint-pedro-alvarez-2/FinanceApp/Screens/ContactList/ViewModel/ContactListViewModel.swift @@ -0,0 +1,29 @@ +// +// ContactListViewModel.swift +// FinanceApp +// +// Created by Kleiton Mendes on 15/12/22. +// + +import UIKit + +class ContactListViewModel { + + let contactList: [ContactListModel] = [ + ContactListModel(name: "Ronald Robertson", phone: "+55 (11) 99999-9999", image: "img"), + ContactListModel(name: "Johnny Watson", phone: "+55 (11) 99999-9999", image: "img2"), + ContactListModel(name: "Annette Cooper", phone: "+55 (11) 99999-9999", image:"img3"), + ContactListModel(name: "Arthur Bell", phone: "+55 (11) 99999-9999", image: "img4"), + ContactListModel(name: "Jane Warren", phone: "+55 (11) 99999-9999", image: "img5"), + ContactListModel(name: "JMorris Henry", phone: "+55 (11) 99999-9999", image: "img6"), + ContactListModel(name: "Irma Flores", phone: "+55 (11) 99999-9999", image: "img7"), + ContactListModel(name: "Ronald Robertson", phone: "+55 (11) 99999-9999", image: "img"), + ContactListModel(name: "Johnny Watson", phone: "+55 (11) 99999-9999", image: "img2"), + ContactListModel(name: "Annette Cooper", phone: "+55 (11) 99999-9999", image:"img3"), + ContactListModel(name: "Arthur Bell", phone: "+55 (11) 99999-9999", image: "img4"), + ContactListModel(name: "Jane Warren", phone: "+55 (11) 99999-9999", image: "img5"), + ContactListModel(name: "JMorris Henry", phone: "+55 (11) 99999-9999", image: "img6"), + ContactListModel(name: "Irma Flores", phone: "+55 (11) 99999-9999", image: "img7"), + + ] +}