Skip to content

Commit 5ad17bc

Browse files
committed
feat: move data fetching into app
1 parent ca2e365 commit 5ad17bc

File tree

41 files changed

+408
-292
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+408
-292
lines changed

.DS_Store

0 Bytes
Binary file not shown.

TrackerApp/TrackerApp.xcodeproj/project.pbxproj TrackerApp.xcodeproj/project.pbxproj

+74-4
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,26 @@
1717
B132E82B2C643BAD004F2069 /* TrackerAppUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B132E82A2C643BAD004F2069 /* TrackerAppUITests.swift */; };
1818
B132E82D2C643BAD004F2069 /* TrackerAppUITestsLaunchTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B132E82C2C643BAD004F2069 /* TrackerAppUITestsLaunchTests.swift */; };
1919
B132E83A2C643F23004F2069 /* MainViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = B132E8392C643F23004F2069 /* MainViewModel.swift */; };
20-
B132E8402C644631004F2069 /* BackendApi.swift in Sources */ = {isa = PBXBuildFile; fileRef = B132E83F2C644631004F2069 /* BackendApi.swift */; };
20+
B15500AA2C6A25EB0039FD88 /* FetchContent.swift in Sources */ = {isa = PBXBuildFile; fileRef = B15500A92C6A25EB0039FD88 /* FetchContent.swift */; };
21+
B15500AB2C6A25EB0039FD88 /* FetchContent.swift in Sources */ = {isa = PBXBuildFile; fileRef = B15500A92C6A25EB0039FD88 /* FetchContent.swift */; };
22+
B15500AC2C6A25EB0039FD88 /* FetchContent.swift in Sources */ = {isa = PBXBuildFile; fileRef = B15500A92C6A25EB0039FD88 /* FetchContent.swift */; };
23+
B15500AD2C6A25EB0039FD88 /* FetchContent.swift in Sources */ = {isa = PBXBuildFile; fileRef = B15500A92C6A25EB0039FD88 /* FetchContent.swift */; };
24+
B15500B52C6A27CA0039FD88 /* GetElementValue.swift in Sources */ = {isa = PBXBuildFile; fileRef = B15500B42C6A27CA0039FD88 /* GetElementValue.swift */; };
25+
B15500B62C6A27CA0039FD88 /* GetElementValue.swift in Sources */ = {isa = PBXBuildFile; fileRef = B15500B42C6A27CA0039FD88 /* GetElementValue.swift */; };
26+
B15500B72C6A27CA0039FD88 /* GetElementValue.swift in Sources */ = {isa = PBXBuildFile; fileRef = B15500B42C6A27CA0039FD88 /* GetElementValue.swift */; };
27+
B15500B82C6A27CA0039FD88 /* GetElementValue.swift in Sources */ = {isa = PBXBuildFile; fileRef = B15500B42C6A27CA0039FD88 /* GetElementValue.swift */; };
28+
B15500BB2C6A28FE0039FD88 /* ContentApi.swift in Sources */ = {isa = PBXBuildFile; fileRef = B15500BA2C6A28FE0039FD88 /* ContentApi.swift */; };
29+
B15500BC2C6A28FE0039FD88 /* ContentApi.swift in Sources */ = {isa = PBXBuildFile; fileRef = B15500BA2C6A28FE0039FD88 /* ContentApi.swift */; };
30+
B15500BD2C6A28FE0039FD88 /* ContentApi.swift in Sources */ = {isa = PBXBuildFile; fileRef = B15500BA2C6A28FE0039FD88 /* ContentApi.swift */; };
31+
B15500BE2C6A28FE0039FD88 /* ContentApi.swift in Sources */ = {isa = PBXBuildFile; fileRef = B15500BA2C6A28FE0039FD88 /* ContentApi.swift */; };
32+
B15500C02C6A29460039FD88 /* ContentApiImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = B15500BF2C6A29460039FD88 /* ContentApiImpl.swift */; };
33+
B15500C12C6A29460039FD88 /* ContentApiImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = B15500BF2C6A29460039FD88 /* ContentApiImpl.swift */; };
34+
B15500C22C6A29460039FD88 /* ContentApiImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = B15500BF2C6A29460039FD88 /* ContentApiImpl.swift */; };
35+
B15500C32C6A29460039FD88 /* ContentApiImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = B15500BF2C6A29460039FD88 /* ContentApiImpl.swift */; };
36+
B15500C52C6A2A5D0039FD88 /* Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = B15500C42C6A2A5D0039FD88 /* Constants.swift */; };
37+
B15500C62C6A2A5D0039FD88 /* Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = B15500C42C6A2A5D0039FD88 /* Constants.swift */; };
38+
B15500C72C6A2A5D0039FD88 /* Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = B15500C42C6A2A5D0039FD88 /* Constants.swift */; };
39+
B15500C82C6A2A5D0039FD88 /* Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = B15500C42C6A2A5D0039FD88 /* Constants.swift */; };
2140
B1CDF5182C6575C30005EF4C /* WidgetKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B1CDF5172C6575C30005EF4C /* WidgetKit.framework */; };
2241
B1CDF51A2C6575C30005EF4C /* SwiftUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B1CDF5192C6575C30005EF4C /* SwiftUI.framework */; };
2342
B1CDF5212C6575C30005EF4C /* TrackerWidget.swift in Sources */ = {isa = PBXBuildFile; fileRef = B1CDF5202C6575C30005EF4C /* TrackerWidget.swift */; };
@@ -79,7 +98,11 @@
7998
B132E82A2C643BAD004F2069 /* TrackerAppUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TrackerAppUITests.swift; sourceTree = "<group>"; };
8099
B132E82C2C643BAD004F2069 /* TrackerAppUITestsLaunchTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TrackerAppUITestsLaunchTests.swift; sourceTree = "<group>"; };
81100
B132E8392C643F23004F2069 /* MainViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainViewModel.swift; sourceTree = "<group>"; };
82-
B132E83F2C644631004F2069 /* BackendApi.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BackendApi.swift; sourceTree = "<group>"; };
101+
B15500A92C6A25EB0039FD88 /* FetchContent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FetchContent.swift; sourceTree = "<group>"; };
102+
B15500B42C6A27CA0039FD88 /* GetElementValue.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GetElementValue.swift; sourceTree = "<group>"; };
103+
B15500BA2C6A28FE0039FD88 /* ContentApi.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentApi.swift; sourceTree = "<group>"; };
104+
B15500BF2C6A29460039FD88 /* ContentApiImpl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentApiImpl.swift; sourceTree = "<group>"; };
105+
B15500C42C6A2A5D0039FD88 /* Constants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Constants.swift; sourceTree = "<group>"; };
83106
B1CDF5152C6575C30005EF4C /* TrackerWidgetExtension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = TrackerWidgetExtension.appex; sourceTree = BUILT_PRODUCTS_DIR; };
84107
B1CDF5172C6575C30005EF4C /* WidgetKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WidgetKit.framework; path = System/Library/Frameworks/WidgetKit.framework; sourceTree = SDKROOT; };
85108
B1CDF5192C6575C30005EF4C /* SwiftUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SwiftUI.framework; path = System/Library/Frameworks/SwiftUI.framework; sourceTree = SDKROOT; };
@@ -150,6 +173,7 @@
150173
isa = PBXGroup;
151174
children = (
152175
B132E83B2C643F39004F2069 /* Core */,
176+
B15500A42C6A22B70039FD88 /* Data */,
153177
B132E83C2C643F3F004F2069 /* Domain */,
154178
B132E83D2C643F4D004F2069 /* Presentation */,
155179
B132E8092C643BAC004F2069 /* AppDelegate.swift */,
@@ -182,14 +206,16 @@
182206
B132E83B2C643F39004F2069 /* Core */ = {
183207
isa = PBXGroup;
184208
children = (
209+
B15500C42C6A2A5D0039FD88 /* Constants.swift */,
185210
);
186211
path = Core;
187212
sourceTree = "<group>";
188213
};
189214
B132E83C2C643F3F004F2069 /* Domain */ = {
190215
isa = PBXGroup;
191216
children = (
192-
B132E83F2C644631004F2069 /* BackendApi.swift */,
217+
B15500B92C6A28C90039FD88 /* Api */,
218+
B15500A62C6A22F20039FD88 /* UseCase */,
193219
);
194220
path = Domain;
195221
sourceTree = "<group>";
@@ -211,6 +237,31 @@
211237
path = Home;
212238
sourceTree = "<group>";
213239
};
240+
B15500A42C6A22B70039FD88 /* Data */ = {
241+
isa = PBXGroup;
242+
children = (
243+
B15500BF2C6A29460039FD88 /* ContentApiImpl.swift */,
244+
);
245+
path = Data;
246+
sourceTree = "<group>";
247+
};
248+
B15500A62C6A22F20039FD88 /* UseCase */ = {
249+
isa = PBXGroup;
250+
children = (
251+
B15500A92C6A25EB0039FD88 /* FetchContent.swift */,
252+
B15500B42C6A27CA0039FD88 /* GetElementValue.swift */,
253+
);
254+
path = UseCase;
255+
sourceTree = "<group>";
256+
};
257+
B15500B92C6A28C90039FD88 /* Api */ = {
258+
isa = PBXGroup;
259+
children = (
260+
B15500BA2C6A28FE0039FD88 /* ContentApi.swift */,
261+
);
262+
path = Api;
263+
sourceTree = "<group>";
264+
};
214265
B1CDF5162C6575C30005EF4C /* Frameworks */ = {
215266
isa = PBXGroup;
216267
children = (
@@ -393,18 +444,27 @@
393444
isa = PBXSourcesBuildPhase;
394445
buildActionMask = 2147483647;
395446
files = (
396-
B132E8402C644631004F2069 /* BackendApi.swift in Sources */,
397447
B132E80E2C643BAC004F2069 /* MainView.swift in Sources */,
448+
B15500C02C6A29460039FD88 /* ContentApiImpl.swift in Sources */,
449+
B15500BB2C6A28FE0039FD88 /* ContentApi.swift in Sources */,
450+
B15500AA2C6A25EB0039FD88 /* FetchContent.swift in Sources */,
451+
B15500C52C6A2A5D0039FD88 /* Constants.swift in Sources */,
398452
B132E80A2C643BAC004F2069 /* AppDelegate.swift in Sources */,
399453
B132E80C2C643BAC004F2069 /* SceneDelegate.swift in Sources */,
400454
B132E83A2C643F23004F2069 /* MainViewModel.swift in Sources */,
455+
B15500B52C6A27CA0039FD88 /* GetElementValue.swift in Sources */,
401456
);
402457
runOnlyForDeploymentPostprocessing = 0;
403458
};
404459
B132E8182C643BAD004F2069 /* Sources */ = {
405460
isa = PBXSourcesBuildPhase;
406461
buildActionMask = 2147483647;
407462
files = (
463+
B15500C12C6A29460039FD88 /* ContentApiImpl.swift in Sources */,
464+
B15500BC2C6A28FE0039FD88 /* ContentApi.swift in Sources */,
465+
B15500AB2C6A25EB0039FD88 /* FetchContent.swift in Sources */,
466+
B15500C62C6A2A5D0039FD88 /* Constants.swift in Sources */,
467+
B15500B62C6A27CA0039FD88 /* GetElementValue.swift in Sources */,
408468
B132E8212C643BAD004F2069 /* TrackerAppTests.swift in Sources */,
409469
);
410470
runOnlyForDeploymentPostprocessing = 0;
@@ -414,7 +474,12 @@
414474
buildActionMask = 2147483647;
415475
files = (
416476
B132E82B2C643BAD004F2069 /* TrackerAppUITests.swift in Sources */,
477+
B15500B72C6A27CA0039FD88 /* GetElementValue.swift in Sources */,
417478
B132E82D2C643BAD004F2069 /* TrackerAppUITestsLaunchTests.swift in Sources */,
479+
B15500AC2C6A25EB0039FD88 /* FetchContent.swift in Sources */,
480+
B15500C22C6A29460039FD88 /* ContentApiImpl.swift in Sources */,
481+
B15500BD2C6A28FE0039FD88 /* ContentApi.swift in Sources */,
482+
B15500C72C6A2A5D0039FD88 /* Constants.swift in Sources */,
418483
);
419484
runOnlyForDeploymentPostprocessing = 0;
420485
};
@@ -423,7 +488,12 @@
423488
buildActionMask = 2147483647;
424489
files = (
425490
B1CDF5302C6585970005EF4C /* TrackerWidgetBundle.swift in Sources */,
491+
B15500B82C6A27CA0039FD88 /* GetElementValue.swift in Sources */,
426492
B1CDF5212C6575C30005EF4C /* TrackerWidget.swift in Sources */,
493+
B15500AD2C6A25EB0039FD88 /* FetchContent.swift in Sources */,
494+
B15500C32C6A29460039FD88 /* ContentApiImpl.swift in Sources */,
495+
B15500BE2C6A28FE0039FD88 /* ContentApi.swift in Sources */,
496+
B15500C82C6A2A5D0039FD88 /* Constants.swift in Sources */,
427497
);
428498
runOnlyForDeploymentPostprocessing = 0;
429499
};

