Skip to content

Commit 4c7bd31

Browse files
committed
Format and coverage
1 parent b1e2dce commit 4c7bd31

File tree

2 files changed

+39
-7
lines changed

2 files changed

+39
-7
lines changed

Sources/ComposableArchitecture/SwiftUI/WithViewStore.swift

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,11 @@ extension WithViewStore: DynamicViewContent where State: Collection, Content: Dy
105105
}
106106

107107
#if compiler(>=5.3)
108-
109108
import SwiftUI
110109

111-
/// A structure that transforms a store into an observable view store in order to compute scenes from
112-
/// store state.
113-
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
110+
/// A structure that transforms a store into an observable view store in order to compute scenes
111+
/// from store state.
112+
@available(iOS 14, macOS 11, tvOS 14, watchOS 7, *)
114113
extension WithViewStore: Scene where Content: Scene {
115114
public typealias Body = Content
116115

@@ -146,7 +145,7 @@ extension WithViewStore: DynamicViewContent where State: Collection, Content: Dy
146145
}
147146
}
148147

149-
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
148+
@available(iOS 14, macOS 11, tvOS 14, watchOS 7, *)
150149
extension WithViewStore where Content: Scene, State: Equatable {
151150
/// Initializes a structure that transforms a store into an observable view store in order to
152151
/// compute views from equatable store state.
@@ -162,7 +161,7 @@ extension WithViewStore: DynamicViewContent where State: Collection, Content: Dy
162161
}
163162
}
164163

165-
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
164+
@available(iOS 14, macOS 11, tvOS 14, watchOS 7, *)
166165
extension WithViewStore where Content: Scene, State == Void {
167166
/// Initializes a structure that transforms a store into an observable view store in order to
168167
/// compute views from equatable store state.
@@ -177,5 +176,4 @@ extension WithViewStore: DynamicViewContent where State: Collection, Content: Dy
177176
self.init(store, removeDuplicates: ==, content: content)
178177
}
179178
}
180-
181179
#endif
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// NB: This file gathers coverage of `WithViewStore` use as a `Scene`.
2+
3+
import ComposableArchitecture
4+
import SwiftUI
5+
6+
#if compiler(>=5.3)
7+
@available(iOS 14, macOS 11, tvOS 14, watchOS 7, *)
8+
struct TestApp: App {
9+
let store = Store(
10+
initialState: 0,
11+
reducer: Reducer<Int, Void, Void> { state, _, _ in
12+
state += 1
13+
return .none
14+
},
15+
environment: ()
16+
)
17+
18+
var body: some Scene {
19+
WithViewStore(self.store) { viewStore in
20+
WindowGroup {
21+
EmptyView()
22+
}
23+
.commands {
24+
CommandMenu("Commands") {
25+
Button("Increment") {
26+
viewStore.send(())
27+
}
28+
.keyboardShortcut("+")
29+
}
30+
}
31+
}
32+
}
33+
}
34+
#endif

0 commit comments

Comments
 (0)