Skip to content

Commit 61ebf50

Browse files
committed
fix request on pull request
1 parent 6e894dd commit 61ebf50

File tree

2 files changed

+49
-36
lines changed

2 files changed

+49
-36
lines changed

solutions/devsprint-pedro-alvarez-2/FinanceApp/Screens/Commons/CodeBaseView.swift

+43-36
Original file line numberDiff line numberDiff line change
@@ -7,43 +7,50 @@
77
import UIKit
88

99
public class CodeBaseView<ViewModel>: UIView {
10-
open var hierarchies: [HierarchyRelation] { [] }
11-
12-
override init(frame: CGRect) {
13-
super.init(frame: frame)
14-
setupHierarchy()
15-
setupConstraints()
16-
}
17-
18-
required init?(coder: NSCoder) {
19-
fatalError("init(coder:) has not been implemented")
20-
}
21-
22-
private var viewModel: ViewModel? {
23-
didSet {
24-
configureView(viewModel)
10+
11+
open var hierarchies: [HierarchyRelation] { [] }
12+
13+
override init(frame: CGRect) {
14+
super.init(frame: frame)
15+
setup()
16+
}
17+
18+
@available(*,unavailable)
19+
required init?(coder: NSCoder) {
20+
fatalError("init(coder:) has not been implemented")
21+
}
22+
23+
private func setup() {
24+
setupHierarchy()
25+
setupConstraints()
26+
}
27+
28+
private var viewModel: ViewModel? {
29+
didSet {
30+
configureView(viewModel)
31+
}
32+
}
33+
34+
public func setupViewModel(_ viewModel: ViewModel) {
35+
self.viewModel = viewModel
2536
}
26-
}
27-
28-
public func setupViewModel(_ viewModel: ViewModel) {
29-
self.viewModel = viewModel
30-
}
31-
32-
private func setupHierarchy() {
33-
for relation in hierarchies {
34-
for subview in relation.subviews {
35-
if let stackView = relation.parentView as? UIStackView {
36-
stackView.addArrangedSubview(subview)
37-
} else {
38-
relation.parentView.addSubview(subview)
37+
38+
private func setupHierarchy() {
39+
for relation in hierarchies {
40+
for subview in relation.subviews {
41+
if let stackView = relation.parentView as? UIStackView {
42+
stackView.addArrangedSubview(subview)
43+
} else {
44+
relation.parentView.addSubview(subview)
45+
}
46+
}
3947
}
40-
}
4148
}
42-
}
43-
44-
private func setupConstraints() {
45-
NSLayoutConstraint.activate(constraints)
46-
}
47-
48-
open func configureView(_ viewModel: ViewModel?) { }
49+
50+
private func setupConstraints() {
51+
NSLayoutConstraint.activate(constraints)
52+
}
53+
54+
open func configureView(_ viewModel: ViewModel?) { }
55+
4956
}

solutions/devsprint-pedro-alvarez-2/FinanceApp/Screens/Home/HomeViewController.swift

+6
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,13 @@ class HomeViewController: UIViewController {
4545
private func setupProfileImage() {
4646
let barButton = UIBarButtonItem()
4747
barButton.customView = ProfileButtonView()
48+
barButton.action = #selector(redirectToUserProfile)
4849
self.navigationItem.rightBarButtonItem = barButton
4950
}
51+
52+
@objc private func redirectToUserProfile(){
53+
//TODO: Implement redirect to UserProfile
54+
print("TODO: implementar redirect")
55+
}
5056

5157
}

0 commit comments

Comments
 (0)