Skip to content

Instantly share code, notes, and snippets.

View KhayalSuleymani's full-sized avatar

Khayal Suleymani KhayalSuleymani

View GitHub Profile
@KhayalSuleymani
KhayalSuleymani / Payments(MVC).swift
Last active December 11, 2024 07:46
# Payment Module with different Architectures
public class Payments: Controller<PaymentsRoute> {
public override func prepareTransition(for route: PaymentsRoute) -> Transition {
switch route {
case let .payments(d):
let m = PaymentsViewItem(d)
let v = PaymentsView()
return .show(v)
case let .payment(d):
let m = PaymentViewItem(d)
let v = PaymentView()
@KhayalSuleymani
KhayalSuleymani / Home(m).swift
Last active October 24, 2024 16:14
EVENT DRIVEN MVVM
import Common
// HOME MODEL
class HomeViewItem: ViewItem<HomeResponse> {
// #MARK: Configurate Bar Button items...
override var bars: Bars {
[
import Foundation
public protocol HomeNetworkServiceDelegate: NetworkServiceDelegate {
@discardableResult func requestUser(_ completion: @escaping Completion<UserEntity>) -> Self
@discardableResult func requestAccounts(id: String, _ completion: @escaping Completion<[AccountEntity]>) -> Self
@discardableResult func requestCards(id: String, _ completion: @escaping Completion<[CardEntity]>) -> Self
@discardableResult func requestOperations(id: String, _ completion: @escaping Completion<[OperationEntity]>) -> Self
@discardableResult func requestTemplates(id: String, _ completion: @escaping Completion<[TemplateEntity]>) -> Self
}
import Common
typealias HomeView = InsetTableView<HomeViewItem>
class HomeViewModel: ViewModel<HomeViewItem> {
@discardableResult
override func move(by c: C<HomeRoute>) -> Self {
service.s1.requestUser(weaks { _weakSelf, result in
switch result {
case .success(let user):
@KhayalSuleymani
KhayalSuleymani / Views(Tests).swift
Created October 16, 2024 12:57
Views memory leak tests
@testable import Quick
@testable import Nimble
@testable import Common
@testable import SpecLeaks
class ViewControllersTests: QuickSpec {
override class func spec() {
describe("My base represented views on common target...") {
describe("call view events when your viewmodel subscribe your views events by .render(state:)") {
it("must not leak") {
@KhayalSuleymani
KhayalSuleymani / Main(Tests).swift
Created October 16, 2024 12:56
app delegate tests
@testable import Quick
@testable import Nimble
@testable import Common
class MainTests: QuickSpec {
override class func spec() {
describe("staring to connect app for testing...") {
it ("will start from application didFinishLaunchingWithOptions...") {
import Common
@main class Main: App {
override var project: Presentable {
Business()
}
override var connection: Connector {
Connector(connections: [
import Common
class PasscodeViewItem: ViewItem<PasscodeState>, ImageConvertable, TextsStyleConvertable, PasscodeDelegate {
// MARK: ImageConvertable & TextsStyleConvertable
private(set) var texts: [TextStyle]
private(set) var image: Image
override init(_ state: PasscodeState) {
import Common
class PasscodeView: ViewController<PasscodeViewItem, View> {
@IBOutlet weak var v1: Button! /// logo image view
@IBOutlet weak var v2: Label! /// logo title label
@IBOutlet weak var v3: Label! /// logo subtitle label
@IBOutlet weak var v4: Passcode! /// passcode fill view
@IBOutlet weak var v5: Button! /// biometric button
@IBOutlet weak var v6: Button! /// delete button
import Common
class PasscodeViewModel: ViewModel<PasscodeViewItem> {
@discardableResult
override func move(by c: C<AuthorizeRoute>) -> Self {
onSelect(weaks { this, event in
switch event {
case let .passcode(state):
switch state {
case let .set(passcode):