Skip to content

Instantly share code, notes, and snippets.

@anuragajwani
anuragajwani / order-testing-example-1.swift
Created May 3, 2020 17:20
iOS Dependecy Injection Swinject Ricardo respose
struct Order {
var itemPrices: [Int]
}
protocol OrderValidator {
func hasMinimumSpend(order: Order) -> Bool
}
class OrderViewModel {
@anuragajwani
anuragajwani / order-testing-example-2.swift
Created May 3, 2020 17:39
iOS Dependecy Injection Swinject Ricardo respose
// use this in unit test target
class StubOrderValidator: OrderValidator {
var stubResponse: Bool!
func hasMinimumSpend(order: Order) -> Bool {
return self.stubResponse
}
}
@anuragajwani
anuragajwani / ProgressBarView.swift
Created October 18, 2020 21:31
Non-accessible progress bar view
import UIKit
class ProgressBarView: UIView {
var progress: CGFloat = 0.0 {
didSet {
self.setNeedsDisplay()
}
}
import UIKit
class MoveInOutViewController: UIViewController {
private weak var cardView: UIView!
private var cardViewHiddenConstraints: [NSLayoutConstraint]!
private var cardViewPresentConstraints: [NSLayoutConstraint]!
override func loadView() {
self.view = UIView()