@@ -15,6 +15,15 @@ class ConfirmationView: UIView {
1515
1616 weak var delegate : ConfirmationViewDelegate ?
1717
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+
1827 private lazy var confirmationImage : UIImageView = {
1928 let element = UIImageView ( )
2029 element. translatesAutoresizingMaskIntoConstraints = false
@@ -29,6 +38,7 @@ class ConfirmationView: UIView {
2938 element. translatesAutoresizingMaskIntoConstraints = false
3039 element. text = " Your transfer was successful "
3140 element. font = UIFont . systemFont ( ofSize: 18 , weight: . bold)
41+ element. numberOfLines = 0
3242 return element
3343 } ( )
3444
@@ -49,42 +59,41 @@ class ConfirmationView: UIView {
4959
5060 override init ( frame: CGRect ) {
5161 super. init ( frame: frame)
52- setUpViews ( )
53- buildHierarchy ( )
54- setupConstraints ( )
62+ setupView ( )
5563 }
5664
5765 required init ? ( coder: NSCoder ) {
5866 fatalError ( " init(coder:) has not been implemented " )
5967 }
6068}
6169
62- extension ConfirmationView : ViewCodable {
70+ extension ConfirmationView : ViewCodable {
6371
64- func setUpViews( ) {
65- backgroundColor = . white
66- }
67-
68- func buildHierarchy( ) {
69- addSubview ( confirmationImage)
70- addSubview ( confirmationLabel)
72+ func buildHierarchy( ) {
73+ addSubview ( stackView)
74+ stackView. addArrangedSubview ( confirmationImage)
75+ stackView. addArrangedSubview ( confirmationLabel)
7176 addSubview ( confirmationButton)
7277 }
7378
7479 func setupConstraints( ) {
7580 NSLayoutConstraint . activate ( [
76- confirmationImage. centerXAnchor. constraint ( equalTo: self . centerXAnchor) ,
77- confirmationImage. centerYAnchor. constraint ( equalTo: self . centerYAnchor) ,
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 ) ,
85+
7886 confirmationImage. widthAnchor. constraint ( equalToConstant: 64 ) ,
7987 confirmationImage. heightAnchor. constraint ( equalToConstant: 64 ) ,
8088
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 ) ,
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 ) ,
8792 confirmationButton. heightAnchor. constraint ( equalToConstant: 64 )
8893 ] )
8994 }
95+
96+ func applyAdditionalChanges( ) {
97+ backgroundColor = . white
98+ }
9099}
0 commit comments