Skip to content

Commit 44ea316

Browse files
authored
Merge pull request #22 from engingulek/develop
Develop
2 parents 5451bf8 + 5c5bcf9 commit 44ea316

8 files changed

Lines changed: 42 additions & 34 deletions

.DS_Store

0 Bytes
Binary file not shown.

ICTMDBAllListModule/AllListInteractor.swift

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,30 @@
88
import Foundation
99

1010

11-
final class AllListInteractor : @preconcurrency PresenterToInteractorAllListProtocol {
11+
final class AllListInteractor : PresenterToInteractorAllListProtocol,@unchecked Sendable {
12+
1213
weak var presenter: (any InteractorToPresenterAllListProtocol)?
13-
14-
1514
private let network : NetworkManagerProtocol
1615
init(network: NetworkManagerProtocol) {
1716

1817
self.network = network
1918
}
19+
2020
let deviceLanguageCode = Locale.current.language.languageCode ?? .english
21-
@MainActor func loadTvShows(type:ListType,page:Int) {
21+
22+
func loadTvShows(type: ListType, page: Int) async {
2223
let request = TvShowRequest(
2324
language: deviceLanguageCode == .turkish ? .tr : .en,
2425
page: page,
2526
allListType: type)
26-
network.execute(request) {[weak self] result in
27-
guard let self else {return}
28-
switch result {
29-
case .success(let result):
30-
presenter?.sendData(result)
31-
case .failure:
32-
presenter?.sendError()
33-
}
27+
28+
29+
do {
30+
let result = try await network.execute(request)
31+
await presenter?.sendData(result)
32+
}catch{
33+
await presenter?.sendError()
3434
}
3535
}
36-
3736
}
3837

ICTMDBAllListModule/AllListPresenter.swift

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,28 @@ final class AllListPresenter {
3131
self.interactor = interactor
3232
self.router = router
3333
}
34+
35+
@MainActor
36+
private func fetchTvShows(at type: ListType) {
37+
Task {@MainActor in
38+
await interactor.loadTvShows(type: type, page: currentPage)
39+
}
40+
}
3441
}
3542

3643
//MARK: AllListPresenter : ViewToPresenterAllListProtocol
37-
extension AllListPresenter : ViewToPresenterAllListProtocol {
44+
extension AllListPresenter : @MainActor ViewToPresenterAllListProtocol {
3845

3946

4047
func viewDidLoad() {
4148
view?.setBackColorAble(color: "backColor")
4249
view?.setNavigationTitle(title: "All List")
4350
}
4451

45-
func getAllList(at type: ListType) {
52+
@MainActor func getAllList(at type: ListType) {
4653
listtype = type
47-
interactor.loadTvShows(type: type, page: currentPage)
48-
54+
fetchTvShows(at: type)
55+
4956
}
5057

5158
func numberOfRowsInSection(in section: Int) -> Int {
@@ -113,12 +120,14 @@ extension AllListPresenter : ViewToPresenterAllListProtocol {
113120
return item
114121
}
115122

116-
func scrollViewDidScroll(endOfPage: Bool) {
123+
@MainActor func scrollViewDidScroll(endOfPage: Bool) {
117124
guard let listtype = listtype else {return}
118125
if endOfPage {
119126
if currentPage <= totalPage {
120127
currentPage += 1
121-
interactor.loadTvShows(type: listtype , page: currentPage)
128+
129+
fetchTvShows(at: listtype)
130+
122131
view?.relaodCollectionView()
123132
}
124133
}
@@ -127,8 +136,8 @@ extension AllListPresenter : ViewToPresenterAllListProtocol {
127136
}
128137

129138
//MARK: AllListPresenter : InteractorToPresenterAllListProtocol
130-
extension AllListPresenter : @preconcurrency InteractorToPresenterAllListProtocol {
131-
@MainActor
139+
extension AllListPresenter : InteractorToPresenterAllListProtocol {
140+
132141
func sendData(_ data: DataResult<TvShow>) {
133142

134143

@@ -147,7 +156,7 @@ extension AllListPresenter : @preconcurrency InteractorToPresenterAllListProtoco
147156

148157
}
149158

150-
@MainActor
159+
151160
func sendError() {
152161

153162

ICTMDBAllListModule/AllListProtocols.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ protocol PresenterToViewAllListProtocol : AnyObject,Ables{
3333
}
3434

3535

36-
protocol PresenterToInteractorAllListProtocol {
36+
protocol PresenterToInteractorAllListProtocol : Sendable,AnyObject {
3737
var presenter: InteractorToPresenterAllListProtocol? {get set}
38-
func loadTvShows(type:ListType,page:Int)
38+
func loadTvShows(type:ListType,page:Int) async
3939

4040
}
4141

42-
42+
@MainActor
4343
protocol InteractorToPresenterAllListProtocol : AnyObject{
4444
func sendData(_ data:DataResult<TvShow> )
4545
func sendError()

ICTMDBAllListModule/AllListViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ final class AllListViewController: UIViewController {
9595
}
9696

9797
// MARK: - PresenterToViewAllListProtocol
98-
extension AllListViewController: @preconcurrency PresenterToViewAllListProtocol {
98+
extension AllListViewController: @MainActor PresenterToViewAllListProtocol {
9999

100100
func prepareCollectionView() {
101101

ICTMDBAllListModule/ICTMDBAllListModule.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import UIKit
1212
import ICTMDBNetworkManagerKit
1313

1414

15-
public class ICTMDBAllListModule : @preconcurrency AllListModuleProtocol {
15+
public class ICTMDBAllListModule : @MainActor AllListModuleProtocol {
1616

1717
public init() { }
1818

Package.resolved

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ let package = Package(
55
name: "ICTMDBAllListModule",
66
defaultLocalization: "en",
77
platforms: [
8-
.iOS(.v18)
8+
.iOS(.v26)
99
],
1010
products: [
1111
.library(

0 commit comments

Comments
 (0)