From 02de258e96fc588bfa0210bd7ebfe230e58795be Mon Sep 17 00:00:00 2001 From: Colin White Date: Thu, 11 Jul 2024 15:53:10 -0700 Subject: [PATCH 1/3] Apply the UIKit LazyList separator style every time the view appears. --- .../cash/redwood/lazylayout/uiview/UIViewLazyList.kt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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 db46fb1c09..b73596c2bc 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 @@ -54,6 +54,7 @@ import platform.UIKit.UITableViewAutomaticDimension import platform.UIKit.UITableViewCell import platform.UIKit.UITableViewCellSeparatorStyle.UITableViewCellSeparatorStyleNone import platform.UIKit.UITableViewCellStyle +import platform.UIKit.UITableViewController import platform.UIKit.UITableViewDataSourceProtocol import platform.UIKit.UITableViewDelegateProtocol import platform.UIKit.UITableViewRowAnimationNone @@ -177,7 +178,8 @@ internal open class UIViewLazyList : } private val tableViewDelegate: UITableViewDelegateProtocol = - object : NSObject(), UITableViewDelegateProtocol { + object : UITableViewController(UITableViewStyle.UITableViewStylePlain), + UITableViewDelegateProtocol { override fun scrollViewDidScroll(scrollView: UIScrollView) { if (ignoreScrollUpdates) return // Only notify of user scrolls. @@ -200,6 +202,11 @@ internal open class UIViewLazyList : override fun scrollViewDidEndScrollingAnimation(scrollView: UIScrollView) { ignoreScrollUpdates = false } + + override fun viewWillAppear(animated: Boolean) { + super.viewWillAppear(animated) + tableView.separatorStyle = UITableViewCellSeparatorStyleNone + } } init { @@ -207,7 +214,6 @@ internal open class UIViewLazyList : dataSource = this@UIViewLazyList.dataSource delegate = tableViewDelegate rowHeight = UITableViewAutomaticDimension - separatorStyle = UITableViewCellSeparatorStyleNone backgroundColor = UIColor.clearColor registerClass( From cdb3e42fc1304b60062429c42f64a1658015ab4a Mon Sep 17 00:00:00 2001 From: Colin White Date: Fri, 12 Jul 2024 09:49:53 -0700 Subject: [PATCH 2/3] Spotless. --- .../app/cash/redwood/lazylayout/uiview/UIViewLazyList.kt | 3 ++- 1 file changed, 2 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 b73596c2bc..91cf325645 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 @@ -178,7 +178,8 @@ internal open class UIViewLazyList : } private val tableViewDelegate: UITableViewDelegateProtocol = - object : UITableViewController(UITableViewStyle.UITableViewStylePlain), + object : + UITableViewController(UITableViewStyle.UITableViewStylePlain), UITableViewDelegateProtocol { override fun scrollViewDidScroll(scrollView: UIScrollView) { if (ignoreScrollUpdates) return // Only notify of user scrolls. From 4267c0757d59cb6b0ec91827513ea3e73c1d399e Mon Sep 17 00:00:00 2001 From: Colin White Date: Thu, 18 Jul 2024 09:21:07 -0700 Subject: [PATCH 3/3] Use willMoveToSuperview instead. --- .../redwood/lazylayout/uiview/UIViewLazyList.kt | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) 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 91cf325645..e58f90a3d6 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 @@ -54,7 +54,6 @@ import platform.UIKit.UITableViewAutomaticDimension import platform.UIKit.UITableViewCell import platform.UIKit.UITableViewCellSeparatorStyle.UITableViewCellSeparatorStyleNone import platform.UIKit.UITableViewCellStyle -import platform.UIKit.UITableViewController import platform.UIKit.UITableViewDataSourceProtocol import platform.UIKit.UITableViewDelegateProtocol import platform.UIKit.UITableViewRowAnimationNone @@ -178,9 +177,7 @@ internal open class UIViewLazyList : } private val tableViewDelegate: UITableViewDelegateProtocol = - object : - UITableViewController(UITableViewStyle.UITableViewStylePlain), - UITableViewDelegateProtocol { + object : NSObject(), UITableViewDelegateProtocol { override fun scrollViewDidScroll(scrollView: UIScrollView) { if (ignoreScrollUpdates) return // Only notify of user scrolls. @@ -203,11 +200,6 @@ internal open class UIViewLazyList : override fun scrollViewDidEndScrollingAnimation(scrollView: UIScrollView) { ignoreScrollUpdates = false } - - override fun viewWillAppear(animated: Boolean) { - super.viewWillAppear(animated) - tableView.separatorStyle = UITableViewCellSeparatorStyleNone - } } init { @@ -215,6 +207,7 @@ internal open class UIViewLazyList : dataSource = this@UIViewLazyList.dataSource delegate = tableViewDelegate rowHeight = UITableViewAutomaticDimension + separatorStyle = UITableViewCellSeparatorStyleNone backgroundColor = UIColor.clearColor registerClass( @@ -303,6 +296,9 @@ internal class LazyListContainerCell( super.willMoveToSuperview(newSuperview) backgroundColor = UIColor.clearColor + if (newSuperview is UITableView) { + newSuperview.separatorStyle = UITableViewCellSeparatorStyleNone + } // Confirm the cell is bound when it's about to be displayed. if (superview == null && newSuperview != null) {