diff options
| author | Andrej Mihajlov <and@mullvad.net> | 2022-03-24 14:33:33 +0100 |
|---|---|---|
| committer | Andrej Mihajlov <and@mullvad.net> | 2022-03-25 16:32:27 +0100 |
| commit | a1533f400aabefe93ea1c157c8ac9b83448c22b4 (patch) | |
| tree | afd3958e01155ef46ac36b610b02aff437146751 | |
| parent | 8c12b2a7ba302ee5f07591df9e45bbd178517b59 (diff) | |
| download | mullvadvpn-a1533f400aabefe93ea1c157c8ac9b83448c22b4.tar.xz mullvadvpn-a1533f400aabefe93ea1c157c8ac9b83448c22b4.zip | |
Settings: add FAQ & Guides row
| -rw-r--r-- | ios/MullvadVPN/ApplicationConfiguration.swift | 3 | ||||
| -rw-r--r-- | ios/MullvadVPN/SettingsDataSource.swift | 13 | ||||
| -rw-r--r-- | ios/MullvadVPN/SettingsViewController.swift | 21 | ||||
| -rw-r--r-- | ios/MullvadVPN/en.lproj/Settings.strings | 3 |
4 files changed, 35 insertions, 5 deletions
diff --git a/ios/MullvadVPN/ApplicationConfiguration.swift b/ios/MullvadVPN/ApplicationConfiguration.swift index a44e372365..35b70ebbf9 100644 --- a/ios/MullvadVPN/ApplicationConfiguration.swift +++ b/ios/MullvadVPN/ApplicationConfiguration.swift @@ -38,6 +38,9 @@ extension ApplicationConfiguration { return [mainApplicationLogFileURL, packetTunnelLogFileURL].compactMap { $0 } } + /// FAQ & Guides URL. + static let faqAndGuidesURL = URL(string: "https://mullvad.net/help/tag/mullvad-app/")! + /// Default API endpoint static let defaultAPIEndpoint = AnyIPEndpoint(string: "193.138.218.78:443")! diff --git a/ios/MullvadVPN/SettingsDataSource.swift b/ios/MullvadVPN/SettingsDataSource.swift index f4a2267492..231bd70b56 100644 --- a/ios/MullvadVPN/SettingsDataSource.swift +++ b/ios/MullvadVPN/SettingsDataSource.swift @@ -46,6 +46,7 @@ class SettingsDataSource: NSObject, AccountObserver, UITableViewDataSource, UITa case wireguardKey case version case problemReport + case faq } private var snapshot = DataSourceSnapshot<Section, Item>() @@ -88,7 +89,7 @@ class SettingsDataSource: NSObject, AccountObserver, UITableViewDataSource, UITa newSnapshot.appendSections([.version, .problemReport]) newSnapshot.appendItems([.version], in: .version) - newSnapshot.appendItems([.problemReport], in: .problemReport) + newSnapshot.appendItems([.problemReport, .faq], in: .problemReport) snapshot = newSnapshot } @@ -153,6 +154,16 @@ class SettingsDataSource: NSObject, AccountObserver, UITableViewDataSource, UITa cell.setCustomDisclosureIndicator() return cell + + case .faq: + let cell = tableView.dequeueReusableCell(withIdentifier: CellReuseIdentifiers.basicCell.rawValue, for: indexPath) as! SettingsCell + cell.titleLabel.text = NSLocalizedString("FAQ_AND_GUIDES_CELL_LABEL", tableName: "Settings", value: "FAQ & Guides", comment: "") + cell.detailTitleLabel.text = nil + cell.accessibilityIdentifier = nil + cell.unsetCustomDisclosureIndicator() + + return cell + } } diff --git a/ios/MullvadVPN/SettingsViewController.swift b/ios/MullvadVPN/SettingsViewController.swift index 16696b977a..031a3fdb7f 100644 --- a/ios/MullvadVPN/SettingsViewController.swift +++ b/ios/MullvadVPN/SettingsViewController.swift @@ -7,13 +7,14 @@ // import Foundation +import SafariServices import UIKit protocol SettingsViewControllerDelegate: AnyObject { func settingsViewControllerDidFinish(_ controller: SettingsViewController) } -class SettingsViewController: UITableViewController, SettingsDataSourceDelegate { +class SettingsViewController: UITableViewController, SettingsDataSourceDelegate, SFSafariViewControllerDelegate { weak var delegate: SettingsViewControllerDelegate? @@ -56,13 +57,23 @@ class SettingsViewController: UITableViewController, SettingsDataSourceDelegate // MARK: - SettingsDataSourceDelegate func settingsDataSource(_ dataSource: SettingsDataSource, didSelectItem item: SettingsDataSource.Item) { - guard let route = item.navigationRoute else { return } + if let route = item.navigationRoute { + let settingsNavigationController = navigationController as? SettingsNavigationController - let settingsNavigationController = navigationController as? SettingsNavigationController + settingsNavigationController?.navigate(to: route, animated: true) + } else if case .faq = item { + let safariViewController = SFSafariViewController(url: ApplicationConfiguration.faqAndGuidesURL) + safariViewController.delegate = self - settingsNavigationController?.navigate(to: route, animated: true) + present(safariViewController, animated: true) + } } + // MARK: - SFSafariViewControllerDelegate + + func safariViewControllerDidFinish(_ controller: SFSafariViewController) { + controller.dismiss(animated: true) + } } extension SettingsDataSource.Item { @@ -78,6 +89,8 @@ extension SettingsDataSource.Item { return nil case .problemReport: return .problemReport + case .faq: + return nil } } } diff --git a/ios/MullvadVPN/en.lproj/Settings.strings b/ios/MullvadVPN/en.lproj/Settings.strings index ccc9fa8df3..b2bf665ace 100644 --- a/ios/MullvadVPN/en.lproj/Settings.strings +++ b/ios/MullvadVPN/en.lproj/Settings.strings @@ -13,6 +13,9 @@ /* No comment provided by engineer. */ "DNS_TEXT_CELL_PLACEHOLDER" = "Enter IP"; +/* No comment provided by engineer. */ +"FAQ_AND_GUIDES_CELL_LABEL" = "FAQ & Guides"; + /* Navigation title */ "NAVIGATION_TITLE" = "Settings"; |
