-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into GT-app-flow-tests-dev-merge
# Conflicts: # godtools/App/Features/Dashboard/Presentation/Tools/Subviews/ToolsFilterSelectionView/Subviews/ToolFilterButtonView/ToolFilterButtonView.swift
- Loading branch information
Showing
210 changed files
with
4,047 additions
and
1,609 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
...essonFilter/Data-DomainInterface/GetLessonFilterLanguagesInterfaceStringsRepository.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// | ||
// GetLessonFilterLanguagesInterfaceStringsRepository.swift | ||
// godtools | ||
// | ||
// Created by Rachael Skeath on 6/29/24. | ||
// Copyright © 2024 Cru. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import Combine | ||
import LocalizationServices | ||
|
||
class GetLessonFilterLanguagesInterfaceStringsRepository: GetLessonFilterLanguagesInterfaceStringsRepositoryInterface { | ||
|
||
private let localizationServices: LocalizationServicesInterface | ||
|
||
init(localizationServices: LocalizationServicesInterface) { | ||
self.localizationServices = localizationServices | ||
} | ||
|
||
func getStringsPublisher(translateInAppLanguage: AppLanguageDomainModel) -> AnyPublisher<LessonFilterLanguagesInterfaceStringsDomainModel, Never> { | ||
|
||
let localeId = translateInAppLanguage.localeId | ||
|
||
let interfaceStrings = LessonFilterLanguagesInterfaceStringsDomainModel( | ||
navTitle: localizationServices.stringForLocaleElseEnglish(localeIdentifier: localeId, key: LessonFilterStringKeys.navTitle.rawValue) | ||
) | ||
|
||
return Just(interfaceStrings) | ||
.eraseToAnyPublisher() | ||
} | ||
} |
115 changes: 115 additions & 0 deletions
115
...s/App/Features/LessonFilter/Data-DomainInterface/GetLessonFilterLanguagesRepository.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
// | ||
// GetLessonFilterLanguagesRepository.swift | ||
// godtools | ||
// | ||
// Created by Rachael Skeath on 7/1/24. | ||
// Copyright © 2024 Cru. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import Combine | ||
import LocalizationServices | ||
|
||
class GetLessonFilterLanguagesRepository: GetLessonFilterLanguagesRepositoryInterface { | ||
|
||
private let resourcesRepository: ResourcesRepository | ||
private let languagesRepository: LanguagesRepository | ||
private let getTranslatedLanguageName: GetTranslatedLanguageName | ||
private let localizationServices: LocalizationServicesInterface | ||
|
||
init(resourcesRepository: ResourcesRepository, languagesRepository: LanguagesRepository, getTranslatedLanguageName: GetTranslatedLanguageName, localizationServices: LocalizationServicesInterface) { | ||
self.resourcesRepository = resourcesRepository | ||
self.languagesRepository = languagesRepository | ||
self.getTranslatedLanguageName = getTranslatedLanguageName | ||
self.localizationServices = localizationServices | ||
} | ||
|
||
func getLessonFilterLanguagesPublisher(translatedInAppLanguage: AppLanguageDomainModel) -> AnyPublisher<[LessonLanguageFilterDomainModel], Never> { | ||
|
||
return resourcesRepository.getResourcesChangedPublisher() | ||
.flatMap { _ in | ||
|
||
let languageIds = self.resourcesRepository.getAllLessonLanguageIds() | ||
|
||
let languages = self.createLessonLanguageFilterDomainModelList(from: languageIds, translatedInAppLanguage: translatedInAppLanguage) | ||
|
||
return Just(languages) | ||
} | ||
.eraseToAnyPublisher() | ||
} | ||
|
||
func getLessonLanguageFilterFromLanguageCode(languageCode: String?, translatedInAppLanguage: AppLanguageDomainModel) -> LessonLanguageFilterDomainModel? { | ||
|
||
guard let languageCode = languageCode, | ||
let language = languagesRepository.getLanguage(code: languageCode) | ||
else { | ||
return nil | ||
} | ||
|
||
return createLessonLanguageFilterDomainModel(with: language, translatedInAppLanguage: translatedInAppLanguage) | ||
} | ||
|
||
func getLessonLanguageFilterFromLanguageId(languageId: String?, translatedInAppLanguage: AppLanguageDomainModel) -> LessonLanguageFilterDomainModel? { | ||
|
||
guard let languageId = languageId, | ||
let language = languagesRepository.getLanguage(id: languageId) | ||
else { | ||
return nil | ||
} | ||
|
||
return createLessonLanguageFilterDomainModel(with: language, translatedInAppLanguage: translatedInAppLanguage) | ||
} | ||
} | ||
|
||
extension GetLessonFilterLanguagesRepository { | ||
|
||
private func createLessonLanguageFilterDomainModelList(from languageIds: [String], translatedInAppLanguage: AppLanguageDomainModel) -> [LessonLanguageFilterDomainModel] { | ||
|
||
let languages: [LessonLanguageFilterDomainModel] = languagesRepository.getLanguages(ids: languageIds) | ||
.compactMap { languageModel in | ||
|
||
let lessonsAvailableCount: Int = resourcesRepository.getAllLessonsCount(filterByLanguageId: languageModel.id) | ||
|
||
guard lessonsAvailableCount > 0 else { | ||
return nil | ||
} | ||
|
||
return self.createLessonLanguageFilterDomainModel(with: languageModel, translatedInAppLanguage: translatedInAppLanguage) | ||
} | ||
.sorted { language1, language2 in | ||
|
||
return language1.translatedName.lowercased() < language2.translatedName.lowercased() | ||
} | ||
|
||
return languages | ||
} | ||
|
||
private func createLessonLanguageFilterDomainModel(with languageModel: LanguageModel, translatedInAppLanguage: AppLanguageDomainModel) -> LessonLanguageFilterDomainModel? { | ||
|
||
let lessonsAvailableCount: Int = resourcesRepository.getAllLessonsCount(filterByLanguageId: languageModel.id) | ||
|
||
let languageName = getTranslatedLanguageName.getLanguageName(language: languageModel.code, translatedInLanguage: languageModel.code) | ||
let translatedLanguageName = getTranslatedLanguageName.getLanguageName(language: languageModel.code, translatedInLanguage: translatedInAppLanguage) | ||
|
||
let lessonsAvailableText: String = getLessonsAvailableText(lessonsAvailableCount: lessonsAvailableCount, translatedInAppLanguage: translatedInAppLanguage) | ||
|
||
return LessonLanguageFilterDomainModel( | ||
languageId: languageModel.id, | ||
languageName: languageName, | ||
translatedName: translatedLanguageName, | ||
lessonsAvailableText: lessonsAvailableText | ||
) | ||
} | ||
|
||
func getLessonsAvailableText(lessonsAvailableCount: Int, translatedInAppLanguage: AppLanguageDomainModel) -> String { | ||
|
||
let formatString = localizationServices.stringForLocaleElseSystemElseEnglish( | ||
localeIdentifier: translatedInAppLanguage.localeId, | ||
key: LessonFilterStringKeys.lessonsAvailableText.rawValue | ||
) | ||
|
||
let localizedString = String(format: formatString, locale: Locale(identifier: translatedInAppLanguage), lessonsAvailableCount) | ||
|
||
return localizedString | ||
} | ||
} |
Oops, something went wrong.