Skip to content

Commit d25e55a

Browse files
committed
Update the SwiftFormat configuration
1 parent 8e596e0 commit d25e55a

File tree

8 files changed

+18
-12
lines changed

8 files changed

+18
-12
lines changed

.swiftformat

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
--swiftversion 5.3
2+
--disable redundantReturn
3+
--disable unusedArguments

HackerNews.xcodeproj/project.pbxproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@
223223
);
224224
runOnlyForDeploymentPostprocessing = 0;
225225
shellPath = /bin/sh;
226-
shellScript = "if which swiftformat >/dev/null; then\n swiftformat . --swiftversion 5.2 --disable redundantReturn\nelse\n echo \"warning: SwiftFormat not installed, download from https://github.com/nicklockwood/SwiftFormat\"\nfi\n";
226+
shellScript = "if which swiftformat >/dev/null; then\n swiftformat .\nelse\n echo \"warning: SwiftFormat not installed, download from https://github.com/nicklockwood/SwiftFormat\"\nfi\n";
227227
};
228228
/* End PBXShellScriptBuildPhase section */
229229

HackerNews/AppDelegate.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import UIKit
1010

1111
@main
1212
class AppDelegate: UIResponder, UIApplicationDelegate {
13-
func application(_: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options _: UIScene.ConnectionOptions) -> UISceneConfiguration {
13+
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
1414
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
1515
}
1616
}

HackerNews/Components/ActivityIndicatorView.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ struct ActivityIndicatorView: View {
2626
let parentSize: CGSize
2727
@Binding var size: CGSize
2828

29-
func makeUIView(context _: Context) -> UIActivityIndicatorView {
29+
func makeUIView(context: Context) -> UIActivityIndicatorView {
3030
let uiView = UIActivityIndicatorView(style: style)
3131
uiView.color = color
3232
uiView.startAnimating()
3333
return uiView
3434
}
3535

36-
func updateUIView(_ uiView: UIActivityIndicatorView, context _: Context) {
36+
func updateUIView(_ uiView: UIActivityIndicatorView, context: Context) {
3737
DispatchQueue.main.async {
3838
self.size = uiView.sizeThatFits(self.parentSize)
3939
}

HackerNews/Components/WebView.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ import SwiftUI
1212
struct WebView: UIViewControllerRepresentable {
1313
let url: URL
1414

15-
func makeUIViewController(context _: Context) -> SFSafariViewController {
15+
func makeUIViewController(context: Context) -> SFSafariViewController {
1616
return SFSafariViewController(url: url)
1717
}
1818

19-
func updateUIViewController(_: SFSafariViewController, context _: Context) {}
19+
func updateUIViewController(_ uiViewController: SFSafariViewController, context: Context) {}
2020
}

HackerNews/Models/HackewNewsAPI.swift

+6-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class HackerNewsAPI {
1919
func receive<S>(subscriber: S) where S: Subscriber, Failure == S.Failure, Output == S.Input {
2020
let request = URLRequest(url: URL(string: "https://hacker-news.firebaseio.com/v0/\(type.rawValue)stories.json")!)
2121
URLSession.DataTaskPublisher(request: request, session: URLSession.shared)
22-
.map { $0.0 }
22+
.map(\.0)
2323
.decode(type: [Int].self, decoder: JSONDecoder())
2424
.receive(subscriber: subscriber)
2525
}
@@ -32,10 +32,13 @@ class HackerNewsAPI {
3232
let id: Int
3333

3434
func receive<S>(subscriber: S) where S: Subscriber, Failure == S.Failure, Output == S.Input {
35+
let decoder = JSONDecoder()
36+
decoder.dateDecodingStrategy = .millisecondsSince1970
37+
3538
let request = URLRequest(url: URL(string: "https://hacker-news.firebaseio.com/v0/item/\(id).json")!)
3639
URLSession.DataTaskPublisher(request: request, session: URLSession.shared)
37-
.map { $0.0 }
38-
.decode(type: Item.self, decoder: JSONDecoder())
40+
.map(\.0)
41+
.decode(type: Item.self, decoder: decoder)
3942
.receive(subscriber: subscriber)
4043
}
4144
}

HackerNews/SceneDelegate.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import UIKit
1212
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
1313
var window: UIWindow?
1414

15-
func scene(_ scene: UIScene, willConnectTo _: UISceneSession, options _: UIScene.ConnectionOptions) {
15+
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options: UIScene.ConnectionOptions) {
1616
if let windowScene = scene as? UIWindowScene {
1717
let window = UIWindow(windowScene: windowScene)
1818
window.rootViewController = UIHostingController(rootView: MainView(viewModel: MainViewModel()))

HackerNews/Screens/Main/MainView.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ struct MainView: View {
2626
ForEach(viewModel.items, id: \.id) { item in
2727
NavigationLink(destination: WebView(url: URL(string: item.htmlUrl)!)
2828
.navigationBarTitle(Text(item.title ?? "Hacker News"))) {
29-
ItemListItemView(item: item)
30-
}
29+
ItemListItemView(item: item)
30+
}
3131
}
3232
if viewModel.hasMoreItems {
3333
ActivityIndicatorView(style: .medium, color: UIColor(named: "Primary")!)

0 commit comments

Comments
 (0)