Skip to content

Commit 2004767

Browse files
authored
Merge pull request #34 from GoodRequest/feat/drobne-zmeny
Code structure & naming changes
2 parents a9c89c3 + 6f7170b commit 2004767

37 files changed

+2159
-615
lines changed
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Scheme
3+
LastUpgradeVersion = "1600"
4+
version = "1.7">
5+
<BuildAction
6+
parallelizeBuildables = "YES"
7+
buildImplicitDependencies = "YES"
8+
buildArchitectures = "Automatic">
9+
<BuildActionEntries>
10+
<BuildActionEntry
11+
buildForTesting = "YES"
12+
buildForRunning = "YES"
13+
buildForProfiling = "YES"
14+
buildForArchiving = "YES"
15+
buildForAnalyzing = "YES">
16+
<BuildableReference
17+
BuildableIdentifier = "primary"
18+
BlueprintIdentifier = "GoodNetworking"
19+
BuildableName = "GoodNetworking"
20+
BlueprintName = "GoodNetworking"
21+
ReferencedContainer = "container:">
22+
</BuildableReference>
23+
</BuildActionEntry>
24+
</BuildActionEntries>
25+
</BuildAction>
26+
<TestAction
27+
buildConfiguration = "Debug"
28+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
29+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
30+
shouldUseLaunchSchemeArgsEnv = "YES"
31+
shouldAutocreateTestPlan = "YES">
32+
</TestAction>
33+
<LaunchAction
34+
buildConfiguration = "Debug"
35+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
36+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
37+
launchStyle = "0"
38+
useCustomWorkingDirectory = "NO"
39+
ignoresPersistentStateOnLaunch = "NO"
40+
debugDocumentVersioning = "YES"
41+
debugServiceExtension = "internal"
42+
allowLocationSimulation = "YES">
43+
</LaunchAction>
44+
<ProfileAction
45+
buildConfiguration = "Release"
46+
shouldUseLaunchSchemeArgsEnv = "YES"
47+
savedToolIdentifier = ""
48+
useCustomWorkingDirectory = "NO"
49+
debugDocumentVersioning = "YES">
50+
<MacroExpansion>
51+
<BuildableReference
52+
BuildableIdentifier = "primary"
53+
BlueprintIdentifier = "GoodNetworking"
54+
BuildableName = "GoodNetworking"
55+
BlueprintName = "GoodNetworking"
56+
ReferencedContainer = "container:">
57+
</BuildableReference>
58+
</MacroExpansion>
59+
</ProfileAction>
60+
<AnalyzeAction
61+
buildConfiguration = "Debug">
62+
</AnalyzeAction>
63+
<ArchiveAction
64+
buildConfiguration = "Release"
65+
revealArchiveInOrganizer = "YES">
66+
</ArchiveAction>
67+
</Scheme>

