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
// | |
// ViewModelTests.swift | |
// UnitTestingTests | |
// | |
// Created by Maksim Vialykh on 7/17/21. | |
// | |
import XCTest | |
@testable | |
import UnitTesting |
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
// | |
// ViewModel.swift | |
// UnitTesting | |
// | |
// Created by Maksim Vialykh on 7/17/21. | |
// | |
import Foundation | |
protocol ViewModel: AnyObject { |
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
//: A UIKit based Playground for presenting user interface | |
import UIKit | |
import PlaygroundSupport | |
typealias EmptyClosure = () -> Void | |
class ActionableTextField: UITextField { | |
private var cancelAction: EmptyClosure? |
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 | |
import PlaygroundSupport | |
// API CLient | |
typealias Resource = (url: String, method: String, data: Data) | |
class APIClient { | |
func request(_ res: Resource, _ result: @escaping (Result<Data, Error>) -> Void) { | |
/* | |
All network code |
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 | |
import PlaygroundSupport | |
let url = URL(string: "https://petstore.swagger.io/v2/user")! | |
var request = URLRequest(url: url) | |
request.addValue("application/json", forHTTPHeaderField: "Content-Type") | |
request.addValue("application/json", forHTTPHeaderField: "accept") | |
request.httpMethod = "POST" | |
request.httpBody = """ | |
{ |
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 | |
class ViewController: UIViewController { | |
/* | |
Current active (firstRespounder) textField | |
*/ | |
private weak var activeTextField: UITextField? | |
/* | |
local intance of KeyboardObserver |
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 | |
class KeyboardObserver { | |
/* | |
KeyboardState provides two states | |
- hide when kyboard is hidden | |
- show(let kyboardHeight) when keyboard is shown | |
*/ | |
enum KeyboardState { |
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
.... | |
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { | |
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`. | |
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene. | |
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). | |
// Get the managed object context from the shared persistent container. | |
let context = (UIApplication.shared.delegate as! AppDelegate).persistentContainer.viewContext |
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 SwiftUI | |
struct ContentView: View { | |
@EnvironmentObject | |
var viewModel: ViewModel | |
var body: some View { | |
VStack { | |
Spacer() |
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 | |
import LocalAuthentication | |
class ViewModel: ObservableObject { | |
@Published | |
var loggedIn: Bool = false | |
@Published | |
var hasChanges: Bool = false | |
NewerOlder