Skip to content

Commit 8c39364

Browse files
authored
Merge pull request #68 from CleberReis/feature/profile-header-view
UserProfileHeaderView
2 parents f544e90 + c5d9af6 commit 8c39364

File tree

4 files changed

+132
-1
lines changed

4 files changed

+132
-1
lines changed
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
//
2+
// UserProfileHeaderView.swift
3+
// FinanceApp
4+
//
5+
// Created by Cleber Reis on 18/10/22.
6+
//
7+
8+
import UIKit
9+
10+
final class UserProfileHeaderView: UIStackView {
11+
12+
private lazy var profileImage: UIImageView = {
13+
let image = UIImageView()
14+
image.translatesAutoresizingMaskIntoConstraints = false
15+
image.image = UIImage(named: "avatar-placeholder")
16+
image.contentMode = .scaleAspectFill
17+
image.layer.cornerRadius = 40
18+
image.layer.masksToBounds = true
19+
20+
return image
21+
}()
22+
23+
private lazy var titleLabel: UILabel = {
24+
let label = UILabel()
25+
label.translatesAutoresizingMaskIntoConstraints = false
26+
label.font = .systemFont(ofSize: 18, weight: .bold)
27+
label.text = "Irma Flores"
28+
label.textColor = .black
29+
30+
return label
31+
}()
32+
33+
private lazy var agencyLabel: UILabel = {
34+
let label = UILabel()
35+
label.translatesAutoresizingMaskIntoConstraints = false
36+
label.text = "Agency 001"
37+
label.font = .systemFont(ofSize: 14, weight: .regular)
38+
label.textColor = .lightGray
39+
40+
return label
41+
}()
42+
43+
private lazy var accountLabel: UILabel = {
44+
let label = UILabel()
45+
label.translatesAutoresizingMaskIntoConstraints = false
46+
label.text = "Account 123456-7"
47+
label.font = .systemFont(ofSize: 14, weight: .regular)
48+
label.textColor = .lightGray
49+
50+
return label
51+
}()
52+
53+
private lazy var bankLabel: UILabel = {
54+
let label = UILabel()
55+
label.translatesAutoresizingMaskIntoConstraints = false
56+
label.text = "DEVPASS Bank"
57+
label.font = .systemFont(ofSize: 14, weight: .regular)
58+
label.textColor = .lightGray
59+
60+
return label
61+
}()
62+
63+
override init(frame: CGRect) {
64+
super.init(frame: frame)
65+
backgroundColor = .systemGray5
66+
setupView()
67+
}
68+
69+
@available(*, unavailable)
70+
required init(coder: NSCoder) {
71+
fatalError("init(coder:) has not been implemented")
72+
}
73+
74+
}
75+
76+
extension UserProfileHeaderView: ViewCodable {
77+
78+
func buildHierarchy() {
79+
addArrangedSubview(profileImage)
80+
addArrangedSubview(titleLabel)
81+
addArrangedSubview(agencyLabel)
82+
addArrangedSubview(accountLabel)
83+
addArrangedSubview(bankLabel)
84+
}
85+
86+
func setupConstraints() {
87+
NSLayoutConstraint.activate([
88+
profileImage.heightAnchor.constraint(equalToConstant: 80),
89+
profileImage.widthAnchor.constraint(equalToConstant: 80),
90+
])
91+
}
92+
93+
func applyAdditionalChanges() {
94+
translatesAutoresizingMaskIntoConstraints = false
95+
axis = .vertical
96+
spacing = 8
97+
alignment = .center
98+
}
99+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
//
2+
// UserProfileHeaderViewTests.swift
3+
// FinanceAppTests
4+
//
5+
// Created by Cleber Reis on 18/10/22.
6+
//
7+
8+
9+
@testable import FinanceApp
10+
import SnapshotTesting
11+
import XCTest
12+
13+
final class UserProfileHeaderViewTests: XCTestCase {
14+
15+
private var sut: UserProfileHeaderView?
16+
17+
override func setUp() {
18+
sut = UserProfileHeaderView()
19+
20+
let frame = CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: 250)
21+
sut?.frame = frame
22+
}
23+
24+
func test_WhenInitUserProfileHeaderView_ThenView_ShouldHaveValidSnapshot() throws {
25+
let unwrappedSut = try XCTUnwrap(sut)
26+
assertSnapshot(matching: unwrappedSut, as: .image)
27+
}
28+
29+
override func tearDown() {
30+
sut = nil
31+
}
32+
}

solutions/devsprint-caio-santos-7/Podfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ SPEC CHECKSUMS:
1313

1414
PODFILE CHECKSUM: 943c16186866fd17226e49884f6360bcda0046f8
1515

16-
COCOAPODS: 1.11.3
16+
COCOAPODS: 1.11.2

0 commit comments

Comments
 (0)