Skip to content

Commit 978ba37

Browse files
committed
Change access level of Transformer's internal protocol type (#37)
1 parent 81e713c commit 978ba37

15 files changed

Lines changed: 66 additions & 78 deletions

File tree

Examples/Communication/Interceptors/ServiceErrorInterceptor.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ final class ServiceErrorInterceptor: InterceptorProtocol {
3535
showRetryDialog(errorMessage: error.localizedDescription) {
3636
proceed(.retry(delay: self.retryDelay))
3737
}
38-
break
3938
case .notSuccess(let statusCode, _):
4039
if statusCode / 500 == 1 {
4140
showRetryDialog(
@@ -46,7 +45,6 @@ final class ServiceErrorInterceptor: InterceptorProtocol {
4645
} else {
4746
proceed(.continue)
4847
}
49-
break
5048
default:
5149
proceed(.continue)
5250
}

Examples/Communication/Models/Domain/City.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
1818
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1919

20-
// swiftlint:disable identifier_name
21-
2220
import Foundation
2321

2422
struct City: Identifiable {

Examples/Communication/Models/Rest/RSCity.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
1818
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1919

20-
// swiftlint:disable identifier_name
21-
2220
import Foundation
2321

2422
struct RSCity: Codable {

Examples/Communication/Routers/CityRoute.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
1818
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1919

20-
// swiftlint:disable identifier_name
21-
2220
import Foundation
2321
import TermiNetwork
2422

Examples/Screens/City Explorer/CityExplorerDetails.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import TermiNetwork
2424
struct CityExplorerDetails: View {
2525

2626
@StateObject var viewModel: ViewModel
27-
27+
2828
init(viewModel: ViewModel) {
2929
Environment.current.configuration?.mockDataEnabled = viewModel.usesMockData
3030
self._viewModel = .init(wrappedValue: viewModel)
@@ -58,23 +58,23 @@ extension CityExplorerDetails {
5858
var cityFetched: Bool = false
5959
var errorMessage: String?
6060
var usesMockData: Bool
61-
61+
6262
init(city: City, usesMockData: Bool) {
6363
self.city = city
6464
self.usesMockData = usesMockData
6565
}
66-
66+
6767
func onAppear() {
6868
Task {
6969
await loadCity()
7070
}
7171
}
72-
72+
7373
func onDisappear() {
7474
activeRequest?.cancel()
7575
}
76-
77-
@MainActor func loadCity() async {
76+
77+
@MainActor func loadCity() async {
7878
let request = Router<CityRoute>().request(for: .city(id: city.cityID))
7979

8080
do {
@@ -88,7 +88,7 @@ extension CityExplorerDetails {
8888
errorMessage = error.localizedDescription
8989
}
9090
} catch { }
91-
91+
9292
activeRequest = request
9393
}
9494
}

Examples/Screens/City Explorer/CityExplorerView.swift

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import TermiNetwork
2222
import Combine
2323

2424
struct CityExplorerView: View {
25-
25+
2626
@StateObject var viewModel: ViewModel
2727

2828
var body: some View {
@@ -37,16 +37,16 @@ struct CityExplorerView: View {
3737
ProgressView()
3838
} else {
3939
List(viewModel.cities, id: \.id) { city in
40-
CityRow(city: city,
40+
CityRow(city: city,
4141
usesMockData: viewModel.usesMockData,
4242
thumbWidth: 100,
4343
thumbHeight: 100)
4444
}
4545
}
4646
}
4747
.navigationTitle("City Explorer")
48-
.onDisappear {
49-
viewModel.onDissapear()
48+
.onDisappear {
49+
viewModel.onDissapear()
5050
}
5151
}
5252
}
@@ -56,7 +56,7 @@ struct CityRow: View {
5656
var usesMockData: Bool
5757
var thumbWidth: CGFloat
5858
var thumbHeight: CGFloat
59-
59+
6060
@State private var imageLoaded: Bool = false
6161

6262
var body: some View {
@@ -72,13 +72,13 @@ struct CityRow: View {
7272
@ViewBuilder
7373
var thumbView: some View {
7474
let request = Router<CityRoute>().request(for: .thumb(city: city))
75-
75+
7676
ZStack {
7777
if !imageLoaded {
7878
ProgressView()
7979
}
80-
81-
TermiNetwork.Image(request: request,
80+
81+
TermiNetwork.Image(request: request,
8282
resizeTo: CGSize(width: thumbWidth,
8383
height: thumbHeight),
8484
onFinish: { _, _ in
@@ -90,14 +90,14 @@ struct CityRow: View {
9090
}
9191

9292
extension CityExplorerView {
93-
@MainActor class ViewModel: ObservableObject {
93+
@MainActor class ViewModel: ObservableObject {
9494
private var activeRequest: Request?
95-
95+
9696
@Published var cities: [City] = []
9797
@Published var errorMessage: String?
98-
98+
9999
var usesMockData: Bool
100-
100+
101101
init(usesMockData: Bool) {
102102
self.usesMockData = usesMockData
103103
Environment.current.configuration?.mockDataEnabled = usesMockData
@@ -106,14 +106,14 @@ extension CityExplorerView {
106106
await loadCities()
107107
}
108108
}
109-
109+
110110
func onDissapear() {
111111
activeRequest?.cancel()
112112
}
113-
113+
114114
func loadCities() async {
115115
activeRequest = Router<CityRoute>().request(for: .cities)
116-
116+
117117
do {
118118
cities = try await activeRequest?.async(using: CitiesTransformer.self) ?? []
119119
} catch let error {

Examples/Screens/DemoApp.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
1818
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1919

20-
// swiftlint:disable identifier_name
21-
2220
import Foundation
2321
import SwiftUI
2422

Examples/Screens/File Downloader/FileDownloader.swift

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ struct FileDownloader: View {
5757
.foregroundColor(.red)
5858
}
5959
Spacer()
60-
UIHelpers.button(!viewModel.downloadStarted ? "Start Download" : "Stop Download") {
60+
UIHelpers.button(!viewModel.downloadStarted ? "Start Download" : "Stop Download") {
6161
viewModel.downloadAction()
6262
}
6363
.padding(.bottom, 20)
@@ -82,17 +82,17 @@ extension FileDownloader {
8282
@Published var downloadFinished: Bool = false
8383
@Published var error: String?
8484
@Published var outputFile: String = ""
85-
85+
8686
var request: Request?
8787
var configuration: Configuration
88-
88+
8989
init() {
9090
// Enable verbose
9191
let configuration = Configuration()
9292
configuration.verbose = true
9393
self.configuration = configuration
9494
}
95-
95+
9696
// MARK: UI Helpers
9797
func updateFilename(_ url: String) {
9898
fileName = String(url.split(separator: "/").last ?? "")
@@ -109,9 +109,9 @@ extension FileDownloader {
109109
await downloadFile()
110110
}
111111
}
112-
112+
113113
// MARK: Helpers
114-
114+
115115
func downloadFile() async {
116116

117117
// Construct the final path of the downloaded file
@@ -123,27 +123,28 @@ extension FileDownloader {
123123
// Reset download
124124
error = nil
125125
resetDownload()
126-
126+
127127
request = Request(method: .get,
128128
url: fileURL,
129129
configuration: configuration)
130-
130+
131131
downloadStarted = true
132132
downloadFinished = false
133133

134134
do {
135-
try await request?.asyncDownload(destinationPath: outputFile,
136-
progressUpdate: { [unowned self] (bytesDownloaded, bytesTotal, progress) in
137-
self.progress = progress * 100
138-
self.bytesDownloaded = bytesDownloaded
139-
self.bytesTotal = bytesTotal
140-
})
135+
try await request?.asyncDownload(
136+
destinationPath: outputFile,
137+
progressUpdate: { [unowned self] (bytesDownloaded, bytesTotal, progress) in
138+
self.progress = progress * 100
139+
self.bytesDownloaded = bytesDownloaded
140+
self.bytesTotal = bytesTotal
141+
})
141142
} catch let error {
142-
self.error = error.localizedDescription
143+
self.error = error.localizedDescription
143144
resetDownload()
144145
}
145146
}
146-
147+
147148
func resetDownload() {
148149
downloadStarted = false
149150
downloadFinished = false
@@ -161,9 +162,9 @@ extension FileDownloader {
161162
let documentsDirectory = paths[0]
162163
return documentsDirectory
163164
}
164-
165+
165166
func removeFileIfNeeded(at path: String) {
166167
try? FileManager.default.removeItem(atPath: path)
167168
}
168-
}
169+
}
169170
}

Examples/Screens/File Uploader/FileUploader.swift

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import TermiNetwork
2323

2424
struct FileUploader: View {
2525
@StateObject var viewModel: ViewModel
26-
26+
2727
var body: some View {
2828
VStack {
2929
UIHelpers.button("🌄 Select Photo",
@@ -93,16 +93,16 @@ struct FileUploader: View {
9393
}
9494
Spacer()
9595
UIHelpers.button(!viewModel.uploadStarted ? "Start Upload" : "Stop Upload",
96-
action: {
97-
viewModel.uploadAction()
96+
action: {
97+
viewModel.uploadAction()
9898
})
9999
.padding(.bottom, 20)
100100

101101
}
102102
.padding([.leading, .trailing, .top], 20)
103103
.navigationTitle("File Uploader")
104-
.onDisappear(perform: {
105-
viewModel.clearAndCancelUpload()
104+
.onDisappear(perform: {
105+
viewModel.clearAndCancelUpload()
106106
})
107107
}
108108
}
@@ -123,27 +123,27 @@ extension FileUploader {
123123
@Published var outputFile: String = ""
124124
@Published var imageUrl: URL?
125125
@Published var showCaptureImageView: Bool = false
126-
126+
127127
func resetUpload() {
128128
uploadStarted = false
129129
uploadFinished = false
130130
bytesTotal = 0
131131
bytesUploaded = 0
132132
}
133-
133+
134134
func clearAndCancelUpload() {
135135
request?.cancel()
136136
resetUpload()
137137
}
138-
138+
139139
func documentsDirectory() -> URL {
140140
let paths = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)
141141
let documentsDirectory = paths[0]
142142
return documentsDirectory
143143
}
144-
144+
145145
// MARK: Helpers
146-
146+
147147
@MainActor
148148
func uploadFile() async {
149149
guard let imageUrl = imageUrl else {
@@ -170,13 +170,13 @@ extension FileUploader {
170170

171171
let request = Router<MiscRoute>().request(for: .upload(fileUrl: imageUrl))
172172
self.request = request
173-
173+
174174
do {
175175
uploadStarted = true
176176
uploadFinished = false
177177

178178
let response = try await request.asyncUpload(
179-
using: FileUploadTransformer.self,
179+
using: FileUploadTransformer.self,
180180
progressUpdate: { [weak self] bytesProcessed, totalBytes, progress in
181181
guard let self = self else { return }
182182
self.progress = progress * 100
@@ -188,15 +188,15 @@ extension FileUploader {
188188
self.uploadFinished = true
189189
self.uploadedFileChecksum = response.checksum
190190
} catch let error {
191-
self.error = error.localizedDescription
191+
self.error = error.localizedDescription
192192
self.resetUpload()
193193
}
194194
}
195195

196196
func removeFileIfNeeded(at path: String) {
197197
try? FileManager.default.removeItem(atPath: path)
198198
}
199-
199+
200200
// MARK: UI Helpers
201201
func updateFilename(_ url: String) {
202202
self.fileName = String(url.split(separator: "/").last ?? "")
@@ -208,11 +208,10 @@ extension FileUploader {
208208
clearAndCancelUpload()
209209
return
210210
}
211-
211+
212212
Task {
213213
await uploadFile()
214214
}
215-
216215
}
217216
}
218217
}

0 commit comments

Comments
 (0)