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
self.viewController = MoviesViewController() | |
self.navigationController.pushViewController(self.viewController, animated: false) |
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
{ | |
"title": "Movie Title", | |
"year": "2017", | |
"genre": [ | |
"Action", | |
"Adventure" | |
] | |
} |
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 Foundation | |
struct Movie { | |
let title: String | |
let year: String | |
let genre: [String] | |
init(title: String, year: String, genre: [String]) { | |
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
private func fetchMovies(onSuccess: ([Movie]) -> Void) { | |
let exampleMovie = Movie(title: "Movie title", year: "2017", genre: ["Action", "Adventure"]) | |
onSuccess([exampleMovie]) | |
} |
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
private func convert(movies: [Movie]) -> MoviesViewModel { | |
let movieCellViewModels = movies.map { movie in | |
MovieCellViewModel( | |
textLabel: "\(movie.title) (\(movie.year))", | |
detailTextLabel: movie.genre.joined(separator: ", ") | |
) | |
} |
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 Foundation | |
import UIKit | |
final class MoviesViewCoordinator { | |
// MARK: - Instance dependencies | |
private let navigationController: UINavigationController | |
// MARK: - Instance state |
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 Foundation | |
import UIKit | |
final class AppCoordinator { | |
private let navigationController: UINavigationController | |
private var childCoordinator: MoviesViewCoordinator! | |
init(navigationController: UINavigationController) { |
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 | |
@UIApplicationMain | |
class AppDelegate: UIResponder, UIApplicationDelegate { | |
var window: UIWindow? | |
var appCoordinator: AppCoordinator! | |
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { |
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
addUIInterruptionMonitor(withDescription: "Camera permission dialog") { (alert) -> Bool in | |
if alert.label == "“Application” Would Like to Access the Camera" { | |
alert.buttons["OK"].tap() | |
self.app.swipeUp() | |
self.app.swipeDown() | |
return true | |
} |
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
// Run in chrome console whilst on the stats page | |
function download(filename, text) { | |
var pom = document.createElement('a'); | |
pom.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text)); | |
pom.setAttribute('download', filename); | |
if (document.createEvent) { | |
var event = document.createEvent('MouseEvents'); | |
event.initEvent('click', true, true); |