Skip to content

Commit 7e36910

Browse files
mluisbrownactions-user
authored andcommitted
Run swift-format
1 parent da96423 commit 7e36910

File tree

6 files changed

+251
-248
lines changed

6 files changed

+251
-248
lines changed

Examples/Todos/Todos/Todos.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ struct AppEnvironment {
4040

4141
let appReducer = Reducer<AppState, AppAction, AppEnvironment>.combine(
4242
todoReducer.forEach(
43-
state: \.todos,
44-
action: /AppAction.todo(id:action:),
45-
environment: { _ in TodoEnvironment() }
43+
state: \.todos,
44+
action: /AppAction.todo(id:action:),
45+
environment: { _ in TodoEnvironment() }
4646
),
4747
Reducer { state, action, environment in
4848
switch action {
Lines changed: 94 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -1,120 +1,123 @@
11
#if canImport(SwiftUI)
2-
import SwiftUI
3-
import ReactiveSwift
2+
import SwiftUI
3+
import ReactiveSwift
44

5-
extension Scheduler {
6-
/// Specifies an animation to perform when an action is scheduled.
7-
///
8-
/// - Parameter animation: An animation to be performed.
9-
/// - Returns: A scheduler that performs an animation when a scheduled action is run.
10-
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
11-
public func animation(_ animation: Animation? = .default) -> Scheduler {
12-
ActionWrappingScheduler(scheduler: self, wrapper: .animation(animation))
13-
}
5+
extension Scheduler {
6+
/// Specifies an animation to perform when an action is scheduled.
7+
///
8+
/// - Parameter animation: An animation to be performed.
9+
/// - Returns: A scheduler that performs an animation when a scheduled action is run.
10+
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
11+
public func animation(_ animation: Animation? = .default) -> Scheduler {
12+
ActionWrappingScheduler(scheduler: self, wrapper: .animation(animation))
13+
}
1414

15-
/// Wraps scheduled actions in a transaction.
16-
///
17-
/// - Parameter transaction: A transaction.
18-
/// - Returns: A scheduler that wraps scheduled actions in a transaction.
19-
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
20-
public func transaction(_ transaction: Transaction) -> Scheduler {
21-
ActionWrappingScheduler(scheduler: self, wrapper: .transaction(transaction))
15+
/// Wraps scheduled actions in a transaction.
16+
///
17+
/// - Parameter transaction: A transaction.
18+
/// - Returns: A scheduler that wraps scheduled actions in a transaction.
19+
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
20+
public func transaction(_ transaction: Transaction) -> Scheduler {
21+
ActionWrappingScheduler(scheduler: self, wrapper: .transaction(transaction))
22+
}
2223
}
23-
}
2424

25-
extension DateScheduler {
26-
/// Specifies an animation to perform when an action is scheduled.
27-
///
28-
/// - Parameter animation: An animation to be performed.
29-
/// - Returns: A scheduler that performs an animation when a scheduled action is run.
30-
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
31-
public func animation(_ animation: Animation? = .default) -> DateScheduler {
32-
ActionWrappingDateScheduler(scheduler: self, wrapper: .animation(animation))
25+
extension DateScheduler {
26+
/// Specifies an animation to perform when an action is scheduled.
27+
///
28+
/// - Parameter animation: An animation to be performed.
29+
/// - Returns: A scheduler that performs an animation when a scheduled action is run.
30+
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
31+
public func animation(_ animation: Animation? = .default) -> DateScheduler {
32+
ActionWrappingDateScheduler(scheduler: self, wrapper: .animation(animation))
33+
}
34+
35+
/// Wraps scheduled actions in a transaction.
36+
///
37+
/// - Parameter transaction: A transaction.
38+
/// - Returns: A scheduler that wraps scheduled actions in a transaction.
39+
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
40+
public func transaction(_ transaction: Transaction) -> DateScheduler {
41+
ActionWrappingDateScheduler(scheduler: self, wrapper: .transaction(transaction))
42+
}
3343
}
3444

35-
/// Wraps scheduled actions in a transaction.
36-
///
37-
/// - Parameter transaction: A transaction.
38-
/// - Returns: A scheduler that wraps scheduled actions in a transaction.
3945
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
40-
public func transaction(_ transaction: Transaction) -> DateScheduler {
41-
ActionWrappingDateScheduler(scheduler: self, wrapper: .transaction(transaction))
46+
private enum ActionWrapper {
47+
case animation(Animation?)
48+
case transaction(Transaction)
4249
}
43-
}
44-
45-
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
46-
private enum ActionWrapper {
47-
case animation(Animation?)
48-
case transaction(Transaction)
49-
}
5050

51-
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
52-
public final class ActionWrappingScheduler: Scheduler {
53-
private let scheduler: Scheduler
54-
private let wrapper: ActionWrapper
51+
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
52+
public final class ActionWrappingScheduler: Scheduler {
53+
private let scheduler: Scheduler
54+
private let wrapper: ActionWrapper
5555

56-
fileprivate init(scheduler: Scheduler, wrapper: ActionWrapper) {
57-
self.scheduler = scheduler
58-
self.wrapper = wrapper
59-
}
56+
fileprivate init(scheduler: Scheduler, wrapper: ActionWrapper) {
57+
self.scheduler = scheduler
58+
self.wrapper = wrapper
59+
}
6060

61-
public func schedule(_ action: @escaping () -> Void) -> Disposable? {
62-
scheduler.schedule {
63-
switch self.wrapper {
64-
case let .animation(animation):
65-
withAnimation(animation, action)
66-
case let .transaction(transaction):
67-
withTransaction(transaction, action)
61+
public func schedule(_ action: @escaping () -> Void) -> Disposable? {
62+
scheduler.schedule {
63+
switch self.wrapper {
64+
case let .animation(animation):
65+
withAnimation(animation, action)
66+
case let .transaction(transaction):
67+
withTransaction(transaction, action)
68+
}
6869
}
6970
}
7071
}
71-
}
7272

73-
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
74-
public final class ActionWrappingDateScheduler: DateScheduler {
75-
public var currentDate: Date {
76-
scheduler.currentDate
77-
}
73+
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
74+
public final class ActionWrappingDateScheduler: DateScheduler {
75+
public var currentDate: Date {
76+
scheduler.currentDate
77+
}
7878

79-
private let scheduler: DateScheduler
80-
private let wrapper: ActionWrapper
79+
private let scheduler: DateScheduler
80+
private let wrapper: ActionWrapper
8181

82-
fileprivate init(scheduler: DateScheduler, wrapper: ActionWrapper) {
83-
self.scheduler = scheduler
84-
self.wrapper = wrapper
85-
}
82+
fileprivate init(scheduler: DateScheduler, wrapper: ActionWrapper) {
83+
self.scheduler = scheduler
84+
self.wrapper = wrapper
85+
}
8686

87-
public func schedule(_ action: @escaping () -> Void) -> Disposable? {
88-
scheduler.schedule {
89-
switch self.wrapper {
90-
case let .animation(animation):
91-
withAnimation(animation, action)
92-
case let .transaction(transaction):
93-
withTransaction(transaction, action)
87+
public func schedule(_ action: @escaping () -> Void) -> Disposable? {
88+
scheduler.schedule {
89+
switch self.wrapper {
90+
case let .animation(animation):
91+
withAnimation(animation, action)
92+
case let .transaction(transaction):
93+
withTransaction(transaction, action)
94+
}
9495
}
9596
}
96-
}
9797

98-
public func schedule(after date: Date, action: @escaping () -> Void) -> Disposable? {
99-
scheduler.schedule(after: date) {
100-
switch self.wrapper {
101-
case let .animation(animation):
102-
withAnimation(animation, action)
103-
case let .transaction(transaction):
104-
withTransaction(transaction, action)
98+
public func schedule(after date: Date, action: @escaping () -> Void) -> Disposable? {
99+
scheduler.schedule(after: date) {
100+
switch self.wrapper {
101+
case let .animation(animation):
102+
withAnimation(animation, action)
103+
case let .transaction(transaction):
104+
withTransaction(transaction, action)
105+
}
105106
}
106107
}
107-
}
108108

109-
public func schedule(after date: Date, interval: DispatchTimeInterval, leeway: DispatchTimeInterval, action: @escaping () -> Void) -> Disposable? {
110-
scheduler.schedule(after: date, interval: interval, leeway: leeway) {
111-
switch self.wrapper {
112-
case let .animation(animation):
113-
withAnimation(animation, action)
114-
case let .transaction(transaction):
115-
withTransaction(transaction, action)
109+
public func schedule(
110+
after date: Date, interval: DispatchTimeInterval, leeway: DispatchTimeInterval,
111+
action: @escaping () -> Void
112+
) -> Disposable? {
113+
scheduler.schedule(after: date, interval: interval, leeway: leeway) {
114+
switch self.wrapper {
115+
case let .animation(animation):
116+
withAnimation(animation, action)
117+
case let .transaction(transaction):
118+
withTransaction(transaction, action)
119+
}
116120
}
117121
}
118122
}
119-
}
120123
#endif
Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
#if canImport(SwiftUI)
2-
import SwiftUI
2+
import SwiftUI
33

4-
extension ViewStore {
5-
/// Sends an action to the store with a given animation.
6-
///
7-
/// - Parameters:
8-
/// - action: An action.
9-
/// - animation: An animation.
10-
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
11-
public func send(_ action: Action, animation: Animation?) {
12-
withAnimation(animation) {
13-
self.send(action)
4+
extension ViewStore {
5+
/// Sends an action to the store with a given animation.
6+
///
7+
/// - Parameters:
8+
/// - action: An action.
9+
/// - animation: An animation.
10+
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
11+
public func send(_ action: Action, animation: Animation?) {
12+
withAnimation(animation) {
13+
self.send(action)
14+
}
1415
}
1516
}
16-
}
1717
#endif

Sources/ComposableArchitecture/SwiftUI/TextState.swift

Lines changed: 62 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -311,72 +311,72 @@
311311
}
312312
}
313313

314-
@available(iOS 13, macOS 10.15, macCatalyst 13, tvOS 13, watchOS 6, *)
315-
extension TextState: CustomDebugOutputConvertible {
316-
public var debugOutput: String {
317-
func debugOutputHelp(_ textState: Self) -> String {
318-
var output: String
319-
switch textState.storage {
320-
case let .concatenated(lhs, rhs):
321-
output = debugOutputHelp(lhs) + debugOutputHelp(rhs)
322-
case let .localized(key, tableName, bundle, comment):
323-
output = key.formatted(tableName: tableName, bundle: bundle, comment: comment)
324-
case let .verbatim(string):
325-
output = string
326-
}
327-
for modifier in textState.modifiers {
328-
switch modifier {
329-
case let .baselineOffset(baselineOffset):
330-
output = "<baseline-offset=\(baselineOffset)>\(output)</baseline-offset>"
331-
case .bold, .fontWeight(.some(.bold)):
332-
output = "**\(output)**"
333-
case .font(.some):
334-
break // TODO: capture Font description using DSL similar to TextState and print here
335-
case let .fontWeight(.some(weight)):
336-
func describe(weight: Font.Weight) -> String {
337-
switch weight {
338-
case .black: return "black"
339-
case .bold: return "bold"
340-
case .heavy: return "heavy"
341-
case .light: return "light"
342-
case .medium: return "medium"
343-
case .regular: return "regular"
344-
case .semibold: return "semibold"
345-
case .thin: return "thin"
346-
default: return "\(weight)"
314+
@available(iOS 13, macOS 10.15, macCatalyst 13, tvOS 13, watchOS 6, *)
315+
extension TextState: CustomDebugOutputConvertible {
316+
public var debugOutput: String {
317+
func debugOutputHelp(_ textState: Self) -> String {
318+
var output: String
319+
switch textState.storage {
320+
case let .concatenated(lhs, rhs):
321+
output = debugOutputHelp(lhs) + debugOutputHelp(rhs)
322+
case let .localized(key, tableName, bundle, comment):
323+
output = key.formatted(tableName: tableName, bundle: bundle, comment: comment)
324+
case let .verbatim(string):
325+
output = string
326+
}
327+
for modifier in textState.modifiers {
328+
switch modifier {
329+
case let .baselineOffset(baselineOffset):
330+
output = "<baseline-offset=\(baselineOffset)>\(output)</baseline-offset>"
331+
case .bold, .fontWeight(.some(.bold)):
332+
output = "**\(output)**"
333+
case .font(.some):
334+
break // TODO: capture Font description using DSL similar to TextState and print here
335+
case let .fontWeight(.some(weight)):
336+
func describe(weight: Font.Weight) -> String {
337+
switch weight {
338+
case .black: return "black"
339+
case .bold: return "bold"
340+
case .heavy: return "heavy"
341+
case .light: return "light"
342+
case .medium: return "medium"
343+
case .regular: return "regular"
344+
case .semibold: return "semibold"
345+
case .thin: return "thin"
346+
default: return "\(weight)"
347+
}
347348
}
349+
output = "<font-weight=\(describe(weight: weight))>\(output)</font-weight>"
350+
case let .foregroundColor(.some(color)):
351+
output = "<foreground-color=\(color)>\(output)</foreground-color>"
352+
case .italic:
353+
output = "_\(output)_"
354+
case let .kerning(kerning):
355+
output = "<kerning=\(kerning)>\(output)</kerning>"
356+
case let .strikethrough(active: true, color: .some(color)):
357+
output = "<s color=\(color)>\(output)</s>"
358+
case .strikethrough(active: true, color: .none):
359+
output = "~~\(output)~~"
360+
case let .tracking(tracking):
361+
output = "<tracking=\(tracking)>\(output)</tracking>"
362+
case let .underline(active: true, color):
363+
output = "<u\(color.map { " color=\($0)" } ?? "")>\(output)</u>"
364+
case .font(.none),
365+
.fontWeight(.none),
366+
.foregroundColor(.none),
367+
.strikethrough(active: false, color: _),
368+
.underline(active: false, color: _):
369+
break
348370
}
349-
output = "<font-weight=\(describe(weight: weight))>\(output)</font-weight>"
350-
case let .foregroundColor(.some(color)):
351-
output = "<foreground-color=\(color)>\(output)</foreground-color>"
352-
case .italic:
353-
output = "_\(output)_"
354-
case let .kerning(kerning):
355-
output = "<kerning=\(kerning)>\(output)</kerning>"
356-
case let .strikethrough(active: true, color: .some(color)):
357-
output = "<s color=\(color)>\(output)</s>"
358-
case .strikethrough(active: true, color: .none):
359-
output = "~~\(output)~~"
360-
case let .tracking(tracking):
361-
output = "<tracking=\(tracking)>\(output)</tracking>"
362-
case let .underline(active: true, color):
363-
output = "<u\(color.map { " color=\($0)" } ?? "")>\(output)</u>"
364-
case .font(.none),
365-
.fontWeight(.none),
366-
.foregroundColor(.none),
367-
.strikethrough(active: false, color: _),
368-
.underline(active: false, color: _):
369-
break
370371
}
372+
return output
371373
}
372-
return output
373-
}
374374

375-
return #"""
376-
\#(Self.self)(
377-
\#(debugOutputHelp(self).indent(by: 2))
378-
)
379-
"""#
375+
return #"""
376+
\#(Self.self)(
377+
\#(debugOutputHelp(self).indent(by: 2))
378+
)
379+
"""#
380+
}
380381
}
381-
}
382382
#endif

0 commit comments

Comments
 (0)