Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 0 additions & 22 deletions Stepic/Legacy/Model/RemoteConfig/RemoteConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ final class RemoteConfig {
Key.showStreaksNotificationTrigger.rawValue: NSString(string: Self.defaultShowStreaksNotificationTrigger.rawValue),
Key.adaptiveBackendUrl.rawValue: NSString(string: StepikApplicationsInfo.adaptiveRatingURL),
Key.supportedInAdaptiveModeCourses.rawValue: NSArray(array: StepikApplicationsInfo.adaptiveSupportedCourses),
Key.darkModeAvailable.rawValue: NSNumber(value: true),
Key.arQuickLookAvailable.rawValue: NSNumber(value: false),
Key.isDisabledStepsSupported.rawValue: NSNumber(value: false),
Key.searchResultsQueryParams.rawValue: NSDictionary(dictionary: ["is_popular": "true", "is_public": "true"]),
Key.isCoursePricesEnabled.rawValue: NSNumber(value: false),
Key.isCourseRevenueAvailable.rawValue: NSNumber(value: false)
Expand Down Expand Up @@ -81,31 +79,13 @@ final class RemoteConfig {
return supportedCourses.compactMap { Int($0) }
}

var isDarkModeAvailable: Bool {
if DeviceInfo.current.OSVersion.major < 13 {
return false
}

return FirebaseRemoteConfig.RemoteConfig
.remoteConfig()
.configValue(forKey: Key.darkModeAvailable.rawValue)
.boolValue
}

var isARQuickLookAvailable: Bool {
FirebaseRemoteConfig.RemoteConfig
.remoteConfig()
.configValue(forKey: Key.arQuickLookAvailable.rawValue)
.boolValue
}

var isDisabledStepsSupported: Bool {
FirebaseRemoteConfig.RemoteConfig
.remoteConfig()
.configValue(forKey: Key.isDisabledStepsSupported.rawValue)
.boolValue
}

var searchResultsQueryParams: JSONDictionary {
guard let configValue = FirebaseRemoteConfig.RemoteConfig.remoteConfig().configValue(
forKey: Key.searchResultsQueryParams.rawValue
Expand Down Expand Up @@ -194,9 +174,7 @@ final class RemoteConfig {
case showStreaksNotificationTrigger = "show_streaks_notification_trigger"
case adaptiveBackendUrl = "adaptive_backend_url"
case supportedInAdaptiveModeCourses = "supported_adaptive_courses_ios"
case darkModeAvailable = "is_dark_mode_available_ios"
case arQuickLookAvailable = "is_ar_quick_look_available_ios"
case isDisabledStepsSupported = "is_disabled_steps_supported"
case searchResultsQueryParams = "search_query_params_ios"
case isCoursePricesEnabled = "is_course_prices_enabled_ios"
case isCourseRevenueAvailable = "is_course_revenue_available_ios"
Expand Down
1 change: 0 additions & 1 deletion Stepic/Sources/Modules/Settings/SettingsAssembly.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ final class SettingsAssembly: Assembly {
provider: provider,
analytics: StepikAnalytics.shared,
userAccountService: UserAccountService(),
remoteConfig: .shared,
downloadsDeletionService: DownloadsDeletionService(),
dataBackUpdateService: DataBackUpdateService.default
)
Expand Down
5 changes: 1 addition & 4 deletions Stepic/Sources/Modules/Settings/SettingsInteractor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ final class SettingsInteractor: SettingsInteractorProtocol {

private let analytics: Analytics
private let userAccountService: UserAccountServiceProtocol
private let remoteConfig: RemoteConfig

private let downloadsDeletionService: DownloadsDeletionServiceProtocol
private let dataBackUpdateService: DataBackUpdateServiceProtocol
Expand All @@ -50,7 +49,7 @@ final class SettingsInteractor: SettingsInteractorProtocol {
shouldUseCellularDataForDownloads: self.provider.shouldUseCellularDataForDownloads,
isAutoplayEnabled: self.provider.isAutoplayEnabled,
isAdaptiveModeEnabled: self.provider.isAdaptiveModeEnabled,
isDarkModeAvailable: self.remoteConfig.isDarkModeAvailable,
isDarkModeAvailable: self.provider.isDarkModeAvailable,
isAuthorized: self.isAuthorized
)
}
Expand All @@ -66,15 +65,13 @@ final class SettingsInteractor: SettingsInteractorProtocol {
provider: SettingsProviderProtocol,
analytics: Analytics,
userAccountService: UserAccountServiceProtocol,
remoteConfig: RemoteConfig,
downloadsDeletionService: DownloadsDeletionServiceProtocol,
dataBackUpdateService: DataBackUpdateServiceProtocol
) {
self.presenter = presenter
self.provider = provider
self.analytics = analytics
self.userAccountService = userAccountService
self.remoteConfig = remoteConfig
self.downloadsDeletionService = downloadsDeletionService
self.dataBackUpdateService = dataBackUpdateService
}
Expand Down
8 changes: 8 additions & 0 deletions Stepic/Sources/Modules/Settings/SettingsProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ protocol SettingsProviderProtocol: AnyObject {
var globalStepFontSize: StepFontSize { get set }
var availableStepFontSizes: [StepFontSize] { get }
// ApplicationTheme
var isDarkModeAvailable: Bool { get }
var globalApplicationTheme: ApplicationTheme { get set }
var availableApplicationThemes: [ApplicationTheme] { get }

Expand Down Expand Up @@ -82,6 +83,13 @@ final class SettingsProvider: SettingsProviderProtocol {

var availableStepFontSizes: [StepFontSize] { StepFontSize.allCases }

var isDarkModeAvailable: Bool {
if #available(iOS 13.0, *) {
return true
}
return false
}

var globalApplicationTheme: ApplicationTheme {
get {
self.applicationThemeService.theme
Expand Down
3 changes: 1 addition & 2 deletions Stepic/Sources/Modules/Step/StepAssembly.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ final class StepAssembly: Assembly {
stepID: self.stepID,
presenter: presenter,
provider: provider,
analytics: StepikAnalytics.shared,
remoteConfig: RemoteConfig.shared
analytics: StepikAnalytics.shared
)
let viewController = StepViewController(
interactor: interactor,
Expand Down
1 change: 0 additions & 1 deletion Stepic/Sources/Modules/Step/StepDataFlow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ enum StepDataFlow {
let step: Step
let stepFontSize: StepFontSize
let storedImages: [StoredImage]
let isDisabledStepsSupported: Bool
}

struct Response {
Expand Down
9 changes: 2 additions & 7 deletions Stepic/Sources/Modules/Step/StepInteractor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ final class StepInteractor: StepInteractorProtocol {
private let provider: StepProviderProtocol
private let analytics: Analytics

private let remoteConfig: RemoteConfig

private let stepID: Step.IdType
private var currentStepPlainObject: StepPlainObject?

Expand All @@ -38,13 +36,11 @@ final class StepInteractor: StepInteractorProtocol {
stepID: Step.IdType,
presenter: StepPresenterProtocol,
provider: StepProviderProtocol,
analytics: Analytics,
remoteConfig: RemoteConfig
analytics: Analytics
) {
self.presenter = presenter
self.provider = provider
self.analytics = analytics
self.remoteConfig = remoteConfig

self.stepID = stepID
}
Expand Down Expand Up @@ -277,8 +273,7 @@ final class StepInteractor: StepInteractorProtocol {
let data = StepDataFlow.StepLoad.Data(
step: step,
stepFontSize: stepFontSize,
storedImages: storedImages,
isDisabledStepsSupported: self.remoteConfig.isDisabledStepsSupported
storedImages: storedImages
)

return .value(data)
Expand Down
2 changes: 1 addition & 1 deletion Stepic/Sources/Modules/Step/StepPresenter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ final class StepPresenter: StepPresenterProtocol {
func presentStep(response: StepDataFlow.StepLoad.Response) {
switch response.result {
case .success(let data):
if !data.step.isEnabled && data.isDisabledStepsSupported {
if !data.step.isEnabled {
let viewModel = self.makeDisabledStepViewModel(
step: data.step,
stepFontSize: data.stepFontSize,
Expand Down
8 changes: 3 additions & 5 deletions Stepic/Sources/Services/ApplicationThemeService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ final class ApplicationThemeService: ApplicationThemeServiceProtocol {
get {
if let userSelectedApplicationTheme = self.userSelectedApplicationTheme {
return userSelectedApplicationTheme
} else if #available(iOS 13.0, *) {
return .default
} else {
return self.remoteConfig.isDarkModeAvailable ? .default : .light
return .light
}
}
set {
Expand All @@ -40,10 +42,6 @@ final class ApplicationThemeService: ApplicationThemeServiceProtocol {

func registerDefaultTheme() {
if #available(iOS 13.0, *) {
guard self.remoteConfig.isDarkModeAvailable else {
return self.applyTheme(.light)
}

if let userSelectedApplicationTheme = self.userSelectedApplicationTheme {
self.applyTheme(userSelectedApplicationTheme)
} else {
Expand Down