Skip to content
This repository was archived by the owner on Sep 5, 2023. It is now read-only.

Commit 2b5c56a

Browse files
committed
fix(swiftformat): executed "swiftformat ."
1 parent 780dc7e commit 2b5c56a

File tree

128 files changed

+1616
-1303
lines changed

Some content is hidden

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

128 files changed

+1616
-1303
lines changed

Example/Harmony/AppDelegate.swift

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,27 @@
66
// Copyright (c) 2017 Mobile Jazz. All rights reserved.
77
//
88

9-
import UIKit
109
import Harmony
1110
import SwiftUI
11+
import UIKit
1212

1313
let applicationComponent: ApplicationComponent = ApplicationDefaultModule()
1414

1515
enum ApplicationUI {
1616
case UIKit
1717
case SwiftUI
1818
}
19+
1920
// Modify this property to change the UI implementation!
2021
let applicationUI: ApplicationUI = .SwiftUI
2122

2223
@UIApplicationMain
2324
class AppDelegate: UIResponder, UIApplicationDelegate {
24-
2525
var window: UIWindow?
2626
var observable: Observable<Int>!
2727

28-
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
28+
func application(_: UIApplication,
29+
didFinishLaunchingWithOptions _: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
2930
switch applicationUI {
3031
case .UIKit:
3132
let splash = SplashViewController()
@@ -59,25 +60,33 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
5960
return true
6061
}
6162

62-
func applicationWillResignActive(_ application: UIApplication) {
63-
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
64-
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
63+
func applicationWillResignActive(_: UIApplication) {
64+
// Sent when the application is about to move from active to inactive state. This can occur for certain types
65+
// of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the
66+
// application and it begins the transition to the background state.
67+
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games
68+
// should use this method to pause the game.
6569
}
6670

67-
func applicationDidEnterBackground(_ application: UIApplication) {
68-
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
69-
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
71+
func applicationDidEnterBackground(_: UIApplication) {
72+
// Use this method to release shared resources, save user data, invalidate timers, and store enough
73+
// application state information to restore your application to its current state in case it is terminated later.
74+
// If your application supports background execution, this method is called instead of
75+
// applicationWillTerminate: when the user quits.
7076
}
7177

72-
func applicationWillEnterForeground(_ application: UIApplication) {
73-
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
78+
func applicationWillEnterForeground(_: UIApplication) {
79+
// Called as part of the transition from the background to the inactive state; here you can undo many of the
80+
// changes made on entering the background.
7481
}
7582

76-
func applicationDidBecomeActive(_ application: UIApplication) {
77-
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
83+
func applicationDidBecomeActive(_: UIApplication) {
84+
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application
85+
// was previously in the background, optionally refresh the user interface.
7886
}
7987

80-
func applicationWillTerminate(_ application: UIApplication) {
81-
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
88+
func applicationWillTerminate(_: UIApplication) {
89+
// Called when the application is about to terminate. Save data if appropriate. See also
90+
// applicationDidEnterBackground:.
8291
}
8392
}

Example/Harmony/Core/ApplicationProvider.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
// Copyright © 2021 CocoaPods. All rights reserved.
77
//
88

9-
import Harmony
109
import Alamofire
10+
import Harmony
1111

1212
// Enabling vastra service as an object validation
1313
extension VastraService: ObjectValidation {}
@@ -17,14 +17,14 @@ protocol ApplicationComponent {
1717
}
1818

1919
class ApplicationDefaultModule: ApplicationComponent {
20-
2120
private lazy var logger: Logger = DeviceConsoleLogger()
2221
private lazy var backgroundExecutor: Executor = DispatchQueueExecutor()
2322

2423
private lazy var apiClient: Session = {
2524
// Alamofire Session Manager
26-
let sessionManager = Session(interceptor: BaseURLRequestAdapter(URL(string: "https://demo3068405.mockable.io")!,
27-
[UnauthorizedStatusCodeRequestRetrier()]))
25+
let sessionManager =
26+
Session(interceptor: BaseURLRequestAdapter(URL(string: "https://demo3068405.mockable.io")!,
27+
[UnauthorizedStatusCodeRequestRetrier()]))
2828
return sessionManager
2929
}()
3030

Example/Harmony/Core/Features/Item/Data/ItemNetworkDataSource.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,20 @@
55

66
import Foundation
77

8-
import Harmony
98
import Alamofire
9+
import Harmony
1010

11-
extension ItemEntity {
12-
fileprivate static var fromNetworkMap: [String: String] {
11+
private extension ItemEntity {
12+
static var fromNetworkMap: [String: String] {
1313
return ["image-url": "imageURL"]
1414
}
1515

16-
fileprivate static var toNetworkMap: [String: String] {
16+
static var toNetworkMap: [String: String] {
1717
return ["imageURL": "image-url"]
1818
}
1919
}
2020

2121
class ItemNetworkDataSource: GetDataSource {
22-
2322
typealias T = ItemEntity
2423

2524
var sessionManager: Session
@@ -56,9 +55,10 @@ private extension ItemNetworkDataSource {
5655
guard let json = data as? [String: AnyObject] else {
5756
throw CoreError.NotFound()
5857
}
59-
let future = json.decodeAs(ItemEntity.self, keyDecodingStrategy: .map(ItemEntity.fromNetworkMap)) { item in
60-
item.lastUpdate = Date()
61-
}
58+
let future = json
59+
.decodeAs(ItemEntity.self, keyDecodingStrategy: .map(ItemEntity.fromNetworkMap)) { item in
60+
item.lastUpdate = Date()
61+
}
6262
return future
6363
}
6464
}

Example/Harmony/Core/Features/Item/Domain/Mappers/ItemMapper.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,13 @@ import Harmony
99

1010
class ItemToItemEntityMapper: Mapper<Item, ItemEntity> {
1111
override func map(_ from: Item) throws -> ItemEntity {
12-
return ItemEntity(id: from.id, name: from.name, price: from.price, count: from.count, imageURL: from.imageURL)
12+
return ItemEntity(
13+
id: from.id,
14+
name: from.name,
15+
price: from.price,
16+
count: from.count,
17+
imageURL: from.imageURL
18+
)
1319
}
1420
}
1521

Example/Harmony/Core/Features/Item/Domain/Presenters/ItemListPresenter.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class ItemListDefaultPresenter: ItemListPresenter {
4848

4949
func onActionReloadList() {
5050
view?.onDisplayProgressHud(show: true)
51-
self.getItems.execute(MainSyncOperation()).then { items in
51+
getItems.execute(MainSyncOperation()).then { items in
5252
self.view?.onDisplayProgressHud(show: false)
5353
self.view?.onDisplayItems(items)
5454
}.fail { error in

Example/Harmony/Core/Features/Item/ItemProvider.swift

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
// Copyright © 2021 CocoaPods. All rights reserved.
77
//
88

9-
import Harmony
109
import Alamofire
10+
import Harmony
1111

1212
protocol ItemComponent {
1313
func itemListPresenter(view: ItemListPresenterView) -> ItemListPresenter
@@ -30,26 +30,28 @@ class ItemDefaultModule: ItemComponent {
3030
// To debug the UI upon random API behavior, adding this intermediate layer
3131
let itemNetworkDataSource = DebugDataSource(DataSourceAssembler(get: baseDataSource),
3232
delay: .sync(0.5),
33-
error: .error(CoreError.Failed("Debug Fail"), probability: 0.01),
33+
error: .error(
34+
CoreError.Failed("Debug Fail"),
35+
probability: 0.01
36+
),
3437
logger: DeviceConsoleLogger())
3538

3639
// Adding retry behavior in case of error
3740
let networkDataSource = RetryDataSource(itemNetworkDataSource, retryCount: 1) { error in
38-
return error._code == NSURLErrorTimedOut && error._domain == NSURLErrorDomain
41+
error._code == NSURLErrorTimedOut && error._domain == NSURLErrorDomain
3942
}
4043
return AnyDataSource(networkDataSource)
4144
}()
4245

4346
private lazy var storageDataSource: AnyDataSource<ItemEntity> = {
44-
return AnyDataSource(
47+
AnyDataSource(
4548
DataSourceMapper(dataSource: self.storage,
4649
toInMapper: EncodableToDataMapper<ItemEntity>(),
4750
toOutMapper: DataToDecodableMapper<ItemEntity>())
4851
)
4952
}()
5053

5154
private lazy var repository: AnyRepository<Item> = {
52-
5355
let vastra = VastraService([VastraTimestampStrategy()])
5456
let storageValidationDataSource = DataSourceValidator(dataSource: self.storageDataSource,
5557
validator: vastra)
@@ -64,11 +66,11 @@ class ItemDefaultModule: ItemComponent {
6466
}()
6567

6668
private func getAllItemsInteractor() -> GetAllItemsInteractor {
67-
return GetAllItemsInteractor(executor: self.executor,
68-
getItems: Interactor.GetAllByQuery(DirectExecutor(), self.repository))
69+
return GetAllItemsInteractor(executor: executor,
70+
getItems: Interactor.GetAllByQuery(DirectExecutor(), repository))
6971
}
7072

7173
func itemListPresenter(view: ItemListPresenterView) -> ItemListPresenter {
72-
return ItemListDefaultPresenter(view, self.getAllItemsInteractor())
74+
return ItemListDefaultPresenter(view, getAllItemsInteractor())
7375
}
7476
}

Example/Harmony/Core/Features/NetworkUtils/UnauthorizedStatusCodeRequestRetrier.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import UIKit
1111
import Alamofire
1212

1313
class UnauthorizedStatusCodeRequestRetrier: RequestRetrier {
14-
func retry(_ request: Request, for session: Session, dueTo error: Error, completion: @escaping (RetryResult) -> Void) {
14+
func retry(_ request: Request, for _: Session, dueTo _: Error, completion: @escaping (RetryResult) -> Void) {
1515
if request.response?.statusCode == 401 {
1616
// TODO: Logout user
1717
}

Example/Harmony/Screens/SwiftUI/ItemDetail/ItemDetailView.swift

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
// Copyright © 2017 Mobile Jazz. All rights reserved.
77
//
88

9-
import SwiftUI
109
import Kingfisher
10+
import SwiftUI
1111

1212
struct ItemDetailView: View {
1313
var item: Item
@@ -24,7 +24,7 @@ struct ItemDetailView: View {
2424
Spacer()
2525
Text("\(Int(item.price))")
2626
.font(.system(size: 80, weight: .bold))
27-
.foregroundColor(Color(red: 0, green: 190.0/256.0, blue: 176.0/256.0))
27+
.foregroundColor(Color(red: 0, green: 190.0 / 256.0, blue: 176.0 / 256.0))
2828
Spacer()
2929
}.navigationTitle(item.name)
3030
}
@@ -33,7 +33,15 @@ struct ItemDetailView: View {
3333
struct ItemDetailView_Previews: PreviewProvider {
3434
static var previews: some View {
3535
NavigationView {
36-
ItemDetailView(item: Item(id: "1", name: "Macbook Pro", price: 1234.56, count: 12, imageURL: URL(string: "(https://store.storeimages.cdn-apple.com/4668/as-images.apple.com/is/mbp-spacegray-select-202206_GEO_ES?wid=904&hei=840&fmt=jpeg&qlt=90&.v=1654014007395")))
36+
ItemDetailView(item: Item(
37+
id: "1",
38+
name: "Macbook Pro",
39+
price: 1234.56,
40+
count: 12,
41+
imageURL: URL(
42+
string: "(https://store.storeimages.cdn-apple.com/4668/as-images.apple.com/is/mbp-spacegray-select-202206_GEO_ES?wid=904&hei=840&fmt=jpeg&qlt=90&.v=1654014007395"
43+
)
44+
))
3745
}
3846
}
3947
}

Example/Harmony/Screens/SwiftUI/ItemList/ItemListView.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@
66
// Copyright © 2022 CocoaPods. All rights reserved.
77
//
88

9-
import SwiftUI
109
import Kingfisher
10+
import SwiftUI
1111

1212
struct ItemListView: View {
13-
1413
@StateObject var viewState: ItemListViewState
1514

1615
var body: some View {
@@ -52,7 +51,7 @@ struct ItemListView: View {
5251
Spacer()
5352
Text("\(Int(item.price))")
5453
.font(.system(size: 23, weight: .bold))
55-
.foregroundColor(Color(red: 0, green: 190.0/256.0, blue: 176.0/256.0))
54+
.foregroundColor(Color(red: 0, green: 190.0 / 256.0, blue: 176.0 / 256.0))
5655
}
5756
}
5857
}
@@ -68,7 +67,6 @@ struct ItemListView: View {
6867
} label: {
6968
Image(systemName: "arrow.clockwise")
7069
}
71-
7270
}
7371
}
7472
}

Example/Harmony/Screens/SwiftUI/ItemList/ItemListViewState.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import Foundation
1010

1111
class ItemListViewState: ObservableObject, ItemListPresenterView {
12-
1312
@Published var items: [Item]
1413
@Published var isLoading: Bool = true
1514
@Published var error: Error?
@@ -23,12 +22,12 @@ class ItemListViewState: ObservableObject, ItemListPresenterView {
2322
lazy var presenter = applicationComponent.itemComponent.itemListPresenter(view: self)
2423

2524
func onDisplayProgressHud(show: Bool) {
26-
self.isLoading = show
25+
isLoading = show
2726
}
2827

2928
func onDisplayItems(_ items: [Item]) {
3029
self.items = items
31-
self.error = nil
30+
error = nil
3231
}
3332

3433
func onNavigateToItem(_ item: Item) {

0 commit comments

Comments
 (0)