-
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.
Merge pull request #8 from helloItsHEssam/feature/modularization-pres…
…entation Feature/modularization presentation
- Loading branch information
Showing
57 changed files
with
2,078 additions
and
115 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
Large diffs are not rendered by default.
Oops, something went wrong.
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,14 @@ | ||
// | ||
// DIContainer.swift | ||
// TransferList | ||
// | ||
// Created by Hessam Mahdiabadi on 11/6/23. | ||
// | ||
|
||
import Foundation | ||
import Domain | ||
|
||
protocol DIContainer { | ||
|
||
func createPresonBankAccountUseCase() -> PersonBankAccountUseCase | ||
} |
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,27 @@ | ||
// | ||
// DIContainerImpl.swift | ||
// TransferList | ||
// | ||
// Created by Hessam Mahdiabadi on 11/6/23. | ||
// | ||
|
||
import Foundation | ||
import Domain | ||
import Data | ||
|
||
final class DIContainerImpl: DIContainer { | ||
|
||
private func createPersonBankAccountRepository() -> PersonBankAccountRepository { | ||
let api: Api = ApiImpl() | ||
let database = DatabaseImpl() | ||
let local = LocalImpl(database: database) | ||
|
||
return PersonBankAccountRepositoryImpl(api: api, local: local) | ||
} | ||
|
||
func createPresonBankAccountUseCase() -> PersonBankAccountUseCase { | ||
let repository = createPersonBankAccountRepository() | ||
let useCase = PersonBankAccountUseCaseImpl(repository: repository) | ||
return useCase | ||
} | ||
} |
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 was deleted.
Oops, something went wrong.
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,32 @@ | ||
// | ||
// PaginationMode.swift | ||
// TransferList | ||
// | ||
// Created by Hessam Mahdiabadi on 11/6/23. | ||
// | ||
|
||
import Foundation | ||
|
||
struct PaginationMode { | ||
|
||
enum Mode { | ||
case continues | ||
case reachedToEnd | ||
} | ||
|
||
var offset: Int = 0 | ||
var mode: Mode = .continues | ||
|
||
var nextOffset: Int { | ||
offset + 1 | ||
} | ||
|
||
mutating func moveToNextOffset() { | ||
self.offset += 1 | ||
} | ||
|
||
mutating func reset() { | ||
offset = 0 | ||
mode = .continues | ||
} | ||
} |
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 @@ | ||
// | ||
// Router.swift | ||
// TransferList | ||
// | ||
// Created by Hessam Mahdiabadi on 11/6/23. | ||
// | ||
|
||
import Foundation | ||
import Domain | ||
|
||
enum Router: Hashable, Equatable { | ||
|
||
case home | ||
case detail(account: PersonBankAccount) | ||
|
||
func hash(into hasher: inout Hasher) { | ||
switch self { | ||
case .home: hasher.combine("home") | ||
case .detail(let account): hasher.combine(account) | ||
} | ||
} | ||
|
||
static func == (lhs: Router, rhs: Router) -> Bool { | ||
return lhs.hashValue == rhs.hashValue | ||
} | ||
} |
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,30 @@ | ||
// | ||
// ViewModelFactory.swift | ||
// TransferList | ||
// | ||
// Created by Hessam Mahdiabadi on 11/6/23. | ||
// | ||
|
||
import Foundation | ||
|
||
class ViewModelFactory { | ||
|
||
private var container: DIContainer! | ||
|
||
static let shared = ViewModelFactory() | ||
|
||
private init() {} | ||
|
||
func register(DIContainer container: DIContainer) { | ||
self.container = container | ||
} | ||
|
||
func createMediaViewModel() -> TransferViewModel { | ||
guard container != nil else { | ||
fatalError("Register DIContainer to Enable ViewModel Creation") | ||
} | ||
|
||
let personBankAccountUseCase = container.createPresonBankAccountUseCase() | ||
return .init(personBackAccountUseCase: personBankAccountUseCase) | ||
} | ||
} |
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,35 @@ | ||
// | ||
// ViewState.swift | ||
// TransferList | ||
// | ||
// Created by Hessam Mahdiabadi on 11/6/23. | ||
// | ||
|
||
import Foundation | ||
|
||
enum ViewState: Hashable, Equatable, CustomStringConvertible { | ||
|
||
case loading | ||
case result | ||
case error(message: String) | ||
|
||
func hash(into hasher: inout Hasher) { | ||
switch self { | ||
case .error: hasher.combine("error") | ||
case .result: hasher.combine("result") | ||
case .loading: hasher.combine("loading") | ||
} | ||
} | ||
|
||
var description: String { | ||
switch self { | ||
case .error(let message): return message | ||
case .result: return "result" | ||
case .loading: return "loading" | ||
} | ||
} | ||
|
||
static func == (lhs: ViewState, rhs: ViewState) -> Bool { | ||
return lhs.hashValue == rhs.hashValue | ||
} | ||
} |
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,19 @@ | ||
// | ||
// UIViewController+Alert.swift | ||
// TransferList | ||
// | ||
// Created by Hessam Mahdiabadi on 11/6/23. | ||
// | ||
|
||
import UIKit | ||
|
||
extension UIViewController { | ||
|
||
func showAlert(title: String, message: String) { | ||
let dialogMessage = UIAlertController(title: title, message: message, preferredStyle: .alert) | ||
let ok = UIAlertAction(title: "OK", style: .default) | ||
|
||
dialogMessage.addAction(ok) | ||
self.present(dialogMessage, animated: true, completion: nil) | ||
} | ||
} |
Oops, something went wrong.