Skip to content

Commit bd427e9

Browse files
committed
style: Auto Swift Lint & Format
1 parent bb489b3 commit bd427e9

6 files changed

Lines changed: 97 additions & 58 deletions

File tree

Examples/TabNavigator/03-TabEventSubscriber/TabEventSubscriber/Pages/Common/Step1/Step1Page.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ struct Step1Page: View {
2727
buttons: [
2828
.init(
2929
title: "OK",
30-
style: .default)
30+
style: .default),
3131
],
3232
flagType: .default))
3333
}) {

Examples/TabNavigator/03-TabEventSubscriber/TabEventSubscriber/TabEventSubscriberApp.swift

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import LinkNavigator
22
import PageTemplate
33
import SwiftUI
44

5+
// MARK: - TabEventSubscriberApp
6+
57
@main
68
struct TabEventSubscriberApp: App {
79
let tabLinkNavigator = TabLinkNavigator(
@@ -45,29 +47,31 @@ struct TabEventSubscriberApp: App {
4547
linkNavigator: tabLinkNavigator,
4648
isHiddenDefaultTabbar: false,
4749
tabItemList: tabList)
48-
.onOpenURL { url in
49-
/// You can test deep links by setting the URL Scheme to "tab-e-s".
50-
/// Example:
51-
/// tab-e-s://navigation/tab2/step1/step2?message=opened+by+deep+link
50+
.onOpenURL { url in
51+
/// You can test deep links by setting the URL Scheme to "tab-e-s".
52+
/// Example:
53+
/// tab-e-s://navigation/tab2/step1/step2?message=opened+by+deep+link
5254

53-
guard let tabPath = getTabPathByDeeplink(url: url),
54-
let linkItem = getLinkItemByDeepLink(url: url),
55-
let targetTab = tabLinkNavigator.targetPartialNavigator(tabPath: tabPath) else { return }
55+
guard
56+
let tabPath = getTabPathByDeeplink(url: url),
57+
let linkItem = getLinkItemByDeepLink(url: url),
58+
let targetTab = tabLinkNavigator.targetPartialNavigator(tabPath: tabPath)
59+
else { return }
5660

57-
tabLinkNavigator.moveTab(targetPath: tabPath)
58-
targetTab.replace(linkItem: linkItem, isAnimated: true)
59-
}
61+
tabLinkNavigator.moveTab(targetPath: tabPath)
62+
targetTab.replace(linkItem: linkItem, isAnimated: true)
63+
}
6064
}
6165
}
6266
}
6367

