-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: Add VIPER Arch as example * refactor: Update hierarchy folders for VIPER module
- Loading branch information
Showing
7 changed files
with
180 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// | ||
// MessageInteractor.swift | ||
// Arch | ||
// | ||
// Created by specktro on 17/10/21. | ||
// Copyright © 2021 specktro. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
// MARK: MessageInteractor class | ||
final class MessageInteractor: MessageInteractorProtocol { | ||
// MARK: - Properties | ||
weak var presenter: MessagePresenterProtocol? | ||
var person: Person? | ||
|
||
// MARK: - MessageInteractorProtocol methods | ||
func prepareMessage() { | ||
guard let person = person else { | ||
preconditionFailure("The person model was not provided") | ||
} | ||
|
||
let greeting: String = "Hello" + " " + person.firstName + " " + person.lastName | ||
presenter?.retrieve(message: greeting) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// | ||
// MessagePresenter.swift | ||
// Arch | ||
// | ||
// Created by specktro on 17/10/21. | ||
// Copyright © 2021 specktro. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
final class MessagePresenter: MessagePresenterProtocol { | ||
weak var view: MessageViewProtocol? | ||
var interactor: MessageInteractorProtocol? | ||
|
||
func askMessage() { | ||
interactor?.prepareMessage() | ||
} | ||
|
||
func retrieve(message: String) { | ||
view?.show(message) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// | ||
// ShowMessageProtocols.swift | ||
// Arch | ||
// | ||
// Created by specktro on 17/10/21. | ||
// Copyright © 2021 specktro. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
|
||
// MARK: MessageViewProtocol | ||
protocol MessageViewProtocol: UIViewController { | ||
var presenter: MessagePresenterProtocol? { get set } | ||
|
||
// Output | ||
func show(_ message: String) | ||
} | ||
|
||
// MARK: MessagePresenterProtocol protocol | ||
protocol MessagePresenterProtocol: AnyObject { | ||
var view: MessageViewProtocol? { get set } | ||
var interactor: MessageInteractorProtocol? { get set } | ||
|
||
// Input | ||
func askMessage() | ||
|
||
// Output | ||
func retrieve(message: String) | ||
} | ||
|
||
// MARK: MessageInteractorProtocol protocol | ||
protocol MessageInteractorProtocol: AnyObject { | ||
var presenter: MessagePresenterProtocol? { get set } | ||
var person: Person? { get set } | ||
|
||
// Input | ||
func prepareMessage() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// | ||
// MessageView.swift | ||
// Arch | ||
// | ||
// Created by specktro on 17/10/21. | ||
// Copyright © 2021 specktro. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
|
||
// MARK: MessageView class | ||
final class MessageView: SharedViewController, MessageViewProtocol { | ||
// MARK: - Properties | ||
var presenter: MessagePresenterProtocol? | ||
|
||
// MARK: - SharedViewController method | ||
override func didTapButton(_ button: UIButton) { | ||
presenter?.askMessage() | ||
} | ||
|
||
// MARK: - MessageViewProtocol | ||
func show(_ message: String) { | ||
greetingLabel?.text = message | ||
} | ||
} |