TrackerApp/TrackerApp.xcodeproj/xcuserdata/ezen.xcuserdatad/xcschemes/xcschememanagement.plist TrackerApp.xcodeproj/xcuserdata/ezen.xcuserdatad/xcschemes/xcschememanagement.plist

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<key>TrackerWidgetExtension.xcscheme_^#shared#^_</key>
1313
<dict>
1414
<key>orderHint</key>
15-
<integer>1</integer>
15+
<integer>0</integer>
1616
</dict>
1717
</dict>
1818
</dict>

TrackerApp/.DS_Store

6 KB
Binary file not shown.
File renamed without changes.

TrackerApp/Core/Constants.swift

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//
2+
// Constants.swift
3+
// TrackerApp
4+
//
5+
// Created by ezen on 12/08/2024.
6+
//
7+
8+
import Foundation
9+
10+
struct Constants {
11+
12+
static let CONTENT_SELECTOR_KEY = "TrackerApp.CONTENT_SELECTOR_KEY"
13+
14+
static let CONTENT_URL_KEY = "TrackerApp.CONTENT_URL_KEY"
15+
16+
static let CONTENT_TAG_KEY = "TrackerApp.CONTENT_TAG_KEY"
17+
18+
static let CONTENT_VALUE_KEY = "TrackerApp.CONTENT_VALUE_KEY"
19+
}