6468
extension TabEventSubscriberApp {
65-
fileprivate func getTabPathByDeeplink(url: URL) -> String? {
69+
private func getTabPathByDeeplink(url: URL) -> String? {
6670
let components = URLComponents(string: url.absoluteString)
6771
return components?.path.split(separator: "/").map(String.init).first
6872
}
6973

70-
fileprivate func getLinkItemByDeepLink(url: URL) -> LinkItem? {
74+
private func getLinkItemByDeepLink(url: URL) -> LinkItem? {
7175
let components = URLComponents(string: url.absoluteString)
7276
guard let paths = components?.path.split(separator: "/").map(String.init) else { return .none }
7377

Sources/LinkNavigator/Core/BaseComponent/LinkItem.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ import URLEncodedForm
66
/// Represents a link item that contains paths and associated items.
77
/// It is used to manage the links and state values that are injected into a page.
88
public struct LinkItem {
9+
910
// MARK: Lifecycle
11+
1012
/// Initializes a LinkItem instance with a given path list and an items parameter.
1113

1214
/// - Parameters:
@@ -76,6 +78,9 @@ extension LinkItem: Equatable {
7678
}
7779

7880
extension String {
81+
82+
// MARK: Public
83+
7984
public func decoded<T: Decodable>() -> T? {
8085
if let decodedValue = self as? T {
8186
return decodedValue
@@ -85,6 +90,8 @@ extension String {
8590
return (try? JSONDecoder().decode(T.self, from: data)) ?? (try? URLEncodedFormDecoder().decode(T.self, from: data))
8691
}
8792

93+
// MARK: Fileprivate
94+
8895
fileprivate func encodedBase64() -> Self {
8996
data(using: .utf8)?.base64EncodedString() ?? self
9097
}

Sources/LinkNavigator/Core/Core/TabLinkNavigator/TabLinkNavigator.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,10 @@ extension TabLinkNavigator {
7676
return curr + [(next.prefersLargeTitles, newNavigatorList)]
7777
}
7878

79-
self.tabRootPartialNavigators = partialNavigators.map(\.1)
79+
tabRootPartialNavigators = partialNavigators.map(\.1)
8080

8181
return partialNavigators
82-
.map { (prefersLargeTitles, navigator) in
82+
.map { prefersLargeTitles, navigator in
8383
let partialNavigationVC = navigator.launch(rootPath: navigator.tabItem.linkItem.pathList.first ?? "")
8484
let item = tagItemList.first(where: { $0.linkItem == navigator.tabItem.linkItem })
8585
partialNavigationVC.navigationController.tabBarItem = item?.tabItem
@@ -148,7 +148,10 @@ extension TabLinkNavigator {
148148
}
149149

150150
public func moveTab(targetPath: String) {
151-
guard let targetController = tabRootPartialNavigators.first(where: { $0.getCurrentRootPaths().first == targetPath })?.currentTabNavigationController else { return }
151+
guard
152+
let targetController = tabRootPartialNavigators.first(where: { $0.getCurrentRootPaths().first == targetPath })?
153+
.currentTabNavigationController
154+
else { return }
152155

153156
if mainController?.selectedViewController == targetController {
154157
targetController.popToRootViewController(animated: true)

Sources/LinkNavigator/Test/SingleLinkNavigatorMock.swift

Lines changed: 50 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
11
import Foundation
22
import UIKit
33

4+
// MARK: - SingleLinkNavigatorMock
5+
46
public final class SingleLinkNavigatorMock {
57

6-
public var value: Value
7-
public var event: Event
8+
// MARK: Lifecycle
89

910
public init(value: Value = .init(), event: Event = .init()) {
1011
self.value = value
1112
self.event = event
1213
}
1314

15+
// MARK: Public
16+
17+
public var value: Value
18+
public var event: Event
19+
1420
public func resetEvent() {
1521
event = .init()
1622
}
@@ -32,11 +38,18 @@ extension SingleLinkNavigatorMock {
3238
public var currentPaths: [String] = []
3339
public var currentRootPaths: [String] = []
3440
public var rangePaths: [String] = []
35-
36-
public init() {}
41+
42+
public init() { }
3743
}
3844

3945
public struct Event: Equatable, Sendable {
46+
47+
// MARK: Lifecycle
48+
49+
public init() { }
50+
51+
// MARK: Public
52+
4053
public var getCurrentPaths: Int = .zero
4154
public var getCurrentRootPaths: Int = .zero
4255
public var next: Int = .zero
@@ -62,10 +75,11 @@ extension SingleLinkNavigatorMock {
6275
public var rootSend: Int = .zero
6376
public var allRootSend: Int = .zero
6477

65-
public init() {}
6678
}
6779
}
6880

81+
// MARK: LinkNavigatorFindLocationUsable
82+
6983
extension SingleLinkNavigatorMock: LinkNavigatorFindLocationUsable {
7084
public func getCurrentPaths() -> [String] {
7185
event.getCurrentPaths += 1
@@ -78,99 +92,101 @@ extension SingleLinkNavigatorMock: LinkNavigatorFindLocationUsable {
7892
}
7993
}
8094

95+
// MARK: LinkNavigatorProtocol
96+
8197
extension SingleLinkNavigatorMock: LinkNavigatorProtocol {
82-
public func rootBackToLast(path: String, isAnimated: Bool) {
98+
public func rootBackToLast(path _: String, isAnimated _: Bool) {
8399
event.rootBackToLast += 1
84100
}
85-
86-
public func rootSend(item: LinkItem) {
101+
102+
public func rootSend(item _: LinkItem) {
87103
event.rootSend += 1
88104
}
89-
90-
public func allRootSend(item: LinkItem) {
105+
106+
public func allRootSend(item _: LinkItem) {
91107
event.allRootSend += 1
92108
}
93-
94-
public func next(linkItem: LinkItem, isAnimated: Bool) {
109+
110+
public func next(linkItem _: LinkItem, isAnimated _: Bool) {
95111
event.next += 1
96112
}
97113

98-
public func rootNext(linkItem: LinkItem, isAnimated: Bool) {
114+
public func rootNext(linkItem _: LinkItem, isAnimated _: Bool) {
99115
event.rootNext += 1
100116
}
101117

102-
public func sheet(linkItem: LinkItem, isAnimated: Bool) {
118+
public func sheet(linkItem _: LinkItem, isAnimated _: Bool) {
103119
event.sheet += 1
104120
}
105121

106-
public func fullSheet(linkItem: LinkItem, isAnimated: Bool, prefersLargeTitles: Bool?) {
122+
public func fullSheet(linkItem _: LinkItem, isAnimated _: Bool, prefersLargeTitles _: Bool?) {
107123
event.fullSheet += 1
108124
}
109125

110126
public func customSheet(
111-
linkItem: LinkItem,
112-
isAnimated: Bool,
113-
iPhonePresentationStyle: UIModalPresentationStyle,
114-
iPadPresentationStyle: UIModalPresentationStyle,
115-
prefersLargeTitles: Bool?)
127+
linkItem _: LinkItem,
128+
isAnimated _: Bool,
129+
iPhonePresentationStyle _: UIModalPresentationStyle,
130+
iPadPresentationStyle _: UIModalPresentationStyle,
131+
prefersLargeTitles _: Bool?)
116132
{
117133
event.customSheet += 1
118134
}
119135

120-
public func replace(linkItem: LinkItem, isAnimated: Bool) {
136+
public func replace(linkItem _: LinkItem, isAnimated _: Bool) {
121137
event.replace += 1
122138
}
123139

124-
public func backOrNext(linkItem: LinkItem, isAnimated: Bool) {
140+
public func backOrNext(linkItem _: LinkItem, isAnimated _: Bool) {
125141
event.backOrNext += 1
126142
}
127143

128-
public func rootBackOrNext(linkItem: LinkItem, isAnimated: Bool) {
144+
public func rootBackOrNext(linkItem _: LinkItem, isAnimated _: Bool) {
129145
event.rootBackOrNext += 1
130146
}
131147

132-
public func back(isAnimated: Bool) {
148+
public func back(isAnimated _: Bool) {
133149
event.back += 1
134150
}
135151

136-
public func remove(pathList: [String]) {
152+
public func remove(pathList _: [String]) {
137153
event.remove += 1
138154
}
139155

140-
public func rootRemove(pathList: [String]) {
156+
public func rootRemove(pathList _: [String]) {
141157
event.rootRemove += 1
142158
}
143159

144-
public func backToLast(path: String, isAnimated: Bool) {
160+
public func backToLast(path _: String, isAnimated _: Bool) {
145161
event.backToLast += 1
146162
}
147163

148-
public func close(isAnimated: Bool, completeAction: @escaping () -> Void) {
164+
public func close(isAnimated _: Bool, completeAction _: @escaping () -> Void) {
149165
event.close += 1
150166
}
151167

152-
public func range(path: String) -> [String] {
168+
public func range(path _: String) -> [String] {
153169
event.range += 1
154170
return value.rangePaths
155171
}
156172

157-
public func rootReloadLast(items: LinkItem, isAnimated: Bool) {
173+
public func rootReloadLast(items _: LinkItem, isAnimated _: Bool) {
158174
event.rootReloadLast += 1
159175
}
160176

161-
public func alert(target: NavigationTarget, model: Alert) {
177+
public func alert(target _: NavigationTarget, model _: Alert) {
162178
event.rootReloadLast += 1
163179
}
164180

165-
public func send(item: LinkItem) {
181+
public func send(item _: LinkItem) {
166182
event.send += 1
167183
}
168184

169-
public func mainSend(item: LinkItem) {
185+
public func mainSend(item _: LinkItem) {
170186
event.mainSend += 1
171187
}
172188

173-
public func allSend(item: LinkItem) {
189+
public func allSend(item _: LinkItem) {
174190
event.allSend += 1
175191
}
176192

Sources/LinkNavigator/Test/TabLinkNavigatorMock.swift

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ import UIKit
55

66
public final class TabLinkNavigatorMock {
77

8-
public var value: Value
9-
public var event: Event
8+
// MARK: Lifecycle
109

1110
public init(
1211
value: Value = .init(),
@@ -16,6 +15,11 @@ public final class TabLinkNavigatorMock {
1615
self.event = event
1716
}
1817

18+
// MARK: Public
19+
20+
public var value: Value
21+
public var event: Event
22+
1923
public func resetEvent() {
2024
event = .init()
2125
}
@@ -36,10 +40,17 @@ extension TabLinkNavigatorMock {
3640
public var currentRootPaths: [String] = []
3741
public var rangePaths: [String] = []
3842

39-
public init() {}
43+
public init() { }
4044
}
4145

4246
public struct Event: Equatable, Sendable {
47+
48+
// MARK: Lifecycle
49+
50+
public init() { }
51+
52+
// MARK: Public
53+
4354
public var next: Int = .zero
4455
public var rootNext: Int = .zero
4556
public var sheet: Int = .zero
@@ -68,19 +79,17 @@ extension TabLinkNavigatorMock {
6879
public var getCurrentRootPaths: Int = .zero
6980
public var getCurrentPaths: Int = .zero
7081

71-
public init() {
72-
}
7382
}
7483
}
7584

7685
// MARK: LinkNavigatorFindLocationUsable, TabLinkNavigatorProtocol
7786

7887
extension TabLinkNavigatorMock: LinkNavigatorFindLocationUsable, TabLinkNavigatorProtocol {
79-
80-
public func alert(model: Alert) {
88+
89+
public func alert(model _: Alert) {
8190
event.alert += 1
8291
}
83-
92+
8493
public func getCurrentPaths() -> [String] {
8594
event.getCurrentPaths += 1
8695
return value.currentPaths

0 commit comments

Comments
 (0)