From 77f3ee0f3993908d17cf3c65a05ee2cfba5c6083 Mon Sep 17 00:00:00 2001 From: Jesse Wilson Date: Tue, 31 Oct 2023 22:07:09 -0400 Subject: [PATCH] Don't get stuck in programmatic scrolling (#1662) --- .../app/cash/redwood/lazylayout/uiview/UIViewLazyList.kt | 9 ++++++++- samples/emoji-search/ios-uikit/EmojiSearchApp/Info.plist | 2 ++ test-app/ios-uikit/TestApp/Info.plist | 2 ++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/redwood-lazylayout-uiview/src/commonMain/kotlin/app/cash/redwood/lazylayout/uiview/UIViewLazyList.kt b/redwood-lazylayout-uiview/src/commonMain/kotlin/app/cash/redwood/lazylayout/uiview/UIViewLazyList.kt index 6233bdfc9b..a48f162202 100644 --- a/redwood-lazylayout-uiview/src/commonMain/kotlin/app/cash/redwood/lazylayout/uiview/UIViewLazyList.kt +++ b/redwood-lazylayout-uiview/src/commonMain/kotlin/app/cash/redwood/lazylayout/uiview/UIViewLazyList.kt @@ -160,6 +160,14 @@ internal open class UIViewLazyList( scrollProcessor.onUserScroll(firstIndex, lastIndex) } + /** + * If the user begins a drag while we’re programmatically scrolling, well then we're not + * programmatically scrolling anymore. + */ + override fun scrollViewWillBeginDragging(scrollView: UIScrollView) { + isDoingProgrammaticScroll = false + } + override fun scrollViewDidEndScrollingAnimation(scrollView: UIScrollView) { isDoingProgrammaticScroll = false } @@ -169,7 +177,6 @@ internal open class UIViewLazyList( tableView.apply { dataSource = this@UIViewLazyList.dataSource delegate = tableViewDelegate - prefetchingEnabled = true rowHeight = UITableViewAutomaticDimension separatorStyle = UITableViewCellSeparatorStyleNone diff --git a/samples/emoji-search/ios-uikit/EmojiSearchApp/Info.plist b/samples/emoji-search/ios-uikit/EmojiSearchApp/Info.plist index 7b1dc55785..103186ca11 100644 --- a/samples/emoji-search/ios-uikit/EmojiSearchApp/Info.plist +++ b/samples/emoji-search/ios-uikit/EmojiSearchApp/Info.plist @@ -4,6 +4,8 @@ NSAppTransportSecurity + NSAllowsArbitraryLoads + NSExceptionDomains localhost diff --git a/test-app/ios-uikit/TestApp/Info.plist b/test-app/ios-uikit/TestApp/Info.plist index 7b1dc55785..103186ca11 100644 --- a/test-app/ios-uikit/TestApp/Info.plist +++ b/test-app/ios-uikit/TestApp/Info.plist @@ -4,6 +4,8 @@ NSAppTransportSecurity + NSAllowsArbitraryLoads + NSExceptionDomains localhost