-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
308 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
// | ||
// BookScrollView.swift | ||
// Development | ||
// | ||
// Created by Muukii on 2024/07/25. | ||
// | ||
|
||
import SwiftUI | ||
import SwiftUIScrollViewInteroperableDragGesture | ||
import SwiftUISnapDraggingModifier | ||
|
||
#if DEBUG | ||
|
||
@available(iOS 18, *) | ||
private var scrollView: some View { | ||
ScrollView([.horizontal, .vertical]) { | ||
Grid(horizontalSpacing: 20, verticalSpacing: 20) { | ||
ForEach(0..<4) { _ in | ||
GridRow { | ||
ForEach(0..<4) { _ in Color.teal.frame(width: 30, height: 30) } | ||
} | ||
} | ||
} | ||
.padding() | ||
.background(Color.red) | ||
.padding() | ||
.background(Color.blue) | ||
} | ||
} | ||
|
||
@available(iOS 18, *) | ||
#Preview("Normal") { | ||
|
||
@Previewable @State var offset: CGSize = .zero | ||
|
||
ZStack { | ||
|
||
VStack { | ||
scrollView | ||
} | ||
.frame(width: 200, height: 200) | ||
.background(Color.green.secondary) | ||
.padding() | ||
.background(Color.green.tertiary) | ||
.modifier( | ||
SnapDraggingModifier( | ||
gestureMode: .scrollViewInteroperable( | ||
.init(ignoresScrollView: false, sticksToEdges: false) | ||
), | ||
offset: $offset | ||
) | ||
) | ||
.background(Color.purple.tertiary) | ||
|
||
} | ||
} | ||
|
||
@available(iOS 18, *) | ||
#Preview("SticksToEdges") { | ||
|
||
@Previewable @State var offset: CGSize = .zero | ||
|
||
ZStack { | ||
|
||
VStack { | ||
scrollView | ||
} | ||
.frame(width: 200, height: 200) | ||
.background(Color.green.secondary) | ||
.padding() | ||
.background(Color.green.tertiary) | ||
.modifier( | ||
SnapDraggingModifier( | ||
gestureMode: .scrollViewInteroperable( | ||
.init(ignoresScrollView: false, sticksToEdges: true) | ||
), | ||
offset: $offset | ||
) | ||
) | ||
.background(Color.purple.tertiary) | ||
|
||
} | ||
} | ||
|
||
@available(iOS 18, *) | ||
#Preview("IgnoreScrollView") { | ||
|
||
@Previewable @State var offset: CGSize = .zero | ||
|
||
ZStack { | ||
|
||
VStack { | ||
scrollView | ||
} | ||
.frame(width: 200, height: 200) | ||
.background(Color.green.secondary) | ||
.padding() | ||
.background(Color.green.tertiary) | ||
.modifier( | ||
SnapDraggingModifier( | ||
gestureMode: .scrollViewInteroperable( | ||
.init(ignoresScrollView: true, sticksToEdges: true) | ||
), | ||
offset: $offset | ||
) | ||
) | ||
.background(Color.purple.tertiary) | ||
|
||
} | ||
} | ||
|
||
|
||
#endif |
Oops, something went wrong.