From 8318821a8031834e37af50dcc5759927ed41ce79 Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Sat, 29 Feb 2020 17:56:24 +0100 Subject: [PATCH] Return provider guidance string dynamically Drop annoying switch/case. --- Passepartout-iOS/Global/Theme.swift | 12 +++++++- .../Scenes/AccountViewController.swift | 28 +------------------ Submodules/Core | 2 +- 3 files changed, 13 insertions(+), 29 deletions(-) diff --git a/Passepartout-iOS/Global/Theme.swift b/Passepartout-iOS/Global/Theme.swift index ce8217ee..d4fb28d2 100644 --- a/Passepartout-iOS/Global/Theme.swift +++ b/Passepartout-iOS/Global/Theme.swift @@ -185,8 +185,9 @@ extension MFMailComposeViewController { } } -// FIXME: load from index JSON extension Infrastructure.Metadata { + + // FIXME: load from index JSON var logo: UIImage? { let bundle = Bundle(for: AppDelegate.self) guard let image = AssetImageTypeAlias(named: name, in: bundle, compatibleWith: nil) else { @@ -194,6 +195,15 @@ extension Infrastructure.Metadata { } return image } + + var guidanceString: String? { + let key = "account.sections.guidance.footer.infrastructure.\(name)" + let format = NSLocalizedString(key, tableName: "Core", bundle: Bundle(for: AppDelegate.self), comment: "") + guard !format.isEmpty else { + return nil + } + return String(format: format, locale: .current, description) + } } extension PoolGroup { diff --git a/Passepartout-iOS/Scenes/AccountViewController.swift b/Passepartout-iOS/Scenes/AccountViewController.swift index b9eebf44..3d7d9001 100644 --- a/Passepartout-iOS/Scenes/AccountViewController.swift +++ b/Passepartout-iOS/Scenes/AccountViewController.swift @@ -61,33 +61,7 @@ class AccountViewController: UIViewController, StrongTableHost { guard let name = infrastructureName, let metadata = InfrastructureFactory.shared.metadata(forName: name) else { return nil } - // XXX: should make this dynamic - let V = L10n.Core.Account.Sections.Guidance.Footer.Infrastructure.self - switch metadata.name { - case .mullvad: - return V.mullvad(metadata.description) - - case .nordvpn: - return V.nordvpn(metadata.description) - - case .pia: - return V.pia(metadata.description) - - case .protonvpn: - return V.protonvpn(metadata.description) - - case .tunnelbear: - return V.tunnelbear(metadata.description) - - case .vyprvpn: - return V.vyprvpn(metadata.description) - - case .windscribe: - return V.windscribe(metadata.description) - - default: - return nil - } + return metadata.guidanceString } private var guidanceURL: String? { diff --git a/Submodules/Core b/Submodules/Core index f3cf90e8..47913267 160000 --- a/Submodules/Core +++ b/Submodules/Core @@ -1 +1 @@ -Subproject commit f3cf90e8276d51860c33b2faef49718ef1e5b269 +Subproject commit 479132676b5de9c746f369338d53f32e769cf794