Skip to content

Commit e57d9e8

Browse files
committed
Fix Swift 6 concurrency warning
1 parent d1642f7 commit e57d9e8

File tree

4 files changed

+16
-4
lines changed

4 files changed

+16
-4
lines changed

RELEASE_NOTES.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ Until then, deprecated features may be removed in any minor version.
66

77

88

9+
## 0.6.1
10+
11+
This version adjusts the code to address a concurrency warning.
12+
13+
14+
915
## 0.6
1016

1117
This version makes ScrollKit use Swift 6.

Sources/ScrollKit/Examples/Spotify+PreviewScreen.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,9 @@ private extension View {
9696
#if os(macOS)
9797
Color.clear
9898
#endif
99-
Spotify.PreviewScreen(info: .regina)
99+
NavigationLink("Test") {
100+
Spotify.PreviewScreen(info: .regina)
101+
}
100102
}
101103
#if os(iOS)
102104
.navigationViewStyle(.stack)

Sources/ScrollKit/Helpers/ScrollViewOffsetTracker.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,14 @@ public extension View {
6464
/// view that has a ``ScrollViewOffsetTracker`` to track
6565
/// its scroll offset.
6666
func withScrollOffsetTracking(
67-
action: @escaping (_ offset: CGPoint) -> Void
67+
action: @escaping @MainActor @Sendable (_ offset: CGPoint) -> Void
6868
) -> some View {
6969
self.coordinateSpace(name: ScrollOffsetNamespace.namespace)
70-
.onPreferenceChange(ScrollOffsetPreferenceKey.self, perform: action)
70+
.onPreferenceChange(ScrollOffsetPreferenceKey.self) { offset in
71+
DispatchQueue.main.async {
72+
action(offset)
73+
}
74+
}
7175
}
7276
}
7377

Sources/ScrollKit/ScrollViewWithOffsetTracking.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public struct ScrollViewWithOffsetTracking<Content: View>: View {
3939
private let onScroll: ScrollAction
4040
private let content: () -> Content
4141

42-
public typealias ScrollAction = (_ offset: CGPoint) -> Void
42+
public typealias ScrollAction = @MainActor @Sendable (_ offset: CGPoint) -> Void
4343

4444
public var body: some View {
4545
ScrollView(axes, showsIndicators: showsIndicators) {

0 commit comments

Comments
 (0)