1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
|
//
// SetupAccountCompletedContentView.swift
// MullvadVPN
//
// Created by Mojgan on 2023-06-30.
// Copyright © 2025 Mullvad VPN AB. All rights reserved.
//
import UIKit
protocol SetupAccountCompletedContentViewDelegate: AnyObject {
func didTapPrivacyButton(view: SetupAccountCompletedContentView, button: AppButton)
func didTapStartingAppButton(view: SetupAccountCompletedContentView, button: AppButton)
}
class SetupAccountCompletedContentView: UIView {
private let titleLabel: UILabel = {
let label = UILabel()
label.font = .preferredFont(forTextStyle: .largeTitle, weight: .bold)
label.textColor = .white
label.adjustsFontForContentSizeCategory = true
label.lineBreakMode = .byWordWrapping
label.numberOfLines = .zero
label.text = NSLocalizedString("You’re all set!", comment: "")
return label
}()
private let commentLabel: UILabel = {
let label = UILabel()
let message = NSMutableAttributedString(
string: [
NSLocalizedString(
"Go ahead and start using the app to begin reclaiming your online privacy.",
comment: ""
),
NSLocalizedString(
"To continue your journey as a privacy ninja, visit our website to pick up"
+ " other privacy-friendly habits and tools.",
comment: ""
),
].joined(separator: " "))
message.apply(paragraphStyle: .alert)
label.attributedText = message
label.font = .preferredFont(forTextStyle: .body)
label.textColor = .white
label.adjustsFontForContentSizeCategory = true
label.numberOfLines = .zero
return label
}()
private let privacyButton: AppButton = {
let button = AppButton(style: .success)
button.setAccessibilityIdentifier(.learnAboutPrivacyButton)
let localizedString = NSLocalizedString("Learn about privacy", comment: "")
button.setTitle(localizedString, for: .normal)
button.setImage(UIImage(named: "IconExtlink")?.imageFlippedForRightToLeftLayoutDirection(), for: .normal)
return button
}()
private let startButton: AppButton = {
let button = AppButton(style: .success)
button.setAccessibilityIdentifier(.startUsingTheAppButton)
button.setTitle(NSLocalizedString("Start using the app", comment: ""), for: .normal)
return button
}()
private let textsStackView: UIStackView = {
let stackView = UIStackView()
stackView.axis = .vertical
return stackView
}()
private let buttonsStackView: UIStackView = {
let stackView = UIStackView()
stackView.axis = .vertical
stackView.spacing = UIMetrics.interButtonSpacing
return stackView
}()
let scrollView = UIScrollView()
weak var delegate: SetupAccountCompletedContentViewDelegate?
override init(frame: CGRect) {
super.init(frame: frame)
backgroundColor = .primaryColor
backgroundColor = .secondaryColor
configureUI()
addActions()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
private func configureUI() {
textsStackView.addArrangedSubview(titleLabel)
textsStackView.setCustomSpacing(UIMetrics.padding8, after: titleLabel)
textsStackView.addArrangedSubview(commentLabel)
textsStackView.setCustomSpacing(UIMetrics.padding16, after: commentLabel)
buttonsStackView.addArrangedSubview(privacyButton)
buttonsStackView.addArrangedSubview(startButton)
scrollView.addConstrainedSubviews([textsStackView]) {
textsStackView.pinEdgesToSuperviewMargins(
PinnableEdges([
.leading(0),
.trailing(0),
]))
textsStackView.pinEdgesToSuperview(
PinnableEdges([
.top(0),
.bottom(0),
]))
}
addConstrainedSubviews([scrollView, buttonsStackView]) {
scrollView.pinEdgesToSuperviewMargins(
PinnableEdges([
.top(UIMetrics.contentLayoutMargins.top),
.leading(0),
.trailing(0),
]))
buttonsStackView.pinEdgesToSuperviewMargins(
PinnableEdges([
.leading(UIMetrics.padding8),
.trailing(UIMetrics.padding8),
.bottom(UIMetrics.contentLayoutMargins.bottom),
]))
buttonsStackView.topAnchor.constraint(
equalTo: scrollView.bottomAnchor,
constant: UIMetrics.contentLayoutMargins.top
)
}
}
private func addActions() {
[privacyButton, startButton].forEach {
$0.addTarget(self, action: #selector(tapped(button:)), for: .touchUpInside)
}
}
@objc private func tapped(button: AppButton) {
switch button.accessibilityIdentifier {
case AccessibilityIdentifier.learnAboutPrivacyButton.asString:
delegate?.didTapPrivacyButton(view: self, button: button)
case AccessibilityIdentifier.startUsingTheAppButton.asString:
delegate?.didTapStartingAppButton(view: self, button: button)
default: return
}
}
}
|