WIP: ScrollContentBackground needs a lot more work than I'd expected
This commit is contained in:
parent
7214afca8c
commit
d55b9e3556
|
@ -6,6 +6,7 @@ public typealias PlatformImage = UIImage
|
||||||
public typealias PlatformScreen = UIScreen
|
public typealias PlatformScreen = UIScreen
|
||||||
|
|
||||||
internal typealias PlatformView = UIView
|
internal typealias PlatformView = UIView
|
||||||
|
internal typealias PlatformScrollView = UIScrollView
|
||||||
internal typealias PlatformViewController = UIViewController
|
internal typealias PlatformViewController = UIViewController
|
||||||
|
|
||||||
extension UIScreen {
|
extension UIScreen {
|
||||||
|
@ -33,6 +34,7 @@ public typealias PlatformImage = NSImage
|
||||||
public typealias PlatformScreen = NSScreen
|
public typealias PlatformScreen = NSScreen
|
||||||
|
|
||||||
internal typealias PlatformView = NSView
|
internal typealias PlatformView = NSView
|
||||||
|
internal typealias PlatformScrollView = NSScrollView
|
||||||
internal typealias PlatformViewController = NSViewController
|
internal typealias PlatformViewController = NSViewController
|
||||||
|
|
||||||
extension NSScreen {
|
extension NSScreen {
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
import SwiftUI
|
||||||
|
|
||||||
|
/*
|
||||||
|
WIP
|
||||||
|
*/
|
||||||
|
|
||||||
|
@available(iOS, deprecated: 16)
|
||||||
|
private extension Backport where Wrapped: View {
|
||||||
|
func scrollContentBackground(_ visibility: Backport<Any>.Visibility) -> some View {
|
||||||
|
content.inspect { inspector in
|
||||||
|
inspector.sibling(ofType: PlatformScrollView.self)
|
||||||
|
} customize: { view in
|
||||||
|
let isHidden = visibility == .hidden
|
||||||
|
print(isHidden)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -35,7 +35,7 @@ extension Backport where Wrapped: View {
|
||||||
/// - axes: The axes of scrollable views that the visibility applies to.
|
/// - axes: The axes of scrollable views that the visibility applies to.
|
||||||
///
|
///
|
||||||
/// - Returns: A view with the specified scroll indicator visibility.
|
/// - Returns: A view with the specified scroll indicator visibility.
|
||||||
public func scrollIndicators(_ visibility: Backport<Any>.ScrollIndicatorVisibility, axes: Axis.Set = [.vertical, .horizontal]) -> some View {
|
public func scrollIndicators(_ visibility: Backport<Any>.ScrollIndicatorVisibility, axes: Axis.Set = [.vertical]) -> some View {
|
||||||
#if os(iOS)
|
#if os(iOS)
|
||||||
content
|
content
|
||||||
.environment(\.backportHorizontalScrollIndicatorVisibility, axes.contains(.horizontal) ? visibility : .automatic)
|
.environment(\.backportHorizontalScrollIndicatorVisibility, axes.contains(.horizontal) ? visibility : .automatic)
|
||||||
|
@ -50,10 +50,16 @@ extension Backport where Wrapped: View {
|
||||||
#if os(iOS)
|
#if os(iOS)
|
||||||
if axes.contains(.horizontal) {
|
if axes.contains(.horizontal) {
|
||||||
scrollView.showsHorizontalScrollIndicator = visibility.scrollViewVisible
|
scrollView.showsHorizontalScrollIndicator = visibility.scrollViewVisible
|
||||||
|
scrollView.alwaysBounceHorizontal = true
|
||||||
|
} else {
|
||||||
|
scrollView.alwaysBounceHorizontal = false
|
||||||
}
|
}
|
||||||
|
|
||||||
if axes.contains(.vertical) {
|
if axes.contains(.vertical) {
|
||||||
scrollView.showsVerticalScrollIndicator = visibility.scrollViewVisible
|
scrollView.showsVerticalScrollIndicator = visibility.scrollViewVisible
|
||||||
|
scrollView.alwaysBounceVertical = true
|
||||||
|
} else {
|
||||||
|
scrollView.alwaysBounceVertical = false
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue