This file contains 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 | |
protocol LoginViewModelInterface { | |
var viewDelegate: LoginViewModelDelegate? {get set} | |
func handleLogin(username: String, password: String) | |
} | |
/// You're coordinator implements this | |
protocol LoginViewModelCoordinatorDelegate: class { | |
func goToLoginSuccessful() |
This file contains 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 Network | |
protocol NetworkStatusChangedDelegate { | |
func networkStatusChanged(_ status: NetworkConnection) | |
} | |
enum NetworkConnection { | |
case Connected | |
case Disconnected | |
} |
This file contains 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 | |
struct Font { | |
enum FontType { | |
case installed(FontName) | |
case custom(String) | |
case system | |
case systemBold | |
case systemItatic | |
case systemWeighted(weight: Double) |
This file contains 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
/// Removes stale objects after 12 hours. | |
final class Cache<Key: Hashable, Value> { | |
private let wrapped = NSCache<WrappedKey, Entry>() | |
private let dateProvider: () -> Date | |
private let entryLifetime: TimeInterval | |
init(dateProvider: @escaping () -> Date = Date.init, | |
entryLifetime: TimeInterval = 12 * 60 * 60) { | |
self.dateProvider = dateProvider | |
self.entryLifetime = entryLifetime |
This file contains 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
@propertyWrapper | |
struct UserDefault<T> { | |
let key: String | |
let defaultValue: T | |
init(_ key: String, defaultValue: T) { | |
self.key = key | |
self.defaultValue = defaultValue | |
} |
This file contains 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 ShoppingList: Codable { | |
let items: [String] | |
} | |
extension ShoppingList { | |
static func mock(with items: [String] = []) -> Self { | |
.init(items: items) | |
} | |
} |
This file contains 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
public struct MockResponse { | |
struct Content { | |
let statusCode: Int | |
let data: Data | |
} | |
enum Response { | |
case success(Content) | |
case error(Error) |
This file contains 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 UITestConnectionHandler: URLProtocol { | |
private static var allowedResponses: [URL: MockResponse] = [:] | |
static func setAllowedResponse(with response: MockResponse) { | |
allowedResponses[response.url] = response | |
} | |
override class func canInit(with request: URLRequest) -> Bool { |
This file contains 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
extension ProcessInfo { | |
static var isRunningUITests: Bool { | |
processInfo.arguments.contains("UITests") | |
} | |
} |
This file contains 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
@main | |
struct MyApp: App { | |
var body: some Scene { | |
WindowGroup { | |
ContentView() | |
.onAppear { | |
#if DEBUG | |
guard ProcessInfo.isRunningUITests else { return } |
OlderNewer