Skip to content

Commit 7fb2a6f

Browse files
committed
implementa ConfirmationView + ConfirmationViewcontroller
1 parent 068c2de commit 7fb2a6f

File tree

4 files changed

+89
-5
lines changed

4 files changed

+89
-5
lines changed

solutions/devsprint-caio-santos-7/FinanceApp/AppDelegate/SceneDelegate.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
1515
guard let windowScene = (scene as? UIWindowScene) else { return }
1616

1717
self.window = UIWindow(frame: UIScreen.main.bounds)
18-
self.window?.rootViewController = TabBarViewController()
18+
self.window?.rootViewController = ConfirmationViewController()
19+
//self.window?.rootViewController = TabBarViewController()
1920
self.window?.windowScene = windowScene
2021
self.window?.makeKeyAndVisible()
2122
}

solutions/devsprint-caio-santos-7/FinanceApp/DebugYourViews/DebugViewController.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ import UIKit
1919

2020
class DebugViewController: UIViewController {
2121

22-
private let myView: AccountSummaryView = {
23-
let view = AccountSummaryView()
22+
private let myView: ConfirmationView = {
23+
let view = ConfirmationView()
2424
view.translatesAutoresizingMaskIntoConstraints = false
2525
return view
2626
}()
@@ -36,7 +36,7 @@ class DebugViewController: UIViewController {
3636
myView.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor, constant: 16),
3737
myView.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor, constant: -16),
3838
myView.centerYAnchor.constraint(equalTo: view.safeAreaLayoutGuide.centerYAnchor),
39-
// myView.heightAnchor.constraint(equalToConstant: myViewHeight)
39+
// myView.heightAnchor.constraint(equalToConstant: myViewHeight)
4040
])
4141
}
4242

solutions/devsprint-caio-santos-7/FinanceApp/Screens/Confirmation/ConfirmationView.swift

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,84 @@
77

88
import UIKit
99

10+
protocol ConfirmationViewDelegate:AnyObject{
11+
func tappedConfirmationButton()
12+
}
13+
1014
class ConfirmationView: UIView {
15+
16+
weak var delegate: ConfirmationViewDelegate?
17+
18+
private lazy var confirmationImage: UIImageView = {
19+
let element = UIImageView()
20+
element.translatesAutoresizingMaskIntoConstraints = false
21+
element.image = UIImage(named: "checkmark.circle.fill")
22+
element.contentMode = .scaleAspectFill
23+
element.tintColor = UIColor(red: 0/255, green: 220/255, blue: 41/255, alpha: 1)
24+
return element
25+
}()
26+
27+
private lazy var confirmationLabel: UILabel = {
28+
let element = UILabel()
29+
element.translatesAutoresizingMaskIntoConstraints = false
30+
element.text = "Your transfer was successful"
31+
element.font = UIFont.systemFont(ofSize: 18, weight: .bold)
32+
return element
33+
}()
34+
35+
private lazy var confirmationButton: UIButton = {
36+
let element = UIButton()
37+
element.translatesAutoresizingMaskIntoConstraints = false
38+
element.backgroundColor = UIColor(red: 0/255, green: 120/255, blue: 255/255, alpha: 1)
39+
element.layer.cornerRadius = 10
40+
element.setTitle("Nice", for: .normal)
41+
element.setTitleColor(UIColor.white, for: .normal)
42+
element.addTarget(self, action: #selector(self.confirmationButtonPressed), for: .touchUpInside)
43+
return element
44+
}()
45+
46+
@objc func confirmationButtonPressed(){
47+
print("Configurar ConfirmationViewDelegate")
48+
}
49+
50+
override init(frame: CGRect) {
51+
super.init(frame: frame)
52+
setUpViews()
53+
buildHierarchy()
54+
setupConstraints()
55+
}
56+
57+
required init?(coder: NSCoder) {
58+
fatalError("init(coder:) has not been implemented")
59+
}
60+
}
1161

62+
extension ConfirmationView: ViewCodable{
63+
64+
func setUpViews(){
65+
backgroundColor = .white
66+
}
67+
68+
func buildHierarchy(){
69+
addSubview(confirmationImage)
70+
addSubview(confirmationLabel)
71+
addSubview(confirmationButton)
72+
}
73+
74+
func setupConstraints() {
75+
NSLayoutConstraint.activate([
76+
confirmationImage.centerXAnchor.constraint(equalTo: self.centerXAnchor),
77+
confirmationImage.centerYAnchor.constraint(equalTo: self.centerYAnchor),
78+
confirmationImage.widthAnchor.constraint(equalToConstant: 64),
79+
confirmationImage.heightAnchor.constraint(equalToConstant: 64),
80+
81+
confirmationLabel.centerXAnchor.constraint(equalTo: self.centerXAnchor),
82+
confirmationLabel.topAnchor.constraint(equalTo: self.confirmationImage.bottomAnchor, constant: 8),
83+
84+
confirmationButton.bottomAnchor.constraint(equalTo: self.safeAreaLayoutGuide.bottomAnchor, constant: -32),
85+
confirmationButton.leadingAnchor.constraint(equalTo: self.safeAreaLayoutGuide.leadingAnchor, constant: 32),
86+
confirmationButton.trailingAnchor.constraint(equalTo: self.safeAreaLayoutGuide.trailingAnchor, constant: -32),
87+
confirmationButton.heightAnchor.constraint(equalToConstant: 64)
88+
])
89+
}
1290
}

solutions/devsprint-caio-santos-7/FinanceApp/Screens/Confirmation/ConfirmationViewController.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@ import UIKit
99

1010
class ConfirmationViewController: UIViewController {
1111

12+
private let confirmationView: ConfirmationView = {
13+
let confirmationView = ConfirmationView()
14+
return confirmationView
15+
}()
16+
1217
override func loadView() {
13-
self.view = ConfirmationView()
18+
self.view = confirmationView
1419
}
1520
}

0 commit comments

Comments
 (0)