Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.

Commit ac26a44

Browse files
author
Juanpe Catalán
committed
Merge branch 'release/1.1' into develop
2 parents ecf8ea2 + a14a30c commit ac26a44

File tree

4 files changed

+183
-84
lines changed

4 files changed

+183
-84
lines changed

Module VIPER.xctemplate/InputOutput/___FILEBASENAME___Presenter.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
import UIKit
1212

13-
class ___FILEBASENAMEASIDENTIFIER___Presenter: ___FILEBASENAMEASIDENTIFIER___PresenterProtocol,___FILEBASENAMEASIDENTIFIER___InteractorOutputProtocol {
13+
class ___FILEBASENAMEASIDENTIFIER___Presenter: ___FILEBASENAMEASIDENTIFIER___PresenterProtocol, ___FILEBASENAMEASIDENTIFIER___InteractorOutputProtocol {
1414

1515
weak private var view: ___FILEBASENAMEASIDENTIFIER___ViewProtocol?
1616
var interactor: ___FILEBASENAMEASIDENTIFIER___InteractorInputProtocol?

README.md

Lines changed: 3 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -27,89 +27,9 @@ This template generates all files that you need to create a new VIPER module. Al
2727

2828
This is an example, we're creating a Login module:
2929

30-
**Protocols**
31-
```swift
32-
//MARK: Wireframe -
33-
protocol LoginWireframeProtocol: class {
34-
35-
}
36-
//MARK: Presenter -
37-
protocol LoginPresenterProtocol: class {
38-
39-
}
40-
41-
//MARK: Interactor -
42-
protocol LoginInteractorProtocol: class {
43-
44-
var presenter: LoginPresenterProtocol? { get set }
45-
}
46-
47-
//MARK: View -
48-
protocol LoginViewProtocol: class {
49-
50-
var presenter: LoginPresenterProtocol? { get set }
51-
}
52-
```
53-
54-
**Interactor**
55-
```swift
56-
class LoginInteractor: LoginInteractorProtocol {
57-
58-
weak var presenter: LoginPresenterProtocol?
59-
}
60-
```
61-
62-
**Presenter**
63-
```swift
64-
class LoginPresenter: LoginPresenterProtocol {
65-
66-
weak private var view: LoginViewProtocol?
67-
private let interactor: LoginInteractorProtocol
68-
private let router: LoginWireframeProtocol
30+
- ![Default, without divide](/assets/defaultOutput.md)
31+
- ![With divided Interactor (Input & Output)](/assets/inputOutput.md)
6932

70-
init(interface: LoginViewProtocol, interactor: LoginInteractorProtocol, router: LoginWireframeProtocol) {
71-
self.view = interface
72-
self.interactor = interactor
73-
self.router = router
74-
75-
self.interactor.presenter = self
76-
}
77-
}
78-
```
79-
80-
**Wireframe**
81-
```swift
82-
class LoginRouter: LoginWireframeProtocol {
83-
84-
weak var viewController: UIViewController?
85-
86-
static func createModule() -> UIViewController {
87-
88-
let view = LoginViewController(nibName: nil, bundle: nil)
89-
let interactor = LoginInteractor()
90-
let router = LoginRouter()
91-
let presenter = LoginPresenter(interface: view, interactor: interactor, router: router)
92-
93-
view.presenter = presenter
94-
interactor.presenter = presenter
95-
router.viewController = view
96-
97-
return view
98-
}
99-
}
100-
```
101-
102-
**View**
103-
```swift
104-
class LoginViewController: UIViewController, LoginViewProtocol {
105-
106-
var presenter: LoginPresenterProtocol?
107-
108-
override func viewDidLoad() {
109-
super.viewDidLoad()
110-
}
111-
}
112-
```
11333
## VIPER diagram overview
11434
![Preview](/assets/viper_diagram.png)
11535

@@ -127,7 +47,7 @@ Would you like decide what will be the next feature? now, you can do it [here](h
12747

12848
* [x] Create bash script to install more easy
12949
* [ ] Add Dependency Injection Framework
130-
* [ ] Divide Interactor protocol (Input & Output)
50+
* [x] Divide Interactor protocol (Input & Output)
13151
* [ ] ~~Create groups in template~~ *(Only available for Project templates)*
13252

13353
## References

assets/defaultOutput.md

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
## Default Login Module
2+
3+
**Protocols**
4+
```swift
5+
//MARK: Wireframe -
6+
protocol LoginWireframeProtocol: class {
7+
8+
}
9+
//MARK: Presenter -
10+
protocol LoginPresenterProtocol: class {
11+
12+
}
13+
14+
//MARK: Interactor -
15+
protocol LoginInteractorProtocol: class {
16+
17+
var presenter: LoginPresenterProtocol? { get set }
18+
}
19+
20+
//MARK: View -
21+
protocol LoginViewProtocol: class {
22+
23+
var presenter: LoginPresenterProtocol? { get set }
24+
}
25+
```
26+
27+
**Interactor**
28+
```swift
29+
class LoginInteractor: LoginInteractorProtocol {
30+
31+
weak var presenter: LoginPresenterProtocol?
32+
}
33+
```
34+
35+
**Presenter**
36+
```swift
37+
class LoginPresenter: LoginPresenterProtocol {
38+
39+
weak private var view: LoginViewProtocol?
40+
private let interactor: LoginInteractorProtocol
41+
private let router: LoginWireframeProtocol
42+
43+
init(interface: LoginViewProtocol, interactor: LoginInteractorProtocol, router: LoginWireframeProtocol) {
44+
self.view = interface
45+
self.interactor = interactor
46+
self.router = router
47+
48+
self.interactor.presenter = self
49+
}
50+
}
51+
```
52+
53+
**Wireframe**
54+
```swift
55+
class LoginRouter: LoginWireframeProtocol {
56+
57+
weak var viewController: UIViewController?
58+
59+
static func createModule() -> UIViewController {
60+
61+
let view = LoginViewController(nibName: nil, bundle: nil)
62+
let interactor = LoginInteractor()
63+
let router = LoginRouter()
64+
let presenter = LoginPresenter(interface: view, interactor: interactor, router: router)
65+
66+
view.presenter = presenter
67+
interactor.presenter = presenter
68+
router.viewController = view
69+
70+
return view
71+
}
72+
}
73+
```
74+
75+
**View**
76+
```swift
77+
class LoginViewController: UIViewController, LoginViewProtocol {
78+
79+
var presenter: LoginPresenterProtocol?
80+
81+
override func viewDidLoad() {
82+
super.viewDidLoad()
83+
}
84+
}
85+
```

assets/inputOutput.md

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
## Login Module with divided Interactor (Input & Output)
2+
3+
**Protocols**
4+
```swift
5+
//MARK: Wireframe -
6+
protocol LoginWireframeProtocol: class {
7+
8+
}
9+
//MARK: Presenter -
10+
protocol LoginPresenterProtocol: class {
11+
12+
var interactor: LoginInteractorInputProtocol? { get set }
13+
}
14+
15+
//MARK: Interactor -
16+
protocol LoginInteractorOutputProtocol: class {
17+
18+
/* Interactor -> Presenter */
19+
}
20+
21+
protocol LoginInteractorInputProtocol: class {
22+
23+
var presenter: LoginInteractorOutputProtocol? { get set }
24+
25+
/* Presenter -> Interactor */
26+
}
27+
28+
//MARK: View -
29+
protocol LoginViewProtocol: class {
30+
31+
var presenter: LoginPresenterProtocol? { get set }
32+
33+
/* Presenter -> ViewController */
34+
}
35+
```
36+
37+
**Interactor**
38+
```swift
39+
class LoginInteractor: LoginInteractorInputProtocol {
40+
41+
weak var presenter: LoginInteractorOutputProtocol?
42+
}
43+
```
44+
45+
**Presenter**
46+
```swift
47+
class LoginPresenter: LoginPresenterProtocol, LoginInteractorOutputProtocol {
48+
49+
weak private var view: LoginViewProtocol?
50+
var interactor: LoginInteractorInputProtocol?
51+
private let router: LoginWireframeProtocol
52+
53+
init(interface: LoginViewProtocol, interactor: LoginInteractorInputProtocol?, router: LoginWireframeProtocol) {
54+
self.view = interface
55+
self.interactor = interactor
56+
self.router = router
57+
}
58+
}
59+
```
60+
61+
**Wireframe**
62+
```swift
63+
class LoginRouter: LoginWireframeProtocol {
64+
65+
weak var viewController: UIViewController?
66+
67+
static func createModule() -> UIViewController {
68+
// Change to get view from storyboard if not using progammatic UI
69+
let view = LoginViewController(nibName: nil, bundle: nil)
70+
let interactor = LoginInteractor()
71+
let router = LoginRouter()
72+
let presenter = LoginPresenter(interface: view, interactor: interactor, router: router)
73+
74+
view.presenter = presenter
75+
interactor.presenter = presenter
76+
router.viewController = view
77+
78+
return view
79+
}
80+
}
81+
82+
```
83+
84+
**View**
85+
```swift
86+
class LoginViewController: UIViewController, LoginViewProtocol {
87+
88+
var presenter: LoginPresenterProtocol?
89+
90+
override func viewDidLoad() {
91+
super.viewDidLoad()
92+
}
93+
}
94+
```

0 commit comments

Comments
 (0)