diff --git a/Kickstarter-iOS/Features/RemoteConfigFeatureFlagTools/Controller/RemoteConfigFeatureFlagToolsViewControllerTests.swift b/Kickstarter-iOS/Features/RemoteConfigFeatureFlagTools/Controller/RemoteConfigFeatureFlagToolsViewControllerTests.swift index 1898d17c58..8f5ae3dcf6 100644 --- a/Kickstarter-iOS/Features/RemoteConfigFeatureFlagTools/Controller/RemoteConfigFeatureFlagToolsViewControllerTests.swift +++ b/Kickstarter-iOS/Features/RemoteConfigFeatureFlagTools/Controller/RemoteConfigFeatureFlagToolsViewControllerTests.swift @@ -23,6 +23,7 @@ final class RemoteConfigFeatureFlagToolsViewControllerTests: TestCase { let mockRemoteConfigClient = MockRemoteConfigClient() |> \.features .~ [ RemoteConfigFeature.consentManagementDialogEnabled.rawValue: false, + RemoteConfigFeature.darkModeEnabled.rawValue: false, RemoteConfigFeature.facebookLoginInterstitialEnabled .rawValue: false, RemoteConfigFeature.reportThisProjectEnabled.rawValue: false diff --git a/Kickstarter-iOS/Features/RemoteConfigFeatureFlagTools/Controller/__Snapshots__/RemoteConfigFeatureFlagToolsViewControllerTests/testRemoteConfigFeatureFlagToolsViewController.1.png b/Kickstarter-iOS/Features/RemoteConfigFeatureFlagTools/Controller/__Snapshots__/RemoteConfigFeatureFlagToolsViewControllerTests/testRemoteConfigFeatureFlagToolsViewController.1.png index e932abc085..27e2035b65 100644 Binary files a/Kickstarter-iOS/Features/RemoteConfigFeatureFlagTools/Controller/__Snapshots__/RemoteConfigFeatureFlagToolsViewControllerTests/testRemoteConfigFeatureFlagToolsViewController.1.png and b/Kickstarter-iOS/Features/RemoteConfigFeatureFlagTools/Controller/__Snapshots__/RemoteConfigFeatureFlagToolsViewControllerTests/testRemoteConfigFeatureFlagToolsViewController.1.png differ diff --git a/Library/RemoteConfig/RemoteConfigFeature+Helpers.swift b/Library/RemoteConfig/RemoteConfigFeature+Helpers.swift index cab4531859..afc2c260e2 100644 --- a/Library/RemoteConfig/RemoteConfigFeature+Helpers.swift +++ b/Library/RemoteConfig/RemoteConfigFeature+Helpers.swift @@ -7,6 +7,13 @@ public func featureConsentManagementDialogEnabled() -> Bool { .isFeatureEnabled(featureKey: RemoteConfigFeature.consentManagementDialogEnabled) ?? false) } +public func featureDarkModeEnabled() -> Bool { + return AppEnvironment.current.userDefaults + .remoteConfigFeatureFlags[RemoteConfigFeature.darkModeEnabled.rawValue] ?? + (AppEnvironment.current.remoteConfigClient? + .isFeatureEnabled(featureKey: RemoteConfigFeature.darkModeEnabled) ?? false) +} + public func featureFacebookLoginInterstitialEnabled() -> Bool { return AppEnvironment.current.userDefaults .remoteConfigFeatureFlags[RemoteConfigFeature.facebookLoginInterstitialEnabled.rawValue] ?? diff --git a/Library/RemoteConfig/RemoteConfigFeature+HelpersTests.swift b/Library/RemoteConfig/RemoteConfigFeature+HelpersTests.swift index 4f3998e3fe..aa1a6812b3 100644 --- a/Library/RemoteConfig/RemoteConfigFeature+HelpersTests.swift +++ b/Library/RemoteConfig/RemoteConfigFeature+HelpersTests.swift @@ -21,6 +21,24 @@ final class RemoteConfigFeatureHelpersTests: TestCase { } } + func testDarkMode_RemoteConfig_FeatureFlag_False() { + let mockRemoteConfigClient = MockRemoteConfigClient() + |> \.features .~ [RemoteConfigFeature.darkModeEnabled.rawValue: false] + + withEnvironment(remoteConfigClient: mockRemoteConfigClient) { + XCTAssertFalse(featureDarkModeEnabled()) + } + } + + func testDarkMode_RemoteConfig_FeatureFlag_True() { + let mockRemoteConfigClient = MockRemoteConfigClient() + |> \.features .~ [RemoteConfigFeature.darkModeEnabled.rawValue: true] + + withEnvironment(remoteConfigClient: mockRemoteConfigClient) { + XCTAssertTrue(featureDarkModeEnabled()) + } + } + func testFacebookDeprecation_RemoteConfig_FeatureFlag_True() { let mockRemoteConfigClient = MockRemoteConfigClient() |> \.features .~ [RemoteConfigFeature.facebookLoginInterstitialEnabled.rawValue: true] diff --git a/Library/RemoteConfig/RemoteConfigFeature.swift b/Library/RemoteConfig/RemoteConfigFeature.swift index 67e63d61d0..e445373059 100644 --- a/Library/RemoteConfig/RemoteConfigFeature.swift +++ b/Library/RemoteConfig/RemoteConfigFeature.swift @@ -2,6 +2,7 @@ import Foundation public enum RemoteConfigFeature: String, CaseIterable { case consentManagementDialogEnabled = "consent_management_dialog" + case darkModeEnabled = "dark_mode" case facebookLoginInterstitialEnabled = "facebook_interstitial" case reportThisProjectEnabled = "report_this_project" case useOfAIProjectTab = "use_of_ai_project_tab" @@ -11,6 +12,7 @@ extension RemoteConfigFeature: CustomStringConvertible { public var description: String { switch self { case .consentManagementDialogEnabled: return "Consent Management Dialog" + case .darkModeEnabled: return "Dark Mode" case .facebookLoginInterstitialEnabled: return "Facebook Login Interstitial" case .reportThisProjectEnabled: return "Report This Project" case .useOfAIProjectTab: return "Use of AI Project Tab" diff --git a/Library/ViewModels/RemoteConfigFeatureFlagToolsViewModel.swift b/Library/ViewModels/RemoteConfigFeatureFlagToolsViewModel.swift index a94c3f40ba..7174227470 100644 --- a/Library/ViewModels/RemoteConfigFeatureFlagToolsViewModel.swift +++ b/Library/ViewModels/RemoteConfigFeatureFlagToolsViewModel.swift @@ -87,6 +87,8 @@ private func isFeatureEnabled(_ feature: RemoteConfigFeature) -> Bool { switch feature { case .consentManagementDialogEnabled: return featureConsentManagementDialogEnabled() + case .darkModeEnabled: + return featureDarkModeEnabled() case .facebookLoginInterstitialEnabled: return featureFacebookLoginInterstitialEnabled() case .reportThisProjectEnabled: @@ -103,6 +105,9 @@ private func getValueFromUserDefaults(for feature: RemoteConfigFeature) -> Bool? case .consentManagementDialogEnabled: return AppEnvironment.current.userDefaults .remoteConfigFeatureFlags[RemoteConfigFeature.consentManagementDialogEnabled.rawValue] + case .darkModeEnabled: + return AppEnvironment.current.userDefaults + .remoteConfigFeatureFlags[RemoteConfigFeature.darkModeEnabled.rawValue] case .facebookLoginInterstitialEnabled: return AppEnvironment.current.userDefaults .remoteConfigFeatureFlags[RemoteConfigFeature.facebookLoginInterstitialEnabled.rawValue] @@ -122,6 +127,9 @@ private func setValueInUserDefaults(for feature: RemoteConfigFeature, and value: case .consentManagementDialogEnabled: AppEnvironment.current.userDefaults .remoteConfigFeatureFlags[RemoteConfigFeature.consentManagementDialogEnabled.rawValue] = value + case .darkModeEnabled: + AppEnvironment.current.userDefaults + .remoteConfigFeatureFlags[RemoteConfigFeature.darkModeEnabled.rawValue] = value case .facebookLoginInterstitialEnabled: return AppEnvironment.current.userDefaults .remoteConfigFeatureFlags[RemoteConfigFeature.facebookLoginInterstitialEnabled.rawValue] = value diff --git a/Library/ViewModels/RemoteConfigFeatureFlagToolsViewModelTests.swift b/Library/ViewModels/RemoteConfigFeatureFlagToolsViewModelTests.swift index ed5eaea83f..e4c68de535 100644 --- a/Library/ViewModels/RemoteConfigFeatureFlagToolsViewModelTests.swift +++ b/Library/ViewModels/RemoteConfigFeatureFlagToolsViewModelTests.swift @@ -23,6 +23,7 @@ final class RemoteConfigFlagToolsViewModelTests: TestCase { let mockRemoteConfigClient = MockRemoteConfigClient() |> \.features .~ [ RemoteConfigFeature.consentManagementDialogEnabled.rawValue: true, + RemoteConfigFeature.darkModeEnabled.rawValue: true, RemoteConfigFeature.facebookLoginInterstitialEnabled.rawValue: true, RemoteConfigFeature.reportThisProjectEnabled.rawValue: true, RemoteConfigFeature.useOfAIProjectTab.rawValue: true @@ -45,6 +46,7 @@ final class RemoteConfigFlagToolsViewModelTests: TestCase { let mockRemoteConfigClient = MockRemoteConfigClient() |> \.features .~ [ RemoteConfigFeature.consentManagementDialogEnabled.rawValue: true, + RemoteConfigFeature.darkModeEnabled.rawValue: false, RemoteConfigFeature.facebookLoginInterstitialEnabled.rawValue: true, RemoteConfigFeature.reportThisProjectEnabled.rawValue: false, RemoteConfigFeature.useOfAIProjectTab.rawValue: false