TrackerApp/Data/ContentApiImpl.swift

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//
2+
// ContentApiImpl.swift
3+
// TrackerApp
4+
//
5+
// Created by ezen on 12/08/2024.
6+
//
7+
8+
import Foundation
9+
10+
final class ContentApiImpl: ContentApi {
11+
12+
static let shared = ContentApiImpl()
13+
14+
func fetchContent(at url: String) async throws -> String? {
15+
if let _url = URL(string: url) {
16+
var _request = URLRequest(url: _url)
17+
_request.httpMethod = "GET"
18+
_request.setValue("Mozilla/5.0", forHTTPHeaderField: "User-Agent")
19+
_request.setValue("text/html; charset=utf-8", forHTTPHeaderField: "Content-Type")
20+
21+
let (_data, _) = try await URLSession.shared.data(for: _request)
22+
23+
return String(data: _data, encoding: .utf8)
24+
}
25+
return nil
26+
}
27+
}
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//
2+
// ContentApi.swift
3+
// TrackerApp
4+
//
5+
// Created by ezen on 12/08/2024.
6+
//
7+
8+
import Foundation
9+
10+
protocol ContentApi {
11+
12+
func fetchContent(at url: String) async throws -> String?
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//
2+
// FetchContent.swift
3+
// TrackerApp
4+
//
5+
// Created by ezen on 12/08/2024.
6+
//
7+
8+
import Foundation
9+
10+
protocol FetchContent {
11+
12+
func execute(at url: String) async throws -> String
13+
}
14+
15+
struct FetchContentUseCase: FetchContent {
16+
17+
var api: ContentApi
18+
19+
func execute(at url: String) async throws -> String {
20+
let _response = try await api.fetchContent(at: url)
21+
return _response ?? ""
22+
}
23+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//
2+
// GetElementValue.swift
3+
// TrackerApp
4+
//
5+
// Created by ezen on 12/08/2024.
6+
//
7+
8+
import Foundation
9+
10+
protocol GetElementValue {
11+
12+
func execute(from documentStr: String) throws -> String
13+
}
14+
15+
struct GetElementValueUseCase: GetElementValue {
16+
17+
func execute(from documentStr: String) throws -> String {
18+
return ""
19+
}
20+
}
21+
File renamed without changes.

0 commit comments

Comments
 (0)