Skip to content

Commit

Permalink
Merge branch 'main' into fix/waterfall_image_module
Browse files Browse the repository at this point in the history
  • Loading branch information
siguangli authored Oct 16, 2024
2 parents 839c5d0 + 55b7622 commit a8457c4
Show file tree
Hide file tree
Showing 10 changed files with 128 additions and 39 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Hippy is now applied in [Tencent](http://www.tencent.com/) major apps such as Mo
* Excellent performance with JS engine binding communication.
* Build-in recyclable component with better performance.
* Smoothly and gracefully migrate to Web browser.
* Fully supported Flex [Layout engine](./layout).
* Fully supported Flex [Layout engine](https://github.com/Tencent/taitank).

## 🔨 Getting started

Expand Down
29 changes: 15 additions & 14 deletions driver/js/packages/hippy-react/src/components/list-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -494,20 +494,21 @@ class ListView extends React.Component<ListViewProps, ListViewState> {
style = getFooterStyle();
}
if (typeof renderPullFooter === 'function') {
pullFooter = (
<PullFooter
// @ts-ignore
style={style}
key={'pull-footer'}
ref={(ref) => {
this.pullFooter = ref;
}}
onFooterPulling={onFooterPulling}
onFooterReleased={onFooterReleased}
>
{ renderPullFooter() }
</PullFooter>
);
const footerProps: any = {
style,
key: 'pull-footer',
ref: (ref) => {
this.pullFooter = ref;
},
};

if (typeof onFooterPulling === 'function') {
footerProps.onFooterPulling = onFooterPulling;
}
if (typeof onFooterPulling === 'function') {
footerProps.onFooterReleased = onFooterReleased;
}
pullFooter = <PullFooter {...footerProps}>{renderPullFooter()}</PullFooter>;
}
return pullFooter;
}
Expand Down
24 changes: 12 additions & 12 deletions driver/js/packages/hippy-react/src/components/waterfall-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -458,18 +458,18 @@ class WaterfallView extends React.Component<WaterfallViewProps> {
) {
let pullFooter: JSX.Element | null = null;
if (typeof renderPullFooter === 'function') {
pullFooter = (
<PullFooter
key={'PullFooter'}
ref={(ref) => {
this.pullFooter = ref;
}}
onFooterPulling={onFooterPulling}
onFooterReleased={onFooterReleased}
>
{ renderPullFooter() }
</PullFooter>
);
const footerProps: any = {
key: 'PullFooter',
ref: (ref) => {
this.pullFooter = ref;
},
onFooterReleased,
};

if (typeof onFooterPulling === 'function') {
footerProps.onFooterPulling = onFooterPulling;
}
pullFooter = <PullFooter {...footerProps}>{renderPullFooter()}</PullFooter>;
}
return pullFooter;
}
Expand Down
12 changes: 12 additions & 0 deletions driver/js/packages/hippy-vue-native-components/src/ul-refresh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,17 @@ function registerUlRefresh(Vue: any) {
Vue.registerElement('hi-ul-refresh-wrapper', {
component: {
name: 'RefreshWrapper',
processEventData(event, nativeEventName, nativeEventParams) {
switch (nativeEventName) {
case 'onScroll': {
event.offsetX = nativeEventParams.contentOffset.x;

Check warning on line 30 in driver/js/packages/hippy-vue-native-components/src/ul-refresh.ts

View workflow job for this annotation

GitHub Actions / frontend_build_tests (16.x)

Assignment to property of function parameter 'event'

Check warning on line 30 in driver/js/packages/hippy-vue-native-components/src/ul-refresh.ts

View workflow job for this annotation

GitHub Actions / frontend_build_tests (17.x)

Assignment to property of function parameter 'event'
event.offsetY = nativeEventParams.contentOffset.y;

Check warning on line 31 in driver/js/packages/hippy-vue-native-components/src/ul-refresh.ts

View workflow job for this annotation

GitHub Actions / frontend_build_tests (16.x)

Assignment to property of function parameter 'event'

Check warning on line 31 in driver/js/packages/hippy-vue-native-components/src/ul-refresh.ts

View workflow job for this annotation

GitHub Actions / frontend_build_tests (17.x)

Assignment to property of function parameter 'event'
break;
}
default:
}
return event;
},
},
});

Expand Down Expand Up @@ -53,6 +64,7 @@ function registerUlRefresh(Vue: any) {
render(h: any) {
const on = getEventRedirector.call(this, [
'refresh',
'scroll',
]);
return h('hi-ul-refresh-wrapper', {
on,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,4 @@

@interface HippyNextBaseListItemView : HippyView <ViewAppearStateProtocol>

@property (nonatomic, strong) id type;
@property (nonatomic, assign) BOOL isSticky;


@end
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,27 @@
#import "HippyNextBaseListItemViewManager.h"
#import "HippyNextBaseListItemView.h"
#import "HippyShadowWaterfallItem.h"
#import "HippyNextShadowListItem.h"


@implementation HippyNextBaseListItemViewManager

HIPPY_EXPORT_MODULE(ListViewItem)

HIPPY_EXPORT_VIEW_PROPERTY(type, id)
HIPPY_EXPORT_VIEW_PROPERTY(isSticky, BOOL)
HIPPY_EXPORT_VIEW_PROPERTY(onAppear, HippyDirectEventBlock)
HIPPY_EXPORT_VIEW_PROPERTY(onDisappear, HippyDirectEventBlock)
HIPPY_EXPORT_VIEW_PROPERTY(onWillAppear, HippyDirectEventBlock)
HIPPY_EXPORT_VIEW_PROPERTY(onWillDisappear, HippyDirectEventBlock)
HIPPY_EXPORT_SHADOW_PROPERTY(sticky, BOOL)
HIPPY_EXPORT_SHADOW_PROPERTY(keepAlive, BOOL)

- (UIView *)view {
return [[HippyNextBaseListItemView alloc] init];
}

- (HippyShadowView *)shadowView {
return [[HippyShadowWaterfallItem alloc] init];
return [[HippyNextShadowListItem alloc] init];
}

@end
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#import "UIView+Hippy.h"
#import "UIView+Render.h"
#import "HippyShadowListView.h"
#import "HippyNextShadowListItem.h"

static NSString *const kCellIdentifier = @"HippyListCellIdentifier";
static NSString *const kSupplementaryIdentifier = @"HippySupplementaryIdentifier";
Expand All @@ -41,6 +42,7 @@
@interface HippyNextBaseListView () <HippyRefreshDelegate> {
BOOL _isInitialListReady;
NSArray<UICollectionViewCell *> *_previousVisibleCells;
NSMutableArray<UIView *> *_keepAliveCellViews; // cellViews that marked keep-Alive
}

@end
Expand Down Expand Up @@ -265,17 +267,28 @@ - (void)collectionView:(UICollectionView *)collectionView

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
HippyNextBaseListViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:kCellIdentifier forIndexPath:indexPath];
HippyShadowView *shadowView = [self.dataSource cellForIndexPath:indexPath];
HippyNextShadowListItem *shadowView = (HippyNextShadowListItem *)[self.dataSource cellForIndexPath:indexPath];

UIView *cellView = nil;
UIView *cachedVisibleCellView = [_cachedWeakCellViews objectForKey:shadowView.hippyTag];
if (cachedVisibleCellView) {
cellView = cachedVisibleCellView;
// Remove keep-Alive cellView if needed
if ([_keepAliveCellViews containsObject:cachedVisibleCellView] && shadowView.keepAlive == NO) {
[_keepAliveCellViews removeObject:cachedVisibleCellView];
}
HippyLogTrace(@"%@ 🟢 use cached visible cellView at {%ld - %ld} for %@",
self.hippyTag, indexPath.section, indexPath.row, shadowView.hippyTag);
} else {
cellView = [self.uiManager createViewForShadowListItem:shadowView];
[_cachedWeakCellViews setObject:cellView forKey:shadowView.hippyTag];
// Add keep-Alive cellView to cache if needed
if (shadowView.keepAlive) {
if (!_keepAliveCellViews) {
_keepAliveCellViews = [NSMutableArray array];
}
[_keepAliveCellViews addObject:cellView];
}
HippyLogTrace(@"%@ 🟡 create cellView at {%ld - %ld} for %@",
self.hippyTag, indexPath.section, indexPath.row, shadowView.hippyTag);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@
#import "HippyNextBaseListViewDataSource.h"
#import "HippyShadowView.h"
#import "HippyShadowListView.h"
#import "HippyNextShadowListItem.h"


static NSString * const kStickyCellPropKey = @"sticky";

@interface HippyNextBaseListViewDataSource () {
NSMutableArray *_shadowHeaderViews;
}
Expand All @@ -42,9 +41,8 @@ - (void)setDataSource:(NSArray<HippyShadowView *> *)dataSource containBannerView
NSMutableArray<HippyShadowView *> *shadowSectionCell = nil;
BOOL isFirstIndex = YES;
for (HippyShadowView *shadowView in dataSource) {
if ([self.itemViewName isEqualToString:shadowView.viewName]) {
NSNumber *sticky = shadowView.props[kStickyCellPropKey];
if ([sticky boolValue]) {
if ([shadowView isKindOfClass:HippyNextShadowListItem.class]) {
if (((HippyNextShadowListItem *)shadowView).isSticky) {
[shadowHeaders addObject:shadowView];
if (shadowSectionCell) {
[shadowCells addObject:shadowSectionCell];
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*!
* iOS SDK
*
* Tencent is pleased to support the open source community by making
* Hippy available.
*
* Copyright (C) 2019 THL A29 Limited, a Tencent company.
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/


#import "HippyShadowWaterfallItem.h"

NS_ASSUME_NONNULL_BEGIN

/// ListView item's shadow view
@interface HippyNextShadowListItem : HippyShadowWaterfallItem

/// Whether item is stick to the top
@property (nonatomic, assign, getter=isSticky) BOOL sticky;

/// Memory management property that sets item to exist for the lifetime of listView
@property (nonatomic, assign) BOOL keepAlive;

@end

NS_ASSUME_NONNULL_END
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*!
* iOS SDK
*
* Tencent is pleased to support the open source community by making
* Hippy available.
*
* Copyright (C) 2019 THL A29 Limited, a Tencent company.
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#import "HippyNextShadowListItem.h"

@implementation HippyNextShadowListItem

@end

0 comments on commit a8457c4

Please sign in to comment.