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 MoveInOutViewController: UIViewController { | |
private weak var cardView: UIView! | |
private var cardViewHiddenConstraints: [NSLayoutConstraint]! | |
private var cardViewPresentConstraints: [NSLayoutConstraint]! | |
override func loadView() { | |
self.view = UIView() |
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 ProgressBarView: UIView { | |
var progress: CGFloat = 0.0 { | |
didSet { | |
self.setNeedsDisplay() | |
} | |
} |
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
// use this in unit test target | |
class StubOrderValidator: OrderValidator { | |
var stubResponse: Bool! | |
func hasMinimumSpend(order: Order) -> Bool { | |
return self.stubResponse | |
} | |
} |
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
struct Order { | |
var itemPrices: [Int] | |
} | |
protocol OrderValidator { | |
func hasMinimumSpend(order: Order) -> Bool | |
} | |
class OrderViewModel { | |
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); |
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
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
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 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
private func convert(movies: [Movie]) -> MoviesViewModel { | |
let movieCellViewModels = movies.map { movie in | |
MovieCellViewModel( | |
textLabel: "\(movie.title) (\(movie.year))", | |
detailTextLabel: movie.genre.joined(separator: ", ") | |
) | |
} |
NewerOlder