From 66d62707c0efe241db5c32773ed6bf3b6d96b376 Mon Sep 17 00:00:00 2001 From: wwwcg Date: Tue, 8 Oct 2024 11:59:39 +0800 Subject: [PATCH] fix(ios): banner view of waterfall not working --- .../waterfalllist/HippyWaterfallView.mm | 4 ++-- ...aSource.mm => HippyWaterfallViewDataSource.m} | 16 ++++++++++++---- 2 files changed, 14 insertions(+), 6 deletions(-) rename renderer/native/ios/renderer/component/waterfalllist/{HippyWaterfallViewDataSource.mm => HippyWaterfallViewDataSource.m} (91%) diff --git a/renderer/native/ios/renderer/component/waterfalllist/HippyWaterfallView.mm b/renderer/native/ios/renderer/component/waterfalllist/HippyWaterfallView.mm index 7431c218e50..e76d0b96ee4 100644 --- a/renderer/native/ios/renderer/component/waterfalllist/HippyWaterfallView.mm +++ b/renderer/native/ios/renderer/component/waterfalllist/HippyWaterfallView.mm @@ -209,8 +209,8 @@ - (void)hippyBridgeDidFinishTransaction { - (void)reloadData { NSArray *datasource = [self.hippyShadowView.hippySubviews copy]; _dataSource = [[HippyWaterfallViewDataSource alloc] initWithDataSource:datasource - itemViewName:[self compoentItemName] - containBannerView:_containBannerView]; + itemViewName:[self compoentItemName] + containBannerView:_containBannerView]; [self.collectionView reloadData]; diff --git a/renderer/native/ios/renderer/component/waterfalllist/HippyWaterfallViewDataSource.mm b/renderer/native/ios/renderer/component/waterfalllist/HippyWaterfallViewDataSource.m similarity index 91% rename from renderer/native/ios/renderer/component/waterfalllist/HippyWaterfallViewDataSource.mm rename to renderer/native/ios/renderer/component/waterfalllist/HippyWaterfallViewDataSource.m index 5219e1509cf..20684fe2beb 100644 --- a/renderer/native/ios/renderer/component/waterfalllist/HippyWaterfallViewDataSource.mm +++ b/renderer/native/ios/renderer/component/waterfalllist/HippyWaterfallViewDataSource.m @@ -20,12 +20,11 @@ * limitations under the License. */ -#import - -#import "HippyAssert.h" #import "HippyWaterfallViewDataSource.h" +#import "HippyAssert.h" #import "HippyShadowView.h" #import "HippyShadowListView.h" +#import "HippyHeaderRefreshManager.h" @interface HippyWaterfallViewDataSource () { BOOL _containBannerView; @@ -71,7 +70,16 @@ - (void)setDataSource:(NSArray *)dataSource _containBannerView = containBannerView; if ([dataSource count] > 0) { if (containBannerView) { - _bannerView = [dataSource firstObject]; + // find the first shadowView that is not pull header or pull footer + for (int i = 0; i < dataSource.count; i++) { + HippyShadowView *subShadowView = [dataSource objectAtIndex:i]; + if ([subShadowView.viewName isEqualToString:HippyHeaderRefreshManager.moduleName]) { + continue; + } else { + _bannerView = subShadowView; + break; + } + } } NSUInteger loc = _containBannerView ? 1 : 0; NSArray *candidateRenderObjectViews = [dataSource subarrayWithRange:NSMakeRange(loc, [dataSource count] - loc)];