@@ -13,6 +13,7 @@ class IPOverrideViewController: UIViewController {
13
13
private let interactor : IPOverrideInteractor
14
14
private var cancellables = Set < AnyCancellable > ( )
15
15
private let alertPresenter : AlertPresenter
16
+ private let headerView = IPOverrideHeaderView ( )
16
17
17
18
weak var delegate : IPOverrideViewControllerDelegate ?
18
19
@@ -51,11 +52,11 @@ class IPOverrideViewController: UIViewController {
51
52
override func viewDidLoad( ) {
52
53
super. viewDidLoad ( )
53
54
54
- navigationController? . navigationItem. largeTitleDisplayMode = . never
55
55
view. backgroundColor = . secondaryColor
56
+ view. directionalLayoutMargins = UIMetrics . contentHeadingLayoutMargins
56
57
57
- addHeader ( )
58
- addPreamble ( )
58
+ configureNavigation ( )
59
+ addHeaderView ( )
59
60
addImportButtons ( )
60
61
addStatusLabel ( )
61
62
@@ -70,44 +71,21 @@ class IPOverrideViewController: UIViewController {
70
71
} . store ( in: & cancellables)
71
72
}
72
73
73
- private func addHeader( ) {
74
- let label = UILabel ( )
75
- label. font = . systemFont( ofSize: 32 , weight: . bold)
76
- label. textColor = . white
77
- label. text = NSLocalizedString (
74
+ private func configureNavigation( ) {
75
+ title = NSLocalizedString (
78
76
" IP_OVERRIDE_HEADER " ,
79
77
tableName: " IPOverride " ,
80
78
value: " Server IP override " ,
81
79
comment: " "
82
80
)
83
-
84
- let infoButton = UIButton ( type: . custom)
85
- infoButton. tintColor = . white
86
- infoButton. setImage ( UIImage ( resource: . iconInfo) , for: . normal)
87
- infoButton. addTarget ( self , action: #selector( didTapInfoButton) , for: . touchUpInside)
88
- infoButton. heightAnchor. constraint ( equalToConstant: 24 ) . isActive = true
89
- infoButton. widthAnchor. constraint ( equalTo: infoButton. heightAnchor, multiplier: 1 ) . isActive = true
90
-
91
- let headerView = UIStackView ( arrangedSubviews: [ label, infoButton, UIView ( ) ] )
92
- headerView. spacing = 8
93
-
94
- containerView. addArrangedSubview ( headerView)
95
- containerView. setCustomSpacing ( 14 , after: headerView)
96
81
}
97
82
98
- private func addPreamble( ) {
99
- let label = UILabel ( )
100
- label. font = . systemFont( ofSize: 12 , weight: . semibold)
101
- label. textColor = . white. withAlphaComponent ( 0.6 )
102
- label. numberOfLines = 0
103
- label. text = NSLocalizedString (
104
- " IP_OVERRIDE_PREAMBLE " ,
105
- tableName: " IPOverride " ,
106
- value: " Import files or text with new IP addresses for the servers in the Select location view. " ,
107
- comment: " "
108
- )
83
+ private func addHeaderView( ) {
84
+ headerView. onAbout = { [ weak self] in
85
+ self ? . delegate? . presentAbout ( )
86
+ }
109
87
110
- containerView. addArrangedSubview ( label )
88
+ containerView. addArrangedSubview ( headerView )
111
89
}
112
90
113
91
private func addImportButtons( ) {
@@ -140,44 +118,6 @@ class IPOverrideViewController: UIViewController {
140
118
containerView. addArrangedSubview ( statusView)
141
119
}
142
120
143
- @objc private func didTapInfoButton( ) {
144
- let message = NSLocalizedString (
145
- " IP_OVERRIDE_DIALOG_MESSAGE " ,
146
- tableName: " IPOverride " ,
147
- value: """
148
- On some networks, where various types of censorship are being used, our server IP addresses are \
149
- sometimes blocked.
150
- To circumvent this you can import a file or a text, provided by our support team, \
151
- with new IP addresses that override the default addresses of the servers in the Select location view.
152
- If you are having issues connecting to VPN servers, please contact support.
153
- """ ,
154
- comment: " "
155
- )
156
-
157
- let presentation = AlertPresentation (
158
- id: " ip-override-info-alert " ,
159
- icon: . info,
160
- title: NSLocalizedString (
161
- " IP_OVERRIDE_INFO_DIALOG_TITLE " ,
162
- tableName: " IPOverride " ,
163
- value: " Server IP override " ,
164
- comment: " "
165
- ) ,
166
- message: message,
167
- buttons: [ AlertAction (
168
- title: NSLocalizedString (
169
- " IP_OVERRIDE_INFO_DIALOG_OK_BUTTON " ,
170
- tableName: " IPOverride " ,
171
- value: " Got it! " ,
172
- comment: " "
173
- ) ,
174
- style: . default
175
- ) ]
176
- )
177
-
178
- alertPresenter. showAlert ( presentation: presentation, animated: true )
179
- }
180
-
181
121
@objc private func didTapClearButton( ) {
182
122
let presentation = AlertPresentation (
183
123
id: " ip-override-clear-alert " ,
0 commit comments