This file contains hidden or 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 hidden or 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 hidden or 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) | |
} | |
This file contains hidden or 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 | |
protocol CombineAPI { | |
var session: URLSession { get } | |
func execute<T>(_ request: URLRequest, decodingType: T.Type, queue: DispatchQueue, retries: Int) -> AnyPublisher<T, Error> where T: Decodable | |
} | |
// 2 | |
extension CombineAPI { | |
func execute<T>(_ request: URLRequest, |
This file contains hidden or 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 | |
@main | |
struct SwiftUIMoviesApp: App { | |
// 2 | |
@StateObject private var model = MoviesProvider() | |
// 3 | |
var body: some Scene { | |
WindowGroup { | |
// 4 |
This file contains hidden or 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 | |
struct GenericList<Element, RowContent: View>: View where Element: Identifiable { | |
// 2 | |
private let items: [Element] | |
private let rowContent: (Element) -> RowContent | |
// 3 | |
public init(_ items: [Element], @ViewBuilder rowContent: @escaping (Element) -> RowContent) { | |
self.items = items |
This file contains hidden or 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 UIKit | |
class Vc: UIViewController { | |
var top: CGFloat? { 8 } | |
} | |
let viewController = Vc() | |
let a: CGFloat = 1.0 | |
let b: CGFloat = 2.0 | |
let result = (viewController as? Vc)?.top ?? a < b ? 10 : 15 |
This file contains hidden or 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
class FrameTransitionAnimator: NSObject { | |
enum OverlayType { | |
case dim | |
case blur(style: UIBlurEffect.Style) | |
} | |
enum DimTransitionMode: Int { | |
case present, dismiss |
This file contains hidden or 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 | |
protocol DisplayModeUpdatable { | |
func displayModeWillChangeTo(_ displayMode: UISplitViewController.DisplayMode) | |
func displayModeDidChangeTo(_ displayMode: UISplitViewController.DisplayMode) | |
} | |
//// | |
@objc func togglePrefferDisplayModeExecutingCompletion(_ executing: Bool = true) { | |
UIView.animate(withDuration: 0.3, animations: { | |
self.preferredDisplayMode = self.displayMode == .allVisible ? .primaryHidden : .allVisible |