Skip to content
This repository was archived by the owner on Nov 19, 2023. It is now read-only.

Commit 41a17ba

Browse files
committed
New interfaces & Swift 5 + SPM support
1 parent de0b236 commit 41a17ba

File tree

14 files changed

+174
-122
lines changed

14 files changed

+174
-122
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.build
2+
xcuserdata

Package.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// swift-tools-version:5.0
2+
import PackageDescription
3+
4+
let package = Package(
5+
name: "viper",
6+
products: [
7+
.library(name: "VIPER", targets: ["VIPER"]),
8+
],
9+
targets: [
10+
.target(name: "VIPER", dependencies: []),
11+
]
12+
)

README.md

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,39 @@
1-
# VIPER protocols
1+
# VIPER interfaces
22

3-
Essential protocols for the VIPER architecture.
3+
Essential interfaces (protocols) for the VIPER architecture.
44

55

66

77
## Installation
88

9+
### SPM
10+
11+
```
12+
.package(url: "https://github.com/CoreKit/VIPER", from: "2.0.0"),
13+
```
914

1015

1116
### CocoaPods
1217

1318
```
1419
source 'https://github.com/CoreKit/VIPER.git'
15-
pod 'VIPER'
20+
pod 'VIPER', '~> 2.0.0'
1621
```
1722

18-
19-
2023
### Carthage
2124

2225
```
23-
github "CoreKit/VIPER" "1.0.2"
26+
github "CoreKit/VIPER" "2.0.0"
2427
```
2528

2629

2730

31+
## Code generation
32+
33+
[VIPERA](https://github.com/corekit/vipera) - The most simple VIPER module generator for Swift projects.
34+
35+
36+
2837
## License
2938

3039
[WTFPL](LICENSE) - Do what the fuck you want to.

Sources/Entity.swift

Lines changed: 0 additions & 13 deletions
This file was deleted.

Sources/Interactor.swift

Lines changed: 0 additions & 13 deletions
This file was deleted.

Sources/Module.swift

Lines changed: 0 additions & 13 deletions
This file was deleted.

Sources/Presenter.swift

Lines changed: 0 additions & 13 deletions
This file was deleted.

Sources/Router.swift

Lines changed: 0 additions & 15 deletions
This file was deleted.

Sources/VIPER/Interfaces.swift

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
//
2+
// Interfaces.swift
3+
// VIPER
4+
//
5+
// Created by Tibor Bödecs on 2019. 05. 16..
6+
// Copyright © 2019. Tibor Bödecs. All rights reserved.
7+
//
8+
9+
import Foundation
10+
11+
// MARK: - basic viper protocols
12+
13+
public protocol ModuleInterface {
14+
15+
}
16+
17+
public protocol RouterInterface: class {
18+
19+
}
20+
21+
public protocol PresenterInterface: class {
22+
23+
}
24+
25+
public protocol InteractorInterface: class {
26+
27+
}
28+
29+
public protocol ViewInterface: class {
30+
31+
}
32+
33+
public protocol EntityInterface {
34+
35+
}
36+
37+
// MARK: - "i/o" transitions
38+
39+
public protocol RouterPresenterInterface {
40+
41+
}
42+
43+
public protocol InteractorPresenterInterface {
44+
45+
}
46+
47+
public protocol PresenterRouterInterface {
48+
49+
}
50+
51+
public protocol PresenterInteractorInterface {
52+
53+
}
54+
55+
public protocol PresenterViewInterface {
56+
57+
}
58+
59+
public protocol ViewPresenterInterface {
60+
61+
}
62+
63+
// MARK: - generic interfaces
64+
65+
public protocol GenericRouterInterface: RouterInterface &
66+
RouterPresenterInterface {
67+
associatedtype PresenterRouter
68+
69+
var presenter: PresenterRouter? { get set }
70+
}
71+
72+
public protocol GenericInteractorInterface: InteractorInterface &
73+
InteractorPresenterInterface {
74+
associatedtype PresenterInteractor
75+
76+
var presenter: PresenterInteractor? { get set }
77+
}
78+
79+
public protocol GenericPresenterInterface: PresenterInterface &
80+
PresenterRouterInterface &
81+
PresenterInteractorInterface &
82+
PresenterViewInterface
83+
{
84+
associatedtype RouterPresenter
85+
associatedtype InteractorPresenter
86+
associatedtype ViewPresenter
87+
88+
var router: RouterPresenter? { get set }
89+
var interactor: InteractorPresenter? { get set }
90+
var view: ViewPresenter? { get set }
91+
}
92+
93+
public protocol GenericViewInterface: ViewInterface &
94+
ViewPresenterInterface {
95+
associatedtype PresenterView
96+
97+
var presenter: PresenterView? { get set }
98+
}
99+
100+
101+
public protocol GenericModuleInterface: ModuleInterface {
102+
associatedtype View where View: GenericViewInterface
103+
associatedtype Presenter where Presenter: GenericPresenterInterface
104+
associatedtype Router where Router: GenericRouterInterface
105+
associatedtype Interactor where Interactor: GenericInteractorInterface
106+
107+
func compose(view: View, presenter: Presenter, router: Router, interactor: Interactor)
108+
}
109+
110+
public extension GenericModuleInterface {
111+
112+
func compose(view: View, presenter: Presenter, router: Router, interactor: Interactor) {
113+
view.presenter = (presenter as! Self.View.PresenterView)
114+
115+
presenter.view = (view as! Self.Presenter.ViewPresenter)
116+
presenter.interactor = (interactor as! Self.Presenter.InteractorPresenter)
117+
presenter.router = (router as! Self.Presenter.RouterPresenter)
118+
119+
interactor.presenter = (presenter as! Self.Interactor.PresenterInteractor)
120+
121+
router.presenter = (presenter as! Self.Router.PresenterRouter)
122+
}
123+
}

Sources/View.swift

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)