Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
# Conflicts:
#	README.md
  • Loading branch information
cejanen committed Sep 6, 2023
2 parents c47a95a + 13a5c93 commit 2fb5cfa
Show file tree
Hide file tree
Showing 47 changed files with 3,074 additions and 60 deletions.
84 changes: 84 additions & 0 deletions NetworkingSampleApp/NetworkingSampleApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,27 @@
23EA9CF9292FB70A00B8E418 /* SampleUserResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 23EA9CEF292FB70A00B8E418 /* SampleUserResponse.swift */; };
23EA9CFA292FB70A00B8E418 /* SampleUserAuthRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 23EA9CF1292FB70A00B8E418 /* SampleUserAuthRequest.swift */; };
23EA9CFB292FB70A00B8E418 /* SampleUserRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 23EA9CF2292FB70A00B8E418 /* SampleUserRequest.swift */; };
58C3E75E29B78EE6004FD1CD /* DownloadsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58C3E75C29B78ED3004FD1CD /* DownloadsView.swift */; };
58C3E75F29B78EE8004FD1CD /* DownloadsViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58C3E75D29B78ED3004FD1CD /* DownloadsViewModel.swift */; };
58C3E76129B79259004FD1CD /* SampleDownloadRouter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58C3E76029B79259004FD1CD /* SampleDownloadRouter.swift */; };
58C3E76529B7D709004FD1CD /* DownloadProgressViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58C3E76429B7D709004FD1CD /* DownloadProgressViewModel.swift */; };
58E4E0ED2982D884000ACBC0 /* SampleAuthorizationStorageManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58E4E0EC2982D884000ACBC0 /* SampleAuthorizationStorageManager.swift */; };
58E4E0EF29843B42000ACBC0 /* NetworkingSampleApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58E4E0EE29843B42000ACBC0 /* NetworkingSampleApp.swift */; };
58E4E0F129850E86000ACBC0 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58E4E0F029850E86000ACBC0 /* ContentView.swift */; };
58FB80C7298521FF0031FC59 /* AuthorizationView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58FB80C6298521FF0031FC59 /* AuthorizationView.swift */; };
58FB80CE29895ABF0031FC59 /* TestData.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 58FB80CD29895ABF0031FC59 /* TestData.xcassets */; };
B52674BA2A370C15006D3B9C /* SampleUploadRouter.swift in Sources */ = {isa = PBXBuildFile; fileRef = B52674B92A370C15006D3B9C /* SampleUploadRouter.swift */; };
B52674BD2A370D1D006D3B9C /* UploadService.swift in Sources */ = {isa = PBXBuildFile; fileRef = B52674BC2A370D1D006D3B9C /* UploadService.swift */; };
B52674BF2A370D33006D3B9C /* UploadItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = B52674BE2A370D33006D3B9C /* UploadItem.swift */; };
B52674C12A370DFF006D3B9C /* UploadsViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = B52674C02A370DFF006D3B9C /* UploadsViewModel.swift */; };
B52674C32A370E35006D3B9C /* UploadItemViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = B52674C22A370E35006D3B9C /* UploadItemViewModel.swift */; };
B52674C52A37102D006D3B9C /* UploadsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B52674C42A37102D006D3B9C /* UploadsView.swift */; };
B52674C72A371046006D3B9C /* UploadItemView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B52674C62A371046006D3B9C /* UploadItemView.swift */; };
B58162F72A4F23420074A115 /* ByteCountFormatter+Convenience.swift in Sources */ = {isa = PBXBuildFile; fileRef = B58162F62A4F23420074A115 /* ByteCountFormatter+Convenience.swift */; };
B5A2CE6C2A3FF42400467EB3 /* FormUploadsViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5A2CE6B2A3FF42400467EB3 /* FormUploadsViewModel.swift */; };
DD410D6F293F2E6E006D8E31 /* AuthorizationViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD410D6E293F2E6E006D8E31 /* AuthorizationViewModel.swift */; };
DD6E48732A0E24D30025AD05 /* DownloadProgressView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD6E48722A0E24D30025AD05 /* DownloadProgressView.swift */; };
DD6E48762A0E2CD30025AD05 /* DownloadAPIManager+SharedInstance.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD6E48752A0E2CD30025AD05 /* DownloadAPIManager+SharedInstance.swift */; };
DD887780293E33850065ED03 /* SampleErrorProcessor.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD88777F293E33850065ED03 /* SampleErrorProcessor.swift */; };
DDD3AD1F2950E794006CB777 /* SampleAuthRouter.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDD3AD1E2950E794006CB777 /* SampleAuthRouter.swift */; };
DDD3AD212951F527006CB777 /* SampleAuthorizationManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDD3AD202951F527006CB777 /* SampleAuthorizationManager.swift */; };
Expand All @@ -45,12 +60,27 @@
23EA9CEF292FB70A00B8E418 /* SampleUserResponse.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SampleUserResponse.swift; sourceTree = "<group>"; };
23EA9CF1292FB70A00B8E418 /* SampleUserAuthRequest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SampleUserAuthRequest.swift; sourceTree = "<group>"; };
23EA9CF2292FB70A00B8E418 /* SampleUserRequest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SampleUserRequest.swift; sourceTree = "<group>"; };
58C3E75C29B78ED3004FD1CD /* DownloadsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DownloadsView.swift; sourceTree = "<group>"; };
58C3E75D29B78ED3004FD1CD /* DownloadsViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DownloadsViewModel.swift; sourceTree = "<group>"; };
58C3E76029B79259004FD1CD /* SampleDownloadRouter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SampleDownloadRouter.swift; sourceTree = "<group>"; };
58C3E76429B7D709004FD1CD /* DownloadProgressViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DownloadProgressViewModel.swift; sourceTree = "<group>"; };
58E4E0EC2982D884000ACBC0 /* SampleAuthorizationStorageManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SampleAuthorizationStorageManager.swift; sourceTree = "<group>"; };
58E4E0EE29843B42000ACBC0 /* NetworkingSampleApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetworkingSampleApp.swift; sourceTree = "<group>"; };
58E4E0F029850E86000ACBC0 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
58FB80C6298521FF0031FC59 /* AuthorizationView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthorizationView.swift; sourceTree = "<group>"; };
58FB80CD29895ABF0031FC59 /* TestData.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = TestData.xcassets; sourceTree = "<group>"; };
B52674B92A370C15006D3B9C /* SampleUploadRouter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SampleUploadRouter.swift; sourceTree = "<group>"; };
B52674BC2A370D1D006D3B9C /* UploadService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UploadService.swift; sourceTree = "<group>"; };
B52674BE2A370D33006D3B9C /* UploadItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UploadItem.swift; sourceTree = "<group>"; };
B52674C02A370DFF006D3B9C /* UploadsViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UploadsViewModel.swift; sourceTree = "<group>"; };
B52674C22A370E35006D3B9C /* UploadItemViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UploadItemViewModel.swift; sourceTree = "<group>"; };
B52674C42A37102D006D3B9C /* UploadsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UploadsView.swift; sourceTree = "<group>"; };
B52674C62A371046006D3B9C /* UploadItemView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UploadItemView.swift; sourceTree = "<group>"; };
B58162F62A4F23420074A115 /* ByteCountFormatter+Convenience.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ByteCountFormatter+Convenience.swift"; sourceTree = "<group>"; };
B5A2CE6B2A3FF42400467EB3 /* FormUploadsViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FormUploadsViewModel.swift; sourceTree = "<group>"; };
DD410D6E293F2E6E006D8E31 /* AuthorizationViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthorizationViewModel.swift; sourceTree = "<group>"; };
DD6E48722A0E24D30025AD05 /* DownloadProgressView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DownloadProgressView.swift; sourceTree = "<group>"; };
DD6E48752A0E2CD30025AD05 /* DownloadAPIManager+SharedInstance.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "DownloadAPIManager+SharedInstance.swift"; sourceTree = "<group>"; };
DD88777F293E33850065ED03 /* SampleErrorProcessor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SampleErrorProcessor.swift; sourceTree = "<group>"; };
DDD3AD1E2950E794006CB777 /* SampleAuthRouter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SampleAuthRouter.swift; sourceTree = "<group>"; };
DDD3AD202951F527006CB777 /* SampleAuthorizationManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SampleAuthorizationManager.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -91,6 +121,7 @@
23A575B325F8B9DA00617551 /* NetworkingSampleApp */ = {
isa = PBXGroup;
children = (
DD6E48742A0E2CC70025AD05 /* Extensions */,
58FB80CC29895A8D0031FC59 /* Resources */,
23EA9CE7292FB70A00B8E418 /* API */,
23A575ED25F8BF0E00617551 /* Scenes */,
Expand All @@ -114,6 +145,8 @@
isa = PBXGroup;
children = (
58FB80C5298521DA0031FC59 /* Authorization */,
58C3E75B29B78ED3004FD1CD /* Download */,
B52674BB2A370D0D006D3B9C /* Upload */,
);
path = Scenes;
sourceTree = "<group>";
Expand Down Expand Up @@ -153,6 +186,8 @@
isa = PBXGroup;
children = (
DDD3AD1E2950E794006CB777 /* SampleAuthRouter.swift */,
58C3E76029B79259004FD1CD /* SampleDownloadRouter.swift */,
B52674B92A370C15006D3B9C /* SampleUploadRouter.swift */,
23EA9CE9292FB70A00B8E418 /* SampleUserRouter.swift */,
);
path = Routers;
Expand All @@ -178,6 +213,17 @@
path = Requests;
sourceTree = "<group>";
};
58C3E75B29B78ED3004FD1CD /* Download */ = {
isa = PBXGroup;
children = (
DD6E48722A0E24D30025AD05 /* DownloadProgressView.swift */,
58C3E75C29B78ED3004FD1CD /* DownloadsView.swift */,
58C3E75D29B78ED3004FD1CD /* DownloadsViewModel.swift */,
58C3E76429B7D709004FD1CD /* DownloadProgressViewModel.swift */,
);
path = Download;
sourceTree = "<group>";
};
58FB80C5298521DA0031FC59 /* Authorization */ = {
isa = PBXGroup;
children = (
Expand All @@ -195,6 +241,29 @@
path = Resources;
sourceTree = "<group>";
};
B52674BB2A370D0D006D3B9C /* Upload */ = {
isa = PBXGroup;
children = (
B5A2CE6B2A3FF42400467EB3 /* FormUploadsViewModel.swift */,
B52674BE2A370D33006D3B9C /* UploadItem.swift */,
B52674C62A371046006D3B9C /* UploadItemView.swift */,
B52674C22A370E35006D3B9C /* UploadItemViewModel.swift */,
B52674BC2A370D1D006D3B9C /* UploadService.swift */,
B52674C42A37102D006D3B9C /* UploadsView.swift */,
B52674C02A370DFF006D3B9C /* UploadsViewModel.swift */,
);
path = Upload;
sourceTree = "<group>";
};
DD6E48742A0E2CC70025AD05 /* Extensions */ = {
isa = PBXGroup;
children = (
DD6E48752A0E2CD30025AD05 /* DownloadAPIManager+SharedInstance.swift */,
B58162F62A4F23420074A115 /* ByteCountFormatter+Convenience.swift */,
);
path = Extensions;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
Expand Down Expand Up @@ -271,21 +340,36 @@
buildActionMask = 2147483647;
files = (
58E4E0EF29843B42000ACBC0 /* NetworkingSampleApp.swift in Sources */,
DD6E48762A0E2CD30025AD05 /* DownloadAPIManager+SharedInstance.swift in Sources */,
DDE8884529476AC300DD3BFF /* SampleRefreshTokenRequest.swift in Sources */,
DDD3AD212951F527006CB777 /* SampleAuthorizationManager.swift in Sources */,
B5A2CE6C2A3FF42400467EB3 /* FormUploadsViewModel.swift in Sources */,
23EA9CF7292FB70A00B8E418 /* SampleUserAuthResponse.swift in Sources */,
58E4E0ED2982D884000ACBC0 /* SampleAuthorizationStorageManager.swift in Sources */,
23EA9CF6292FB70A00B8E418 /* SampleAPIError.swift in Sources */,
B58162F72A4F23420074A115 /* ByteCountFormatter+Convenience.swift in Sources */,
58E4E0F129850E86000ACBC0 /* ContentView.swift in Sources */,
B52674BD2A370D1D006D3B9C /* UploadService.swift in Sources */,
58C3E76529B7D709004FD1CD /* DownloadProgressViewModel.swift in Sources */,
23EA9CF9292FB70A00B8E418 /* SampleUserResponse.swift in Sources */,
DDD3AD1F2950E794006CB777 /* SampleAuthRouter.swift in Sources */,
DD887780293E33850065ED03 /* SampleErrorProcessor.swift in Sources */,
23EA9CFB292FB70A00B8E418 /* SampleUserRequest.swift in Sources */,
23EA9CFA292FB70A00B8E418 /* SampleUserAuthRequest.swift in Sources */,
58C3E76129B79259004FD1CD /* SampleDownloadRouter.swift in Sources */,
23EA9CF4292FB70A00B8E418 /* SampleUserRouter.swift in Sources */,
B52674BF2A370D33006D3B9C /* UploadItem.swift in Sources */,
23EA9CF5292FB70A00B8E418 /* SampleAPIConstants.swift in Sources */,
58FB80C7298521FF0031FC59 /* AuthorizationView.swift in Sources */,
DD410D6F293F2E6E006D8E31 /* AuthorizationViewModel.swift in Sources */,
B52674BA2A370C15006D3B9C /* SampleUploadRouter.swift in Sources */,
B52674C72A371046006D3B9C /* UploadItemView.swift in Sources */,
58C3E75F29B78EE8004FD1CD /* DownloadsViewModel.swift in Sources */,
58C3E75E29B78EE6004FD1CD /* DownloadsView.swift in Sources */,
B52674C32A370E35006D3B9C /* UploadItemViewModel.swift in Sources */,
B52674C12A370DFF006D3B9C /* UploadsViewModel.swift in Sources */,
B52674C52A37102D006D3B9C /* UploadsView.swift in Sources */,
DD6E48732A0E24D30025AD05 /* DownloadProgressView.swift in Sources */,
23EA9CF8292FB70A00B8E418 /* SampleUsersResponse.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//
// SampleDownloadRouter.swift
//
//
// Created by Matej Molnár on 07.03.2023.
//

import Foundation
import Networking

/// Implementation of sample API router
enum SampleDownloadRouter: Requestable {
case download(url: URL)

var baseURL: URL {
switch self {
case let .download(url):
return url
}
}

var path: String {
switch self {
case .download:
return ""
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//
// SampleUploadRouter.swift
// NetworkingSampleApp
//
// Created by Tony Ngo on 12.06.2023.
//

import Foundation
import Networking

enum SampleUploadRouter: Requestable {
case image
case file(URL)
case multipart(boundary: String)

var baseURL: URL {
URL(string: SampleAPIConstants.uploadHost)!
}

var headers: [String: String]? {
switch self {
case .image:
return ["Content-Type": "image/png"]
case let .file(url):
return ["Content-Type": url.mimeType]
case let .multipart(boundary):
return ["Content-Type": "multipart/form-data; boundary=\(boundary)"]
}
}

var path: String {
"/post"
}

var method: HTTPMethod {
.post
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import Foundation
enum SampleAPIConstants {
static let userHost = "https://reqres.in/api"
static let authHost = "https://nonexistentmockauth.com/api"
static let uploadHost = "https://httpbin.org"
static let validEmail = "[email protected]"
static let validPassword = "cityslicka"
static let videoUrl = "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4"
}
16 changes: 11 additions & 5 deletions NetworkingSampleApp/NetworkingSampleApp/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,29 @@

import SwiftUI

enum NetworkingCase: String, Hashable, CaseIterable {
enum NetworkingFeature: String, Hashable, CaseIterable {
case authorization
case downloads
case uploads
}

struct ContentView: View {
var body: some View {
NavigationStack {
List {
ForEach(NetworkingCase.allCases, id: \.self) { screen in
NavigationLink(screen.rawValue.capitalized, value: NetworkingCase.authorization)
ForEach(NetworkingFeature.allCases, id: \.self) { feature in
NavigationLink(feature.rawValue.capitalized, value: feature)
}
}
.navigationTitle("Examples")
.navigationDestination(for: NetworkingCase.self) { screen in
switch screen {
.navigationDestination(for: NetworkingFeature.self) { feature in
switch feature {
case .authorization:
AuthorizationView()
case .downloads:
DownloadsView()
case .uploads:
UploadsView()
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// ByteCountFormatter+Convenience.swift
// NetworkingSampleApp
//
// Created by Tony Ngo on 30.06.2023.
//

import Foundation

extension ByteCountFormatter {
static let megaBytesFormatter: ByteCountFormatter = {
let formatter = ByteCountFormatter()
formatter.allowedUnits = [.useMB]
formatter.countStyle = .file
return formatter
}()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//
// DownloadAPIManager+SharedInstance.swift
// NetworkingSampleApp
//
// Created by Dominika Gajdová on 12.05.2023.
//

import Networking

extension DownloadAPIManager {
static var shared: DownloadAPIManaging = {
var responseProcessors: [ResponseProcessing] = [
LoggingInterceptor.shared,
StatusCodeProcessor.shared
]
var errorProcessors: [ErrorProcessing] = [LoggingInterceptor.shared]

#if DEBUG
responseProcessors.append(EndpointRequestStorageProcessor.shared)
errorProcessors.append(EndpointRequestStorageProcessor.shared)
#endif

return DownloadAPIManager(
urlSessionConfiguration: .default,
requestAdapters: [
LoggingInterceptor.shared
],
responseProcessors: responseProcessors,
errorProcessors: errorProcessors
)
}()
}
5 changes: 5 additions & 0 deletions NetworkingSampleApp/NetworkingSampleApp/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
Expand Down
Loading

0 comments on commit 2fb5cfa

Please sign in to comment.