Renamed the FeedViewModel view model in the Feed framework as FeedListViewModel.
This commit is contained in:
parent
05c4ed08d9
commit
656c0ee5ff
@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// FeedViewModel.swift
|
// FeedListViewModel.swift
|
||||||
// ReviewsFeed
|
// ReviewsFeed
|
||||||
//
|
//
|
||||||
// Created by Javier Cicchelli on 18/03/2024.
|
// Created by Javier Cicchelli on 18/03/2024.
|
||||||
@ -19,25 +19,27 @@ extension FeedListViewController {
|
|||||||
private let configuration: Configuration
|
private let configuration: Configuration
|
||||||
|
|
||||||
// MARK: Properties
|
// MARK: Properties
|
||||||
@Published var loading: Bool = false
|
@Published var filter: FilterOption = .all
|
||||||
|
@Published var isFilterEnabled: Bool = false
|
||||||
|
@Published var isLoading: Bool = false
|
||||||
|
|
||||||
var items: [Review] = []
|
var items: [Review] = []
|
||||||
|
|
||||||
|
lazy private var iTunesService: iTunesService = {
|
||||||
|
.init(configuration: .init(session: configuration.session))
|
||||||
|
}()
|
||||||
|
|
||||||
// MARK: Initialisers
|
// MARK: Initialisers
|
||||||
init(configuration: Configuration = .init()) {
|
init(configuration: Configuration = .init()) {
|
||||||
self.configuration = configuration
|
self.configuration = configuration
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: Computed
|
|
||||||
lazy private var iTunesService: iTunesService = {
|
|
||||||
.init(configuration: .init(session: configuration.session))
|
|
||||||
}()
|
|
||||||
|
|
||||||
// MARK: Functions
|
// MARK: Functions
|
||||||
func fetch() {
|
func fetch() {
|
||||||
Task {
|
Task {
|
||||||
loading = true
|
isFilterEnabled = false
|
||||||
|
isLoading = items.isEmpty
|
||||||
|
|
||||||
do {
|
do {
|
||||||
let output = try await iTunesService.getReviews(.init(
|
let output = try await iTunesService.getReviews(.init(
|
||||||
appID: configuration.appID,
|
appID: configuration.appID,
|
||||||
@ -57,11 +59,13 @@ extension FeedListViewController {
|
|||||||
title: review.title
|
title: review.title
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
isFilterEnabled = !items.isEmpty
|
||||||
} catch {
|
} catch {
|
||||||
// TODO: handle this error gracefully.
|
// TODO: handle this error gracefully.
|
||||||
|
print("ERROR: \(error.localizedDescription)")
|
||||||
}
|
}
|
||||||
|
|
||||||
loading = false
|
isLoading = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -9,7 +9,7 @@
|
|||||||
/* Begin PBXBuildFile section */
|
/* Begin PBXBuildFile section */
|
||||||
0220ADA32BA90646001E6A9F /* FeedItemCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0220ADA22BA90646001E6A9F /* FeedItemCell.swift */; };
|
0220ADA32BA90646001E6A9F /* FeedItemCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0220ADA22BA90646001E6A9F /* FeedItemCell.swift */; };
|
||||||
023AC7FC2BAA3EC10027D064 /* Int+Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 023AC7FB2BAA3EC10027D064 /* Int+Constants.swift */; };
|
023AC7FC2BAA3EC10027D064 /* Int+Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 023AC7FB2BAA3EC10027D064 /* Int+Constants.swift */; };
|
||||||
02620B8C2BA89C9A00DE7137 /* FeedViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02620B8B2BA89C9A00DE7137 /* FeedViewModel.swift */; };
|
02620B8C2BA89C9A00DE7137 /* FeedListViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02620B8B2BA89C9A00DE7137 /* FeedListViewModel.swift */; };
|
||||||
02909E792BAB6B0200710E14 /* FilterOption.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02909E782BAB6B0200710E14 /* FilterOption.swift */; };
|
02909E792BAB6B0200710E14 /* FilterOption.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02909E782BAB6B0200710E14 /* FilterOption.swift */; };
|
||||||
02909E7B2BAB6D2E00710E14 /* Bundle+Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02909E7A2BAB6D2E00710E14 /* Bundle+Constants.swift */; };
|
02909E7B2BAB6D2E00710E14 /* Bundle+Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02909E7A2BAB6D2E00710E14 /* Bundle+Constants.swift */; };
|
||||||
02DA924E2BAAE3FD00C47985 /* Localizable.xcstrings in Resources */ = {isa = PBXBuildFile; fileRef = 02DA924D2BAAE3FD00C47985 /* Localizable.xcstrings */; };
|
02DA924E2BAAE3FD00C47985 /* Localizable.xcstrings in Resources */ = {isa = PBXBuildFile; fileRef = 02DA924D2BAAE3FD00C47985 /* Localizable.xcstrings */; };
|
||||||
@ -53,7 +53,7 @@
|
|||||||
/* Begin PBXFileReference section */
|
/* Begin PBXFileReference section */
|
||||||
0220ADA22BA90646001E6A9F /* FeedItemCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeedItemCell.swift; sourceTree = "<group>"; };
|
0220ADA22BA90646001E6A9F /* FeedItemCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeedItemCell.swift; sourceTree = "<group>"; };
|
||||||
023AC7FB2BAA3EC10027D064 /* Int+Constants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Int+Constants.swift"; sourceTree = "<group>"; };
|
023AC7FB2BAA3EC10027D064 /* Int+Constants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Int+Constants.swift"; sourceTree = "<group>"; };
|
||||||
02620B8B2BA89C9A00DE7137 /* FeedViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeedViewModel.swift; sourceTree = "<group>"; };
|
02620B8B2BA89C9A00DE7137 /* FeedListViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeedListViewModel.swift; sourceTree = "<group>"; };
|
||||||
02909E782BAB6B0200710E14 /* FilterOption.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FilterOption.swift; sourceTree = "<group>"; };
|
02909E782BAB6B0200710E14 /* FilterOption.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FilterOption.swift; sourceTree = "<group>"; };
|
||||||
02909E7A2BAB6D2E00710E14 /* Bundle+Constants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Bundle+Constants.swift"; sourceTree = "<group>"; };
|
02909E7A2BAB6D2E00710E14 /* Bundle+Constants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Bundle+Constants.swift"; sourceTree = "<group>"; };
|
||||||
02DA924D2BAAE3FD00C47985 /* Localizable.xcstrings */ = {isa = PBXFileReference; lastKnownFileType = text.json.xcstrings; path = Localizable.xcstrings; sourceTree = "<group>"; };
|
02DA924D2BAAE3FD00C47985 /* Localizable.xcstrings */ = {isa = PBXFileReference; lastKnownFileType = text.json.xcstrings; path = Localizable.xcstrings; sourceTree = "<group>"; };
|
||||||
@ -131,7 +131,7 @@
|
|||||||
02620B872BA89C0700DE7137 /* View Models */ = {
|
02620B872BA89C0700DE7137 /* View Models */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
02620B8B2BA89C9A00DE7137 /* FeedViewModel.swift */,
|
02620B8B2BA89C9A00DE7137 /* FeedListViewModel.swift */,
|
||||||
);
|
);
|
||||||
path = "View Models";
|
path = "View Models";
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@ -418,7 +418,7 @@
|
|||||||
isa = PBXSourcesBuildPhase;
|
isa = PBXSourcesBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
02620B8C2BA89C9A00DE7137 /* FeedViewModel.swift in Sources */,
|
02620B8C2BA89C9A00DE7137 /* FeedListViewModel.swift in Sources */,
|
||||||
023AC7FC2BAA3EC10027D064 /* Int+Constants.swift in Sources */,
|
023AC7FC2BAA3EC10027D064 /* Int+Constants.swift in Sources */,
|
||||||
02DC7FAC2BA51B4C000EEEBE /* FeedItemViewController.swift in Sources */,
|
02DC7FAC2BA51B4C000EEEBE /* FeedItemViewController.swift in Sources */,
|
||||||
02909E7B2BAB6D2E00710E14 /* Bundle+Constants.swift in Sources */,
|
02909E7B2BAB6D2E00710E14 /* Bundle+Constants.swift in Sources */,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user