Skip to content

Commit

Permalink
Add isScrollEnabled property to List behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
kyleve authored and mseijas committed Aug 27, 2024
1 parent 03a27c2 commit 88899f7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ListableUI/Sources/Behavior.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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,
Expand All @@ -59,6 +63,7 @@ public struct Behavior : Equatable
decelerationRate : DecelerationRate = .normal,
verticalLayoutGravity : VerticalLayoutGravity = .top
) {
self.isScrollEnabled = isScrollEnabled
self.keyboardDismissMode = keyboardDismissMode
self.keyboardAdjustmentMode = keyboardAdjustmentMode

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 88899f7

Please sign in to comment.