diff --git a/ListableUI/Sources/Behavior.swift b/ListableUI/Sources/Behavior.swift index 180e60c2..1e52886c 100644 --- a/ListableUI/Sources/Behavior.swift +++ b/ListableUI/Sources/Behavior.swift @@ -13,6 +13,9 @@ import UIKit /// when the list content underflows the available space in the list view. public struct Behavior : Equatable { + /// Whether the list scroll view should be enabled. + public var isScrollEnabled: Bool + /// How the keyboard should be dismissed (if at all) based on scrolling of the list view. public var keyboardDismissMode : UIScrollView.KeyboardDismissMode @@ -48,6 +51,7 @@ public struct Behavior : Equatable /// Creates a new `Behavior` based on the provided parameters. public init( + isScrollEnabled: Bool = true, keyboardDismissMode : UIScrollView.KeyboardDismissMode = .interactive, keyboardAdjustmentMode : KeyboardAdjustmentMode = .adjustsWhenVisible, scrollsToTop : ScrollsToTop = .enabled, @@ -59,6 +63,7 @@ public struct Behavior : Equatable decelerationRate : DecelerationRate = .normal, verticalLayoutGravity : VerticalLayoutGravity = .top ) { + self.isScrollEnabled = isScrollEnabled self.keyboardDismissMode = keyboardDismissMode self.keyboardAdjustmentMode = keyboardAdjustmentMode diff --git a/ListableUI/Sources/Layout/ListLayout/ListLayoutScrollViewProperties.swift b/ListableUI/Sources/Layout/ListLayout/ListLayoutScrollViewProperties.swift index 3d633ca8..b7b0aea1 100644 --- a/ListableUI/Sources/Layout/ListLayout/ListLayoutScrollViewProperties.swift +++ b/ListableUI/Sources/Layout/ListLayout/ListLayoutScrollViewProperties.swift @@ -48,6 +48,10 @@ public struct ListLayoutScrollViewProperties : Equatable /// because some UIScrollView properties, even when set to the same value, can affect or stop scrolling if it /// is in progress. Hard to tell which across iOS versions, so just always be defensive. + if view.isScrollEnabled != behavior.isScrollEnabled { + view.isScrollEnabled = behavior.isScrollEnabled + } + let isPagingEnabled = self.isPagingEnabled || behavior.isPagingEnabled if view.isPagingEnabled != isPagingEnabled {