-
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 pull request #1940 from CruGlobal/GT-2219-Languages-Available-O…
…ffline GT-2219 languages available offline
- Loading branch information
Showing
13 changed files
with
188 additions
and
57 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
60 changes: 60 additions & 0 deletions
60
.../App/Features/AppLanguage/Data-DomainInterface/GetDownloadedLanguagesListRepository.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,60 @@ | ||
// | ||
// GetDownloadedLanguagesListRepository.swift | ||
// godtools | ||
// | ||
// Created by Rachael Skeath on 1/30/24. | ||
// Copyright © 2024 Cru. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import Combine | ||
|
||
class GetDownloadedLanguagesListRepository: GetDownloadedLanguagesListRepositoryInterface { | ||
|
||
private let languagesRepository: LanguagesRepository | ||
private let downloadedLanguagesRepository: DownloadedLanguagesRepository | ||
private let translatedLanguageNameRepository: TranslatedLanguageNameRepository | ||
|
||
init(languagesRepository: LanguagesRepository, downloadedLanguagesRepository: DownloadedLanguagesRepository, translatedLanguageNameRepository: TranslatedLanguageNameRepository) { | ||
|
||
self.languagesRepository = languagesRepository | ||
self.downloadedLanguagesRepository = downloadedLanguagesRepository | ||
self.translatedLanguageNameRepository = translatedLanguageNameRepository | ||
} | ||
|
||
func getDownloadedLanguagesPublisher(currentAppLanguage: AppLanguageDomainModel) -> AnyPublisher<[DownloadedLanguageListItemDomainModel], Never> { | ||
|
||
return Publishers.CombineLatest( | ||
languagesRepository.getLanguagesChanged(), | ||
downloadedLanguagesRepository.getDownloadedLanguagesChangedPublisher() | ||
) | ||
.flatMap { _ in | ||
|
||
return self.downloadedLanguagesRepository.getDownloadedLanguagesPublisher(completedDownloadsOnly: true) | ||
} | ||
.map { downloadedLanguageDataModels in | ||
|
||
let downloadedLanguageIds = downloadedLanguageDataModels.map { $0.languageId } | ||
|
||
return self.languagesRepository.getLanguages(ids: downloadedLanguageIds).map { language in | ||
|
||
let languageNameInOwnLanguage = self.translatedLanguageNameRepository.getLanguageName( | ||
language: language, | ||
translatedInLanguage: language.code | ||
) | ||
let languageNameInAppLanguage = self.translatedLanguageNameRepository.getLanguageName( | ||
language: language, | ||
translatedInLanguage: currentAppLanguage | ||
) | ||
|
||
return DownloadedLanguageListItemDomainModel( | ||
languageId: language.id, | ||
languageCode: language.code, | ||
languageNameInOwnLanguage: languageNameInOwnLanguage, | ||
languageNameInAppLanguage: languageNameInAppLanguage | ||
) | ||
} | ||
} | ||
.eraseToAnyPublisher() | ||
} | ||
} |
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
24 changes: 24 additions & 0 deletions
24
...ools/App/Features/AppLanguage/Domain/Entities/DownloadedLanguageListItemDomainModel.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,24 @@ | ||
// | ||
// DownloadedLanguageListItemDomainModel.swift | ||
// godtools | ||
// | ||
// Created by Rachael Skeath on 1/30/24. | ||
// Copyright © 2024 Cru. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
struct DownloadedLanguageListItemDomainModel { | ||
|
||
let languageId: String | ||
let languageCode: BCP47LanguageIdentifier | ||
let languageNameInOwnLanguage: String | ||
let languageNameInAppLanguage: String | ||
} | ||
|
||
extension DownloadedLanguageListItemDomainModel: Identifiable { | ||
|
||
var id: String { | ||
return languageId | ||
} | ||
} |
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
15 changes: 15 additions & 0 deletions
15
...Features/AppLanguage/Domain/Interface/GetDownloadedLanguagesListRepositoryInterface.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,15 @@ | ||
// | ||
// GetDownloadedLanguagesListRepositoryInterface.swift | ||
// godtools | ||
// | ||
// Created by Rachael Skeath on 1/30/24. | ||
// Copyright © 2024 Cru. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import Combine | ||
|
||
protocol GetDownloadedLanguagesListRepositoryInterface { | ||
|
||
func getDownloadedLanguagesPublisher(currentAppLanguage: AppLanguageDomainModel) -> AnyPublisher<[DownloadedLanguageListItemDomainModel], Never> | ||
} |
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
Oops, something went wrong.