Skip to content

Instantly share code, notes, and snippets.

@prostakm
prostakm / Factory.swift
Last active May 28, 2018 09:40
CellFactory
//
// ChatBubbleTableViewCell.swift
// LufthansaServiceCenter
//
// Created by Nermin Sehic on 27/05/2018.
// Copyright © 2018 Lufthansa. All rights reserved.
//
import UIKit
class ModuleConnector {
weak var navigationController: UINavigationController?
init(navigationController: UINavigationController) {
self.navigationController = navigationController
}
func connect() {
let gateway = StaticDataGateway()
protocol UseCase {
func execute() -> String
}
class ShowDataUseCase: UseCase {
let gateway: DataGateway
init(dataGateway: DataGateway) {
self.gateway = dataGateway
protocol DataGateway {
func getData() -> String
}
class StaticDataGateway: DataGateway {
func getData() -> String {
return "Important Data"
}
}
protocol Presenter {
func viewLoaded()
}
class ViewPresenter: Presenter {
let useCase: UseCase
let connector: ModuleConnector
weak var view: View?
protocol View: class {
func show(data: String)
}
class ViewController: UIViewController, View {
let presenter: Presenter
var label: UILabel!
init(presenter: Presenter) {