Skip to content

Commit

Permalink
Keep references to the presenter, and the view model private
Browse files Browse the repository at this point in the history
  • Loading branch information
dcordero committed Jun 12, 2019
1 parent 4be9214 commit 07d1c1b
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 35 deletions.
16 changes: 4 additions & 12 deletions ModelViewPresenter.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
objects = {

/* Begin PBXBuildFile section */
FF8539D422AD479A00F13E87 /* LoggedInUI.swift in Sources */ = {isa = PBXBuildFile; fileRef = FF8539D322AD479A00F13E87 /* LoggedInUI.swift */; };
FF91FE7C22AC5F1100C9180A /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = FF91FE7B22AC5F1100C9180A /* AppDelegate.swift */; };
FF91FE7E22AC5F1100C9180A /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = FF91FE7D22AC5F1100C9180A /* SceneDelegate.swift */; };
FF91FE8022AC5F1100C9180A /* LoginView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FF91FE7F22AC5F1100C9180A /* LoginView.swift */; };
Expand All @@ -21,14 +20,12 @@
FF91FE9F22AC68F600C9180A /* LoggedInServiceLocator.swift in Sources */ = {isa = PBXBuildFile; fileRef = FF91FE9E22AC68F600C9180A /* LoggedInServiceLocator.swift */; };
FF91FEA122AC690600C9180A /* LoggedInView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FF91FEA022AC690600C9180A /* LoggedInView.swift */; };
FF91FEA322AC694E00C9180A /* LoggedInPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = FF91FEA222AC694E00C9180A /* LoggedInPresenter.swift */; };
FF91FEA522AC696C00C9180A /* LoggedInImp.swift in Sources */ = {isa = PBXBuildFile; fileRef = FF91FEA422AC696C00C9180A /* LoggedInImp.swift */; };
FF91FEA522AC696C00C9180A /* LoggedInPresenterImp.swift in Sources */ = {isa = PBXBuildFile; fileRef = FF91FEA422AC696C00C9180A /* LoggedInPresenterImp.swift */; };
FF91FEA722AC6A4700C9180A /* Wireframe.swift in Sources */ = {isa = PBXBuildFile; fileRef = FF91FEA622AC6A4700C9180A /* Wireframe.swift */; };
FF91FEA922AC7E4600C9180A /* LoginUI.swift in Sources */ = {isa = PBXBuildFile; fileRef = FF91FEA822AC7E4600C9180A /* LoginUI.swift */; };
FFDB568C22AFFAA100EFFF68 /* CredentialsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FFDB568B22AFFAA100EFFF68 /* CredentialsView.swift */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
FF8539D322AD479A00F13E87 /* LoggedInUI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoggedInUI.swift; sourceTree = "<group>"; };
FF91FE7822AC5F1100C9180A /* ModelViewPresenter.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ModelViewPresenter.app; sourceTree = BUILT_PRODUCTS_DIR; };
FF91FE7B22AC5F1100C9180A /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
FF91FE7D22AC5F1100C9180A /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
Expand All @@ -44,9 +41,8 @@
FF91FE9E22AC68F600C9180A /* LoggedInServiceLocator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoggedInServiceLocator.swift; sourceTree = "<group>"; };
FF91FEA022AC690600C9180A /* LoggedInView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoggedInView.swift; sourceTree = "<group>"; };
FF91FEA222AC694E00C9180A /* LoggedInPresenter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoggedInPresenter.swift; sourceTree = "<group>"; };
FF91FEA422AC696C00C9180A /* LoggedInImp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoggedInImp.swift; sourceTree = "<group>"; };
FF91FEA422AC696C00C9180A /* LoggedInPresenterImp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoggedInPresenterImp.swift; sourceTree = "<group>"; };
FF91FEA622AC6A4700C9180A /* Wireframe.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Wireframe.swift; sourceTree = "<group>"; };
FF91FEA822AC7E4600C9180A /* LoginUI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginUI.swift; sourceTree = "<group>"; };
FFDB568B22AFFAA100EFFF68 /* CredentialsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CredentialsView.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

Expand Down Expand Up @@ -132,7 +128,6 @@
FF91FE9222AC61C400C9180A /* View */ = {
isa = PBXGroup;
children = (
FF91FEA822AC7E4600C9180A /* LoginUI.swift */,
FF91FE7F22AC5F1100C9180A /* LoginView.swift */,
FFDB568B22AFFAA100EFFF68 /* CredentialsView.swift */,
FF91FE9822AC625E00C9180A /* LoginViewModel.swift */,
Expand All @@ -153,15 +148,14 @@
isa = PBXGroup;
children = (
FF91FEA222AC694E00C9180A /* LoggedInPresenter.swift */,
FF91FEA422AC696C00C9180A /* LoggedInImp.swift */,
FF91FEA422AC696C00C9180A /* LoggedInPresenterImp.swift */,
);
path = Presenter;
sourceTree = "<group>";
};
FF91FE9D22AC68E200C9180A /* View */ = {
isa = PBXGroup;
children = (
FF8539D322AD479A00F13E87 /* LoggedInUI.swift */,
FF91FEA022AC690600C9180A /* LoggedInView.swift */,
);
path = View;
Expand Down Expand Up @@ -241,16 +235,14 @@
FF91FE9522AC61DE00C9180A /* LoginPresenter.swift in Sources */,
FF91FE9B22AC65C700C9180A /* LoginServiceLocator.swift in Sources */,
FF91FE9722AC620F00C9180A /* LoginPresenterImp.swift in Sources */,
FF91FEA522AC696C00C9180A /* LoggedInImp.swift in Sources */,
FF91FEA522AC696C00C9180A /* LoggedInPresenterImp.swift in Sources */,
FF91FE9922AC625E00C9180A /* LoginViewModel.swift in Sources */,
FF91FE7C22AC5F1100C9180A /* AppDelegate.swift in Sources */,
FF91FE9F22AC68F600C9180A /* LoggedInServiceLocator.swift in Sources */,
FF91FE7E22AC5F1100C9180A /* SceneDelegate.swift in Sources */,
FF8539D422AD479A00F13E87 /* LoggedInUI.swift in Sources */,
FF91FEA722AC6A4700C9180A /* Wireframe.swift in Sources */,
FF91FEA322AC694E00C9180A /* LoggedInPresenter.swift in Sources */,
FFDB568C22AFFAA100EFFF68 /* CredentialsView.swift in Sources */,
FF91FEA922AC7E4600C9180A /* LoginUI.swift in Sources */,
FF91FEA122AC690600C9180A /* LoggedInView.swift in Sources */,
FF91FE8022AC5F1100C9180A /* LoginView.swift in Sources */,
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import Foundation

protocol LoggedInPresenter {

func viewDidAppear()
func logoutButtonWasPressed()
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import UIKit
final class LoggedInPresenterImp: LoggedInPresenter {

weak var hostingUI: UIViewController?
var wireframe: Wireframe

private var wireframe: Wireframe

init(wireframe: Wireframe) {
self.wireframe = wireframe
Expand Down
5 changes: 0 additions & 5 deletions ModelViewPresenter/Modules/Logged in/View/LoggedInUI.swift

This file was deleted.

8 changes: 6 additions & 2 deletions ModelViewPresenter/Modules/Logged in/View/LoggedInView.swift
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import SwiftUI

struct LoggedInView: View, LoggedInUI{
struct LoggedInView: View {

var presenter: LoggedInPresenter?
private var presenter: LoggedInPresenter?

init(presenter: LoggedInPresenter?) {
self.presenter = presenter
}

// MARK: - View

var body: some View {
Expand Down
5 changes: 3 additions & 2 deletions ModelViewPresenter/Modules/Login/LoginServiceLocator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import SwiftUI
final class LoginServiceLocator {

static func provideLoginViewController() -> UIViewController {
let presenter = LoginPresenterImp(wireframe: Wireframe.shared)
let view = LoginView(presenter: presenter, viewModel: presenter.viewModel)
let viewModel = LoginViewModel()
let presenter = LoginPresenterImp(viewModel: viewModel, wireframe: Wireframe.shared)
let view = LoginView(presenter: presenter, viewModel: viewModel)
let viewController = UIHostingController(rootView: view)
presenter.hostingUI = viewController

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ import UIKit
final class LoginPresenterImp: LoginPresenter {

weak var hostingUI: UIViewController?
var viewModel: LoginViewModel
var wireframe: Wireframe

init(viewModel: LoginViewModel = LoginViewModel(), wireframe: Wireframe) {
private var viewModel: LoginViewModel
private var wireframe: Wireframe

init(viewModel: LoginViewModel, wireframe: Wireframe) {
self.viewModel = viewModel
self.wireframe = wireframe
}
Expand Down
6 changes: 0 additions & 6 deletions ModelViewPresenter/Modules/Login/View/LoginUI.swift

This file was deleted.

6 changes: 3 additions & 3 deletions ModelViewPresenter/Modules/Login/View/LoginView.swift
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import SwiftUI

struct LoginView: View, LoginUI {
struct LoginView: View {

var presenter: LoginPresenter?
private var presenter: LoginPresenter?

@ObjectBinding var viewModel: LoginViewModel
@ObjectBinding private var viewModel: LoginViewModel

init(presenter: LoginPresenter?, viewModel: LoginViewModel) {
self.presenter = presenter
Expand Down

0 comments on commit 07d1c1b

Please sign in to comment.