GoodNetworking-Sample/GoodNetworking-Sample.xcodeproj/project.pbxproj

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,15 @@
1010
0973C9FD2C4C3FC6007BAF6A /* GoodMacros in Frameworks */ = {isa = PBXBuildFile; productRef = 0973C9FC2C4C3FC6007BAF6A /* GoodMacros */; };
1111
09A9EC8F2C47FF8E0032C359 /* UserScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09A9EC8E2C47FF8E0032C359 /* UserScreen.swift */; };
1212
09A9EC922C48002C0032C359 /* User.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09A9EC912C48002C0032C359 /* User.swift */; };
13-
09A9EC952C4800BA0032C359 /* NetworkSessions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09A9EC942C4800B90032C359 /* NetworkSessions.swift */; };
13+
09A9EC952C4800BA0032C359 /* SampleNetworkSessions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09A9EC942C4800B90032C359 /* SampleNetworkSessions.swift */; };
1414
09A9EC9A2C48015C0032C359 /* SampleEndpoint.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09A9EC992C48015C0032C359 /* SampleEndpoint.swift */; };
1515
09A9EC9D2C48115A0032C359 /* GRAsyncImage in Frameworks */ = {isa = PBXBuildFile; productRef = 09A9EC9C2C48115A0032C359 /* GRAsyncImage */; };
1616
09A9EC9F2C48115A0032C359 /* GRInputField in Frameworks */ = {isa = PBXBuildFile; productRef = 09A9EC9E2C48115A0032C359 /* GRInputField */; };
1717
09A9ECA12C48115A0032C359 /* GoodSwiftUI in Frameworks */ = {isa = PBXBuildFile; productRef = 09A9ECA02C48115A0032C359 /* GoodSwiftUI */; };
1818
09A9ECA32C4811B00032C359 /* UserListScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09A9ECA22C4811B00032C359 /* UserListScreen.swift */; };
1919
09A9ECAE2C4AC9810032C359 /* JobUser.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09A9ECAD2C4AC9810032C359 /* JobUser.swift */; };
20+
5D4200142CBEE7ED006C4292 /* UserDefaultsExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D4200132CBEE7ED006C4292 /* UserDefaultsExtensions.swift */; };
21+
5D4200192CBF97CC006C4292 /* ServerPickerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D4200182CBF97CC006C4292 /* ServerPickerView.swift */; };
2022
5D4A967C299C190B00DFAEAE /* GoodNetworking in Frameworks */ = {isa = PBXBuildFile; productRef = 5D4A967B299C190B00DFAEAE /* GoodNetworking */; };
2123
5D4A967E299C190B00DFAEAE /* Mockable in Frameworks */ = {isa = PBXBuildFile; productRef = 5D4A967D299C190B00DFAEAE /* Mockable */; };
2224
5D7C80652CA2CDB900116E10 /* SampleSelectableBaseUrlProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D7C80642CA2CDB900116E10 /* SampleSelectableBaseUrlProvider.swift */; };
@@ -29,10 +31,12 @@
2931
/* Begin PBXFileReference section */
3032
09A9EC8E2C47FF8E0032C359 /* UserScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserScreen.swift; sourceTree = "<group>"; };
3133
09A9EC912C48002C0032C359 /* User.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = User.swift; sourceTree = "<group>"; };
32-
09A9EC942C4800B90032C359 /* NetworkSessions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetworkSessions.swift; sourceTree = "<group>"; };
34+
09A9EC942C4800B90032C359 /* SampleNetworkSessions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SampleNetworkSessions.swift; sourceTree = "<group>"; };
3335
09A9EC992C48015C0032C359 /* SampleEndpoint.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SampleEndpoint.swift; sourceTree = "<group>"; };
3436
09A9ECA22C4811B00032C359 /* UserListScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserListScreen.swift; sourceTree = "<group>"; };
3537
09A9ECAD2C4AC9810032C359 /* JobUser.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JobUser.swift; sourceTree = "<group>"; };
38+
5D4200132CBEE7ED006C4292 /* UserDefaultsExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserDefaultsExtensions.swift; sourceTree = "<group>"; };
39+
5D4200182CBF97CC006C4292 /* ServerPickerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ServerPickerView.swift; sourceTree = "<group>"; };
3640
5D4A967A299C18FB00DFAEAE /* GoodNetworking */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = GoodNetworking; path = ..; sourceTree = "<group>"; };
3741
5D7C80642CA2CDB900116E10 /* SampleSelectableBaseUrlProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SampleSelectableBaseUrlProvider.swift; sourceTree = "<group>"; };
3842
5D9BD7302CBD19C100667B76 /* ApiServer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ApiServer.swift; sourceTree = "<group>"; };
@@ -65,6 +69,7 @@
6569
children = (
6670
09A9ECA22C4811B00032C359 /* UserListScreen.swift */,
6771
09A9EC8E2C47FF8E0032C359 /* UserScreen.swift */,
72+
5D4200182CBF97CC006C4292 /* ServerPickerView.swift */,
6873
);
6974
path = Screens;
7075
sourceTree = "<group>";
@@ -83,13 +88,21 @@
8388
09A9EC932C4800AA0032C359 /* Managers */ = {
8489
isa = PBXGroup;
8590
children = (
86-
09A9EC942C4800B90032C359 /* NetworkSessions.swift */,
91+
09A9EC942C4800B90032C359 /* SampleNetworkSessions.swift */,
8792
09A9EC992C48015C0032C359 /* SampleEndpoint.swift */,
8893
5D7C80642CA2CDB900116E10 /* SampleSelectableBaseUrlProvider.swift */,
8994
);
9095
path = Managers;
9196
sourceTree = "<group>";
9297
};
98+
5D4200152CBEE7F2006C4292 /* Extensions */ = {
99+
isa = PBXGroup;
100+
children = (
101+
5D4200132CBEE7ED006C4292 /* UserDefaultsExtensions.swift */,
102+
);
103+
path = Extensions;
104+
sourceTree = "<group>";
105+
};
93106
5D4A9679299C18FB00DFAEAE /* Packages */ = {
94107
isa = PBXGroup;
95108
children = (
@@ -120,6 +133,7 @@
120133
isa = PBXGroup;
121134
children = (
122135
EACEC433299582F0008242AA /* Application */,
136+
5D4200152CBEE7F2006C4292 /* Extensions */,
123137
09A9EC902C4800240032C359 /* Models */,
124138
09A9EC932C4800AA0032C359 /* Managers */,
125139
09A9EC8D2C47FF830032C359 /* Screens */,
@@ -180,7 +194,7 @@
180194
attributes = {
181195
BuildIndependentTargetsInParallel = 1;
182196
LastSwiftUpdateCheck = 1410;
183-
LastUpgradeCheck = 1410;
197+
LastUpgradeCheck = 1600;
184198
TargetAttributes = {
185199
EACEC3F529953DCB008242AA = {
186200
CreatedOnToolsVersion = 14.1;
@@ -230,9 +244,11 @@
230244
09A9EC8F2C47FF8E0032C359 /* UserScreen.swift in Sources */,
231245
EACEC3FA29953DCB008242AA /* AppDelegate.swift in Sources */,
232246
09A9ECAE2C4AC9810032C359 /* JobUser.swift in Sources */,
247+
5D4200142CBEE7ED006C4292 /* UserDefaultsExtensions.swift in Sources */,
233248
5D9BD7322CBD19C100667B76 /* ApiServerCollection.swift in Sources */,
234249
5D9BD7332CBD19C100667B76 /* ApiServer.swift in Sources */,
235-
09A9EC952C4800BA0032C359 /* NetworkSessions.swift in Sources */,
250+
09A9EC952C4800BA0032C359 /* SampleNetworkSessions.swift in Sources */,
251+
5D4200192CBF97CC006C4292 /* ServerPickerView.swift in Sources */,
236252
09A9EC922C48002C0032C359 /* User.swift in Sources */,
237253
5D7C80652CA2CDB900116E10 /* SampleSelectableBaseUrlProvider.swift in Sources */,
238254
);
@@ -288,6 +304,7 @@
288304
DEBUG_INFORMATION_FORMAT = dwarf;
289305
ENABLE_STRICT_OBJC_MSGSEND = YES;
290306
ENABLE_TESTABILITY = YES;
307+
ENABLE_USER_SCRIPT_SANDBOXING = YES;
291308
GCC_C_LANGUAGE_STANDARD = gnu11;
292309
GCC_DYNAMIC_NO_PIC = NO;
293310
GCC_NO_COMMON_BLOCKS = YES;
@@ -349,6 +366,7 @@
349366
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
350367
ENABLE_NS_ASSERTIONS = NO;
351368
ENABLE_STRICT_OBJC_MSGSEND = YES;
369+
ENABLE_USER_SCRIPT_SANDBOXING = YES;
352370
GCC_C_LANGUAGE_STANDARD = gnu11;
353371
GCC_NO_COMMON_BLOCKS = YES;
354372
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;

GoodNetworking-Sample/GoodNetworking-Sample.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

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

Sources/GoodNetworking/Extensions/UserDefaultsExtensions.swift renamed to GoodNetworking-Sample/GoodNetworking-Sample/Extensions/UserDefaultsExtensions.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import Foundation
99

10-
public extension UserDefaults {
10+
extension UserDefaults {
1111

1212
func setObject<Object>(_ object: Object, forKey: String) throws where Object: Encodable {
1313
let encoder = JSONEncoder()

GoodNetworking-Sample/GoodNetworking-Sample/Managers/SampleEndpoint.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ enum SampleEndpoint: Endpoint {
8282

8383
var encoding: ParameterEncoding {
8484
switch self {
85-
case .updateUser(let user):
85+
case .updateUser:
8686
JSONEncoding.default
8787

8888
default:

GoodNetworking-Sample/GoodNetworking-Sample/Managers/NetworkSessions.swift renamed to GoodNetworking-Sample/GoodNetworking-Sample/Managers/SampleNetworkSessions.swift

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// NetworkSessions.swift
2+
// SampleNetworkSessions
33
// GoodNetworking-Sample
44
//
55
// Created by Filip Šašala on 17/07/2024.
@@ -13,9 +13,7 @@ extension NetworkSession {
1313
static var sampleSession: NetworkSession!
1414

1515
static func makeSampleSession() {
16-
NetworkSession.sampleSession = NetworkSession(
17-
baseUrl: "https://reqres.in/api"
18-
)
16+
NetworkSession.sampleSession = NetworkSession(baseUrl: "https://reqres.in/api")
1917
}
2018

2119
static var baseURLProvider: SampleSelectableBaseUrlProvider?
@@ -29,11 +27,11 @@ extension NetworkSession {
2927
let debugServerCollection = ApiServerCollection(
3028
name: "Debug Server Collection",
3129
servers: [devServer, testServer, prodServer],
32-
defaultServer: devServer
30+
defaultServer: prodServer
3331
)
3432
let urlProvider = SampleSelectableBaseUrlProvider(serverCollection: debugServerCollection)
3533
#else
36-
let prodServerCollection = ApiServerCollection(servers: [prodServer], defaultServer: devServer, name: "Debug Server Collection")
34+
let prodServerCollection = ApiServerCollection(servers: [prodServer], defaultServer: prodServer, name: "Production Collection")
3735
let urlProvider = CustomBaseUrlProvider(serverCollection: prodServerCollection)
3836
#endif
3937
baseURLProvider = urlProvider

GoodNetworking-Sample/GoodNetworking-Sample/Managers/SampleSelectableBaseUrlProvider.swift

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//
22
// CustomBaseUrlProvider.swift
3-
// GoodNetworking
3+
// GoodNetworking-Sample
44
//
55
// Created by Andrej Jasso on 23/09/2024.
66
//
@@ -10,11 +10,13 @@ import GoodNetworking
1010

1111
public actor SampleSelectableBaseUrlProvider: BaseUrlProviding, ObservableObject {
1212

13-
// MARK: - Properties
13+
// MARK: - Constants
1414

1515
private let userDefaults = UserDefaults(suiteName: "CustomBaseUrlProvider")
16+
17+
// MARK: - Properties
18+
1619
public var serverCollection: ApiServerCollection
17-
public var customServers: [ApiServer] = []
1820
public var selectedServerName: String = ""
1921

2022
// MARK: - Initializer
@@ -23,33 +25,15 @@ public actor SampleSelectableBaseUrlProvider: BaseUrlProviding, ObservableObject
2325
self.serverCollection = serverCollection
2426

2527
if let userDefaults {
26-
if let customServers = try? userDefaults.getObject(forKey: "CustomServers", castTo: [ApiServer].self) {
27-
self.customServers = customServers
28-
}
29-
3028
if let selectedServerName = try? userDefaults.getObject(forKey: serverCollection.name, castTo: String.self) {
3129
self.selectedServerName = selectedServerName
3230
}
3331
}
3432
}
3533

36-
// MARK: - Methods
37-
38-
#warning("new Swift predicate")
39-
public func addCustomServer(customServerUrlString: String, customName: String, collectionName: String) {
40-
let urlPredicate = NSPredicate(format: "SELF MATCHES %@", "^https://[A-Za-z0-9.-]{2,}\\.[A-Za-z]{2,}(?:/[^\\s]*)?$")
41-
if urlPredicate.evaluate(with: customServerUrlString) {
42-
let customServer = ApiServer(name: customName, url: customServerUrlString)
43-
customServers.append(customServer)
44-
saveToUserDefaults(customServers, key: "CustomServers")
45-
}
46-
}
47-
4834
public func getSelectedServer() -> ApiServer {
4935
if let selectedServer = serverCollection.servers.first(where: { $0.name == selectedServerName }) {
5036
return selectedServer
51-
} else if let selectedServer = customServers.first(where: { $0.name == selectedServerName }){
52-
return selectedServer
5337
}
5438

5539
return serverCollection.defaultServer

GoodNetworking-Sample/GoodNetworking-Sample/Models/ApiServer.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//
22
// ApiServer.swift
3-
// GoodNetworking
3+
// GoodNetworking-Sample
44
//
55
// Created by Andrej Jasso on 23/09/2024.
66
//

GoodNetworking-Sample/GoodNetworking-Sample/Models/ApiServerCollection.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//
22
// ApiServerCollection.swift
3-
// GoodNetworking
3+
// GoodNetworking-Sample
44
//
55
// Created by Andrej Jasso on 23/09/2024.
66
//

GoodNetworking-Sample/GoodNetworking-Sample/Models/JobUser.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
// Created by Filip Šašala on 19/07/2024.
66
//
77

8-
import Foundation
98
import GoodNetworking
109

1110
// MARK: - Model + remote

0 commit comments

Comments
 (0)