[Framework] Feed Item coordinator (#17)
This PR contains the work done to implement the `FeedItemCoordinator` coordinator in the `Feed` framework. Reviewed-on: rock-n-code/app-reviews#17 Co-authored-by: Javier Cicchelli <javier@rock-n-code.com> Co-committed-by: Javier Cicchelli <javier@rock-n-code.com>
This commit was merged in pull request #17.
This commit is contained in:
@@ -13,11 +13,8 @@ import ReviewsiTunesKit
|
||||
extension FeedListViewController {
|
||||
final class ViewModel: ObservableObject {
|
||||
|
||||
// MARK: Type aliases
|
||||
typealias Configuration = FeedListViewController.Configuration
|
||||
|
||||
// MARK: Constants
|
||||
private let configuration: Configuration
|
||||
private let configuration: FeedListConfiguration
|
||||
|
||||
private let filterWords: FilterWordsUseCase = .init()
|
||||
private let topWords: TopWordsUseCase = .init()
|
||||
@@ -30,18 +27,24 @@ extension FeedListViewController {
|
||||
|
||||
var items: [Review] = []
|
||||
var words: [TopWord] = []
|
||||
|
||||
|
||||
private var reviewsAll: [Review] = []
|
||||
private var reviewsFiltered: FilteredReviews = [:]
|
||||
private var reviewsTopWords: TopWordsReviews = [:]
|
||||
|
||||
private weak var coordination: FeedListCoordination?
|
||||
|
||||
lazy private var iTunesService: iTunesService = {
|
||||
.init(configuration: .init(session: configuration.session))
|
||||
}()
|
||||
|
||||
// MARK: Initialisers
|
||||
init(configuration: Configuration = .init()) {
|
||||
init(
|
||||
configuration: FeedListConfiguration = .init(),
|
||||
coordination: FeedListCoordination? = nil
|
||||
) {
|
||||
self.configuration = configuration
|
||||
self.coordination = coordination
|
||||
}
|
||||
|
||||
// MARK: Computed
|
||||
@@ -114,6 +117,12 @@ extension FeedListViewController {
|
||||
? items[index - 1]
|
||||
: items[index]
|
||||
}
|
||||
|
||||
func openItem(at index: Int) {
|
||||
guard let item = item(for: index) else { return }
|
||||
|
||||
coordination?.open(item)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user