Skip to content

Commit 9b59b25

Browse files
authored
Merge pull request #70 from rafallgo/feat/transfersView
Implementar TransfersView
2 parents d66f994 + a5b522c commit 9b59b25

File tree

5 files changed

+143
-0
lines changed

5 files changed

+143
-0
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ class TabBarViewController: UITabBarController, UITabBarControllerDelegate {
1414

1515
// Atribuir delegate para que a VC utilize os metodos do delegate
1616
self.delegate = self
17+
18+
let lineView = UIView(frame: CGRect(x: 0, y: 0, width: tabBar.frame.size.width, height: 0.5))
19+
lineView.backgroundColor = UIColor.systemGray
20+
tabBar.addSubview(lineView)
1721
}
1822

1923
override func viewWillAppear(_ animated: Bool) {

solutions/devsprint-caio-santos-7/FinanceApp/Screens/Transfers/TransfersView.swift

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,119 @@
88
import UIKit
99

1010
class TransfersView: UIView {
11+
12+
private lazy var stackViewPrincipal: UIStackView = {
13+
let sv = UIStackView()
14+
sv.translatesAutoresizingMaskIntoConstraints = false
15+
sv.spacing = 10
16+
sv.axis = .vertical
17+
sv.distribution = .fill
18+
return sv
19+
}()
20+
21+
private lazy var stackViewSec: UIStackView = {
22+
let sv = UIStackView()
23+
sv.translatesAutoresizingMaskIntoConstraints = false
24+
sv.alignment = .center
25+
sv.spacing = 10
26+
sv.axis = .horizontal
27+
return sv
28+
}()
29+
30+
lazy var centerLabel: UITextField = {
31+
var input = UITextField()
32+
input.translatesAutoresizingMaskIntoConstraints = false
33+
input.keyboardType = .numberPad
34+
input.font = UIFont.boldSystemFont(ofSize: 40)
35+
input.attributedPlaceholder = .init(
36+
string: "$0",
37+
attributes: [NSAttributedString.Key.foregroundColor: UIColor(red: 0.235, green: 0.235, blue: 0.263, alpha: 0.6)]
38+
)
39+
input.textAlignment = .center
40+
41+
return input
42+
}()
43+
44+
private lazy var to: UILabel = {
45+
let to = UILabel()
46+
to.translatesAutoresizingMaskIntoConstraints = false
47+
to.text = "To"
48+
to.textColor = UIColor(red: 0.235, green: 0.235, blue: 0.263, alpha: 0.6)
49+
to.font = UIFont.systemFont(ofSize: 12)
50+
return to
51+
}()
52+
53+
lazy var buttonContact: UIButton = {
54+
var button = UIButton()
55+
button.translatesAutoresizingMaskIntoConstraints = false
56+
button.backgroundColor = UIColor(red: 0.463, green: 0.463, blue: 0.502, alpha: 0.12)
57+
button.setTitle("Choose contact", for: .normal)
58+
button.titleLabel?.font = UIFont.boldSystemFont(ofSize: 12)
59+
button.setTitleColor(.black, for: .normal)
60+
button.layer.cornerRadius = 15
61+
return button
62+
}()
63+
64+
private lazy var iconGreen: UIView = {
65+
let view = UIView()
66+
view.translatesAutoresizingMaskIntoConstraints = false
67+
view.layer.cornerRadius = 4
68+
view.backgroundColor = .green
69+
return view
70+
}()
71+
72+
lazy var buttonTransfer: UIButton = {
73+
var button = UIButton()
74+
button.translatesAutoresizingMaskIntoConstraints = false
75+
button.backgroundColor = .systemBlue
76+
button.setTitle("Transfer", for: .normal)
77+
button.titleLabel?.font = UIFont.boldSystemFont(ofSize: 15)
78+
button.layer.cornerRadius = 10
79+
return button
80+
}()
81+
82+
83+
override init(frame: CGRect) {
84+
super.init(frame: frame)
85+
backgroundColor = .systemBackground
86+
self.configSetup()
87+
self.setUpContraints()
88+
}
89+
90+
private func configSetup(){
91+
addSubview(stackViewPrincipal)
92+
stackViewPrincipal.addArrangedSubview(centerLabel)
93+
stackViewPrincipal.addArrangedSubview(stackViewSec)
94+
stackViewSec.addArrangedSubview(to)
95+
stackViewSec.addArrangedSubview(buttonContact)
96+
buttonContact.addSubview(iconGreen)
97+
addSubview(buttonTransfer)
98+
}
99+
100+
required init?(coder: NSCoder) {
101+
fatalError("init(coder:) has not been implemented")
102+
}
103+
104+
private func setUpContraints(){
105+
let lg = safeAreaLayoutGuide
106+
107+
NSLayoutConstraint.activate([
108+
stackViewPrincipal.centerYAnchor.constraint(equalTo: lg.centerYAnchor),
109+
stackViewPrincipal.centerXAnchor.constraint(equalTo: lg.centerXAnchor),
11110

111+
iconGreen.widthAnchor.constraint(equalToConstant: 10),
112+
iconGreen.heightAnchor.constraint(equalToConstant: 10),
113+
iconGreen.centerYAnchor.constraint(equalTo: buttonContact.centerYAnchor),
114+
iconGreen.leadingAnchor.constraint(equalTo: buttonContact.leadingAnchor, constant: 8),
115+
116+
buttonContact.widthAnchor.constraint(equalToConstant: 135),
117+
buttonContact.heightAnchor.constraint(equalToConstant: 30),
118+
119+
buttonTransfer.bottomAnchor.constraint(equalTo: lg.bottomAnchor, constant: -16),
120+
buttonTransfer.heightAnchor.constraint(equalToConstant: 45),
121+
buttonTransfer.leadingAnchor.constraint(equalTo: lg.leadingAnchor, constant: 45),
122+
buttonTransfer.trailingAnchor.constraint(equalTo: lg.trailingAnchor, constant: -45)
123+
])
124+
}
125+
12126
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//
2+
// TransfersViewTests.swift
3+
// FinanceAppTests
4+
//
5+
// Created by Caio Santos on 20/10/22.
6+
//
7+
8+
@testable import FinanceApp
9+
import SnapshotTesting
10+
import XCTest
11+
12+
final class TransfersViewTests: XCTestCase {
13+
14+
override class func setUp() {
15+
// SnapshotTesting.isRecording = true
16+
}
17+
18+
func testRenderView() {
19+
let component = TransfersView()
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+
}
42.6 KB
Loading
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit 87d7c7e136caf6392738096dae0568355a0619e3

0 commit comments

Comments
 (0)