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 | |
public class AppCoordinator: Coordinator { | |
public enum AppCoordinatorState { | |
case inital | |
case willShowLoginFlow | |
case didShowLoginFlow | |
case willShowTasksFlow(userId:Int?) | |
} |
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
class LoginViewBuilder: Builder { | |
var coordinatorOutput: (LoginViewOutput) -> Void | |
init( coordinatorOtput:@escaping(LoginViewOutput)-> Void) { | |
self.coordinatorOutput = coordinatorOtput | |
} | |
func build() -> UIViewController { | |
let dataManager = LoginDataManager() | |
let presenter = LoginViewPresenter(dataManager: dataManager, coordinatorOutput: coordinatorOutput) |
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 | |
class LoginDataManager: LoginDataManagerProtocol { | |
func getUser(callback: @escaping (Result<[User], ApiError>) -> Void) { | |
URLSession.shared.get(UserEndPoint.userList, type: [User].self) { (result) in | |
switch result { | |
case .success(let users): | |
if let users = users { | |
callback(.success(users)) |
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
extension URLSession { | |
func get<T:Codable>(_ builder: RequestBuilder, type: T.Type, callback: @escaping(Result<T?,ApiError>) -> Void) { | |
let decoder = JSONDecoder() | |
decoder.keyDecodingStrategy = .convertFromSnakeCase | |
let dataTask = self.dataTask(with: builder.urlRequest) { data, response, error in | |
if let error = error { |
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
enum UserEndPoint { | |
case userList | |
} | |
extension UserEndPoint: RequestBuilder { | |
var urlRequest: URLRequest { | |
switch self { | |
case .userList: | |
guard let url = URL(string: "https://jsonplaceholder.typicode.com/users") |
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 | |
class LoginViewPresenter: LoginViewControllerPresenterProtocol { | |
weak var view: LoginViewProtocol? | |
var dataManager: LoginDataManagerProtocol | |
var coordinatorOutPut: (LoginViewOutput) -> Void | |
init(dataManager: LoginDataManagerProtocol,coordinatorOutput:@escaping(LoginViewOutput)->Void) { | |
self.dataManager = dataManager |
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 LoginViewController: UIViewController { | |
var presenter: LoginViewControllerPresenterProtocol | |
let model: LoginViewControllerModel | |
lazy var titleLabel: UIView = { | |
let view = UIView(frame: .zero) |
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
// | |
// Debouncer.swift | |
// DesignPatternsShowCase | |
// | |
// Created by Alex.personal on 9/10/25. | |
// | |
import Foundation | |
public typealias DebounceAction = @Sendable () async throws -> Void |
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
/// Print Current simulator folder | |
// Catch a Breakpoint somewhere. (or Pause program execution (tap on pause in debug area) | |
// Enter po NSHomeDirectory() in console window | |
po NSHomeDirectory() -> | |
//Users/usernam/Library/Developer/CoreSimulator/Devices/ | |
//4734F8C7-B90F-4566-8E89-5060505E387F/data/Containers/Data/Application/395818BB-6D0F-499F-AAFE-068A783D9753 |