Skip to content

Commit 754524b

Browse files
authored
Merge pull request #69 from mauriciodesm/main
ConfirmationView
2 parents 9d252f4 + dd9830d commit 754524b

File tree

6 files changed

+122
-5
lines changed

6 files changed

+122
-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: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,93 @@
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 stackView: UIStackView = {
19+
let stack = UIStackView()
20+
stack.translatesAutoresizingMaskIntoConstraints = false
21+
stack.axis = .vertical
22+
stack.spacing = 8
23+
stack.alignment = .center
24+
return stack
25+
}()
26+
27+
private lazy var confirmationImage: UIImageView = {
28+
let element = UIImageView()
29+
element.translatesAutoresizingMaskIntoConstraints = false
30+
element.image = UIImage(named: "checkmark.circle.fill")
31+
element.contentMode = .scaleAspectFill
32+
element.tintColor = UIColor(red: 0/255, green: 220/255, blue: 41/255, alpha: 1)
33+
return element
34+
}()
35+
36+
private lazy var confirmationLabel: UILabel = {
37+
let element = UILabel()
38+
element.translatesAutoresizingMaskIntoConstraints = false
39+
element.text = "Your transfer was successful"
40+
element.font = UIFont.systemFont(ofSize: 18, weight: .bold)
41+
element.numberOfLines = 0
42+
return element
43+
}()
44+
45+
private lazy var confirmationButton: UIButton = {
46+
let element = UIButton()
47+
element.translatesAutoresizingMaskIntoConstraints = false
48+
element.backgroundColor = UIColor(red: 0/255, green: 120/255, blue: 255/255, alpha: 1)
49+
element.layer.cornerRadius = 10
50+
element.setTitle("Nice", for: .normal)
51+
element.setTitleColor(UIColor.white, for: .normal)
52+
element.addTarget(self, action: #selector(self.confirmationButtonPressed), for: .touchUpInside)
53+
return element
54+
}()
55+
56+
@objc func confirmationButtonPressed(){
57+
print("Configurar ConfirmationViewDelegate")
58+
}
59+
60+
override init(frame: CGRect) {
61+
super.init(frame: frame)
62+
setupView()
63+
}
64+
65+
required init?(coder: NSCoder) {
66+
fatalError("init(coder:) has not been implemented")
67+
}
68+
}
69+
70+
extension ConfirmationView: ViewCodable {
71+
72+
func buildHierarchy() {
73+
addSubview(stackView)
74+
stackView.addArrangedSubview(confirmationImage)
75+
stackView.addArrangedSubview(confirmationLabel)
76+
addSubview(confirmationButton)
77+
}
78+
79+
func setupConstraints() {
80+
NSLayoutConstraint.activate([
81+
stackView.centerXAnchor.constraint(equalTo: safeAreaLayoutGuide.centerXAnchor),
82+
stackView.centerYAnchor.constraint(equalTo: safeAreaLayoutGuide.centerYAnchor),
83+
stackView.leadingAnchor.constraint(equalTo: safeAreaLayoutGuide.leadingAnchor, constant: 16),
84+
stackView.trailingAnchor.constraint(equalTo: safeAreaLayoutGuide.trailingAnchor, constant: -16),
1185

86+
confirmationImage.widthAnchor.constraint(equalToConstant: 64),
87+
confirmationImage.heightAnchor.constraint(equalToConstant: 64),
88+
89+
confirmationButton.bottomAnchor.constraint(equalTo: safeAreaLayoutGuide.bottomAnchor, constant: -32),
90+
confirmationButton.leadingAnchor.constraint(equalTo: safeAreaLayoutGuide.leadingAnchor, constant: 32),
91+
confirmationButton.trailingAnchor.constraint(equalTo: safeAreaLayoutGuide.trailingAnchor, constant: -32),
92+
confirmationButton.heightAnchor.constraint(equalToConstant: 64)
93+
])
94+
}
95+
96+
func applyAdditionalChanges() {
97+
backgroundColor = .white
98+
}
1299
}

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
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//
2+
// ConfirmationViewTests.swift
3+
// FinanceAppTests
4+
//
5+
// Created by Mauricio on 19/10/22.
6+
//
7+
8+
@testable import FinanceApp
9+
import SnapshotTesting
10+
import XCTest
11+
12+
final class ConfirmationViewTests: XCTestCase {
13+
14+
override class func setUp() {
15+
// SnapshotTesting.isRecording = true
16+
}
17+
18+
func testRenderView() {
19+
let component = ConfirmationView()
20+
component.backgroundColor = .white
21+
assertSnapshot(matching: component, as: .image(size: CGSize(width: UIScreen.main.bounds.width,
22+
height: UIScreen.main.bounds.height)))
23+
}
24+
}
43.5 KB
Loading

0 commit comments

Comments
 (0)