Commit d39d3a03 authored by Jose Blaya's avatar Jose Blaya
Browse files

Use feature flags to show or hide a view

parent 31f457e6
......@@ -137,6 +137,14 @@ public protocol AccountProvider: class {
*/
func cleanDatabase()
/**
Returns the enabled features in the app.
- Parameter callback: Returns `nil` on success.
*/
func featureFlags(_ callback: SuccessLibraryCallback?)
#if os(iOS)
/**
Lists the available plans with their corresponding product to purchase in order to get them.
......
......@@ -70,4 +70,6 @@ protocol WebServices: class {
func submitDebugLog(_ log: DebugLog, _ callback: SuccessLibraryCallback?)
func featureFlags(_ callback: LibraryCallback<[String]>?)
}
......@@ -319,6 +319,15 @@ class DefaultAccountProvider: AccountProvider, ConfigurationAccess, DatabaseAcce
}
}
func featureFlags(_ callback: SuccessLibraryCallback?) {
webServices.featureFlags { (features, nil) in
if let features = features, !features.isEmpty {
Client.configuration.featureFlags.append(contentsOf: features)
}
callback?(nil)
}
}
#if os(iOS)
func subscriptionInformation(_ callback: LibraryCallback<AppStoreInformation>?) {
log.debug("Fetching available product keys...")
......
......@@ -144,6 +144,9 @@ extension Client {
/// Store the account password in memory when the email is set and the user is LoggedIn.
public var tempAccountPassword: String
/// Enabled features
public var featureFlags: [String]
// MARK: Initialization
init() {
......@@ -216,6 +219,7 @@ extension Client {
maxQuickConnectServers = 6
tempAccountPassword = ""
featureFlags = []
}
// MARK: WebServices
......
......@@ -260,6 +260,11 @@ class PIAWebServices: WebServices, ConfigurationAccess {
}
}
func featureFlags(_ callback: LibraryCallback<[String]>?) {
callback?(["dedicated-ip"], nil)
}
#if os(iOS)
func signup(with request: Signup, _ callback: ((Credentials?, Error?) -> Void)?) {
......
......@@ -306,4 +306,7 @@ public class MockAccountProvider: AccountProvider, WebServicesConsumer {
callback?(true, nil)
}
public func featureFlags(_ callback: SuccessLibraryCallback?) {
callback?(nil)
}
}
......@@ -131,4 +131,8 @@ class MockWebServices: WebServices {
}
func featureFlags(_ callback: LibraryCallback<[String]>?) {
callback?(["mock-test"], nil)
}
}
......@@ -431,4 +431,8 @@ class EphemeralAccountProvider: AccountProvider, ProvidersAccess, InAppAccess {
}
}
func featureFlags(_ callback: SuccessLibraryCallback?) {
callback?(nil)
}
}
......@@ -114,6 +114,6 @@ SPEC CHECKSUMS:
TunnelKit: 1733ed87934deb57edc7aa5f4b25185bf302a7d4
TweetNacl: 3abf4d1d2082b0114e7a67410e300892448951e6
PODFILE CHECKSUM: 4e30427f8560a243bbdac8f09b026767a23a302a
PODFILE CHECKSUM: 7b505471eb03240fadcb14de86defe1d40d92822
COCOAPODS: 1.9.3
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment