Allow configuring proxy in onboarding

This commit is contained in:
Nora Trapp 2022-09-26 07:19:56 -07:00 committed by Nora Trapp
parent 8d1e038611
commit a0970db6fa
2 changed files with 46 additions and 1 deletions

View File

@ -21,6 +21,14 @@ class ProxySettingsViewController: OWSTableViewController2, OWSNavigationView {
}
private func updateNavigationBar() {
if navigationController?.viewControllers.count == 1 {
navigationItem.leftBarButtonItem = .init(
barButtonSystemItem: .cancel,
target: self,
action: #selector(didTapCancel)
)
}
navigationItem.rightBarButtonItem = UIBarButtonItem(
barButtonSystemItem: .save,
target: self,
@ -113,7 +121,22 @@ class ProxySettingsViewController: OWSTableViewController2, OWSNavigationView {
databaseStorage.write { transaction in
SignalProxy.setProxyHost(host: self.hostTextField.text, useProxy: self.useProxy, transaction: transaction)
}
navigationController?.popViewController(animated: true)
if navigationController?.viewControllers.count == 1 {
dismiss(animated: true)
} else {
navigationController?.popViewController(animated: true)
}
}
@objc
private func didTapCancel() {
if hasPendingChanges {
OWSActionSheets.showPendingChangesActionSheet { [weak self] in
self?.dismiss(animated: true)
}
} else {
dismiss(animated: true)
}
}
func shouldCancelNavigationBack() -> Bool {

View File

@ -147,6 +147,28 @@ public class RegistrationPhoneNumberViewController: OnboardingBaseViewController
view.addSubview(primaryView)
primaryView.autoPinEdgesToSuperviewEdges()
let proxyButton = ContextMenuButton(contextMenu: .init([
.init(
title: NSLocalizedString(
"USE_PROXY_BUTTON",
comment: "Button to activate the signal proxy"
),
handler: { [weak self] _ in
guard let self = self else { return }
let vc = ProxySettingsViewController()
self.presentFormSheet(OWSNavigationController(rootViewController: vc), animated: true)
}
)
]))
proxyButton.showsContextMenuAsPrimaryAction = true
proxyButton.setImage(Theme.iconImage(.more24), for: .normal)
proxyButton.tintColor = Theme.primaryIconColor
proxyButton.autoSetDimensions(to: .square(40))
view.addSubview(proxyButton)
proxyButton.autoPinEdge(toSuperviewMargin: .trailing)
proxyButton.autoPinEdge(toSuperviewMargin: .top)
// Setup subviews and stack views
let titleString = (Self.tsAccountManager.isReregistering
? NSLocalizedString(