|
8 | 8 | import UIKit |
9 | 9 |
|
10 | 10 | 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), |
11 | 110 |
|
| 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 | + |
12 | 126 | } |
0 commit comments