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
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *) | |
struct CenteredLoadingText: View { | |
private let mainText: String | |
private let dots = [".", ".", "."] | |
private let repeatInterval: TimeInterval | |
private let accessibilityLabel: String | |
private let loadingAnimation: Animation | |
private let spacing: CGFloat |
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
// MARK:- Async/await Group task | |
// 1 | |
@available(iOS 15, *) | |
func asyncGroups( | |
from categoryIdentifiers: [ItunesCategoryIdentifier]) { | |
// 2 | |
Task.init { | |
// 3 | |
var sections: [ItunesCategorySection] = [] | |
// 4 |
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
func dispatchGroups( | |
from categoryIdentifiers: [ItunesCategoryIdentifier]) { | |
// 1 | |
let dispatchGroup = DispatchGroup() | |
// 2 | |
var sections: [ItunesCategorySection] = [] | |
// 3 | |
for categoryIdentifier in categoryIdentifiers { | |
// 4 |
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
// 1 | |
final class ItunesRemote: ObservableObject { | |
// 2 | |
struct ItunesCategorySection: IdentifiableHashable { | |
let sectionID: ItunesCategoryIdentifier | |
let cellIDs: [FeedItemViewModel] | |
var id: ItunesCategoryIdentifier { sectionID } | |
} |
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
enum ItunesCategoryIdentifier: Int, CaseIterable { | |
// 1 | |
case apps | |
case podcasts | |
case tvShows | |
// 2 | |
var title: String { | |
switch self { |
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
enum APIError: Error { | |
case requestFailed(description: String) | |
case jsonConversionFailure(description: String) | |
case invalidData | |
case responseUnsuccessful(description: String) | |
case jsonParsingFailure | |
case noInternet | |
case failedSerialization |
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
/// 1 Errors | |
enum APIError: Error { | |
case requestFailed(description: String) | |
case jsonConversionFailure(description: String) | |
case invalidData | |
case responseUnsuccessful(description: String) | |
case jsonParsingFailure | |
case noInternet | |
case failedSerialization |
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
import SwiftUI | |
import CompositionalList | |
struct FeedView: View { | |
@ObservedObject private var remote = ItunesRemote() | |
@State var selectedItem: FeedItemViewModel? | |
var body: some View { | |
NavigationView { |
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
// 1 | |
final class MoviesProvider: ObservableObject { | |
// MARK:- Subscribers | |
// 2 | |
private var cancellable: AnyCancellable? | |
// MARK:- Publishers | |
// 3 | |
@Published var movies: [MovieViewModel] = [] |
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
final class MovieClient: CombineAPI { | |
// 1 | |
let session: URLSession | |
// 2 | |
init(configuration: URLSessionConfiguration) { | |
self.session = URLSession(configuration: configuration) | |
} | |
NewerOlder