Skip to content

Instantly share code, notes, and snippets.

View trupin's full-sized avatar

Theophane RUPIN trupin

View GitHub Profile
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
window = UIWindow()
// MARK: - Error
enum MovieManagerError: Error {
case oops
}
// MARK: - Manager
protocol MovieManaging {
struct Page<Model: Decodable>: Decodable {
let page: UInt
let total_results: UInt
let total_pages: UInt
let results: [Model]
}
struct Movie: Decodable {
let vote_count: UInt
let id: UInt
let video: Bool
let vote_average: Float
let title: String
let popularity: Float
let poster_path: String
let original_language: String
let original_title: String
import UIKit
final class MovieTableViewCell: UITableViewCell {
struct ViewModel {
let title: String
}
func bind(_ viewModel: ViewModel) {
textLabel?.text = viewModel.title
final class MovieManager {
func getDiscoverMovies(_ completion: @escaping (Page<Movie>?) -> Void) {
let completionOnMainThread = { result in
DispatchQueue.main.async {
completion(result)
}
}
import UIKit
final class MovieTableViewCell: UITableViewCell {
struct ViewModel {
let title: String
}
func bind(_ viewModel: ViewModel) {
textLabel?.text = viewModel.title
import UIKit
final class MovieViewController: UIViewController {
private let dependencies: MovieViewControllerDependencyResolver
// weaver: movie <= Movie
private lazy var overviewLabel: UILabel = {
let label = UILabel()
import UIKit
final class MovieTableViewCell: UITableViewCell {
struct ViewModel {
let title: String
}
func bind(_ viewModel: ViewModel) {
textLabel?.text = viewModel.title
import UIKit
final class ImageManager {
func getImage(with path: String, completion: @escaping (UIImage?) -> Void) {
let completionOnMainThread = { result in
DispatchQueue.main.async {
completion(result)
}