Skip to content

Commit c089bfc

Browse files
committed
Ajuste de PR.
1 parent 472a847 commit c089bfc

File tree

6 files changed

+46
-114
lines changed

6 files changed

+46
-114
lines changed

solutions/devsprint-caio-santos-7/FinanceApp/Screens/UserProfile/UserProfileHeaderView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ final class UserProfileHeaderView: UIStackView {
6262

6363
override init(frame: CGRect) {
6464
super.init(frame: frame)
65-
backgroundColor = .systemGray5
65+
backgroundColor = .init(hexString: "#F2F2F7")
6666
setupView()
6767
}
6868

solutions/devsprint-caio-santos-7/FinanceApp/Screens/UserProfile/UserProfileView.swift

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,19 @@ class UserProfileView: UIView {
2323
}()
2424

2525
private lazy var tableView: UITableView = {
26-
let tableView = UITableView(frame: .zero)
26+
let tableView = UITableView(frame: .zero, style: .insetGrouped)
2727
tableView.translatesAutoresizingMaskIntoConstraints = false
2828
tableView.register(UserProfileViewCell.self, forCellReuseIdentifier: UserProfileViewCell.identifier)
29-
tableView.register(UserProfileViewGeneralCell.self, forCellReuseIdentifier: UserProfileViewGeneralCell.identifier)
29+
// tableView.register(UserProfileViewGeneralCell.self, forCellReuseIdentifier: UserProfileViewGeneralCell.identifier)
30+
tableView.register(UITableViewCell.self, forCellReuseIdentifier: UITableViewCell.reuseIdentifier)
3031
return tableView
3132
}()
3233

3334
override init(frame: CGRect) {
3435
super.init(frame: frame)
3536
self.tableView.delegate = self
3637
self.tableView.dataSource = self
37-
self.configViews()
38-
self.buildHierarchy()
39-
self.setupConstraints()
38+
self.setupView()
4039
}
4140

4241
required init?(coder: NSCoder) {
@@ -46,27 +45,27 @@ class UserProfileView: UIView {
4645

4746
extension UserProfileView: ViewCodable {
4847

49-
func configViews (){
50-
backgroundColor = .white
51-
}
52-
53-
func buildHierarchy(){
48+
func buildHierarchy() {
5449
addSubview(headerStackView)
5550
addSubview(tableView)
5651
}
5752

58-
func setupConstraints(){
53+
func setupConstraints() {
5954
NSLayoutConstraint.activate([
60-
headerStackView.topAnchor.constraint(equalTo: topAnchor),
55+
headerStackView.topAnchor.constraint(equalTo: topAnchor, constant: 32),
6156
headerStackView.leadingAnchor.constraint(equalTo: leadingAnchor),
6257
headerStackView.trailingAnchor.constraint(equalTo: trailingAnchor),
6358

64-
tableView.topAnchor.constraint(lessThanOrEqualTo: headerStackView.bottomAnchor, constant: 16),
59+
tableView.topAnchor.constraint(lessThanOrEqualTo: headerStackView.bottomAnchor, constant: 8),
6560
tableView.leadingAnchor.constraint(equalTo: leadingAnchor),
6661
tableView.trailingAnchor.constraint(equalTo: trailingAnchor),
6762
tableView.bottomAnchor.constraint(equalTo: bottomAnchor)
6863
])
6964
}
65+
66+
func applyAdditionalChanges() {
67+
backgroundColor = .init(hexString: "#F2F2F7")
68+
}
7069
}
7170

7271
extension UserProfileView: UITableViewDelegate, UITableViewDataSource {
@@ -97,22 +96,25 @@ extension UserProfileView: UITableViewDelegate, UITableViewDataSource {
9796
cell.configure(leftLabel: userData[indexPath.row] , rightLabel: userModel[indexPath.row])
9897
return cell
9998
} else if indexPath.section == 0 && indexPath.row > 2 && indexPath.row < 6 {
100-
let buttonCell = tableView.dequeueReusableCell(withIdentifier: UserProfileViewGeneralCell.identifier, for: indexPath) as! UserProfileViewGeneralCell
101-
buttonCell.configure(generalLabel: self.testModel[indexPath.row - 3])
102-
99+
let buttonCell: UITableViewCell = .createCell(for: tableView, at: indexPath)!
100+
buttonCell.textLabel?.text = self.testModel[indexPath.row - 3]
101+
buttonCell.accessoryType = .disclosureIndicator
103102
return buttonCell
104-
105103
} else if indexPath.section == 1 && indexPath.row < 2 {
106-
let generalCell = tableView.dequeueReusableCell(withIdentifier: UserProfileViewGeneralCell.identifier, for: indexPath) as! UserProfileViewGeneralCell
107-
generalCell.configure(generalLabel: generalModel[indexPath.row])
108-
109-
return generalCell
110-
104+
let buttonCell: UITableViewCell = .createCell(for: tableView, at: indexPath)!
105+
buttonCell.textLabel?.text = generalModel[indexPath.row]
106+
buttonCell.accessoryType = .disclosureIndicator
107+
return buttonCell
111108
} else {
112109
let versionCell = tableView.dequeueReusableCell(withIdentifier: UserProfileViewCell.identifier, for: indexPath) as! UserProfileViewCell
113110
versionCell.configure(leftLabel: appModel[indexPath.row - 2], rightLabel: versionModel[indexPath.row - 2])
114-
115111
return versionCell
116112
}
117113
}
114+
115+
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
116+
// Chamar um método
117+
118+
tableView.deselectRow(at: indexPath, animated: false)
119+
}
118120
}

solutions/devsprint-caio-santos-7/FinanceApp/Screens/UserProfile/UserProfileViewCell.swift

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,7 @@ class UserProfileViewCell: UITableViewCell {
1414
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
1515
super.init(style: style, reuseIdentifier: reuseIdentifier)
1616
contentView.backgroundColor = .white
17-
configViews()
18-
buildHierarchy()
19-
setupConstraints()
20-
17+
setupView()
2118
}
2219

2320
required init?(coder: NSCoder) {
@@ -57,11 +54,6 @@ extension UserProfileViewCell: ViewCodable {
5754
self.rightLabel.text = rightLabel
5855
}
5956

60-
61-
func configViews() {
62-
backgroundColor = .white
63-
}
64-
6557
func buildHierarchy() {
6658
contentView.addSubview(leftLabel)
6759
contentView.addSubview(rightLabel)

solutions/devsprint-caio-santos-7/FinanceApp/Screens/UserProfile/UserProfileViewGeneralCell.swift

Lines changed: 0 additions & 81 deletions
This file was deleted.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//
2+
// UserProfileViewTests.swift
3+
// FinanceAppTests
4+
//
5+
// Created by Caio Santos on 21/10/22.
6+
//
7+
@testable import FinanceApp
8+
import SnapshotTesting
9+
import XCTest
10+
11+
final class UserProfileViewTests: XCTestCase {
12+
13+
func testRenderView() {
14+
let component = UserProfileView()
15+
assertSnapshot(matching: component, as: .image(size: CGSize(width: UIScreen.main.bounds.width,
16+
height: UIScreen.main.bounds.height)))
17+
}
18+
19+
}
100 KB
Loading

0 commit comments

Comments
 (0)