From 4a3952d1eec02e645fa35990a34b22b2ce9f38d4 Mon Sep 17 00:00:00 2001 From: wwwcg Date: Wed, 31 Jan 2024 20:22:04 +0800 Subject: [PATCH 1/8] fix(ios): revert rename symbol Prefix and fix compatibility issues --- .../native/ios/renderer/HippyComponentData.h | 2 +- ...ObjectRootView.h => HippyRootShadowView.h} | 2 +- ...jectRootView.mm => HippyRootShadowView.mm} | 4 +- renderer/native/ios/renderer/HippyRootView.mm | 1 - renderer/native/ios/renderer/HippyUIManager.h | 33 ++++++- .../native/ios/renderer/HippyUIManager.mm | 86 +++++++++---------- .../native/ios/renderer/NativeRenderDefines.h | 52 ----------- ...ItemView.h => HippyNextBaseListItemView.h} | 4 +- ...ItemView.m => HippyNextBaseListItemView.m} | 8 +- ...r.h => HippyNextBaseListItemViewManager.h} | 2 +- ...mm => HippyNextBaseListItemViewManager.mm} | 12 +-- ...BaseListView.h => HippyNextBaseListView.h} | 12 +-- ...seListView.mm => HippyNextBaseListView.mm} | 34 ++++---- ...ViewCell.h => HippyNextBaseListViewCell.h} | 6 +- ...ViewCell.m => HippyNextBaseListViewCell.m} | 6 +- ...m.mm => HippyNextBaseListViewDataSource.h} | 4 +- ....mm => HippyNextBaseListViewDataSource.mm} | 6 +- ...nager.h => HippyNextBaseListViewManager.h} | 2 +- ...ger.mm => HippyNextBaseListViewManager.mm} | 16 ++-- ....h => HippyNextCollectionViewFlowLayout.h} | 6 +- ....m => HippyNextCollectionViewFlowLayout.m} | 18 ++-- ...stTableView.h => HippyNextListTableView.h} | 8 +- ...stTableView.m => HippyNextListTableView.m} | 4 +- .../NativeRenderBaseListViewDataSource.h | 27 ------ .../listview/NativeRenderObjectBaseListItem.h | 32 ------- .../modal/HippyModalHostViewManager.mm | 6 +- ....h => HippyNavigationControllerAnimator.h} | 2 +- ....m => HippyNavigationControllerAnimator.m} | 8 +- ...torHostView.h => HippyNavigatorHostView.h} | 2 +- ...torHostView.m => HippyNavigatorHostView.m} | 22 ++--- ...r.h => HippyNavigatorItemViewController.h} | 2 +- ...r.m => HippyNavigatorItemViewController.m} | 6 +- ...r.h => HippyNavigatorRootViewController.h} | 2 +- ...r.m => HippyNavigatorRootViewController.m} | 6 +- ...wManager.h => HippyNavigatorViewManager.h} | 4 +- ...anager.mm => HippyNavigatorViewManager.mm} | 12 +-- .../NativeRenderSmartViewPagerView.h | 8 +- .../NativeRenderSmartViewPagerView.mm | 20 ++--- .../component/text/HippyShadowText.mm | 12 +-- .../renderer/component/view/HippyShadowView.h | 16 ++-- .../component/view/HippyShadowView.mm | 8 +- .../ios/renderer/component/view/HippyView.h | 4 +- .../ios/renderer/component/view/HippyView.m | 2 +- .../component/view/HippyViewManager.h | 9 +- .../component/view/HippyViewManager.mm | 4 +- ...h => HippyCollectionViewWaterfallLayout.h} | 42 ++++----- ...m => HippyCollectionViewWaterfallLayout.m} | 50 +++++------ .../waterfalllist/HippyShadowListView.h | 4 +- .../waterfalllist/HippyShadowListView.mm | 12 +-- ...rfallItem.h => HippyShadowWaterfallItem.h} | 10 +-- ...allItem.mm => HippyShadowWaterfallItem.mm} | 8 +- ...allItemView.h => HippyWaterfallItemView.h} | 2 +- ...allItemView.m => HippyWaterfallItemView.m} | 8 +- ...ager.h => HippyWaterfallItemViewManager.h} | 2 +- ...ger.mm => HippyWaterfallItemViewManager.m} | 12 +-- ...erWaterfallView.h => HippyWaterfallView.h} | 32 +++---- ...WaterfallView.mm => HippyWaterfallView.mm} | 34 ++++---- ...allViewCell.h => HippyWaterfallViewCell.h} | 2 +- ...allViewCell.m => HippyWaterfallViewCell.m} | 4 +- ...ource.h => HippyWaterfallViewDataSource.h} | 2 +- ...rce.mm => HippyWaterfallViewDataSource.mm} | 8 +- ...wManager.h => HippyWaterfallViewManager.h} | 2 +- ...Manager.mm => HippyWaterfallViewManager.m} | 50 +++++------ ...GradientObject.h => HippyGradientObject.h} | 36 ++++---- ...GradientObject.m => HippyGradientObject.m} | 60 ++++++------- ...NativeRenderUtils.h => HippyRenderUtils.h} | 20 ++--- ...NativeRenderUtils.m => HippyRenderUtils.m} | 30 +++---- 67 files changed, 440 insertions(+), 532 deletions(-) rename renderer/native/ios/renderer/{NativeRenderObjectRootView.h => HippyRootShadowView.h} (94%) rename renderer/native/ios/renderer/{NativeRenderObjectRootView.mm => HippyRootShadowView.mm} (93%) delete mode 100644 renderer/native/ios/renderer/NativeRenderDefines.h rename renderer/native/ios/renderer/component/listview/{NativeRenderBaseListItemView.h => HippyNextBaseListItemView.h} (88%) rename renderer/native/ios/renderer/component/listview/{NativeRenderBaseListItemView.m => HippyNextBaseListItemView.m} (92%) rename renderer/native/ios/renderer/component/listview/{NativeRenderBaseListItemViewManager.h => HippyNextBaseListItemViewManager.h} (92%) rename renderer/native/ios/renderer/component/listview/{NativeRenderBaseListItemViewManager.mm => HippyNextBaseListItemViewManager.mm} (80%) rename renderer/native/ios/renderer/component/listview/{NativeRenderBaseListView.h => HippyNextBaseListView.h} (82%) rename renderer/native/ios/renderer/component/listview/{NativeRenderBaseListView.mm => HippyNextBaseListView.mm} (92%) rename renderer/native/ios/renderer/component/listview/{NativeRenderBaseListViewCell.h => HippyNextBaseListViewCell.h} (89%) rename renderer/native/ios/renderer/component/listview/{NativeRenderBaseListViewCell.m => HippyNextBaseListViewCell.m} (95%) rename renderer/native/ios/renderer/component/listview/{NativeRenderObjectBaseListItem.mm => HippyNextBaseListViewDataSource.h} (86%) rename renderer/native/ios/renderer/component/listview/{NativeRenderBaseListViewDataSource.mm => HippyNextBaseListViewDataSource.mm} (97%) rename renderer/native/ios/renderer/component/listview/{NativeRenderBaseListViewManager.h => HippyNextBaseListViewManager.h} (92%) rename renderer/native/ios/renderer/component/listview/{NativeRenderBaseListViewManager.mm => HippyNextBaseListViewManager.mm} (86%) rename renderer/native/ios/renderer/component/listview/{NativeRenderCollectionViewFlowLayout.h => HippyNextCollectionViewFlowLayout.h} (83%) rename renderer/native/ios/renderer/component/listview/{NativeRenderCollectionViewFlowLayout.m => HippyNextCollectionViewFlowLayout.m} (72%) rename renderer/native/ios/renderer/component/listview/{NativeRenderListTableView.h => HippyNextListTableView.h} (81%) rename renderer/native/ios/renderer/component/listview/{NativeRenderListTableView.m => HippyNextListTableView.m} (94%) delete mode 100644 renderer/native/ios/renderer/component/listview/NativeRenderBaseListViewDataSource.h delete mode 100644 renderer/native/ios/renderer/component/listview/NativeRenderObjectBaseListItem.h rename renderer/native/ios/renderer/component/navigator/{NativeRenderNavigationControllerAnimator.h => HippyNavigationControllerAnimator.h} (92%) rename renderer/native/ios/renderer/component/navigator/{NativeRenderNavigationControllerAnimator.m => HippyNavigationControllerAnimator.m} (94%) rename renderer/native/ios/renderer/component/navigator/{NativeRenderNavigatorHostView.h => HippyNavigatorHostView.h} (92%) rename renderer/native/ios/renderer/component/navigator/{NativeRenderNavigatorHostView.m => HippyNavigatorHostView.m} (85%) rename renderer/native/ios/renderer/component/navigator/{NativeRenderNavigatorItemViewController.h => HippyNavigatorItemViewController.h} (92%) rename renderer/native/ios/renderer/component/navigator/{NativeRenderNavigatorItemViewController.m => HippyNavigatorItemViewController.m} (86%) rename renderer/native/ios/renderer/component/navigator/{NativeRenderNavigatorRootViewController.h => HippyNavigatorRootViewController.h} (91%) rename renderer/native/ios/renderer/component/navigator/{NativeRenderNavigatorRootViewController.m => HippyNavigatorRootViewController.m} (88%) rename renderer/native/ios/renderer/component/navigator/{NativeRenderNavigatorViewManager.h => HippyNavigatorViewManager.h} (86%) rename renderer/native/ios/renderer/component/navigator/{NativeRenderNavigatorViewManager.mm => HippyNavigatorViewManager.mm} (77%) rename renderer/native/ios/renderer/component/waterfalllist/{NativeRenderCollectionViewWaterfallLayout.h => HippyCollectionViewWaterfallLayout.h} (86%) rename renderer/native/ios/renderer/component/waterfalllist/{NativeRenderCollectionViewWaterfallLayout.m => HippyCollectionViewWaterfallLayout.m} (90%) rename renderer/native/ios/renderer/component/waterfalllist/{NativeRenderObjectWaterfallItem.h => HippyShadowWaterfallItem.h} (73%) rename renderer/native/ios/renderer/component/waterfalllist/{NativeRenderObjectWaterfallItem.mm => HippyShadowWaterfallItem.mm} (89%) rename renderer/native/ios/renderer/component/waterfalllist/{NativeRenderWaterfallItemView.h => HippyWaterfallItemView.h} (94%) rename renderer/native/ios/renderer/component/waterfalllist/{NativeRenderWaterfallItemView.m => HippyWaterfallItemView.m} (90%) rename renderer/native/ios/renderer/component/waterfalllist/{NativeRenderWaterfallViewManager.h => HippyWaterfallItemViewManager.h} (93%) rename renderer/native/ios/renderer/component/waterfalllist/{NativeRenderWaterfallItemViewManager.mm => HippyWaterfallItemViewManager.m} (74%) rename renderer/native/ios/renderer/component/waterfalllist/{NativeRenderWaterfallView.h => HippyWaterfallView.h} (82%) rename renderer/native/ios/renderer/component/waterfalllist/{NativeRenderWaterfallView.mm => HippyWaterfallView.mm} (94%) rename renderer/native/ios/renderer/component/waterfalllist/{NativeRenderWaterfallViewCell.h => HippyWaterfallViewCell.h} (93%) rename renderer/native/ios/renderer/component/waterfalllist/{NativeRenderWaterfallViewCell.m => HippyWaterfallViewCell.m} (93%) rename renderer/native/ios/renderer/component/waterfalllist/{NativeRenderWaterfallViewDataSource.h => HippyWaterfallViewDataSource.h} (96%) rename renderer/native/ios/renderer/component/waterfalllist/{NativeRenderWaterfallViewDataSource.mm => HippyWaterfallViewDataSource.mm} (95%) rename renderer/native/ios/renderer/component/waterfalllist/{NativeRenderWaterfallItemViewManager.h => HippyWaterfallViewManager.h} (92%) rename renderer/native/ios/renderer/component/waterfalllist/{NativeRenderWaterfallViewManager.mm => HippyWaterfallViewManager.m} (74%) rename renderer/native/ios/utils/{NativeRenderGradientObject.h => HippyGradientObject.h} (66%) rename renderer/native/ios/utils/{NativeRenderGradientObject.m => HippyGradientObject.m} (85%) rename renderer/native/ios/utils/{NativeRenderUtils.h => HippyRenderUtils.h} (63%) rename renderer/native/ios/utils/{NativeRenderUtils.m => HippyRenderUtils.m} (66%) diff --git a/renderer/native/ios/renderer/HippyComponentData.h b/renderer/native/ios/renderer/HippyComponentData.h index 56d541af26c..892d663b312 100644 --- a/renderer/native/ios/renderer/HippyComponentData.h +++ b/renderer/native/ios/renderer/HippyComponentData.h @@ -22,7 +22,7 @@ #import #import "HippyComponent.h" -#import "NativeRenderDefines.h" +#import "HippyViewManager.h" @class HippyShadowView, HippyViewManager; @class UIView; diff --git a/renderer/native/ios/renderer/NativeRenderObjectRootView.h b/renderer/native/ios/renderer/HippyRootShadowView.h similarity index 94% rename from renderer/native/ios/renderer/NativeRenderObjectRootView.h rename to renderer/native/ios/renderer/HippyRootShadowView.h index ac4b9df4930..5d46ad61cf3 100644 --- a/renderer/native/ios/renderer/NativeRenderObjectRootView.h +++ b/renderer/native/ios/renderer/HippyRootShadowView.h @@ -22,7 +22,7 @@ #import "HippyShadowView.h" -@interface NativeRenderObjectRootView : HippyShadowView +@interface HippyRootShadowView : HippyShadowView /** * Calculate all views whose frame needs updating after layout has been calculated. diff --git a/renderer/native/ios/renderer/NativeRenderObjectRootView.mm b/renderer/native/ios/renderer/HippyRootShadowView.mm similarity index 93% rename from renderer/native/ios/renderer/NativeRenderObjectRootView.mm rename to renderer/native/ios/renderer/HippyRootShadowView.mm index 33b65c3a469..8609254e851 100644 --- a/renderer/native/ios/renderer/NativeRenderObjectRootView.mm +++ b/renderer/native/ios/renderer/HippyRootShadowView.mm @@ -20,11 +20,11 @@ * limitations under the License. */ -#import "NativeRenderObjectRootView.h" +#import "HippyRootShadowView.h" #import "HippyUtils.h" #import "HippyI18nUtils.h" -@implementation NativeRenderObjectRootView +@implementation HippyRootShadowView - (void)applySizeConstraints { } diff --git a/renderer/native/ios/renderer/HippyRootView.mm b/renderer/native/ios/renderer/HippyRootView.mm index 33f77e015a0..60947c36d86 100644 --- a/renderer/native/ios/renderer/HippyRootView.mm +++ b/renderer/native/ios/renderer/HippyRootView.mm @@ -24,7 +24,6 @@ #import "HippyAssert.h" #import "HippyView.h" #import "UIView+Hippy.h" -#import "NativeRenderDefines.h" #import "HippyInvalidating.h" #import "HippyBridge.h" #import "HippyUIManager.h" diff --git a/renderer/native/ios/renderer/HippyUIManager.h b/renderer/native/ios/renderer/HippyUIManager.h index c95ad3d214c..6b43f28c7c1 100644 --- a/renderer/native/ios/renderer/HippyUIManager.h +++ b/renderer/native/ios/renderer/HippyUIManager.h @@ -22,20 +22,47 @@ #import #import "HippyBridge.h" +#import "HippyViewManager.h" #import "HippyInvalidating.h" -#import "NativeRenderDefines.h" #import "HippyBridgeModule.h" #import "HippyCustomTouchHandlerProtocol.h" -@class NativeRenderAnimationViewParams; @class HippyShadowView; @class HippyUIManager; @class HippyViewManager; -@class NativeRenderReusePool; @class HippyComponentMap; @protocol HippyImageProviderProtocol; +/** + * Posted whenever a new root view is registered with HippyUIManager. The userInfo property + * will contain a HippyUIManagerRootViewKey with the registered root view. + */ +HIPPY_EXTERN NSString *const HippyUIManagerDidRegisterRootViewNotification; + +/** + * Posted whenever a root view is removed from the HippyUIManager. The userInfo property + * will contain a HippyUIManagerRootViewKey with the removed root view. + */ +HIPPY_EXTERN NSString *const HippyUIManagerDidRemoveRootViewNotification; + +/** + * Key for the root view in the above notifications + */ +HIPPY_EXTERN NSString *const HippyUIManagerRootViewKey; + +/** + * Key for the root view's HippyTag in the above notifications + */ +HIPPY_EXTERN NSString *const HippyUIManagerRootViewTagKey; + +/** + * Posted whenever endBatch is called + */ +HIPPY_EXTERN NSString *const HippyUIManagerDidEndBatchNotification; + + + /// The HippyUIManager responsible for updating the view hierarchy. @interface HippyUIManager : NSObject diff --git a/renderer/native/ios/renderer/HippyUIManager.mm b/renderer/native/ios/renderer/HippyUIManager.mm index 5862789c5b0..c0636a31d67 100644 --- a/renderer/native/ios/renderer/HippyUIManager.mm +++ b/renderer/native/ios/renderer/HippyUIManager.mm @@ -32,10 +32,10 @@ #import "HippyComponentMap.h" #import "HippyUIManager.h" #import "HippyUIManager+Private.h" -#import "NativeRenderObjectRootView.h" +#import "HippyRootShadowView.h" #import "HippyShadowView.h" #import "HippyShadowView+Internal.h" -#import "NativeRenderUtils.h" +#import "HippyRenderUtils.h" #import "HippyView.h" #import "HippyViewManager.h" #import "RenderVsyncManager.h" @@ -160,10 +160,11 @@ static void NativeRenderTraverseViewNodes(id view, void (^block) #define AssertMainQueue() NSAssert(HippyIsMainQueue(), @"This function must be called on the main thread") -NSString *const NativeRenderUIManagerDidRegisterRootViewNotification = @"NativeRenderUIManagerDidRegisterRootViewNotification"; -NSString *const NativeRenderUIManagerRootViewTagKey = @"NativeRenderUIManagerRootViewKey"; -NSString *const NativeRenderUIManagerKey = @"NativeRenderUIManagerKey"; -NSString *const NativeRenderUIManagerDidEndBatchNotification = @"NativeRenderUIManagerDidEndBatchNotification"; +NSString *const HippyUIManagerDidRegisterRootViewNotification = @"HippyUIManagerDidRegisterRootViewNotification"; +NSString *const HippyUIManagerDidRemoveRootViewNotification = @"HippyUIManagerDidRemoveRootViewNotification"; +NSString *const HippyUIManagerRootViewKey = @"HippyUIManagerRootViewKey"; +NSString *const HippyUIManagerRootViewTagKey = @"HippyUIManagerRootViewTagKey"; +NSString *const HippyUIManagerDidEndBatchNotification = @"HippyUIManagerDidEndBatchNotification"; @interface HippyUIManager() { NSMutableArray *_pendingUIBlocks; @@ -221,8 +222,8 @@ - (void)initContext { _pendingUIBlocks = [NSMutableArray new]; _componentTransactionListeners = [NSHashTable weakObjectsHashTable]; _componentDataByName = [NSMutableDictionary dictionaryWithCapacity:64]; - NativeRenderScreenScale(); - NativeRenderScreenSize(); + HippyScreenScale(); + HippyScreenSize(); } - (void)invalidate { @@ -303,46 +304,38 @@ - (HippyComponentData *)componentDataForViewName:(NSString *)viewName { - (void)registerRootView:(UIView *)rootView asRootNode:(std::weak_ptr)rootNode { AssertMainQueue(); - NSNumber *componentTag = rootView.hippyTag; - NSAssert(HippyIsHippyRootView(componentTag), @"View %@ with tag #%@ is not a root view", rootView, componentTag); + NSNumber *hippyTag = rootView.hippyTag; + NSAssert(HippyIsHippyRootView(hippyTag), @"View %@ with tag #%@ is not a root view", rootView, hippyTag); #if HIPPY_DEBUG - NSAssert(![_viewRegistry containRootComponentWithTag:componentTag], @"RootView Tag already exists. Added %@ twice", componentTag); + NSAssert(![_viewRegistry containRootComponentWithTag:hippyTag], @"RootView Tag already exists. Added %@ twice", hippyTag); #endif + // Register view - [_viewRegistry addRootComponent:rootView rootNode:rootNode forTag:componentTag]; + [_viewRegistry addRootComponent:rootView rootNode:rootNode forTag:hippyTag]; - [rootView addObserver:self forKeyPath:@"frame" options:(NSKeyValueObservingOptionOld | NSKeyValueObservingOptionNew) context:NULL]; + [rootView addObserver:self forKeyPath:@"frame" + options:(NSKeyValueObservingOptionOld | NSKeyValueObservingOptionNew) + context:NULL]; rootView.renderManager = [self renderManager]; CGRect frame = rootView.frame; - UIColor *backgroundColor = [rootView backgroundColor]; - NSString *rootViewClassName = NSStringFromClass([rootView class]); // Register shadow view - __weak HippyUIManager *weakSelf = self; - std::function registerRootViewFunction = [weakSelf, componentTag, frame, backgroundColor, rootViewClassName, rootNode](){ - @autoreleasepool { - HippyUIManager *strongSelf = weakSelf; - if (!strongSelf) { - return; - } - std::lock_guard lock([strongSelf renderQueueLock]); - NativeRenderObjectRootView *renderObject = [[NativeRenderObjectRootView alloc] init]; - renderObject.hippyTag = componentTag; - renderObject.frame = frame; - renderObject.backgroundColor = backgroundColor; - renderObject.viewName = rootViewClassName; - renderObject.rootNode = rootNode; - renderObject.domNode = rootNode; - [strongSelf->_shadowViewRegistry addRootComponent:renderObject rootNode:rootNode forTag:componentTag]; - NSDictionary *userInfo = @{ NativeRenderUIManagerRootViewTagKey: componentTag, - NativeRenderUIManagerKey: strongSelf}; - [[NSNotificationCenter defaultCenter] postNotificationName:NativeRenderUIManagerDidRegisterRootViewNotification - object:nil - userInfo:userInfo]; - } - }; - registerRootViewFunction(); + std::lock_guard lock([self renderQueueLock]); + HippyRootShadowView *shadowView = [[HippyRootShadowView alloc] init]; + shadowView.hippyTag = hippyTag; + shadowView.frame = frame; + shadowView.backgroundColor = [rootView backgroundColor]; + shadowView.viewName = NSStringFromClass([rootView class]);; + shadowView.rootNode = rootNode; + shadowView.domNode = rootNode; + [self->_shadowViewRegistry addRootComponent:shadowView rootNode:rootNode forTag:hippyTag]; + + + NSDictionary *userInfo = @{ HippyUIManagerRootViewKey: rootView, HippyUIManagerRootViewTagKey: hippyTag }; + [[NSNotificationCenter defaultCenter] postNotificationName:HippyUIManagerDidRegisterRootViewNotification + object:self + userInfo:userInfo]; } - (void)unregisterRootViewFromTag:(NSNumber *)rootTag { @@ -354,6 +347,11 @@ - (void)unregisterRootViewFromTag:(NSNumber *)rootTag { std::lock_guard lock([self renderQueueLock]); [_viewRegistry removeRootComponentWithTag:rootTag]; [_shadowViewRegistry removeRootComponentWithTag:rootTag]; + + NSDictionary *userInfo = @{ HippyUIManagerRootViewKey: rootView, HippyUIManagerRootViewTagKey: rootTag }; + [[NSNotificationCenter defaultCenter] postNotificationName:HippyUIManagerDidRemoveRootViewNotification + object:self + userInfo:userInfo]; } - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { @@ -799,7 +797,7 @@ - (void)createRenderNodes:(std::vector> &&)nodes for (const std::shared_ptr &node : nodes) { NSNumber *componentTag = @(node->GetId()); HippyShadowView *shadowView = [_shadowViewRegistry componentForTag:componentTag onRootTag:rootNodeTag]; - if (NativeRenderCreationTypeInstantly == [shadowView creationType] && !_uiCreationLazilyEnabled) { + if (HippyCreationTypeInstantly == [shadowView creationType] && !_uiCreationLazilyEnabled) { [self addUIBlock:^(HippyUIManager *uiManager, __unused NSDictionary *viewRegistry) { UIView *view = [uiManager createViewFromShadowView:shadowView]; view.hippyShadowView = shadowView; @@ -832,7 +830,7 @@ - (void)createRenderNodes:(std::vector> &&)nodes auto subViewTags_ = subviewTags; auto subViewIndices_ = subviewIndices; HippyShadowView *renderObject = [self->_shadowViewRegistry componentForTag:@(tag) onRootTag:rootNodeTag]; - if (NativeRenderCreationTypeInstantly == [renderObject creationType] && !self->_uiCreationLazilyEnabled) { + if (HippyCreationTypeInstantly == [renderObject creationType] && !self->_uiCreationLazilyEnabled) { [self addUIBlock:^(HippyUIManager *uiManager, NSDictionary *viewRegistry) { UIView *superView = viewRegistry[@(tag)]; for (NSUInteger index = 0; index < subViewTags_.size(); index++) { @@ -1061,9 +1059,9 @@ - (void)batchOnRootNode:(std::weak_ptr)rootNode { auto strongRootNode = rootNode.lock(); if (strongRootNode) { uint32_t rootNodeId = strongRootNode->GetId(); - NSDictionary *userInfo = @{NativeRenderUIManagerRootViewTagKey: @(rootNodeId)}; - [[NSNotificationCenter defaultCenter] postNotificationName:NativeRenderUIManagerDidEndBatchNotification - object:nil + NSDictionary *userInfo = @{ HippyUIManagerRootViewTagKey: @(rootNodeId) }; + [[NSNotificationCenter defaultCenter] postNotificationName:HippyUIManagerDidEndBatchNotification + object:self userInfo:userInfo]; } } diff --git a/renderer/native/ios/renderer/NativeRenderDefines.h b/renderer/native/ios/renderer/NativeRenderDefines.h deleted file mode 100644 index 7bad664813a..00000000000 --- a/renderer/native/ios/renderer/NativeRenderDefines.h +++ /dev/null @@ -1,52 +0,0 @@ -/*! - * 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. - */ - -#ifndef NativeRenderDefines_h -#define NativeRenderDefines_h -#import "HippyDefines.h" - -@class HippyUIManager, UIView, NSDictionary; - - -typedef void (^HippyViewManagerUIBlock)(HippyUIManager *uiManager, NSDictionary *viewRegistry); -/** - * Posted whenever a new root view is registered with NativeRenderUIManager. The userInfo property - * will contain a NativeRenderUIManagerRootViewKey with the registered root view. - */ -HIPPY_EXTERN NSString *const NativeRenderUIManagerDidRegisterRootViewNotification; - -/** - * Key for the root view property in the above notifications - */ -HIPPY_EXTERN NSString *const NativeRenderUIManagerRootViewTagKey; - -/** - * Key for Render UIManager - */ -HIPPY_EXTERN NSString *const NativeRenderUIManagerKey; - -/** - * Posted whenever endBatch is called - */ -HIPPY_EXTERN NSString *const NativeRenderUIManagerDidEndBatchNotification; - -#endif /* NativeRenderDefines_h */ diff --git a/renderer/native/ios/renderer/component/listview/NativeRenderBaseListItemView.h b/renderer/native/ios/renderer/component/listview/HippyNextBaseListItemView.h similarity index 88% rename from renderer/native/ios/renderer/component/listview/NativeRenderBaseListItemView.h rename to renderer/native/ios/renderer/component/listview/HippyNextBaseListItemView.h index 91a52da240f..8a97cecbdf9 100644 --- a/renderer/native/ios/renderer/component/listview/NativeRenderBaseListItemView.h +++ b/renderer/native/ios/renderer/component/listview/HippyNextBaseListItemView.h @@ -21,10 +21,10 @@ */ #import -#import "NativeRenderBaseListViewCell.h" +#import "HippyNextBaseListViewCell.h" #import "HippyView.h" -@interface NativeRenderBaseListItemView : HippyView +@interface HippyNextBaseListItemView : HippyView @property (nonatomic, strong) id type; @property (nonatomic, assign) BOOL isSticky; diff --git a/renderer/native/ios/renderer/component/listview/NativeRenderBaseListItemView.m b/renderer/native/ios/renderer/component/listview/HippyNextBaseListItemView.m similarity index 92% rename from renderer/native/ios/renderer/component/listview/NativeRenderBaseListItemView.m rename to renderer/native/ios/renderer/component/listview/HippyNextBaseListItemView.m index 00c0d4ab335..67577f54f6f 100644 --- a/renderer/native/ios/renderer/component/listview/NativeRenderBaseListItemView.m +++ b/renderer/native/ios/renderer/component/listview/HippyNextBaseListItemView.m @@ -20,11 +20,11 @@ * limitations under the License. */ -#import "NativeRenderBaseListItemView.h" +#import "HippyNextBaseListItemView.h" #import "UIView+Hippy.h" #import "UIView+MountEvent.h" -@implementation NativeRenderBaseListItemView +@implementation HippyNextBaseListItemView - (void)hippySetFrame:(CGRect)frame { [super hippySetFrame:frame]; @@ -54,8 +54,4 @@ - (void)setFrame:(CGRect)frame { [super setFrame:frame]; } -- (void)dealloc { - -} - @end diff --git a/renderer/native/ios/renderer/component/listview/NativeRenderBaseListItemViewManager.h b/renderer/native/ios/renderer/component/listview/HippyNextBaseListItemViewManager.h similarity index 92% rename from renderer/native/ios/renderer/component/listview/NativeRenderBaseListItemViewManager.h rename to renderer/native/ios/renderer/component/listview/HippyNextBaseListItemViewManager.h index 91fef6833d2..c1de0a343c4 100644 --- a/renderer/native/ios/renderer/component/listview/NativeRenderBaseListItemViewManager.h +++ b/renderer/native/ios/renderer/component/listview/HippyNextBaseListItemViewManager.h @@ -22,6 +22,6 @@ #import "HippyViewManager.h" -@interface NativeRenderBaseListItemViewManager : HippyViewManager +@interface HippyNextBaseListItemViewManager : HippyViewManager @end diff --git a/renderer/native/ios/renderer/component/listview/NativeRenderBaseListItemViewManager.mm b/renderer/native/ios/renderer/component/listview/HippyNextBaseListItemViewManager.mm similarity index 80% rename from renderer/native/ios/renderer/component/listview/NativeRenderBaseListItemViewManager.mm rename to renderer/native/ios/renderer/component/listview/HippyNextBaseListItemViewManager.mm index 381173ce438..0f1e7187826 100644 --- a/renderer/native/ios/renderer/component/listview/NativeRenderBaseListItemViewManager.mm +++ b/renderer/native/ios/renderer/component/listview/HippyNextBaseListItemViewManager.mm @@ -20,11 +20,11 @@ * limitations under the License. */ -#import "NativeRenderBaseListItemViewManager.h" -#import "NativeRenderBaseListItemView.h" -#import "NativeRenderObjectBaseListItem.h" +#import "HippyNextBaseListItemViewManager.h" +#import "HippyNextBaseListItemView.h" +#import "HippyShadowWaterfallItem.h" -@implementation NativeRenderBaseListItemViewManager +@implementation HippyNextBaseListItemViewManager HIPPY_EXPORT_MODULE(ListViewItem) @@ -36,11 +36,11 @@ @implementation NativeRenderBaseListItemViewManager HIPPY_EXPORT_VIEW_PROPERTY(onWillDisappear, HippyDirectEventBlock) - (UIView *)view { - return [[NativeRenderBaseListItemView alloc] init]; + return [[HippyNextBaseListItemView alloc] init]; } - (HippyShadowView *)hippyShadowView { - return [[NativeRenderObjectBaseListItem alloc] init]; + return [[HippyShadowWaterfallItem alloc] init]; } @end diff --git a/renderer/native/ios/renderer/component/listview/NativeRenderBaseListView.h b/renderer/native/ios/renderer/component/listview/HippyNextBaseListView.h similarity index 82% rename from renderer/native/ios/renderer/component/listview/NativeRenderBaseListView.h rename to renderer/native/ios/renderer/component/listview/HippyNextBaseListView.h index 633522e5a1f..125e6c4265d 100644 --- a/renderer/native/ios/renderer/component/listview/NativeRenderBaseListView.h +++ b/renderer/native/ios/renderer/component/listview/HippyNextBaseListView.h @@ -22,13 +22,13 @@ #import #import "HippyScrollView.h" -#import "NativeRenderListTableView.h" +#import "HippyNextListTableView.h" #import "NativeRenderTouchesView.h" -#import "NativeRenderWaterfallView.h" +#import "HippyWaterfallView.h" -@class NativeRenderBaseListViewCell; +@class HippyNextBaseListViewCell; -@interface NativeRenderBaseListView : NativeRenderWaterfallView +@interface HippyNextBaseListView : HippyWaterfallView /** * Hippy events @@ -42,9 +42,9 @@ @property(nonatomic, copy) HippyDirectEventBlock onDelete; /** - * Indication initial content offset when NativeRenderBaseListView finish loading data + * Indication initial content offset when HippyNextBaseListView finish loading data * - * @discuss This variable will be set to 0 after NativeRenderBaseListView finish loading data + * @discuss This variable will be set to 0 after HippyNextBaseListView finish loading data */ @property(nonatomic, assign) CGFloat initialContentOffset; diff --git a/renderer/native/ios/renderer/component/listview/NativeRenderBaseListView.mm b/renderer/native/ios/renderer/component/listview/HippyNextBaseListView.mm similarity index 92% rename from renderer/native/ios/renderer/component/listview/NativeRenderBaseListView.mm rename to renderer/native/ios/renderer/component/listview/HippyNextBaseListView.mm index 58191a5be31..91732f6ec39 100644 --- a/renderer/native/ios/renderer/component/listview/NativeRenderBaseListView.mm +++ b/renderer/native/ios/renderer/component/listview/HippyNextBaseListView.mm @@ -21,10 +21,10 @@ */ #import "HippyAssert.h" -#import "NativeRenderBaseListView.h" -#import "NativeRenderBaseListViewCell.h" -#import "NativeRenderBaseListViewDataSource.h" -#import "NativeRenderCollectionViewFlowLayout.h" +#import "HippyNextBaseListView.h" +#import "HippyNextBaseListViewCell.h" +#import "HippyNextBaseListViewDataSource.h" +#import "HippyNextCollectionViewFlowLayout.h" #import "HippyFooterRefresh.h" #import "HippyHeaderRefresh.h" #import "HippyUIManager.h" @@ -38,14 +38,14 @@ static NSString *const kSupplementaryIdentifier = @"HippySupplementaryIdentifier"; static NSString *const kListViewItem = @"ListViewItem"; -@interface NativeRenderBaseListView () { +@interface HippyNextBaseListView () { BOOL _isInitialListReady; NSArray *_previousVisibleCells; } @end -@implementation NativeRenderBaseListView +@implementation HippyNextBaseListView #pragma mark - Life Cycle @@ -70,13 +70,13 @@ - (NSString *)compoentItemName { } - (Class)listItemClass { - return [NativeRenderBaseListViewCell class]; + return [HippyNextBaseListViewCell class]; } - (__kindof UICollectionViewLayout *)collectionViewLayout { BOOL layoutDirectionRTL = [self isLayoutSubviewsRTL]; - [[NativeRenderCollectionViewFlowLayoutRTLStack sharedInstance] pushRTLConfig:layoutDirectionRTL]; - NativeRenderCollectionViewFlowLayout *layout = [[NativeRenderCollectionViewFlowLayout alloc] init]; + [[HippyCollectionViewFlowLayoutRTLStack sharedInstance] pushRTLConfig:layoutDirectionRTL]; + HippyNextCollectionViewFlowLayout *layout = [[HippyNextCollectionViewFlowLayout alloc] init]; layout.minimumLineSpacing = .0f; layout.minimumInteritemSpacing = .0f; layout.sectionHeadersPinToVisibleBounds = YES; @@ -92,7 +92,7 @@ - (void)applyLayoutDirectionFromParent:(hippy::Direction)direction { - (void)registerCells { Class cls = [self listItemClass]; - HippyAssert([cls isSubclassOfClass:[NativeRenderBaseListViewCell class]], + HippyAssert([cls isSubclassOfClass:[HippyNextBaseListViewCell class]], @"list item class must be subclass of NativeRenderBaseListViewCell"); [self.collectionView registerClass:cls forCellWithReuseIdentifier:kCellIdentifier]; } @@ -144,7 +144,7 @@ - (void)setScrollEnabled:(BOOL)value { // and override reloadData to handle special logic - (void)reloadData { NSArray *datasource = [self.hippyShadowView.subcomponents copy]; - self->_dataSource = [[NativeRenderBaseListViewDataSource alloc] initWithDataSource:datasource + self->_dataSource = [[HippyNextBaseListViewDataSource alloc] initWithDataSource:datasource itemViewName:[self compoentItemName] containBannerView:NO]; [self.collectionView reloadData]; @@ -266,14 +266,14 @@ - (void)collectionView:(UICollectionView *)collectionView } - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { - NativeRenderBaseListViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:kCellIdentifier forIndexPath:indexPath]; + HippyNextBaseListViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:kCellIdentifier forIndexPath:indexPath]; HippyShadowView *shadowView = [self.dataSource cellForIndexPath:indexPath]; UIView *cellView = nil; UIView *cachedVisibleCellView = [_cachedWeakCellViews objectForKey:shadowView.hippyTag]; if (cachedVisibleCellView && - [shadowView isKindOfClass:NativeRenderObjectWaterfallItem.class] && - !((NativeRenderObjectWaterfallItem *)shadowView).layoutDirty) { + [shadowView isKindOfClass:HippyShadowWaterfallItem.class] && + !((HippyShadowWaterfallItem *)shadowView).layoutDirty) { cellView = cachedVisibleCellView; HippyLogTrace(@"🟢 use cached visible cellView at %@ for %@", indexPath, shadowView.hippyTag); } else { @@ -289,10 +289,10 @@ - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cell return cell; } -- (void)tableViewDidLayoutSubviews:(NativeRenderListTableView *)tableView { +- (void)tableViewDidLayoutSubviews:(HippyNextListTableView *)tableView { [super tableViewDidLayoutSubviews:tableView]; NSArray *visibleCells = [self.collectionView visibleCells]; - for (NativeRenderBaseListViewCell *cell in visibleCells) { + for (HippyNextBaseListViewCell *cell in visibleCells) { CGRect cellRectInTableView = [self.collectionView convertRect:[cell bounds] fromView:cell]; CGRect intersection = CGRectIntersection(cellRectInTableView, [self.collectionView bounds]); if (CGRectEqualToRect(cellRectInTableView, intersection)) { @@ -304,7 +304,7 @@ - (void)tableViewDidLayoutSubviews:(NativeRenderListTableView *)tableView { if (_previousVisibleCells && ![_previousVisibleCells isEqualToArray:visibleCells]) { NSMutableArray *diff = [_previousVisibleCells mutableCopy]; [diff removeObjectsInArray:visibleCells]; - for (NativeRenderBaseListViewCell *cell in diff) { + for (HippyNextBaseListViewCell *cell in diff) { [cell setCellShowState:CellNotShowState]; } } diff --git a/renderer/native/ios/renderer/component/listview/NativeRenderBaseListViewCell.h b/renderer/native/ios/renderer/component/listview/HippyNextBaseListViewCell.h similarity index 89% rename from renderer/native/ios/renderer/component/listview/NativeRenderBaseListViewCell.h rename to renderer/native/ios/renderer/component/listview/HippyNextBaseListViewCell.h index 0f41cb4083a..196a5e6fbef 100644 --- a/renderer/native/ios/renderer/component/listview/NativeRenderBaseListViewCell.h +++ b/renderer/native/ios/renderer/component/listview/HippyNextBaseListViewCell.h @@ -21,8 +21,8 @@ */ #import -#import "NativeRenderWaterfallView.h" -#import "NativeRenderWaterfallViewCell.h" +#import "HippyWaterfallView.h" +#import "HippyWaterfallViewCell.h" NS_ASSUME_NONNULL_BEGIN @@ -42,7 +42,7 @@ typedef NS_ENUM(NSUInteger, CellShowState) { CellNotShowState, CellHalfShowState @end -@interface NativeRenderBaseListViewCell : NativeRenderWaterfallViewCell +@interface HippyNextBaseListViewCell : HippyWaterfallViewCell - (void)setCellShowState:(CellShowState)cellShowState NS_REQUIRES_SUPER; diff --git a/renderer/native/ios/renderer/component/listview/NativeRenderBaseListViewCell.m b/renderer/native/ios/renderer/component/listview/HippyNextBaseListViewCell.m similarity index 95% rename from renderer/native/ios/renderer/component/listview/NativeRenderBaseListViewCell.m rename to renderer/native/ios/renderer/component/listview/HippyNextBaseListViewCell.m index 8e3d5218445..4b16623c532 100644 --- a/renderer/native/ios/renderer/component/listview/NativeRenderBaseListViewCell.m +++ b/renderer/native/ios/renderer/component/listview/HippyNextBaseListViewCell.m @@ -20,16 +20,16 @@ * limitations under the License. */ -#import "NativeRenderBaseListViewCell.h" +#import "HippyNextBaseListViewCell.h" -@interface NativeRenderBaseListViewCell () { +@interface HippyNextBaseListViewCell () { CellShowState _cellShowState; CellShowState _previousShowState; } @end -@implementation NativeRenderBaseListViewCell +@implementation HippyNextBaseListViewCell - (instancetype)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; diff --git a/renderer/native/ios/renderer/component/listview/NativeRenderObjectBaseListItem.mm b/renderer/native/ios/renderer/component/listview/HippyNextBaseListViewDataSource.h similarity index 86% rename from renderer/native/ios/renderer/component/listview/NativeRenderObjectBaseListItem.mm rename to renderer/native/ios/renderer/component/listview/HippyNextBaseListViewDataSource.h index 1da4d000561..b6c85003d11 100644 --- a/renderer/native/ios/renderer/component/listview/NativeRenderObjectBaseListItem.mm +++ b/renderer/native/ios/renderer/component/listview/HippyNextBaseListViewDataSource.h @@ -20,8 +20,8 @@ * limitations under the License. */ -#import "NativeRenderObjectBaseListItem.h" +#import "HippyWaterfallViewDataSource.h" -@implementation NativeRenderObjectBaseListItem +@interface HippyNextBaseListViewDataSource : HippyWaterfallViewDataSource @end diff --git a/renderer/native/ios/renderer/component/listview/NativeRenderBaseListViewDataSource.mm b/renderer/native/ios/renderer/component/listview/HippyNextBaseListViewDataSource.mm similarity index 97% rename from renderer/native/ios/renderer/component/listview/NativeRenderBaseListViewDataSource.mm rename to renderer/native/ios/renderer/component/listview/HippyNextBaseListViewDataSource.mm index d9de8955b57..e4f473cfd30 100644 --- a/renderer/native/ios/renderer/component/listview/NativeRenderBaseListViewDataSource.mm +++ b/renderer/native/ios/renderer/component/listview/HippyNextBaseListViewDataSource.mm @@ -21,17 +21,17 @@ */ #import -#import "NativeRenderBaseListViewDataSource.h" +#import "HippyNextBaseListViewDataSource.h" #import "HippyShadowView.h" #import "HippyShadowListView.h" -@interface NativeRenderBaseListViewDataSource () { +@interface HippyNextBaseListViewDataSource () { NSMutableArray *_headerRenderObjects; } @end -@implementation NativeRenderBaseListViewDataSource +@implementation HippyNextBaseListViewDataSource - (void)setDataSource:(NSArray *)dataSource containBannerView:(BOOL)containBannerView { NSMutableArray *headerRenderObjects = [NSMutableArray array]; diff --git a/renderer/native/ios/renderer/component/listview/NativeRenderBaseListViewManager.h b/renderer/native/ios/renderer/component/listview/HippyNextBaseListViewManager.h similarity index 92% rename from renderer/native/ios/renderer/component/listview/NativeRenderBaseListViewManager.h rename to renderer/native/ios/renderer/component/listview/HippyNextBaseListViewManager.h index 9470a7e44da..c990faa1135 100644 --- a/renderer/native/ios/renderer/component/listview/NativeRenderBaseListViewManager.h +++ b/renderer/native/ios/renderer/component/listview/HippyNextBaseListViewManager.h @@ -22,6 +22,6 @@ #import "HippyViewManager.h" -@interface NativeRenderBaseListViewManager : HippyViewManager +@interface HippyNextBaseListViewManager : HippyViewManager @end diff --git a/renderer/native/ios/renderer/component/listview/NativeRenderBaseListViewManager.mm b/renderer/native/ios/renderer/component/listview/HippyNextBaseListViewManager.mm similarity index 86% rename from renderer/native/ios/renderer/component/listview/NativeRenderBaseListViewManager.mm rename to renderer/native/ios/renderer/component/listview/HippyNextBaseListViewManager.mm index c688755f11e..ee65c6afb3c 100644 --- a/renderer/native/ios/renderer/component/listview/NativeRenderBaseListViewManager.mm +++ b/renderer/native/ios/renderer/component/listview/HippyNextBaseListViewManager.mm @@ -20,12 +20,12 @@ * limitations under the License. */ -#import "NativeRenderBaseListViewManager.h" -#import "NativeRenderBaseListView.h" +#import "HippyNextBaseListViewManager.h" +#import "HippyNextBaseListView.h" #import "HippyShadowListView.h" #import "HippyUIManager.h" -@implementation NativeRenderBaseListViewManager +@implementation HippyNextBaseListViewManager HIPPY_EXPORT_MODULE(ListView) @@ -48,7 +48,7 @@ @implementation NativeRenderBaseListViewManager HIPPY_EXPORT_VIEW_PROPERTY(horizontal, BOOL) - (UIView *)view { - return [[NativeRenderBaseListView alloc] init]; + return [[HippyNextBaseListView alloc] init]; } - (HippyShadowView *)hippyShadowView { @@ -61,9 +61,9 @@ - (HippyShadowView *)hippyShadowView { animation:(nonnull NSNumber *)animation) { [self.bridge.uiManager addUIBlock: ^(__unused HippyUIManager *uiManager, NSDictionary *viewRegistry){ - NativeRenderBaseListView *view = (NativeRenderBaseListView *)viewRegistry[componentTag]; + HippyNextBaseListView *view = (HippyNextBaseListView *)viewRegistry[componentTag]; if (view == nil) return; - if (![view isKindOfClass:[NativeRenderBaseListView class]]) { + if (![view isKindOfClass:[HippyNextBaseListView class]]) { HippyLogError(@"Invalid view returned from registry, expecting NativeRenderBaseListView, got: %@", view); } [view scrollToIndex:view.horizontal ? xIndex.integerValue : yIndex.integerValue animated:[animation boolValue]]; @@ -76,9 +76,9 @@ - (HippyShadowView *)hippyShadowView { animation:(nonnull NSNumber *)animation) { [self.bridge.uiManager addUIBlock: ^(__unused HippyUIManager *uiManager, NSDictionary *viewRegistry){ - NativeRenderBaseListView *view = (NativeRenderBaseListView *)viewRegistry[componentTag]; + HippyNextBaseListView *view = (HippyNextBaseListView *)viewRegistry[componentTag]; if (view == nil) return ; - if (![view isKindOfClass:[NativeRenderBaseListView class]]) { + if (![view isKindOfClass:[HippyNextBaseListView class]]) { HippyLogError(@"Invalid view returned from registry, expecting NativeRenderBaseListView, got: %@", view); } [view scrollToOffset:CGPointMake([x floatValue], [y floatValue]) animated:[animation boolValue]]; diff --git a/renderer/native/ios/renderer/component/listview/NativeRenderCollectionViewFlowLayout.h b/renderer/native/ios/renderer/component/listview/HippyNextCollectionViewFlowLayout.h similarity index 83% rename from renderer/native/ios/renderer/component/listview/NativeRenderCollectionViewFlowLayout.h rename to renderer/native/ios/renderer/component/listview/HippyNextCollectionViewFlowLayout.h index 0f746959f72..02890ada2bf 100644 --- a/renderer/native/ios/renderer/component/listview/NativeRenderCollectionViewFlowLayout.h +++ b/renderer/native/ios/renderer/component/listview/HippyNextCollectionViewFlowLayout.h @@ -24,16 +24,16 @@ NS_ASSUME_NONNULL_BEGIN -@interface NativeRenderCollectionViewFlowLayoutRTLStack : NSObject +@interface HippyCollectionViewFlowLayoutRTLStack : NSObject -+ (NativeRenderCollectionViewFlowLayoutRTLStack *)sharedInstance; ++ (HippyCollectionViewFlowLayoutRTLStack *)sharedInstance; - (void)pushRTLConfig:(BOOL)isRTL; - (BOOL)popRTLConfig; @end -@interface NativeRenderCollectionViewFlowLayout : UICollectionViewFlowLayout +@interface HippyNextCollectionViewFlowLayout : UICollectionViewFlowLayout @property(nonatomic, assign) BOOL layoutDirectionRTL; @property(nonatomic, assign) BOOL flipsHorizontallyInOppositeLayoutDirection; diff --git a/renderer/native/ios/renderer/component/listview/NativeRenderCollectionViewFlowLayout.m b/renderer/native/ios/renderer/component/listview/HippyNextCollectionViewFlowLayout.m similarity index 72% rename from renderer/native/ios/renderer/component/listview/NativeRenderCollectionViewFlowLayout.m rename to renderer/native/ios/renderer/component/listview/HippyNextCollectionViewFlowLayout.m index 1020a05b24a..2256c3f0e16 100644 --- a/renderer/native/ios/renderer/component/listview/NativeRenderCollectionViewFlowLayout.m +++ b/renderer/native/ios/renderer/component/listview/HippyNextCollectionViewFlowLayout.m @@ -20,21 +20,21 @@ * limitations under the License. */ -#import "NativeRenderCollectionViewFlowLayout.h" +#import "HippyNextCollectionViewFlowLayout.h" -@interface NativeRenderCollectionViewFlowLayoutRTLStack () { +@interface HippyCollectionViewFlowLayoutRTLStack () { NSMutableArray *_stack; } @end -@implementation NativeRenderCollectionViewFlowLayoutRTLStack +@implementation HippyCollectionViewFlowLayoutRTLStack -+ (NativeRenderCollectionViewFlowLayoutRTLStack *)sharedInstance { ++ (HippyCollectionViewFlowLayoutRTLStack *)sharedInstance { static dispatch_once_t onceToken; - static NativeRenderCollectionViewFlowLayoutRTLStack *stack = nil; + static HippyCollectionViewFlowLayoutRTLStack *stack = nil; dispatch_once(&onceToken, ^{ - stack = [[NativeRenderCollectionViewFlowLayoutRTLStack alloc] init]; + stack = [[HippyCollectionViewFlowLayoutRTLStack alloc] init]; }); return stack; } @@ -47,7 +47,7 @@ - (instancetype)init { return self; } -- (NativeRenderCollectionViewFlowLayoutRTLStack *)copy { +- (HippyCollectionViewFlowLayoutRTLStack *)copy { return self; } @@ -65,10 +65,10 @@ - (BOOL)popRTLConfig { @end -@implementation NativeRenderCollectionViewFlowLayout +@implementation HippyNextCollectionViewFlowLayout - (BOOL)flipsHorizontallyInOppositeLayoutDirection { - _layoutDirectionRTL = [[NativeRenderCollectionViewFlowLayoutRTLStack sharedInstance] popRTLConfig]; + _layoutDirectionRTL = [[HippyCollectionViewFlowLayoutRTLStack sharedInstance] popRTLConfig]; return _layoutDirectionRTL; } diff --git a/renderer/native/ios/renderer/component/listview/NativeRenderListTableView.h b/renderer/native/ios/renderer/component/listview/HippyNextListTableView.h similarity index 81% rename from renderer/native/ios/renderer/component/listview/NativeRenderListTableView.h rename to renderer/native/ios/renderer/component/listview/HippyNextListTableView.h index e9784d4de7a..fa6d129ee8b 100644 --- a/renderer/native/ios/renderer/component/listview/NativeRenderListTableView.h +++ b/renderer/native/ios/renderer/component/listview/HippyNextListTableView.h @@ -24,18 +24,18 @@ NS_ASSUME_NONNULL_BEGIN -@class NativeRenderListTableView; +@class HippyNextListTableView; @protocol HippyListTableViewLayoutProtocol /** - * Invoke when NativeRenderListTableView layout its subviews + * Invoke when HippyNextListTableView layout its subviews */ -- (void)tableViewDidLayoutSubviews:(NativeRenderListTableView *)tableView; +- (void)tableViewDidLayoutSubviews:(HippyNextListTableView *)tableView; @end -@interface NativeRenderListTableView : UICollectionView +@interface HippyNextListTableView : UICollectionView @property (nonatomic, weak) id layoutDelegate; diff --git a/renderer/native/ios/renderer/component/listview/NativeRenderListTableView.m b/renderer/native/ios/renderer/component/listview/HippyNextListTableView.m similarity index 94% rename from renderer/native/ios/renderer/component/listview/NativeRenderListTableView.m rename to renderer/native/ios/renderer/component/listview/HippyNextListTableView.m index 48bcf896e19..f4fd24790e5 100644 --- a/renderer/native/ios/renderer/component/listview/NativeRenderListTableView.m +++ b/renderer/native/ios/renderer/component/listview/HippyNextListTableView.m @@ -20,9 +20,9 @@ * limitations under the License. */ -#import "NativeRenderListTableView.h" +#import "HippyNextListTableView.h" -@implementation NativeRenderListTableView +@implementation HippyNextListTableView /** * we need scroll indicator to be at top diff --git a/renderer/native/ios/renderer/component/listview/NativeRenderBaseListViewDataSource.h b/renderer/native/ios/renderer/component/listview/NativeRenderBaseListViewDataSource.h deleted file mode 100644 index bd328438d24..00000000000 --- a/renderer/native/ios/renderer/component/listview/NativeRenderBaseListViewDataSource.h +++ /dev/null @@ -1,27 +0,0 @@ -/*! - * 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 "NativeRenderWaterfallViewDataSource.h" - -@interface NativeRenderBaseListViewDataSource : NativeRenderWaterfallViewDataSource - -@end diff --git a/renderer/native/ios/renderer/component/listview/NativeRenderObjectBaseListItem.h b/renderer/native/ios/renderer/component/listview/NativeRenderObjectBaseListItem.h deleted file mode 100644 index 9b4434d1fa6..00000000000 --- a/renderer/native/ios/renderer/component/listview/NativeRenderObjectBaseListItem.h +++ /dev/null @@ -1,32 +0,0 @@ -/*! - * 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 "HippyShadowView.h" -#import "NativeRenderObjectWaterfallItem.h" - -NS_ASSUME_NONNULL_BEGIN - -@interface NativeRenderObjectBaseListItem : NativeRenderObjectWaterfallItem - -@end - -NS_ASSUME_NONNULL_END diff --git a/renderer/native/ios/renderer/component/modal/HippyModalHostViewManager.mm b/renderer/native/ios/renderer/component/modal/HippyModalHostViewManager.mm index 2d783118120..8842d547518 100644 --- a/renderer/native/ios/renderer/component/modal/HippyModalHostViewManager.mm +++ b/renderer/native/ios/renderer/component/modal/HippyModalHostViewManager.mm @@ -26,7 +26,7 @@ #import "HippyModalTransitioningDelegate.h" #import "HippyShadowView.h" #import "HippyShadowView+Internal.h" -#import "NativeRenderUtils.h" +#import "HippyRenderUtils.h" NSString * const HippyModalHostViewDismissNotification = @"HippyModalHostViewDismissNotification"; @@ -40,13 +40,13 @@ @implementation HippyModalHostShadowView - (void)insertHippySubview:(HippyShadowView *)subview atIndex:(NSInteger)atIndex{ [super insertHippySubview:subview atIndex:atIndex]; - CGRect frame = { .origin = CGPointZero, .size = NativeRenderScreenSize() }; + CGRect frame = { .origin = CGPointZero, .size = HippyScreenSize() }; [subview setLayoutFrame:frame]; } - (void)setDomManager:(std::weak_ptr)domManager { [super setDomManager:domManager]; - CGRect frame = { .origin = CGPointZero, .size = NativeRenderScreenSize() }; + CGRect frame = { .origin = CGPointZero, .size = HippyScreenSize() }; [self setLayoutFrame:frame]; } diff --git a/renderer/native/ios/renderer/component/navigator/NativeRenderNavigationControllerAnimator.h b/renderer/native/ios/renderer/component/navigator/HippyNavigationControllerAnimator.h similarity index 92% rename from renderer/native/ios/renderer/component/navigator/NativeRenderNavigationControllerAnimator.h rename to renderer/native/ios/renderer/component/navigator/HippyNavigationControllerAnimator.h index 1bb80142883..f16266d213f 100644 --- a/renderer/native/ios/renderer/component/navigator/NativeRenderNavigationControllerAnimator.h +++ b/renderer/native/ios/renderer/component/navigator/HippyNavigationControllerAnimator.h @@ -29,7 +29,7 @@ typedef NS_ENUM(NSInteger, NativeRenderNavigatorDirection) { NativeRenderNavigatorDirectionTypeBottom, }; -@interface NativeRenderNavigationControllerAnimator : NSObject +@interface HippyNavigationControllerAnimator : NSObject + (NSObject *)animatorWithAction:(UINavigationControllerOperation)action diretion:(NativeRenderNavigatorDirection)direction; diff --git a/renderer/native/ios/renderer/component/navigator/NativeRenderNavigationControllerAnimator.m b/renderer/native/ios/renderer/component/navigator/HippyNavigationControllerAnimator.m similarity index 94% rename from renderer/native/ios/renderer/component/navigator/NativeRenderNavigationControllerAnimator.m rename to renderer/native/ios/renderer/component/navigator/HippyNavigationControllerAnimator.m index cd5c4f42689..7d05441c7a8 100644 --- a/renderer/native/ios/renderer/component/navigator/NativeRenderNavigationControllerAnimator.m +++ b/renderer/native/ios/renderer/component/navigator/HippyNavigationControllerAnimator.m @@ -20,7 +20,7 @@ * limitations under the License. */ -#import "NativeRenderNavigationControllerAnimator.h" +#import "HippyNavigationControllerAnimator.h" const NSTimeInterval kTrainsitionDurationDefault = 0.4; @@ -29,20 +29,20 @@ const CGPoint topPageOrigin = { 0, -1 }; const CGPoint bottomPageOrigin = { 0, 1 }; -@interface NativeRenderNavigationControllerAnimator () +@interface HippyNavigationControllerAnimator () @property (assign, nonatomic) NativeRenderNavigatorDirection direction; @property (assign, nonatomic) UINavigationControllerOperation action; @end -@implementation NativeRenderNavigationControllerAnimator +@implementation HippyNavigationControllerAnimator + (NSObject *)animatorWithAction:(UINavigationControllerOperation)action diretion:(NativeRenderNavigatorDirection)direction { if (action == UINavigationControllerOperationNone) { return nil; } - NativeRenderNavigationControllerAnimator *animator = [NativeRenderNavigationControllerAnimator new]; + HippyNavigationControllerAnimator *animator = [HippyNavigationControllerAnimator new]; animator.action = action; animator.direction = direction; return animator; diff --git a/renderer/native/ios/renderer/component/navigator/NativeRenderNavigatorHostView.h b/renderer/native/ios/renderer/component/navigator/HippyNavigatorHostView.h similarity index 92% rename from renderer/native/ios/renderer/component/navigator/NativeRenderNavigatorHostView.h rename to renderer/native/ios/renderer/component/navigator/HippyNavigatorHostView.h index 3e8764b9bc9..42750b8ca99 100644 --- a/renderer/native/ios/renderer/component/navigator/NativeRenderNavigatorHostView.h +++ b/renderer/native/ios/renderer/component/navigator/HippyNavigatorHostView.h @@ -27,7 +27,7 @@ NS_ASSUME_NONNULL_BEGIN @protocol NavigatorHostViewDelegate @end -@interface NativeRenderNavigatorHostView : UIView +@interface HippyNavigatorHostView : UIView @property (nonatomic, weak) id delegate; diff --git a/renderer/native/ios/renderer/component/navigator/NativeRenderNavigatorHostView.m b/renderer/native/ios/renderer/component/navigator/HippyNavigatorHostView.m similarity index 85% rename from renderer/native/ios/renderer/component/navigator/NativeRenderNavigatorHostView.m rename to renderer/native/ios/renderer/component/navigator/HippyNavigatorHostView.m index 0f025ffd054..2d5575e0792 100644 --- a/renderer/native/ios/renderer/component/navigator/NativeRenderNavigatorHostView.m +++ b/renderer/native/ios/renderer/component/navigator/HippyNavigatorHostView.m @@ -20,23 +20,23 @@ * limitations under the License. */ -#import "NativeRenderNavigatorHostView.h" -#import "NativeRenderNavigationControllerAnimator.h" +#import "HippyNavigatorHostView.h" +#import "HippyNavigationControllerAnimator.h" #import "UIView+Hippy.h" -#import "NativeRenderNavigatorItemViewController.h" -#import "NativeRenderNavigatorRootViewController.h" +#import "HippyNavigatorItemViewController.h" +#import "HippyNavigatorRootViewController.h" #import "UIView+MountEvent.h" -@interface NativeRenderNavigatorHostView () { +@interface HippyNavigatorHostView () { NSDictionary *_initProps; NSString *_appName; - NativeRenderNavigatorRootViewController *_navigatorRootViewController; + HippyNavigatorRootViewController *_navigatorRootViewController; BOOL _isPresented; } @property (nonatomic, assign) NativeRenderNavigatorDirection nowDirection; @end -@implementation NativeRenderNavigatorHostView +@implementation HippyNavigatorHostView - (instancetype)initWithProps:(nonnull NSDictionary *)props { self = [super init]; @@ -71,10 +71,10 @@ - (void)presentRootView { if (!_isPresented && self.window) { _isPresented = YES; UIView *rootView = [self createRootViewForModuleName:_appName initProperties:_initProps]; - NativeRenderNavigatorItemViewController *itemViewController = [[NativeRenderNavigatorItemViewController alloc] initWithView:rootView]; + HippyNavigatorItemViewController *itemViewController = [[HippyNavigatorItemViewController alloc] initWithView:rootView]; UIViewController *presentingViewController = [self hippyViewController]; NSAssert(presentingViewController, @"no presenting view controller for navigator module"); - _navigatorRootViewController = [[NativeRenderNavigatorRootViewController alloc] initWithRootViewController:itemViewController]; + _navigatorRootViewController = [[HippyNavigatorRootViewController alloc] initWithRootViewController:itemViewController]; _navigatorRootViewController.navigationBar.hidden = YES; _navigatorRootViewController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve; _navigatorRootViewController.delegate = self; @@ -105,7 +105,7 @@ - (void)push:(NSDictionary *)params { NSString *direction = params[@"fromDirection"]; self.nowDirection = [self findDirection:direction]; UIView *rootView = [self createRootViewForModuleName:appName initProperties:initProps]; - NativeRenderNavigatorItemViewController *itemViewController = [[NativeRenderNavigatorItemViewController alloc] initWithView:rootView]; + HippyNavigatorItemViewController *itemViewController = [[HippyNavigatorItemViewController alloc] initWithView:rootView]; [_navigatorRootViewController pushViewController:itemViewController animated:animated]; } @@ -143,7 +143,7 @@ - (NativeRenderNavigatorDirection)findDirection:(NSString *)directionString { //用系统默认的 return nil; } - return [NativeRenderNavigationControllerAnimator animatorWithAction:operation diretion:self.nowDirection]; + return [HippyNavigationControllerAnimator animatorWithAction:operation diretion:self.nowDirection]; } - (void)dealloc { diff --git a/renderer/native/ios/renderer/component/navigator/NativeRenderNavigatorItemViewController.h b/renderer/native/ios/renderer/component/navigator/HippyNavigatorItemViewController.h similarity index 92% rename from renderer/native/ios/renderer/component/navigator/NativeRenderNavigatorItemViewController.h rename to renderer/native/ios/renderer/component/navigator/HippyNavigatorItemViewController.h index e568351d0c2..88016d3954a 100644 --- a/renderer/native/ios/renderer/component/navigator/NativeRenderNavigatorItemViewController.h +++ b/renderer/native/ios/renderer/component/navigator/HippyNavigatorItemViewController.h @@ -24,7 +24,7 @@ NS_ASSUME_NONNULL_BEGIN -@interface NativeRenderNavigatorItemViewController : UIViewController +@interface HippyNavigatorItemViewController : UIViewController - (instancetype)initWithView:(UIView *)view; @end diff --git a/renderer/native/ios/renderer/component/navigator/NativeRenderNavigatorItemViewController.m b/renderer/native/ios/renderer/component/navigator/HippyNavigatorItemViewController.m similarity index 86% rename from renderer/native/ios/renderer/component/navigator/NativeRenderNavigatorItemViewController.m rename to renderer/native/ios/renderer/component/navigator/HippyNavigatorItemViewController.m index 6b78fa2b101..bc7fd36c5ce 100644 --- a/renderer/native/ios/renderer/component/navigator/NativeRenderNavigatorItemViewController.m +++ b/renderer/native/ios/renderer/component/navigator/HippyNavigatorItemViewController.m @@ -20,13 +20,13 @@ * limitations under the License. */ -#import "NativeRenderNavigatorItemViewController.h" +#import "HippyNavigatorItemViewController.h" -@interface NativeRenderNavigatorItemViewController () +@interface HippyNavigatorItemViewController () @end -@implementation NativeRenderNavigatorItemViewController +@implementation HippyNavigatorItemViewController - (instancetype)initWithView:(UIView *)view { self = [super init]; diff --git a/renderer/native/ios/renderer/component/navigator/NativeRenderNavigatorRootViewController.h b/renderer/native/ios/renderer/component/navigator/HippyNavigatorRootViewController.h similarity index 91% rename from renderer/native/ios/renderer/component/navigator/NativeRenderNavigatorRootViewController.h rename to renderer/native/ios/renderer/component/navigator/HippyNavigatorRootViewController.h index a5805e11118..c855667cdd8 100644 --- a/renderer/native/ios/renderer/component/navigator/NativeRenderNavigatorRootViewController.h +++ b/renderer/native/ios/renderer/component/navigator/HippyNavigatorRootViewController.h @@ -24,7 +24,7 @@ NS_ASSUME_NONNULL_BEGIN -@interface NativeRenderNavigatorRootViewController : UINavigationController +@interface HippyNavigatorRootViewController : UINavigationController @end diff --git a/renderer/native/ios/renderer/component/navigator/NativeRenderNavigatorRootViewController.m b/renderer/native/ios/renderer/component/navigator/HippyNavigatorRootViewController.m similarity index 88% rename from renderer/native/ios/renderer/component/navigator/NativeRenderNavigatorRootViewController.m rename to renderer/native/ios/renderer/component/navigator/HippyNavigatorRootViewController.m index ec30df6ad2c..039e77af973 100644 --- a/renderer/native/ios/renderer/component/navigator/NativeRenderNavigatorRootViewController.m +++ b/renderer/native/ios/renderer/component/navigator/HippyNavigatorRootViewController.m @@ -21,13 +21,13 @@ * limitations under the License. */ -#import "NativeRenderNavigatorRootViewController.h" +#import "HippyNavigatorRootViewController.h" -@interface NativeRenderNavigatorRootViewController () +@interface HippyNavigatorRootViewController () @end -@implementation NativeRenderNavigatorRootViewController +@implementation HippyNavigatorRootViewController - (void)viewDidLoad { [super viewDidLoad]; diff --git a/renderer/native/ios/renderer/component/navigator/NativeRenderNavigatorViewManager.h b/renderer/native/ios/renderer/component/navigator/HippyNavigatorViewManager.h similarity index 86% rename from renderer/native/ios/renderer/component/navigator/NativeRenderNavigatorViewManager.h rename to renderer/native/ios/renderer/component/navigator/HippyNavigatorViewManager.h index 374c13657f4..79a8378da5f 100644 --- a/renderer/native/ios/renderer/component/navigator/NativeRenderNavigatorViewManager.h +++ b/renderer/native/ios/renderer/component/navigator/HippyNavigatorViewManager.h @@ -21,11 +21,11 @@ */ #import "HippyViewManager.h" -#import "NativeRenderNavigatorHostView.h" +#import "HippyNavigatorHostView.h" NS_ASSUME_NONNULL_BEGIN -@interface NativeRenderNavigatorViewManager : HippyViewManager +@interface HippyNavigatorViewManager : HippyViewManager @end diff --git a/renderer/native/ios/renderer/component/navigator/NativeRenderNavigatorViewManager.mm b/renderer/native/ios/renderer/component/navigator/HippyNavigatorViewManager.mm similarity index 77% rename from renderer/native/ios/renderer/component/navigator/NativeRenderNavigatorViewManager.mm rename to renderer/native/ios/renderer/component/navigator/HippyNavigatorViewManager.mm index d6ce1ab6999..48e477cb3f5 100644 --- a/renderer/native/ios/renderer/component/navigator/NativeRenderNavigatorViewManager.mm +++ b/renderer/native/ios/renderer/component/navigator/HippyNavigatorViewManager.mm @@ -21,32 +21,32 @@ */ #import "HippyUIManager.h" -#import "NativeRenderNavigatorViewManager.h" +#import "HippyNavigatorViewManager.h" -@interface NativeRenderNavigatorViewManager () +@interface HippyNavigatorViewManager () @end -@implementation NativeRenderNavigatorViewManager +@implementation HippyNavigatorViewManager HIPPY_EXPORT_MODULE(Navigator) - (UIView *)view { - NativeRenderNavigatorHostView *hostView = [[NativeRenderNavigatorHostView alloc] initWithProps:self.props]; + HippyNavigatorHostView *hostView = [[HippyNavigatorHostView alloc] initWithProps:self.props]; hostView.delegate = self; return hostView; } HIPPY_EXPORT_METHOD(push:(NSNumber *__nonnull)componentTag parms:(NSDictionary *__nonnull)params) { [self.bridge.uiManager addUIBlock:^(HippyUIManager *uiManager, NSDictionary *viewRegistry) { - NativeRenderNavigatorHostView *navigatorHostView = viewRegistry[componentTag]; + HippyNavigatorHostView *navigatorHostView = viewRegistry[componentTag]; [navigatorHostView push:params]; }]; } HIPPY_EXPORT_METHOD(pop:(NSNumber *__nonnull)componentTag parms:(NSDictionary *__nonnull)params) { [self.bridge.uiManager addUIBlock:^(HippyUIManager *uiManager, NSDictionary *viewRegistry) { - NativeRenderNavigatorHostView *navigatorHostView = viewRegistry[componentTag]; + HippyNavigatorHostView *navigatorHostView = viewRegistry[componentTag]; [navigatorHostView pop:params]; }]; } diff --git a/renderer/native/ios/renderer/component/smartViewPager/NativeRenderSmartViewPagerView.h b/renderer/native/ios/renderer/component/smartViewPager/NativeRenderSmartViewPagerView.h index 263d7a06e27..08b859cf21c 100644 --- a/renderer/native/ios/renderer/component/smartViewPager/NativeRenderSmartViewPagerView.h +++ b/renderer/native/ios/renderer/component/smartViewPager/NativeRenderSmartViewPagerView.h @@ -22,14 +22,14 @@ #import #import "HippyComponent.h" -#import "NativeRenderListTableView.h" -#import "NativeRenderWaterfallView.h" +#import "HippyNextListTableView.h" +#import "HippyWaterfallView.h" NS_ASSUME_NONNULL_BEGIN -@class NativeRenderBaseListViewCell; +@class HippyNextBaseListViewCell; -@interface NativeRenderSmartViewPagerView : NativeRenderWaterfallView +@interface NativeRenderSmartViewPagerView : HippyWaterfallView /** * Hippy events diff --git a/renderer/native/ios/renderer/component/smartViewPager/NativeRenderSmartViewPagerView.mm b/renderer/native/ios/renderer/component/smartViewPager/NativeRenderSmartViewPagerView.mm index 91c53a9292d..19837cc5a8f 100644 --- a/renderer/native/ios/renderer/component/smartViewPager/NativeRenderSmartViewPagerView.mm +++ b/renderer/native/ios/renderer/component/smartViewPager/NativeRenderSmartViewPagerView.mm @@ -20,8 +20,8 @@ * limitations under the License. */ -#import "NativeRenderBaseListViewCell.h" -#import "NativeRenderBaseListViewDataSource.h" +#import "HippyNextBaseListViewCell.h" +#import "HippyNextBaseListViewDataSource.h" #import "HippyFooterRefresh.h" #import "HippyHeaderRefresh.h" #import "HippyUIManager.h" @@ -62,7 +62,7 @@ @implementation NativeRenderSmartViewPagerView - (instancetype)initWithFrame:(CGRect)frame { if (self = [super initWithFrame:frame]) { _isInitialListReady = NO; - _dataSource = [[NativeRenderBaseListViewDataSource alloc] init]; + _dataSource = [[HippyNextBaseListViewDataSource alloc] init]; self.dataSource.itemViewName = [self compoentItemName]; [self initialization]; self.collectionView.alwaysBounceVertical = NO; @@ -238,7 +238,7 @@ - (NSString *)compoentItemName { } - (Class)listItemClass { - return [NativeRenderBaseListViewCell class]; + return [HippyNextBaseListViewCell class]; } - (__kindof UICollectionViewLayout *)collectionViewLayout { @@ -252,7 +252,7 @@ - (__kindof UICollectionViewLayout *)collectionViewLayout { - (void)registerCells { Class cls = [self listItemClass]; - NSAssert([cls isSubclassOfClass:[NativeRenderBaseListViewCell class]], @"list item class must be a subclass of NativeRenderBaseListViewCell"); + NSAssert([cls isSubclassOfClass:[HippyNextBaseListViewCell class]], @"list item class must be a subclass of NativeRenderBaseListViewCell"); [self.collectionView registerClass:cls forCellWithReuseIdentifier:kCellIdentifier]; } @@ -336,7 +336,7 @@ - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSe - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { NSInteger cellIndex = _itemIndexArray[indexPath.row].integerValue; NSIndexPath *adjustIndexPath = [NSIndexPath indexPathForRow:cellIndex inSection:indexPath.section]; - NativeRenderBaseListViewCell *cell = (NativeRenderBaseListViewCell *)[collectionView dequeueReusableCellWithReuseIdentifier:kCellIdentifier forIndexPath:adjustIndexPath]; + HippyNextBaseListViewCell *cell = (HippyNextBaseListViewCell *)[collectionView dequeueReusableCellWithReuseIdentifier:kCellIdentifier forIndexPath:adjustIndexPath]; return cell; } @@ -354,17 +354,17 @@ - (void)collectionView:(UICollectionView *)collectionView forItemAtIndexPath:(NSIndexPath *)indexPath { NSInteger cellIndex = _itemIndexArray[indexPath.row].integerValue; NSIndexPath *adjustIndexPath = [NSIndexPath indexPathForRow:cellIndex inSection:indexPath.section]; - NativeRenderWaterfallViewCell *hpCell = (NativeRenderWaterfallViewCell *)cell; + HippyWaterfallViewCell *hpCell = (HippyWaterfallViewCell *)cell; HippyShadowView *renderObject = [_dataSource cellForIndexPath:adjustIndexPath]; UIView *cellView = [self.renderImpl createViewForShadowListItem:renderObject]; hpCell.cellView = cellView; cellView.parent = self; } -- (void)tableViewDidLayoutSubviews:(NativeRenderListTableView *)tableView { +- (void)tableViewDidLayoutSubviews:(HippyNextListTableView *)tableView { [super tableViewDidLayoutSubviews:tableView]; NSArray *visibleCells = [self.collectionView visibleCells]; - for (NativeRenderBaseListViewCell *cell in visibleCells) { + for (HippyNextBaseListViewCell *cell in visibleCells) { CGRect cellRectInTableView = [self.collectionView convertRect:[cell bounds] fromView:cell]; CGRect intersection = CGRectIntersection(cellRectInTableView, [self.collectionView bounds]); if (CGRectEqualToRect(cellRectInTableView, intersection)) { @@ -376,7 +376,7 @@ - (void)tableViewDidLayoutSubviews:(NativeRenderListTableView *)tableView { if (_previousVisibleCells && ![_previousVisibleCells isEqualToArray:visibleCells]) { NSMutableArray *diff = [_previousVisibleCells mutableCopy]; [diff removeObjectsInArray:visibleCells]; - for (NativeRenderBaseListViewCell *cell in diff) { + for (HippyNextBaseListViewCell *cell in diff) { [cell setCellShowState:CellNotShowState]; } } diff --git a/renderer/native/ios/renderer/component/text/HippyShadowText.mm b/renderer/native/ios/renderer/component/text/HippyShadowText.mm index a3a083713d3..46b3e36c56e 100644 --- a/renderer/native/ios/renderer/component/text/HippyShadowText.mm +++ b/renderer/native/ios/renderer/component/text/HippyShadowText.mm @@ -28,7 +28,7 @@ #import "HippyShadowView+Internal.h" #import "HippyText.h" #import "HippyTextView.h" -#import "NativeRenderUtils.h" +#import "HippyRenderUtils.h" #include "dom/dom_manager.h" #include "dom/dom_node.h" @@ -258,15 +258,15 @@ - (void)amendLayoutBeforeMount:(NSMutableSet *)blocks effectiveRange:nil withoutAdditionalLayout:YES]; CGPoint location = [layoutManager locationForGlyphAtIndex:range.location]; - CGFloat roundedHeight = NativeRenderRoundPixelValue(height); - CGFloat roundedWidth = NativeRenderRoundPixelValue(width); + CGFloat roundedHeight = HippyRoundPixelValue(height); + CGFloat roundedWidth = HippyRoundPixelValue(width); // take margin into account // FIXME: margin currently not working, may have some bug in layout process float left = 0; float top = 0; float marginV = child.nodeLayoutResult.marginTop + child.nodeLayoutResult.marginBottom; - CGFloat roundedHeightWithMargin = NativeRenderRoundPixelValue(height + marginV); + CGFloat roundedHeightWithMargin = HippyRoundPixelValue(height + marginV); CGFloat positionY = .0f; NSNumber *verticalAlignType = [textStorage attribute:HippyTextVerticalAlignAttributeName @@ -301,7 +301,7 @@ - (void)amendLayoutBeforeMount:(NSMutableSet *)blocks textFrame.origin.y + positionY + top, roundedWidth, roundedHeight); CGRect childFrame = child.frame; - if (!NativeRenderCGRectNearlyEqual(childFrame, childFrameToSet)) { + if (!HippyCGRectNearlyEqual(childFrame, childFrameToSet)) { [child setLayoutFrame:childFrameToSet dirtyPropagation:NO]; } } @@ -771,7 +771,7 @@ - (CGRect)updateStorage:(NSTextStorage *)textStorage toFitFrame:(CGRect)frame { } // Vertically center draw position for new text sizing. - frame.origin.y = self.paddingAsInsets.top + NativeRenderRoundPixelValue((CGRectGetHeight(frame) - requiredSize.height) / 2.0f); + frame.origin.y = self.paddingAsInsets.top + HippyRoundPixelValue((CGRectGetHeight(frame) - requiredSize.height) / 2.0f); return frame; } diff --git a/renderer/native/ios/renderer/component/view/HippyShadowView.h b/renderer/native/ios/renderer/component/view/HippyShadowView.h index 3501a9dc461..c6c359053e7 100644 --- a/renderer/native/ios/renderer/component/view/HippyShadowView.h +++ b/renderer/native/ios/renderer/component/view/HippyShadowView.h @@ -34,10 +34,10 @@ typedef NS_ENUM(NSUInteger, NativeRenderUpdateLifecycle) { NativeRenderUpdateLifecycleAllDirtied = 4, }; -typedef NS_ENUM(NSUInteger, NativeRenderCreationType) { - NativeRenderCreationTypeUndetermined = 0, - NativeRenderCreationTypeInstantly, - NativeRenderCreationTypeLazily, +typedef NS_ENUM(NSUInteger, HippyCreationType) { + HippyCreationTypeUndetermined = 0, + HippyCreationTypeInstantly, + HippyCreationTypeLazily, }; @class HippyShadowView; @@ -124,13 +124,13 @@ typedef void (^HippyViewInsertionBlock)(UIView *container, NSArray *ch /** * Indicate how we create coresponding UIView - * NativeRenderCreationTypeInstantly : create views instantly when NativeRenderObject is created - * NativeRenderCreationTypeLazily: create views when UIView is needed + * HippyCreationTypeInstantly : create views instantly when NativeRenderObject is created + * HippyCreationTypeLazily: create views when UIView is needed */ -@property (nonatomic, assign) NativeRenderCreationType creationType; +@property (nonatomic, assign) HippyCreationType creationType; /** - * set create type of itself and its all descendants to NativeRenderCreationTypeInstantly + * set create type of itself and its all descendants to HippyCreationTypeInstantly */ - (void)synchronousRecusivelySetCreationTypeToInstant; diff --git a/renderer/native/ios/renderer/component/view/HippyShadowView.mm b/renderer/native/ios/renderer/component/view/HippyShadowView.mm index 43bce5d049d..3688d2a04f1 100644 --- a/renderer/native/ios/renderer/component/view/HippyShadowView.mm +++ b/renderer/native/ios/renderer/component/view/HippyShadowView.mm @@ -143,14 +143,14 @@ - (BOOL)isTextDirty { return NO; } -- (NativeRenderCreationType)creationType { - if (NativeRenderCreationTypeUndetermined == _creationType) { +- (HippyCreationType)creationType { + if (HippyCreationTypeUndetermined == _creationType) { HippyShadowView *superRenderObject = [self parent]; if (superRenderObject && ![superRenderObject isHippyRootView]) { _creationType = [superRenderObject creationType]; } else { - _creationType = NativeRenderCreationTypeInstantly; + _creationType = HippyCreationTypeInstantly; } } return _creationType; @@ -161,7 +161,7 @@ - (void)setTextComputed { } - (void)synchronousRecusivelySetCreationTypeToInstant { - self.creationType = NativeRenderCreationTypeInstantly; + self.creationType = HippyCreationTypeInstantly; for (HippyShadowView *subShadowView in self.subcomponents) { [subShadowView synchronousRecusivelySetCreationTypeToInstant]; } diff --git a/renderer/native/ios/renderer/component/view/HippyView.h b/renderer/native/ios/renderer/component/view/HippyView.h index d388230eed5..fee1cc7d928 100644 --- a/renderer/native/ios/renderer/component/view/HippyView.h +++ b/renderer/native/ios/renderer/component/view/HippyView.h @@ -25,7 +25,7 @@ #import "HippyComponent.h" #import "NativeRenderTouchesView.h" -@class NativeRenderGradientObject; +@class HippyGradientObject; @interface HippyView : NativeRenderTouchesView @@ -91,5 +91,5 @@ @property (nonatomic, strong) NSString *backgroundSize; @property (nonatomic, assign) CGFloat backgroundPositionX; @property (nonatomic, assign) CGFloat backgroundPositionY; -@property (nonatomic, strong) NativeRenderGradientObject *gradientObject; +@property (nonatomic, strong) HippyGradientObject *gradientObject; @end diff --git a/renderer/native/ios/renderer/component/view/HippyView.m b/renderer/native/ios/renderer/component/view/HippyView.m index fb3c93b1d2e..c3e2a05a8b4 100644 --- a/renderer/native/ios/renderer/component/view/HippyView.m +++ b/renderer/native/ios/renderer/component/view/HippyView.m @@ -23,7 +23,7 @@ #import "HippyConvert.h" #import "HippyUtils.h" #import "HippyBorderDrawing.h" -#import "NativeRenderGradientObject.h" +#import "HippyGradientObject.h" #import "HippyView.h" #import "UIView+DomEvent.h" #import "UIView+Hippy.h" diff --git a/renderer/native/ios/renderer/component/view/HippyViewManager.h b/renderer/native/ios/renderer/component/view/HippyViewManager.h index 3c3dc8d39f6..3143e0798e6 100644 --- a/renderer/native/ios/renderer/component/view/HippyViewManager.h +++ b/renderer/native/ios/renderer/component/view/HippyViewManager.h @@ -22,11 +22,16 @@ #import #import "HippyConvert.h" -#import "NativeRenderDefines.h" #import "HippyBridgeModule.h" @class HippyBridge; @class HippyShadowView; +@class HippyUIManager; + + +typedef void (^HippyViewManagerUIBlock)(HippyUIManager *uiManager, + NSDictionary *viewRegistry); + @interface HippyViewManager : NSObject @@ -72,7 +77,7 @@ * This handles the simple case, where JS and native property names match. */ #define HIPPY_EXPORT_VIEW_PROPERTY(name, type) \ - typedef type HippyTypeExistCheck##type; \ + typedef type HIPPY_CONCAT(HippyTypeExistCheck, __COUNTER__); \ +(NSArray *)propConfig_##name { \ return @[@ #type]; \ } diff --git a/renderer/native/ios/renderer/component/view/HippyViewManager.mm b/renderer/native/ios/renderer/component/view/HippyViewManager.mm index 0caef284acb..8592a216464 100644 --- a/renderer/native/ios/renderer/component/view/HippyViewManager.mm +++ b/renderer/native/ios/renderer/component/view/HippyViewManager.mm @@ -25,7 +25,7 @@ #import "HippyConvert+NativeRender.h" #import "HippyImageProviderProtocol.h" #import "HippyUtils.h" -#import "NativeRenderGradientObject.h" +#import "HippyGradientObject.h" #import "HippyUIManager.h" #import "HippyShadowView.h" #import "HippyShadowView+Internal.h" @@ -299,7 +299,7 @@ - (void)loadImageSource:(NSString *)path forView:(HippyView *)view { HIPPY_CUSTOM_VIEW_PROPERTY(linearGradient, NSDictionary, HippyView) { if (json) { NSDictionary *linearGradientObject = [HippyConvert NSDictionary:json]; - view.gradientObject = [[NativeRenderGradientObject alloc] initWithGradientObject:linearGradientObject]; + view.gradientObject = [[HippyGradientObject alloc] initWithGradientObject:linearGradientObject]; [view.layer setNeedsDisplay]; } else { diff --git a/renderer/native/ios/renderer/component/waterfalllist/NativeRenderCollectionViewWaterfallLayout.h b/renderer/native/ios/renderer/component/waterfalllist/HippyCollectionViewWaterfallLayout.h similarity index 86% rename from renderer/native/ios/renderer/component/waterfalllist/NativeRenderCollectionViewWaterfallLayout.h rename to renderer/native/ios/renderer/component/waterfalllist/HippyCollectionViewWaterfallLayout.h index 93a0f0e4db7..eb7d90ed3ab 100644 --- a/renderer/native/ios/renderer/component/waterfalllist/NativeRenderCollectionViewWaterfallLayout.h +++ b/renderer/native/ios/renderer/component/waterfalllist/HippyCollectionViewWaterfallLayout.h @@ -25,10 +25,10 @@ /** * Enumerated structure to define direction in which items can be rendered. */ -typedef NS_ENUM(NSUInteger, NativeRenderCollectionViewWaterfallLayoutItemRenderDirection) { - NativeRenderCollectionViewWaterfallLayoutItemRenderDirectionShortestFirst, - NativeRenderCollectionViewWaterfallLayoutItemRenderDirectionLeftToRight, - NativeRenderCollectionViewWaterfallLayoutItemRenderDirectionRightToLeft +typedef NS_ENUM(NSUInteger, HippyCollectionViewWaterfallLayoutItemRenderDirection) { + HippyCollectionViewWaterfallLayoutItemRenderDirectionShortestFirst, + HippyCollectionViewWaterfallLayoutItemRenderDirectionLeftToRight, + HippyCollectionViewWaterfallLayoutItemRenderDirectionRightToLeft }; /** @@ -36,23 +36,23 @@ typedef NS_ENUM(NSUInteger, NativeRenderCollectionViewWaterfallLayoutItemRenderD */ /// A supplementary view that identifies the header for a given section. -extern NSString *const NativeRenderCollectionElementKindSectionHeader; +extern NSString *const HippyCollectionElementKindSectionHeader; /// A supplementary view that identifies the footer for a given section. -extern NSString *const NativeRenderCollectionElementKindSectionFooter; +extern NSString *const HippyCollectionElementKindSectionFooter; -#pragma mark - NativeRenderCollectionViewDelegateWaterfallLayout +#pragma mark - HippyCollectionViewDelegateWaterfallLayout -@class NativeRenderCollectionViewWaterfallLayout; +@class HippyCollectionViewWaterfallLayout; /** - * The NativeRenderCollectionViewDelegateWaterfallLayout protocol defines methods that let you coordinate with a - * NativeRenderCollectionViewWaterfallLayout object to implement a waterfall-based layout. + * The HippyCollectionViewDelegateWaterfallLayout protocol defines methods that let you coordinate with a + * HippyCollectionViewWaterfallLayout object to implement a waterfall-based layout. * The methods of this protocol define the size of items. * * The waterfall layout object expects the collection view’s delegate object to adopt this protocol. * Therefore, implement this protocol on object assigned to your collection view’s delegate property. */ -@protocol NativeRenderCollectionViewDelegateWaterfallLayout +@protocol HippyCollectionViewDelegateWaterfallLayout @required /** * Asks the delegate for the size of the specified item’s cell. @@ -242,23 +242,23 @@ extern NSString *const NativeRenderCollectionElementKindSectionFooter; @end -#pragma mark - NativeRenderCollectionViewWaterfallLayout +#pragma mark - HippyCollectionViewWaterfallLayout /** - * The NativeRenderCollectionViewWaterfallLayout class is a concrete layout object that organizes items into waterfall-based grids + * The HippyCollectionViewWaterfallLayout class is a concrete layout object that organizes items into waterfall-based grids * with optional header and footer views for each section. * * A waterfall layout works with the collection view’s delegate object to determine the size of items, headers, and footers - * in each section. That delegate object must conform to the `NativeRenderCollectionViewDelegateWaterfallLayout` protocol. + * in each section. That delegate object must conform to the `HippyCollectionViewDelegateWaterfallLayout` protocol. * * Each section in a waterfall layout can have its own custom header and footer. To configure the header or footer for a view, * you must configure the height of the header or footer to be non zero. You can do this by implementing the appropriate delegate * methods or by assigning appropriate values to the `headerHeight` and `footerHeight` properties. * If the header or footer height is 0, the corresponding view is not added to the collection view. * - * @note NativeRenderCollectionViewWaterfallLayout doesn't support decoration view, and it supports vertical scrolling direction only. + * @note HippyCollectionViewWaterfallLayout doesn't support decoration view, and it supports vertical scrolling direction only. */ -@interface NativeRenderCollectionViewWaterfallLayout : UICollectionViewLayout +@interface HippyCollectionViewWaterfallLayout : UICollectionViewLayout /** * @brief How many columns for this layout. @@ -335,13 +335,13 @@ extern NSString *const NativeRenderCollectionElementKindSectionFooter; /** * @brief The direction in which items will be rendered in subsequent rows. * @discussion - * The direction in which each item is rendered. This could be left to right (NativeRenderCollectionViewWaterfallLayoutItemRenderDirectionLeftToRight), - * right to left (NativeRenderCollectionViewWaterfallLayoutItemRenderDirectionRightToLeft), or shortest column fills first - * (NativeRenderCollectionViewWaterfallLayoutItemRenderDirectionShortestFirst). + * The direction in which each item is rendered. This could be left to right (HippyCollectionViewWaterfallLayoutItemRenderDirectionLeftToRight), + * right to left (HippyCollectionViewWaterfallLayoutItemRenderDirectionRightToLeft), or shortest column fills first + * (HippyCollectionViewWaterfallLayoutItemRenderDirectionShortestFirst). * - * Default: NativeRenderCollectionViewWaterfallLayoutItemRenderDirectionShortestFirst + * Default: HippyCollectionViewWaterfallLayoutItemRenderDirectionShortestFirst */ -@property (nonatomic, assign) NativeRenderCollectionViewWaterfallLayoutItemRenderDirection itemRenderDirection; +@property (nonatomic, assign) HippyCollectionViewWaterfallLayoutItemRenderDirection itemRenderDirection; /** * @brief The minimum height of the collection view's content. diff --git a/renderer/native/ios/renderer/component/waterfalllist/NativeRenderCollectionViewWaterfallLayout.m b/renderer/native/ios/renderer/component/waterfalllist/HippyCollectionViewWaterfallLayout.m similarity index 90% rename from renderer/native/ios/renderer/component/waterfalllist/NativeRenderCollectionViewWaterfallLayout.m rename to renderer/native/ios/renderer/component/waterfalllist/HippyCollectionViewWaterfallLayout.m index 9c7103e02e0..ccda6ad053d 100644 --- a/renderer/native/ios/renderer/component/waterfalllist/NativeRenderCollectionViewWaterfallLayout.m +++ b/renderer/native/ios/renderer/component/waterfalllist/HippyCollectionViewWaterfallLayout.m @@ -20,15 +20,15 @@ * limitations under the License. */ -#import "NativeRenderCollectionViewWaterfallLayout.h" +#import "HippyCollectionViewWaterfallLayout.h" #import "tgmath.h" -NSString *const NativeRenderCollectionElementKindSectionHeader = @"NativeRenderCollectionElementKindSectionHeader"; -NSString *const NativeRenderCollectionElementKindSectionFooter = @"NativeRenderCollectionElementKindSectionFooter"; +NSString *const HippyCollectionElementKindSectionHeader = @"HippyCollectionElementKindSectionHeader"; +NSString *const HippyCollectionElementKindSectionFooter = @"HippyCollectionElementKindSectionFooter"; -@interface NativeRenderCollectionViewWaterfallLayout () +@interface HippyCollectionViewWaterfallLayout () /// The delegate will point to collection view's delegate automatically. -@property (nonatomic, weak) id delegate; +@property (nonatomic, weak) id delegate; /// Array to store height for each column @property (nonatomic, strong) NSMutableArray *columnHeights; /// Array of arrays. Each array stores item attributes for each section @@ -43,12 +43,12 @@ @interface NativeRenderCollectionViewWaterfallLayout () @property (nonatomic, strong) NSMutableArray *unionRects; @end -@implementation NativeRenderCollectionViewWaterfallLayout +@implementation HippyCollectionViewWaterfallLayout /// How many items to be union into a single rectangle static const NSInteger unionSize = 20; -static CGFloat NativeRenderFloorCGFloat(CGFloat value) { +static CGFloat HippyFloorCGFloat(CGFloat value) { CGFloat scale = [UIScreen mainScreen].scale; return floor(value * scale) / scale; } @@ -110,7 +110,7 @@ - (void)setSectionInset:(UIEdgeInsets)sectionInset { } } -- (void)setItemRenderDirection:(NativeRenderCollectionViewWaterfallLayoutItemRenderDirection)itemRenderDirection { +- (void)setItemRenderDirection:(HippyCollectionViewWaterfallLayoutItemRenderDirection)itemRenderDirection { if (_itemRenderDirection != itemRenderDirection) { _itemRenderDirection = itemRenderDirection; [self invalidateLayout]; @@ -140,7 +140,7 @@ - (CGFloat)itemWidthInSectionAtIndex:(NSInteger)section { columnSpacing = [self.delegate collectionView:self.collectionView layout:self minimumColumnSpacingForSectionAtIndex:section]; } - return NativeRenderFloorCGFloat((width - (columnCount - 1) * columnSpacing) / columnCount); + return HippyFloorCGFloat((width - (columnCount - 1) * columnSpacing) / columnCount); } #pragma mark - Private Accessors @@ -186,8 +186,8 @@ - (NSMutableArray *)sectionItemAttributes { return _sectionItemAttributes; } -- (id)delegate { - return (id)self.collectionView.delegate; +- (id)delegate { + return (id)self.collectionView.delegate; } #pragma mark - Init @@ -200,7 +200,7 @@ - (void)commonInit { _sectionInset = UIEdgeInsetsZero; _headerInset = UIEdgeInsetsZero; _footerInset = UIEdgeInsetsZero; - _itemRenderDirection = NativeRenderCollectionViewWaterfallLayoutItemRenderDirectionShortestFirst; + _itemRenderDirection = HippyCollectionViewWaterfallLayoutItemRenderDirectionShortestFirst; } - (id)init { @@ -228,8 +228,8 @@ - (void)prepareLayout { return; } - NSAssert([self.delegate conformsToProtocol:@protocol(NativeRenderCollectionViewDelegateWaterfallLayout)], - @"UICollectionView's delegate should conform to NativeRenderCollectionViewDelegateWaterfallLayout protocol"); + NSAssert([self.delegate conformsToProtocol:@protocol(HippyCollectionViewDelegateWaterfallLayout)], + @"UICollectionView's delegate should conform to HippyCollectionViewDelegateWaterfallLayout protocol"); NSAssert(self.columnCount > 0 || [self.delegate respondsToSelector:@selector(collectionView:layout:columnCountForSection:)], @"UICollectionViewWaterfallLayout's columnCount should be greater than 0, or delegate must implement columnCountForSection:"); @@ -371,7 +371,7 @@ - (void)createItemAttributesInSection:(NSInteger)section { CGFloat width = self.collectionView.bounds.size.width - sectionInset.left - sectionInset.right; NSInteger columnCount = [self columnCountForSection:section]; - CGFloat itemWidth = NativeRenderFloorCGFloat((width - (columnCount - 1) * columnSpacing) / columnCount); + CGFloat itemWidth = HippyFloorCGFloat((width - (columnCount - 1) * columnSpacing) / columnCount); NSInteger itemCount = [self.collectionView numberOfItemsInSection:section]; NSMutableArray *itemAttributes = [NSMutableArray arrayWithCapacity:itemCount]; @@ -383,7 +383,7 @@ - (void)createItemAttributesInSection:(NSInteger)section { CGSize itemSize = [self.delegate collectionView:self.collectionView layout:self sizeForItemAtIndexPath:indexPath]; CGFloat itemHeight = 0; if (itemSize.height > 0 && itemSize.width > 0) { - itemHeight = NativeRenderFloorCGFloat(itemSize.height * itemWidth / itemSize.width); + itemHeight = HippyFloorCGFloat(itemSize.height * itemWidth / itemSize.width); } UICollectionViewLayoutAttributes *attributes = [UICollectionViewLayoutAttributes layoutAttributesForCellWithIndexPath:indexPath]; @@ -405,7 +405,7 @@ - (void)createHeadersAttributeInSection:(NSInteger)section top:(CGFloat *)top { if (headerHeight > 0) { UICollectionViewLayoutAttributes *attributes = - [UICollectionViewLayoutAttributes layoutAttributesForSupplementaryViewOfKind:NativeRenderCollectionElementKindSectionHeader + [UICollectionViewLayoutAttributes layoutAttributesForSupplementaryViewOfKind:HippyCollectionElementKindSectionHeader withIndexPath:[NSIndexPath indexPathForItem:0 inSection:section]]; CGFloat startX = headerInset.left; CGFloat width = self.collectionView.bounds.size.width - (headerInset.left + headerInset.right); @@ -436,7 +436,7 @@ - (void)createFootersAttributeInSection:(NSInteger)section top:(CGFloat *)top { if (footerHeight > 0) { UICollectionViewLayoutAttributes *attributes = - [UICollectionViewLayoutAttributes layoutAttributesForSupplementaryViewOfKind:NativeRenderCollectionElementKindSectionFooter + [UICollectionViewLayoutAttributes layoutAttributesForSupplementaryViewOfKind:HippyCollectionElementKindSectionFooter withIndexPath:[NSIndexPath indexPathForItem:0 inSection:section]]; attributes.frame = CGRectMake(footerInset.left, *top, self.collectionView.bounds.size.width - (footerInset.left + footerInset.right), footerHeight); @@ -476,9 +476,9 @@ - (UICollectionViewLayoutAttributes *)layoutAttributesForItemAtIndexPath:(NSInde - (UICollectionViewLayoutAttributes *)layoutAttributesForSupplementaryViewOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath { UICollectionViewLayoutAttributes *attribute = nil; - if ([kind isEqualToString:NativeRenderCollectionElementKindSectionHeader]) { + if ([kind isEqualToString:HippyCollectionElementKindSectionHeader]) { attribute = self.headersAttribute[@(indexPath.section)]; - } else if ([kind isEqualToString:NativeRenderCollectionElementKindSectionFooter]) { + } else if ([kind isEqualToString:HippyCollectionElementKindSectionFooter]) { attribute = self.footersAttribute[@(indexPath.section)]; } return attribute; @@ -495,9 +495,9 @@ - (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect { if (CGRectIntersectsRect(rect, attr.frame)) { switch (attr.representedElementCategory) { case UICollectionElementCategorySupplementaryView: - if ([attr.representedElementKind isEqualToString:NativeRenderCollectionElementKindSectionHeader]) { + if ([attr.representedElementKind isEqualToString:HippyCollectionElementKindSectionHeader]) { supplHeaderAttrDict[attr.indexPath] = attr; - } else if ([attr.representedElementKind isEqualToString:NativeRenderCollectionElementKindSectionFooter]) { + } else if ([attr.representedElementKind isEqualToString:HippyCollectionElementKindSectionFooter]) { supplFooterAttrDict[attr.indexPath] = attr; } break; @@ -598,15 +598,15 @@ - (NSUInteger)nextColumnIndexForItem:(NSInteger)item inSection:(NSInteger)sectio NSUInteger index = 0; NSInteger columnCount = [self columnCountForSection:section]; switch (self.itemRenderDirection) { - case NativeRenderCollectionViewWaterfallLayoutItemRenderDirectionShortestFirst: + case HippyCollectionViewWaterfallLayoutItemRenderDirectionShortestFirst: index = [self shortestColumnIndexInSection:section]; break; - case NativeRenderCollectionViewWaterfallLayoutItemRenderDirectionLeftToRight: + case HippyCollectionViewWaterfallLayoutItemRenderDirectionLeftToRight: index = (item % columnCount); break; - case NativeRenderCollectionViewWaterfallLayoutItemRenderDirectionRightToLeft: + case HippyCollectionViewWaterfallLayoutItemRenderDirectionRightToLeft: index = (columnCount - 1) - (item % columnCount); break; diff --git a/renderer/native/ios/renderer/component/waterfalllist/HippyShadowListView.h b/renderer/native/ios/renderer/component/waterfalllist/HippyShadowListView.h index c36233db9ef..d055174d6ff 100644 --- a/renderer/native/ios/renderer/component/waterfalllist/HippyShadowListView.h +++ b/renderer/native/ios/renderer/component/waterfalllist/HippyShadowListView.h @@ -21,7 +21,7 @@ */ #import "HippyShadowView.h" -#import "NativeRenderObjectWaterfallItem.h" +#import "HippyShadowWaterfallItem.h" NS_ASSUME_NONNULL_BEGIN @@ -43,7 +43,7 @@ NS_ASSUME_NONNULL_BEGIN @end -@interface HippyShadowListView : HippyShadowView +@interface HippyShadowListView : HippyShadowView ///// Whether current ShadowList is dirty. //@property (nonatomic, assign) BOOL isDirty; diff --git a/renderer/native/ios/renderer/component/waterfalllist/HippyShadowListView.mm b/renderer/native/ios/renderer/component/waterfalllist/HippyShadowListView.mm index c3cb331333c..484ce2b462e 100644 --- a/renderer/native/ios/renderer/component/waterfalllist/HippyShadowListView.mm +++ b/renderer/native/ios/renderer/component/waterfalllist/HippyShadowListView.mm @@ -21,7 +21,7 @@ */ #import "HippyShadowListView.h" -#import "NativeRenderWaterfallView.h" +#import "HippyWaterfallView.h" #import "HippyAssert.h" @interface WaterfallItemChangeContext () { @@ -152,8 +152,8 @@ - (WaterfallItemChangeContext *)itemChangeContext { - (void)insertHippySubview:(HippyShadowView *)subview atIndex:(NSInteger)atIndex { [super insertHippySubview:subview atIndex:atIndex]; - if ([subview isKindOfClass:[NativeRenderObjectWaterfallItem class]]) { - NativeRenderObjectWaterfallItem *objectItem = (NativeRenderObjectWaterfallItem *)subview; + if ([subview isKindOfClass:[HippyShadowWaterfallItem class]]) { + HippyShadowWaterfallItem *objectItem = (HippyShadowWaterfallItem *)subview; objectItem.observer = self; } [_itemChangeContext appendAddedItem:subview]; @@ -161,8 +161,8 @@ - (void)insertHippySubview:(HippyShadowView *)subview atIndex:(NSInteger)atIndex - (void)removeHippySubview:(HippyShadowView *)subview { [super removeHippySubview:subview]; - if ([subview isKindOfClass:[NativeRenderObjectWaterfallItem class]]) { - NativeRenderObjectWaterfallItem *objectItem = (NativeRenderObjectWaterfallItem *)subview; + if ([subview isKindOfClass:[HippyShadowWaterfallItem class]]) { + HippyShadowWaterfallItem *objectItem = (HippyShadowWaterfallItem *)subview; objectItem.observer = nil; } [_itemChangeContext appendDeletedItem:subview]; @@ -173,7 +173,7 @@ - (void)moveHippySubview:(id)subview toIndex:(NSInteger)atIndex [_itemChangeContext appendMovedItem:subview]; } -- (void)itemFrameChanged:(__kindof NativeRenderObjectWaterfallItem *)item { +- (void)itemFrameChanged:(__kindof HippyShadowWaterfallItem *)item { [_itemChangeContext appendFrameChangedItem:item]; } diff --git a/renderer/native/ios/renderer/component/waterfalllist/NativeRenderObjectWaterfallItem.h b/renderer/native/ios/renderer/component/waterfalllist/HippyShadowWaterfallItem.h similarity index 73% rename from renderer/native/ios/renderer/component/waterfalllist/NativeRenderObjectWaterfallItem.h rename to renderer/native/ios/renderer/component/waterfalllist/HippyShadowWaterfallItem.h index 2691eefc9e9..7c123460d2f 100644 --- a/renderer/native/ios/renderer/component/waterfalllist/NativeRenderObjectWaterfallItem.h +++ b/renderer/native/ios/renderer/component/waterfalllist/HippyShadowWaterfallItem.h @@ -24,19 +24,19 @@ NS_ASSUME_NONNULL_BEGIN -@class NativeRenderObjectWaterfallItem; +@class HippyShadowWaterfallItem; -@protocol NativeRenderObjectWaterfallItemFrameChangedProtocol +@protocol HippyShadowWaterfallItemFrameChangedProtocol @required -- (void)itemFrameChanged:(__kindof NativeRenderObjectWaterfallItem *)item; +- (void)itemFrameChanged:(__kindof HippyShadowWaterfallItem *)item; @end -@interface NativeRenderObjectWaterfallItem : HippyShadowView +@interface HippyShadowWaterfallItem : HippyShadowView @property(nonatomic, assign, getter=isLayoutDirty) BOOL layoutDirty; -@property(nonatomic, weak) id observer; +@property(nonatomic, weak) id observer; @end diff --git a/renderer/native/ios/renderer/component/waterfalllist/NativeRenderObjectWaterfallItem.mm b/renderer/native/ios/renderer/component/waterfalllist/HippyShadowWaterfallItem.mm similarity index 89% rename from renderer/native/ios/renderer/component/waterfalllist/NativeRenderObjectWaterfallItem.mm rename to renderer/native/ios/renderer/component/waterfalllist/HippyShadowWaterfallItem.mm index fc7c295d4e1..c5a1844cc13 100644 --- a/renderer/native/ios/renderer/component/waterfalllist/NativeRenderObjectWaterfallItem.mm +++ b/renderer/native/ios/renderer/component/waterfalllist/HippyShadowWaterfallItem.mm @@ -20,14 +20,14 @@ * limitations under the License. */ -#import "NativeRenderObjectWaterfallItem.h" +#import "HippyShadowWaterfallItem.h" -@implementation NativeRenderObjectWaterfallItem +@implementation HippyShadowWaterfallItem - (instancetype)init { self = [super init]; if (self) { - self.creationType = NativeRenderCreationTypeLazily; + self.creationType = HippyCreationTypeLazily; } return self; } @@ -42,7 +42,7 @@ - (void)setFrame:(CGRect)frame { } - (void)amendLayoutBeforeMount:(NSMutableSet *)blocks { - if (NativeRenderCreationTypeLazily == self.creationType) { + if (HippyCreationTypeLazily == self.creationType) { // If item has not yet been created, then no need to collect blocks. return; } diff --git a/renderer/native/ios/renderer/component/waterfalllist/NativeRenderWaterfallItemView.h b/renderer/native/ios/renderer/component/waterfalllist/HippyWaterfallItemView.h similarity index 94% rename from renderer/native/ios/renderer/component/waterfalllist/NativeRenderWaterfallItemView.h rename to renderer/native/ios/renderer/component/waterfalllist/HippyWaterfallItemView.h index d528b2445e7..e36eeabd2c7 100644 --- a/renderer/native/ios/renderer/component/waterfalllist/NativeRenderWaterfallItemView.h +++ b/renderer/native/ios/renderer/component/waterfalllist/HippyWaterfallItemView.h @@ -25,7 +25,7 @@ NS_ASSUME_NONNULL_BEGIN -@interface NativeRenderWaterfallItemView : HippyView +@interface HippyWaterfallItemView : HippyView @property (nonatomic, copy) NSString *type; diff --git a/renderer/native/ios/renderer/component/waterfalllist/NativeRenderWaterfallItemView.m b/renderer/native/ios/renderer/component/waterfalllist/HippyWaterfallItemView.m similarity index 90% rename from renderer/native/ios/renderer/component/waterfalllist/NativeRenderWaterfallItemView.m rename to renderer/native/ios/renderer/component/waterfalllist/HippyWaterfallItemView.m index 12e576a2eb2..1055fc2cee0 100644 --- a/renderer/native/ios/renderer/component/waterfalllist/NativeRenderWaterfallItemView.m +++ b/renderer/native/ios/renderer/component/waterfalllist/HippyWaterfallItemView.m @@ -20,10 +20,10 @@ * limitations under the License. */ -#import "NativeRenderWaterfallItemView.h" +#import "HippyWaterfallItemView.h" #import "UIView+Hippy.h" -@implementation NativeRenderWaterfallItemView +@implementation HippyWaterfallItemView - (instancetype)initWithFrame:(CGRect)frame { if (self = [super initWithFrame:frame]) { @@ -37,8 +37,4 @@ - (void)hippySetFrame:(CGRect)frame { self.frame = self.bounds; } -- (void)dealloc { - -} - @end diff --git a/renderer/native/ios/renderer/component/waterfalllist/NativeRenderWaterfallViewManager.h b/renderer/native/ios/renderer/component/waterfalllist/HippyWaterfallItemViewManager.h similarity index 93% rename from renderer/native/ios/renderer/component/waterfalllist/NativeRenderWaterfallViewManager.h rename to renderer/native/ios/renderer/component/waterfalllist/HippyWaterfallItemViewManager.h index 65892cc2e2c..d582f19dd6b 100644 --- a/renderer/native/ios/renderer/component/waterfalllist/NativeRenderWaterfallViewManager.h +++ b/renderer/native/ios/renderer/component/waterfalllist/HippyWaterfallItemViewManager.h @@ -24,7 +24,7 @@ NS_ASSUME_NONNULL_BEGIN -@interface NativeRenderWaterfallViewManager : HippyViewManager +@interface HippyWaterfallItemViewManager : HippyViewManager @end diff --git a/renderer/native/ios/renderer/component/waterfalllist/NativeRenderWaterfallItemViewManager.mm b/renderer/native/ios/renderer/component/waterfalllist/HippyWaterfallItemViewManager.m similarity index 74% rename from renderer/native/ios/renderer/component/waterfalllist/NativeRenderWaterfallItemViewManager.mm rename to renderer/native/ios/renderer/component/waterfalllist/HippyWaterfallItemViewManager.m index bfe847a1cb4..719c6422dd8 100644 --- a/renderer/native/ios/renderer/component/waterfalllist/NativeRenderWaterfallItemViewManager.mm +++ b/renderer/native/ios/renderer/component/waterfalllist/HippyWaterfallItemViewManager.m @@ -20,20 +20,20 @@ * limitations under the License. */ -#import "NativeRenderWaterfallItemViewManager.h" -#import "NativeRenderWaterfallItemView.h" -#import "NativeRenderObjectWaterfallItem.h" +#import "HippyWaterfallItemViewManager.h" +#import "HippyWaterfallItemView.h" +#import "HippyShadowWaterfallItem.h" -@implementation NativeRenderWaterfallItemViewManager +@implementation HippyWaterfallItemViewManager HIPPY_EXPORT_MODULE(WaterfallItem) - (UIView *)view { - return [NativeRenderWaterfallItemView new]; + return [HippyWaterfallItemView new]; } - (HippyShadowView *)hippyShadowView { - return [[NativeRenderObjectWaterfallItem alloc] init]; + return [[HippyShadowWaterfallItem alloc] init]; } @end diff --git a/renderer/native/ios/renderer/component/waterfalllist/NativeRenderWaterfallView.h b/renderer/native/ios/renderer/component/waterfalllist/HippyWaterfallView.h similarity index 82% rename from renderer/native/ios/renderer/component/waterfalllist/NativeRenderWaterfallView.h rename to renderer/native/ios/renderer/component/waterfalllist/HippyWaterfallView.h index 49698365b84..eaceb729376 100644 --- a/renderer/native/ios/renderer/component/waterfalllist/NativeRenderWaterfallView.h +++ b/renderer/native/ios/renderer/component/waterfalllist/HippyWaterfallView.h @@ -22,16 +22,16 @@ #import -#import "NativeRenderCollectionViewWaterfallLayout.h" +#import "HippyCollectionViewWaterfallLayout.h" #import "HippyComponent.h" #import "HippyScrollableProtocol.h" #import "HippyScrollProtocol.h" #import "NativeRenderTouchesView.h" -#import "NativeRenderListTableView.h" +#import "HippyNextListTableView.h" NS_ASSUME_NONNULL_BEGIN -@class NativeRenderWaterfallViewDataSource, HippyHeaderRefresh, HippyFooterRefresh, WaterfallItemChangeContext, HippyShadowView; +@class HippyWaterfallViewDataSource, HippyHeaderRefresh, HippyFooterRefresh, WaterfallItemChangeContext, HippyShadowView; typedef NS_ENUM(NSInteger, NativeRenderScrollState) { ScrollStateStop, @@ -40,13 +40,13 @@ typedef NS_ENUM(NSInteger, NativeRenderScrollState) { }; /** - * NativeRenderWaterfallView is a waterfall component, internal implementation is UICollectionView + * HippyWaterfallView is a waterfall component, internal implementation is UICollectionView */ -@interface NativeRenderWaterfallView : NativeRenderTouchesView { @protected - NativeRenderWaterfallViewDataSource *_dataSource; + HippyWaterfallViewDataSource *_dataSource; NSMapTable *_cachedWeakCellViews; @@ -57,22 +57,22 @@ typedef NS_ENUM(NSInteger, NativeRenderScrollState) { } /** - * Content inset for NativeRenderWaterfallView + * Content inset for HippyWaterfallView */ @property(nonatomic, assign) UIEdgeInsets contentInset; /** - * Number of columns for NativeRenderWaterfallView + * Number of columns for HippyWaterfallView */ @property(nonatomic, assign) NSInteger numberOfColumns; /** - * Column spacing for NativeRenderWaterfallView + * Column spacing for HippyWaterfallView */ @property(nonatomic, assign) CGFloat columnSpacing; /** - * Item spacing for NativeRenderWaterfallView + * Item spacing for HippyWaterfallView */ @property(nonatomic, assign) CGFloat interItemSpacing; @@ -94,12 +94,12 @@ typedef NS_ENUM(NSInteger, NativeRenderScrollState) { /** * Indicate internal collectionview */ -@property(nonatomic, strong) __kindof UICollectionView *collectionView; +@property(nonatomic, strong) HippyNextListTableView *collectionView; /** - * Get data source for NativeRenderWaterfallView + * Get data source for HippyWaterfallView */ -@property(nonatomic, readonly)NativeRenderWaterfallViewDataSource *dataSource; +@property(nonatomic, readonly)HippyWaterfallViewDataSource *dataSource; /** * Indicate whether components is scrolling manully @@ -143,13 +143,13 @@ typedef NS_ENUM(NSInteger, NativeRenderScrollState) { - (__kindof UICollectionViewLayout *)collectionViewLayout; /** - * Called when NativeRenderWaterfallView register its cell class + * Called when HippyWaterfallView register its cell class * Override it if custom cell is needed */ - (void)registerCells; /** - * Called when NativeRenderWaterfallView register its supplementary views + * Called when HippyWaterfallView register its supplementary views * Override it if custome supplementary view is needed */ - (void)registerSupplementaryViews; diff --git a/renderer/native/ios/renderer/component/waterfalllist/NativeRenderWaterfallView.mm b/renderer/native/ios/renderer/component/waterfalllist/HippyWaterfallView.mm similarity index 94% rename from renderer/native/ios/renderer/component/waterfalllist/NativeRenderWaterfallView.mm rename to renderer/native/ios/renderer/component/waterfalllist/HippyWaterfallView.mm index 1efe1e8693b..df539ed3276 100644 --- a/renderer/native/ios/renderer/component/waterfalllist/NativeRenderWaterfallView.mm +++ b/renderer/native/ios/renderer/component/waterfalllist/HippyWaterfallView.mm @@ -20,17 +20,17 @@ * limitations under the License. */ -#import "NativeRenderWaterfallView.h" +#import "HippyWaterfallView.h" #import "HippyHeaderRefresh.h" #import "HippyFooterRefresh.h" -#import "NativeRenderWaterfallItemView.h" +#import "HippyWaterfallItemView.h" #import "UIView+Hippy.h" #import "HippyRefresh.h" -#import "NativeRenderWaterfallViewDataSource.h" +#import "HippyWaterfallViewDataSource.h" #import "HippyShadowView.h" #import "HippyUIManager.h" #import "UIView+Render.h" -#import "NativeRenderWaterfallViewCell.h" +#import "HippyWaterfallViewCell.h" #import "HippyRootView.h" #import "HippyShadowListView.h" @@ -38,14 +38,14 @@ static NSString *kCellIdentifier = @"HippyWaterfallCellIdentifier"; static NSString *kWaterfallItemName = @"WaterfallItem"; -@interface NativeRenderWaterfallView () { +@interface HippyWaterfallView () { NSHashTable> *_scrollListeners; BOOL _isInitialListReady; UIColor *_backgroundColor; BOOL _manualScroll; } -@property (nonatomic, strong) NativeRenderCollectionViewWaterfallLayout *layout; +@property (nonatomic, strong) HippyCollectionViewWaterfallLayout *layout; @property (nonatomic, assign) NSInteger initialListSize; @property (nonatomic, assign) BOOL containBannerView; @@ -55,7 +55,7 @@ @interface NativeRenderWaterfallView () *datasource = [self.hippyShadowView.subcomponents copy]; - _dataSource = [[NativeRenderWaterfallViewDataSource alloc] initWithDataSource:datasource + _dataSource = [[HippyWaterfallViewDataSource alloc] initWithDataSource:datasource itemViewName:[self compoentItemName] containBannerView:_containBannerView]; @@ -258,14 +258,14 @@ - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSe } - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { - NativeRenderWaterfallViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:kCellIdentifier forIndexPath:indexPath]; + HippyWaterfallViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:kCellIdentifier forIndexPath:indexPath]; HippyShadowView *shadowView = [_dataSource cellForIndexPath:indexPath]; UIView *cellView = nil; UIView *cachedCellView = [_cachedWeakCellViews objectForKey:shadowView.hippyTag]; if (cachedCellView && - [shadowView isKindOfClass:NativeRenderObjectWaterfallItem.class] && - !((NativeRenderObjectWaterfallItem *)shadowView).layoutDirty) { + [shadowView isKindOfClass:HippyShadowWaterfallItem.class] && + !((HippyShadowWaterfallItem *)shadowView).layoutDirty) { cellView = cachedCellView; } else { cellView = [self.renderImpl createViewForShadowListItem:shadowView]; @@ -556,7 +556,7 @@ - (BOOL)scrollViewShouldScrollToTop:(UIScrollView *)scrollViewxt { - (void)scrollViewDidScrollToTop:(UIScrollView *)scrollView { } -- (void)tableViewDidLayoutSubviews:(NativeRenderListTableView *)tableView { +- (void)tableViewDidLayoutSubviews:(HippyNextListTableView *)tableView { [self clearVisibleCellViewsCacheBeforeReload]; } @@ -656,8 +656,8 @@ - (void)cacheVisibleCellViewsForReuse { NSArray *visibleCells = [self.collectionView visibleCells]; NSMutableArray *visibleCellViews = [NSMutableArray arrayWithCapacity:visibleCells.count]; for (UICollectionViewCell *cell in visibleCells) { - if ([cell isKindOfClass:NativeRenderWaterfallViewCell.class]) { - [visibleCellViews addObject:((NativeRenderWaterfallViewCell *)cell).cellView]; + if ([cell isKindOfClass:HippyWaterfallViewCell.class]) { + [visibleCellViews addObject:((HippyWaterfallViewCell *)cell).cellView]; } } _visibleCellViewsBeforeReload = visibleCellViews; diff --git a/renderer/native/ios/renderer/component/waterfalllist/NativeRenderWaterfallViewCell.h b/renderer/native/ios/renderer/component/waterfalllist/HippyWaterfallViewCell.h similarity index 93% rename from renderer/native/ios/renderer/component/waterfalllist/NativeRenderWaterfallViewCell.h rename to renderer/native/ios/renderer/component/waterfalllist/HippyWaterfallViewCell.h index 9fd70b6825c..58fe17cd665 100644 --- a/renderer/native/ios/renderer/component/waterfalllist/NativeRenderWaterfallViewCell.h +++ b/renderer/native/ios/renderer/component/waterfalllist/HippyWaterfallViewCell.h @@ -24,7 +24,7 @@ NS_ASSUME_NONNULL_BEGIN -@interface NativeRenderWaterfallViewCell : UICollectionViewCell +@interface HippyWaterfallViewCell : UICollectionViewCell @property (nonatomic, weak) UIView *cellView; diff --git a/renderer/native/ios/renderer/component/waterfalllist/NativeRenderWaterfallViewCell.m b/renderer/native/ios/renderer/component/waterfalllist/HippyWaterfallViewCell.m similarity index 93% rename from renderer/native/ios/renderer/component/waterfalllist/NativeRenderWaterfallViewCell.m rename to renderer/native/ios/renderer/component/waterfalllist/HippyWaterfallViewCell.m index 1928e20ab46..1abee292264 100644 --- a/renderer/native/ios/renderer/component/waterfalllist/NativeRenderWaterfallViewCell.m +++ b/renderer/native/ios/renderer/component/waterfalllist/HippyWaterfallViewCell.m @@ -20,12 +20,12 @@ * limitations under the License. */ -#import "NativeRenderWaterfallViewCell.h" +#import "HippyWaterfallViewCell.h" #import "objc/runtime.h" static const NSInteger CellTag = 10089; -@implementation NativeRenderWaterfallViewCell +@implementation HippyWaterfallViewCell - (UIView *)cellView { return [self.contentView viewWithTag:CellTag]; diff --git a/renderer/native/ios/renderer/component/waterfalllist/NativeRenderWaterfallViewDataSource.h b/renderer/native/ios/renderer/component/waterfalllist/HippyWaterfallViewDataSource.h similarity index 96% rename from renderer/native/ios/renderer/component/waterfalllist/NativeRenderWaterfallViewDataSource.h rename to renderer/native/ios/renderer/component/waterfalllist/HippyWaterfallViewDataSource.h index 8b9330da8e2..e0c91615059 100644 --- a/renderer/native/ios/renderer/component/waterfalllist/NativeRenderWaterfallViewDataSource.h +++ b/renderer/native/ios/renderer/component/waterfalllist/HippyWaterfallViewDataSource.h @@ -27,7 +27,7 @@ NS_ASSUME_NONNULL_BEGIN @class HippyShadowView; -@interface NativeRenderWaterfallViewDataSource : NSObject +@interface HippyWaterfallViewDataSource : NSObject - (instancetype)initWithDataSource:(NSArray<__kindof HippyShadowView *> *)dataSource itemViewName:(NSString *)itemViewName diff --git a/renderer/native/ios/renderer/component/waterfalllist/NativeRenderWaterfallViewDataSource.mm b/renderer/native/ios/renderer/component/waterfalllist/HippyWaterfallViewDataSource.mm similarity index 95% rename from renderer/native/ios/renderer/component/waterfalllist/NativeRenderWaterfallViewDataSource.mm rename to renderer/native/ios/renderer/component/waterfalllist/HippyWaterfallViewDataSource.mm index 02bc1755cd1..3876f8ec343 100644 --- a/renderer/native/ios/renderer/component/waterfalllist/NativeRenderWaterfallViewDataSource.mm +++ b/renderer/native/ios/renderer/component/waterfalllist/HippyWaterfallViewDataSource.mm @@ -23,11 +23,11 @@ #import #import "HippyAssert.h" -#import "NativeRenderWaterfallViewDataSource.h" +#import "HippyWaterfallViewDataSource.h" #import "HippyShadowView.h" #import "HippyShadowListView.h" -@interface NativeRenderWaterfallViewDataSource () { +@interface HippyWaterfallViewDataSource () { BOOL _containBannerView; NSArray *> *_cellRenderObjectViews; HippyShadowView *_bannerView; @@ -35,7 +35,7 @@ @interface NativeRenderWaterfallViewDataSource () { @end -@implementation NativeRenderWaterfallViewDataSource +@implementation HippyWaterfallViewDataSource - (instancetype)initWithDataSource:(NSArray<__kindof HippyShadowView *> *)dataSource itemViewName:(NSString *)itemViewName @@ -49,7 +49,7 @@ - (instancetype)initWithDataSource:(NSArray<__kindof HippyShadowView *> *)dataSo } - (id)copyWithZone:(nullable NSZone *)zone { - NativeRenderWaterfallViewDataSource *dataSource = [[[self class] allocWithZone:zone] init]; + HippyWaterfallViewDataSource *dataSource = [[[self class] allocWithZone:zone] init]; dataSource->_containBannerView = self.containBannerView; dataSource->_bannerView = _bannerView; NSMutableArray *> *objectSectionViews = [NSMutableArray arrayWithCapacity:[_cellRenderObjectViews count]]; diff --git a/renderer/native/ios/renderer/component/waterfalllist/NativeRenderWaterfallItemViewManager.h b/renderer/native/ios/renderer/component/waterfalllist/HippyWaterfallViewManager.h similarity index 92% rename from renderer/native/ios/renderer/component/waterfalllist/NativeRenderWaterfallItemViewManager.h rename to renderer/native/ios/renderer/component/waterfalllist/HippyWaterfallViewManager.h index ca2d2b92651..b405f50fae9 100644 --- a/renderer/native/ios/renderer/component/waterfalllist/NativeRenderWaterfallItemViewManager.h +++ b/renderer/native/ios/renderer/component/waterfalllist/HippyWaterfallViewManager.h @@ -24,7 +24,7 @@ NS_ASSUME_NONNULL_BEGIN -@interface NativeRenderWaterfallItemViewManager : HippyViewManager +@interface HippyWaterfallViewManager : HippyViewManager @end diff --git a/renderer/native/ios/renderer/component/waterfalllist/NativeRenderWaterfallViewManager.mm b/renderer/native/ios/renderer/component/waterfalllist/HippyWaterfallViewManager.m similarity index 74% rename from renderer/native/ios/renderer/component/waterfalllist/NativeRenderWaterfallViewManager.mm rename to renderer/native/ios/renderer/component/waterfalllist/HippyWaterfallViewManager.m index 4421ece300f..7655d4019db 100644 --- a/renderer/native/ios/renderer/component/waterfalllist/NativeRenderWaterfallViewManager.mm +++ b/renderer/native/ios/renderer/component/waterfalllist/HippyWaterfallViewManager.m @@ -20,12 +20,12 @@ * limitations under the License. */ -#import "NativeRenderWaterfallViewManager.h" -#import "NativeRenderWaterfallView.h" +#import "HippyWaterfallViewManager.h" +#import "HippyWaterfallView.h" #import "HippyShadowListView.h" #import "HippyUIManager.h" -@implementation NativeRenderWaterfallViewManager +@implementation HippyWaterfallViewManager HIPPY_EXPORT_MODULE(WaterfallView) @@ -46,7 +46,7 @@ @implementation NativeRenderWaterfallViewManager HIPPY_EXPORT_VIEW_PROPERTY(onScroll, HippyDirectEventBlock) - (UIView *)view { - return [[NativeRenderWaterfallView alloc] init]; + return [[HippyWaterfallView alloc] init]; } - (HippyShadowView *)hippyShadowView { @@ -59,11 +59,11 @@ - (HippyShadowView *)hippyShadowView { duration:(nonnull NSNumber *)duration imageUrl:(nonnull NSString *)imageUrl) { [self.bridge.uiManager addUIBlock:^(__unused HippyUIManager *uiManager, NSDictionary *viewRegistry) { - NativeRenderWaterfallView *view = (NativeRenderWaterfallView *)viewRegistry[reactTag]; + HippyWaterfallView *view = (HippyWaterfallView *)viewRegistry[reactTag]; if (view == nil) return; - if (![view isKindOfClass:[NativeRenderWaterfallView class]]) { - HippyLogError(@"Invalid view returned from registry, expecting NativeRenderWaterfallView, got: %@", view); + if (![view isKindOfClass:[HippyWaterfallView class]]) { + HippyLogError(@"Invalid view returned from registry, expecting HippyWaterfallView, got: %@", view); } [view refreshCompleted:status.integerValue text:text]; }]; @@ -71,11 +71,11 @@ - (HippyShadowView *)hippyShadowView { HIPPY_EXPORT_METHOD(startRefresh:(nonnull NSNumber *)reactTag) { [self.bridge.uiManager addUIBlock:^(__unused HippyUIManager *uiManager, NSDictionary *viewRegistry) { - NativeRenderWaterfallView *view = (NativeRenderWaterfallView *)viewRegistry[reactTag]; + HippyWaterfallView *view = (HippyWaterfallView *)viewRegistry[reactTag]; if (view == nil) return; - if (![view isKindOfClass:[NativeRenderWaterfallView class]]) { - HippyLogError(@"Invalid view returned from registry, expecting NativeRenderWaterfallView, got: %@", view); + if (![view isKindOfClass:[HippyWaterfallView class]]) { + HippyLogError(@"Invalid view returned from registry, expecting HippyWaterfallView, got: %@", view); } [view startRefreshFromJS]; }]; @@ -84,11 +84,11 @@ - (HippyShadowView *)hippyShadowView { HIPPY_EXPORT_METHOD(startRefreshWithType:(nonnull NSNumber *)reactTag type:(NSNumber *)type) { [self.bridge.uiManager addUIBlock:^(__unused HippyUIManager *uiManager, NSDictionary *viewRegistry) { - NativeRenderWaterfallView *view = (NativeRenderWaterfallView *)viewRegistry[reactTag]; + HippyWaterfallView *view = (HippyWaterfallView *)viewRegistry[reactTag]; if (view == nil) return; - if (![view isKindOfClass:[NativeRenderWaterfallView class]]) { - HippyLogError(@"Invalid view returned from registry, expecting NativeRenderWaterfallView, got: %@", view); + if (![view isKindOfClass:[HippyWaterfallView class]]) { + HippyLogError(@"Invalid view returned from registry, expecting HippyWaterfallView, got: %@", view); } [view startRefreshFromJSWithType:[type unsignedIntegerValue]]; }]; @@ -96,11 +96,11 @@ - (HippyShadowView *)hippyShadowView { HIPPY_EXPORT_METHOD(callExposureReport:(nonnull NSNumber *)reactTag) { [self.bridge.uiManager addUIBlock:^(__unused HippyUIManager *uiManager, NSDictionary *viewRegistry) { - NativeRenderWaterfallView *view = (NativeRenderWaterfallView *)viewRegistry[reactTag]; + HippyWaterfallView *view = (HippyWaterfallView *)viewRegistry[reactTag]; if (view == nil) return; - if (![view isKindOfClass:[NativeRenderWaterfallView class]]) { - HippyLogError(@"Invalid view returned from registry, expecting NativeRenderWaterfallView, got: %@", view); + if (![view isKindOfClass:[HippyWaterfallView class]]) { + HippyLogError(@"Invalid view returned from registry, expecting HippyWaterfallView, got: %@", view); } [view callExposureReport]; }]; @@ -111,11 +111,11 @@ - (HippyShadowView *)hippyShadowView { yIndex:(nonnull NSNumber *)yIndex animation:(nonnull NSNumber *)animation) { [self.bridge.uiManager addUIBlock:^(__unused HippyUIManager *uiManager, NSDictionary *viewRegistry) { - NativeRenderWaterfallView *view = (NativeRenderWaterfallView *)viewRegistry[reactTag]; + HippyWaterfallView *view = (HippyWaterfallView *)viewRegistry[reactTag]; if (view == nil) return; - if (![view isKindOfClass:[NativeRenderWaterfallView class]]) { - HippyLogError(@"Invalid view returned from registry, expecting NativeRenderWaterfallView, got: %@", view); + if (![view isKindOfClass:[HippyWaterfallView class]]) { + HippyLogError(@"Invalid view returned from registry, expecting HippyWaterfallView, got: %@", view); } [view scrollToIndex:xIndex.integerValue animated:[animation boolValue]]; }]; @@ -126,11 +126,11 @@ - (HippyShadowView *)hippyShadowView { y:(nonnull NSNumber *)y animation:(nonnull NSNumber *)animation) { [self.bridge.uiManager addUIBlock:^(__unused HippyUIManager *uiManager, NSDictionary *viewRegistry) { - NativeRenderWaterfallView *view = (NativeRenderWaterfallView *)viewRegistry[reactTag]; + HippyWaterfallView *view = (HippyWaterfallView *)viewRegistry[reactTag]; if (view == nil) return; - if (![view isKindOfClass:[NativeRenderWaterfallView class]]) { - HippyLogError(@"Invalid view returned from registry, expecting NativeRenderWaterfallView, got: %@", view); + if (![view isKindOfClass:[HippyWaterfallView class]]) { + HippyLogError(@"Invalid view returned from registry, expecting HippyWaterfallView, got: %@", view); } [view scrollToOffset:CGPointMake([x floatValue], [y floatValue]) animated:[animation boolValue]]; }]; @@ -138,11 +138,11 @@ - (HippyShadowView *)hippyShadowView { HIPPY_EXPORT_METHOD(startLoadMore:(nonnull NSNumber *)reactTag) { [self.bridge.uiManager addUIBlock:^(__unused HippyUIManager *uiManager, NSDictionary *viewRegistry) { - NativeRenderWaterfallView *view = (NativeRenderWaterfallView *)viewRegistry[reactTag]; + HippyWaterfallView *view = (HippyWaterfallView *)viewRegistry[reactTag]; if (view == nil) return; - if (![view isKindOfClass:[NativeRenderWaterfallView class]]) { - HippyLogError(@"Invalid view returned from registry, expecting NativeRenderWaterfallView, got: %@", view); + if (![view isKindOfClass:[HippyWaterfallView class]]) { + HippyLogError(@"Invalid view returned from registry, expecting HippyWaterfallView, got: %@", view); } [view startLoadMore]; }]; diff --git a/renderer/native/ios/utils/NativeRenderGradientObject.h b/renderer/native/ios/utils/HippyGradientObject.h similarity index 66% rename from renderer/native/ios/utils/NativeRenderGradientObject.h rename to renderer/native/ios/utils/HippyGradientObject.h index feada75828b..33d5b27b25c 100644 --- a/renderer/native/ios/utils/NativeRenderGradientObject.h +++ b/renderer/native/ios/utils/HippyGradientObject.h @@ -27,7 +27,7 @@ NS_ASSUME_NONNULL_BEGIN -@interface NativeRenderGradientLocationParser : NSObject +@interface HippyGradientLocationParser : NSObject @property(nonatomic, assign) NSUInteger locationsCount; @@ -39,20 +39,20 @@ NS_ASSUME_NONNULL_BEGIN @end -typedef NS_ENUM(NSUInteger, NativeRenderGradientType) { - NativeRenderGradientTypeLinear, - NativeRenderGradientTypeRadial, +typedef NS_ENUM(NSUInteger, HippyGradientType) { + HippyGradientTypeLinear, + HippyGradientTypeRadial, }; -typedef NS_ENUM(NSUInteger, NativeRenderGradientDirection) { - NativeRenderGradientDirectionTop, - NativeRenderGradientDirectionTopRight, - NativeRenderGradientDirectionRight, - NativeRenderGradientDirectionBottomRight, - NativeRenderGradientDirectionBottom, - NativeRenderGradientDirectionBottomLeft, - NativeRenderGradientDirectionLeft, - NativeRenderGradientDirectionTopLeft, +typedef NS_ENUM(NSUInteger, HippyGradientDirection) { + HippyGradientDirectionTop, + HippyGradientDirectionTopRight, + HippyGradientDirectionRight, + HippyGradientDirectionBottomRight, + HippyGradientDirectionBottom, + HippyGradientDirectionBottomLeft, + HippyGradientDirectionLeft, + HippyGradientDirectionTopLeft, }; typedef struct _LinearGradientPoints { @@ -66,7 +66,7 @@ typedef struct _CanvasInfo { HippyCornerInsets insets; }CanvasInfo; -@interface NativeRenderGradientObject : NSObject +@interface HippyGradientObject : NSObject - (instancetype)initWithGradientObject:(NSDictionary *)object; @@ -74,11 +74,11 @@ typedef struct _CanvasInfo { @property(nonatomic, strong) NSArray *locations; //degree by angle @property(nonatomic, assign) NSInteger degree; -@property(nonatomic, assign) NativeRenderGradientDirection direction; +@property(nonatomic, assign) HippyGradientDirection direction; //determine if gradient drawn by degree.Default is NO. //if YES, gradient is drawn by degree,otherwise by direction @property(nonatomic, assign, getter=isDrawnByDegree) BOOL drawnByDegree; -@property(nonatomic, assign) NativeRenderGradientType gradientType; +@property(nonatomic, assign) HippyGradientType gradientType; - (void)drawInContext:(CGContextRef)context canvasInfo:(CanvasInfo)canvasInfo; @@ -86,7 +86,7 @@ typedef struct _CanvasInfo { @end -HIPPY_EXTERN void NativeRenderDrawLinearGradientInContext(NativeRenderGradientObject *object, CGContextRef context, CanvasInfo canvasInfo); -HIPPY_EXTERN void NativeRenderDrawRadialGradientInContext(NativeRenderGradientObject *object, CGContextRef context, CGSize); +HIPPY_EXTERN void HippyDrawLinearGradientInContext(HippyGradientObject *object, CGContextRef context, CanvasInfo canvasInfo); +HIPPY_EXTERN void HippyDrawRadialGradientInContext(HippyGradientObject *object, CGContextRef context, CGSize); NS_ASSUME_NONNULL_END diff --git a/renderer/native/ios/utils/NativeRenderGradientObject.m b/renderer/native/ios/utils/HippyGradientObject.m similarity index 85% rename from renderer/native/ios/utils/NativeRenderGradientObject.m rename to renderer/native/ios/utils/HippyGradientObject.m index 679ad1ec1af..382c2217018 100644 --- a/renderer/native/ios/utils/NativeRenderGradientObject.m +++ b/renderer/native/ios/utils/HippyGradientObject.m @@ -23,16 +23,16 @@ #import "HippyAssert.h" #import "HippyUtils.h" #import "HippyBorderDrawing.h" -#import "NativeRenderGradientObject.h" +#import "HippyGradientObject.h" -@interface NativeRenderGradientLocationParser () { +@interface HippyGradientLocationParser () { NSPointerArray *_locations; NSInteger _previousSettedLocation; } @end -@implementation NativeRenderGradientLocationParser +@implementation HippyGradientLocationParser - (instancetype)initWithLocationsCount:(NSUInteger)count { self = [super init]; @@ -98,15 +98,15 @@ - (void)setLocationValuesBetweenLocations1:(NSUInteger)location1 location2:(NSUI @end -@implementation NativeRenderGradientObject +@implementation HippyGradientObject - (void)drawInContext:(CGContextRef)context canvasInfo:(CanvasInfo)canvasInfo { switch (self.gradientType) { - case NativeRenderGradientTypeLinear: - NativeRenderDrawLinearGradientInContext(self, context, canvasInfo); + case HippyGradientTypeLinear: + HippyDrawLinearGradientInContext(self, context, canvasInfo); break; - case NativeRenderGradientTypeRadial: - NativeRenderDrawRadialGradientInContext(self, context, canvasInfo.size); + case HippyGradientTypeRadial: + HippyDrawRadialGradientInContext(self, context, canvasInfo.size); break; default: break; @@ -172,67 +172,67 @@ static LinearGradientPoints gradientPointsWithSizeAndDegree(CGSize size, NSInteg return (LinearGradientPoints){startPoint, endPoint}; } -static BOOL getDirectionFromString(NSString *string, NativeRenderGradientDirection *direction) { +static BOOL getDirectionFromString(NSString *string, HippyGradientDirection *direction) { BOOL isDrawnByDirection = NO; if (direction) { if ([string isEqualToString:@"totop"]) { - *direction = NativeRenderGradientDirectionTop; + *direction = HippyGradientDirectionTop; isDrawnByDirection = YES; } else if ([string isEqualToString:@"totopright"]) { - *direction = NativeRenderGradientDirectionTopRight; + *direction = HippyGradientDirectionTopRight; isDrawnByDirection = YES; } else if ([string isEqualToString:@"toright"]) { - *direction = NativeRenderGradientDirectionRight; + *direction = HippyGradientDirectionRight; isDrawnByDirection = YES; } else if ([string isEqualToString:@"tobottomright"]) { - *direction = NativeRenderGradientDirectionBottomRight; + *direction = HippyGradientDirectionBottomRight; isDrawnByDirection = YES; } else if ([string isEqualToString:@"tobottom"]) { - *direction = NativeRenderGradientDirectionBottom; + *direction = HippyGradientDirectionBottom; isDrawnByDirection = YES; } else if ([string isEqualToString:@"tobottomleft"]) { - *direction = NativeRenderGradientDirectionBottomLeft; + *direction = HippyGradientDirectionBottomLeft; isDrawnByDirection = YES; } else if ([string isEqualToString:@"toleft"]) { - *direction = NativeRenderGradientDirectionLeft; + *direction = HippyGradientDirectionLeft; isDrawnByDirection = YES; } else if ([string isEqualToString:@"totopleft"]) { - *direction = NativeRenderGradientDirectionTopLeft; + *direction = HippyGradientDirectionTopLeft; isDrawnByDirection = YES; } } return isDrawnByDirection; } -static CGFloat degreeFromDirection(NativeRenderGradientDirection direction, CGSize size) { +static CGFloat degreeFromDirection(HippyGradientDirection direction, CGSize size) { CGFloat degree = 0.0f; switch (direction) { - case NativeRenderGradientDirectionTopRight: + case HippyGradientDirectionTopRight: degree = atan(size.height / size.width); break; - case NativeRenderGradientDirectionRight: + case HippyGradientDirectionRight: degree = M_PI_2; break; - case NativeRenderGradientDirectionBottomRight: + case HippyGradientDirectionBottomRight: degree = M_PI - atan(size.height / size.width); break; - case NativeRenderGradientDirectionBottom: + case HippyGradientDirectionBottom: degree = M_PI; break; - case NativeRenderGradientDirectionBottomLeft: + case HippyGradientDirectionBottomLeft: degree = M_PI + atan(size.height / size.width); break; - case NativeRenderGradientDirectionLeft: + case HippyGradientDirectionLeft: degree = M_PI + M_PI_2; break; - case NativeRenderGradientDirectionTopLeft: + case HippyGradientDirectionTopLeft: degree = M_PI + M_PI - atan(size.height / size.width); break; default: @@ -241,7 +241,7 @@ static CGFloat degreeFromDirection(NativeRenderGradientDirection direction, CGSi return degree * 180.f / M_PI; } -static LinearGradientPoints pointsFromDirection(NativeRenderGradientObject *object, CGSize size) { +static LinearGradientPoints pointsFromDirection(HippyGradientObject *object, CGSize size) { return gradientPointsWithSizeAndDegree(size, degreeFromDirection(object.direction, size)); } @@ -258,7 +258,7 @@ - (instancetype)initWithGradientObject:(NSDictionary *)object { // }; @try { NSString *angleString = [object objectForKey:@"angle"]; - NativeRenderGradientDirection direction; + HippyGradientDirection direction; if (getDirectionFromString(angleString, &direction)) { self.direction = direction; } @@ -269,7 +269,7 @@ - (instancetype)initWithGradientObject:(NSDictionary *)object { NSArray *colorStopList = [object objectForKey:@"colorStopList"]; NSMutableArray *colors = [NSMutableArray arrayWithCapacity:[colorStopList count]]; - NativeRenderGradientLocationParser *locationParser = [[NativeRenderGradientLocationParser alloc] initWithLocationsCount:[colorStopList count]]; + HippyGradientLocationParser *locationParser = [[HippyGradientLocationParser alloc] initWithLocationsCount:[colorStopList count]]; for (NSUInteger i = 0; i < [colorStopList count]; i++) { NSDictionary *colorStop = [colorStopList objectAtIndex:i]; NSNumber *colorNumber = [colorStop objectForKey:@"color"]; @@ -325,7 +325,7 @@ static CFArrayRef UIColorsToCGColors(NSArray *colors) { return pLocs; } -void NativeRenderDrawLinearGradientInContext(NativeRenderGradientObject *object, CGContextRef context, CanvasInfo canvasInfo) { +void HippyDrawLinearGradientInContext(HippyGradientObject *object, CGContextRef context, CanvasInfo canvasInfo) { NSCAssert(context, @"context cannot be null for drawing linear gradient"); if (nil == context) { return; @@ -354,7 +354,7 @@ void NativeRenderDrawLinearGradientInContext(NativeRenderGradientObject *object, CGContextRestoreGState(context); } -HIPPY_EXTERN void NativeRenderDrawRadialGradientInContext(NativeRenderGradientObject *object, CGContextRef context, CGSize size) { +HIPPY_EXTERN void HippyDrawRadialGradientInContext(HippyGradientObject *object, CGContextRef context, CGSize size) { NSCAssert(context, @"context cannot be null for drawing radial gradient"); NSCAssert(NO, @"NativeRenderDrawRadialGradientInContext not implemented"); } diff --git a/renderer/native/ios/utils/NativeRenderUtils.h b/renderer/native/ios/utils/HippyRenderUtils.h similarity index 63% rename from renderer/native/ios/utils/NativeRenderUtils.h rename to renderer/native/ios/utils/HippyRenderUtils.h index fc85ede6517..99a544eb3b8 100644 --- a/renderer/native/ios/utils/NativeRenderUtils.h +++ b/renderer/native/ios/utils/HippyRenderUtils.h @@ -26,21 +26,19 @@ NS_ASSUME_NONNULL_BEGIN // Get screen metrics in a thread-safe way -HIPPY_EXTERN CGFloat NativeRenderScreenScale(void); -HIPPY_EXTERN CGSize NativeRenderScreenSize(void); +HIPPY_EXTERN CGFloat HippyScreenScale(void); +HIPPY_EXTERN CGSize HippyScreenSize(void); // Round float coordinates to nearest whole screen pixel (not point) -HIPPY_EXTERN CGFloat NativeRenderRoundPixelValue(CGFloat value); -HIPPY_EXTERN CGFloat NativeRenderCeilPixelValue(CGFloat value); -HIPPY_EXTERN CGFloat NativeRenderFloorPixelValue(CGFloat value); +HIPPY_EXTERN CGFloat HippyRoundPixelValue(CGFloat value); +HIPPY_EXTERN CGFloat HippyCeilPixelValue(CGFloat value); +HIPPY_EXTERN CGFloat HippyFloorPixelValue(CGFloat value); // Convert a size in points to pixels, rounded up to the nearest integral size -HIPPY_EXTERN CGSize NativeRenderSizeInPixels(CGSize pointSize, CGFloat scale); +HIPPY_EXTERN CGSize HippySizeInPixels(CGSize pointSize, CGFloat scale); -HIPPY_EXTERN BOOL NativeRenderCGRectNearlyEqual(CGRect frame1, CGRect frame2); - -HIPPY_EXTERN BOOL NativeRenderCGPointNearlyEqual(CGPoint point1, CGPoint point2); - -HIPPY_EXTERN BOOL NativeRenderCGSizeNearlyEqual(CGSize size1, CGSize size2); +HIPPY_EXTERN BOOL HippyCGRectNearlyEqual(CGRect frame1, CGRect frame2); +HIPPY_EXTERN BOOL HippyCGPointNearlyEqual(CGPoint point1, CGPoint point2); +HIPPY_EXTERN BOOL HippyCGSizeNearlyEqual(CGSize size1, CGSize size2); NS_ASSUME_NONNULL_END diff --git a/renderer/native/ios/utils/NativeRenderUtils.m b/renderer/native/ios/utils/HippyRenderUtils.m similarity index 66% rename from renderer/native/ios/utils/NativeRenderUtils.m rename to renderer/native/ios/utils/HippyRenderUtils.m index 577931e611f..29252b937ec 100644 --- a/renderer/native/ios/utils/NativeRenderUtils.m +++ b/renderer/native/ios/utils/HippyRenderUtils.m @@ -21,9 +21,9 @@ */ #import "HippyUtils.h" -#import "NativeRenderUtils.h" +#import "HippyRenderUtils.h" -CGFloat NativeRenderScreenScale(void) { +CGFloat HippyScreenScale(void) { static CGFloat scale = CGFLOAT_MAX; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ @@ -32,7 +32,7 @@ CGFloat NativeRenderScreenScale(void) { return scale; } -CGSize NativeRenderScreenSize(void) { +CGSize HippyScreenSize(void) { static CGSize size = { 0, 0 }; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ @@ -41,39 +41,39 @@ CGSize NativeRenderScreenSize(void) { return size; } -CGFloat NativeRenderRoundPixelValue(CGFloat value) { - CGFloat scale = NativeRenderScreenScale(); +CGFloat HippyRoundPixelValue(CGFloat value) { + CGFloat scale = HippyScreenScale(); return round(value * scale) / scale; } -CGFloat NativeRenderCeilPixelValue(CGFloat value) { - CGFloat scale = NativeRenderScreenScale(); +CGFloat HippyCeilPixelValue(CGFloat value) { + CGFloat scale = HippyScreenScale(); return ceil(value * scale) / scale; } -CGFloat NativeRenderFloorPixelValue(CGFloat value) { - CGFloat scale = NativeRenderScreenScale(); +CGFloat HippyFloorPixelValue(CGFloat value) { + CGFloat scale = HippyScreenScale(); return floor(value * scale) / scale; } -CGSize NativeRenderSizeInPixels(CGSize pointSize, CGFloat scale) { +CGSize HippySizeInPixels(CGSize pointSize, CGFloat scale) { return (CGSize) { ceil(pointSize.width * scale), ceil(pointSize.height * scale), }; } -BOOL NativeRenderCGRectNearlyEqual(CGRect frame1, CGRect frame2) { - return NativeRenderCGPointNearlyEqual(frame1.origin, frame2.origin) && - NativeRenderCGSizeNearlyEqual(frame1.size, frame2.size); +BOOL HippyCGRectNearlyEqual(CGRect frame1, CGRect frame2) { + return HippyCGPointNearlyEqual(frame1.origin, frame2.origin) && + HippyCGSizeNearlyEqual(frame1.size, frame2.size); } -BOOL NativeRenderCGPointNearlyEqual(CGPoint point1, CGPoint point2) { +BOOL HippyCGPointNearlyEqual(CGPoint point1, CGPoint point2) { return fabs(point1.x - point2.x) < CGFLOAT_EPSILON && fabs(point1.y - point2.y) < CGFLOAT_EPSILON; } -BOOL NativeRenderCGSizeNearlyEqual(CGSize size1, CGSize size2) { +BOOL HippyCGSizeNearlyEqual(CGSize size1, CGSize size2) { return fabs(size1.width - size2.width) < CGFLOAT_EPSILON && fabs(size1.height - size2.height) < CGFLOAT_EPSILON; } From 867b946038064aaf08d0a4b1936a5f429879785b Mon Sep 17 00:00:00 2001 From: wwwcg Date: Wed, 31 Jan 2024 21:41:14 +0800 Subject: [PATCH 2/8] refactor(ios): improve version compatibility --- modules/ios/base/HippyConvert.h | 30 ++++++--- modules/ios/base/HippyConvert.m | 64 +++++++++---------- modules/ios/base/HippyDefines.h | 9 +++ renderer/native/ios/renderer/HippyFont.mm | 6 +- renderer/native/ios/renderer/UIView+Render.h | 2 +- renderer/native/ios/renderer/UIView+Render.mm | 2 +- .../renderer/component/image/HippyImageView.m | 4 +- .../listview/HippyNextBaseListView.mm | 4 +- .../scrollview/HippyScrollViewManager.mm | 4 +- .../NativeRenderSmartViewPagerView.mm | 2 +- .../waterfalllist/HippyWaterfallView.mm | 2 +- .../ios/utils/HippyConvert+NativeRender.m | 10 +-- 12 files changed, 79 insertions(+), 60 deletions(-) diff --git a/modules/ios/base/HippyConvert.h b/modules/ios/base/HippyConvert.h index e147cbf1f1e..6072993e641 100644 --- a/modules/ios/base/HippyConvert.h +++ b/modules/ios/base/HippyConvert.h @@ -21,7 +21,6 @@ */ #import - #import "HippyLog.h" /** @@ -132,12 +131,12 @@ HIPPY_EXTERN SEL HippyConvertSelectorForType(NSString *type); * This macro is used for creating simple converter functions that just call * the specified getter method on the json value. */ -#define HP_CONVERTER(type, name, getter) HP_CUSTOM_CONVERTER(type, name, [json getter]) +#define HIPPY_CONVERTER(type, name, getter) HIPPY_CUSTOM_CONVERTER(type, name, [json getter]) /** * This macro is used for creating converter functions with arbitrary logic. */ -#define HP_CUSTOM_CONVERTER(type, name, code) \ +#define HIPPY_CUSTOM_CONVERTER(type, name, code) \ +(type)name : (id)json { \ if (!HIPPY_DEBUG) { \ return code; \ @@ -153,17 +152,17 @@ HIPPY_EXTERN SEL HippyConvertSelectorForType(NSString *type); } /** - * This macro is similar to HP_CONVERTER, but specifically geared towards + * This macro is similar to HIPPY_CONVERTER, but specifically geared towards * numeric types. It will handle string input correctly, and provides more * detailed error reporting if an invalid value is passed in. */ -#define HP_NUMBER_CONVERTER(type, getter) \ - HP_CUSTOM_CONVERTER(type, type, [HIPPY_DEBUG ? [self NSNumber:json] : json getter]) +#define HIPPY_NUMBER_CONVERTER(type, getter) \ + HIPPY_CUSTOM_CONVERTER(type, type, [HIPPY_DEBUG ? [self NSNumber:json] : json getter]) /** * This macro is used for creating converters for enum types. */ -#define HP_ENUM_CONVERTER(type, values, default, getter) \ +#define HIPPY_ENUM_CONVERTER(type, values, default, getter) \ +(type)type : (id)json { \ static NSDictionary *mapping; \ static dispatch_once_t onceToken; \ @@ -177,7 +176,7 @@ HIPPY_EXTERN SEL HippyConvertSelectorForType(NSString *type); * This macro is used for creating converters for enum types for * multiple enum values combined with | operator */ -#define HP_MULTI_ENUM_CONVERTER(type, values, default, getter) \ +#define HIPPY_MULTI_ENUM_CONVERTER(type, values, default, getter) \ +(type)type : (id)json { \ static NSDictionary *mapping; \ static dispatch_once_t onceToken; \ @@ -190,7 +189,18 @@ HIPPY_EXTERN SEL HippyConvertSelectorForType(NSString *type); /** * This macro is used for creating converter functions for typed arrays. */ -#define HP_ARRAY_CONVERTER(type) \ +#define HIPPY_ARRAY_CONVERTER(type) \ +(NSArray *)type##Array : (id)json { \ - return HippyConvertArrayValue(@selector(type:), json); \ + return HippyConvertArrayValue(@selector(type:), json); \ } + + +/** + * Those macros are used for older version compatibility. + */ +#define Hippy_CONVERTER HIPPY_CONVERTER +#define Hippy_CUSTOM_CONVERTER HIPPY_CUSTOM_CONVERTER +#define Hippy_NUMBER_CONVERTER HIPPY_NUMBER_CONVERTER +#define Hippy_MULTI_ENUM_CONVERTER HIPPY_MULTI_ENUM_CONVERTER +#define Hippy_ARRAY_CONVERTER HIPPY_ARRAY_CONVERTER + diff --git a/modules/ios/base/HippyConvert.m b/modules/ios/base/HippyConvert.m index ca97cebd48f..505109cb291 100644 --- a/modules/ios/base/HippyConvert.m +++ b/modules/ios/base/HippyConvert.m @@ -29,15 +29,15 @@ @implementation HippyConvert -HP_CONVERTER(id, id, self) -HP_CONVERTER(BOOL, BOOL, boolValue) -HP_NUMBER_CONVERTER(double, doubleValue) -HP_NUMBER_CONVERTER(float, floatValue) -HP_NUMBER_CONVERTER(int, intValue) -HP_NUMBER_CONVERTER(int64_t, longLongValue) -HP_NUMBER_CONVERTER(uint64_t, unsignedLongLongValue) -HP_NUMBER_CONVERTER(NSInteger, integerValue) -HP_NUMBER_CONVERTER(NSUInteger, unsignedIntegerValue) +HIPPY_CONVERTER(id, id, self) +HIPPY_CONVERTER(BOOL, BOOL, boolValue) +HIPPY_NUMBER_CONVERTER(double, doubleValue) +HIPPY_NUMBER_CONVERTER(float, floatValue) +HIPPY_NUMBER_CONVERTER(int, intValue) +HIPPY_NUMBER_CONVERTER(int64_t, longLongValue) +HIPPY_NUMBER_CONVERTER(uint64_t, unsignedLongLongValue) +HIPPY_NUMBER_CONVERTER(NSInteger, integerValue) +HIPPY_NUMBER_CONVERTER(NSUInteger, unsignedIntegerValue) /** * This macro is used for creating converter functions for directly * representable json values that require no conversion. @@ -64,7 +64,7 @@ +(type *)type : (id)json { \ HP_JSON_CONVERTER(NSString) HP_JSON_CONVERTER(NSNumber) -HP_CUSTOM_CONVERTER(NSSet *, NSSet, [NSSet setWithArray:json]) +HIPPY_CUSTOM_CONVERTER(NSSet *, NSSet, [NSSet setWithArray:json]) + (NSData*)NSData:(id)json { if([json isKindOfClass:[NSString class]]) { @@ -217,10 +217,10 @@ + (NSDate *)NSDate:(id)json { } // JS Standard for time is milliseconds -HP_CUSTOM_CONVERTER(NSTimeInterval, NSTimeInterval, [self double:json] / 1000.0) +HIPPY_CUSTOM_CONVERTER(NSTimeInterval, NSTimeInterval, [self double:json] / 1000.0) // JS standard for time zones is minutes. -HP_CUSTOM_CONVERTER(NSTimeZone *, NSTimeZone, [NSTimeZone timeZoneForSecondsFromGMT:[self double:json] * 60.0]) +HIPPY_CUSTOM_CONVERTER(NSTimeZone *, NSTimeZone, [NSTimeZone timeZoneForSecondsFromGMT:[self double:json] * 60.0]) NSNumber *HippyConvertEnumValue(__unused const char *typeName, NSDictionary *mapping, NSNumber *defaultValue, id json) { if (!json) { @@ -260,7 +260,7 @@ + (NSDate *)NSDate:(id)json { return HippyConvertEnumValue(typeName, mapping, defaultValue, json); } -HP_ENUM_CONVERTER(NSLineBreakMode, (@{ +HIPPY_ENUM_CONVERTER(NSLineBreakMode, (@{ @"clip": @(NSLineBreakByClipping), @"head": @(NSLineBreakByTruncatingHead), @"tail": @(NSLineBreakByTruncatingTail), @@ -269,7 +269,7 @@ + (NSDate *)NSDate:(id)json { }), NSLineBreakByTruncatingTail, integerValue) -HP_ENUM_CONVERTER(NSTextAlignment, (@{ +HIPPY_ENUM_CONVERTER(NSTextAlignment, (@{ @"auto": @(NSTextAlignmentNatural), @"left": @(NSTextAlignmentLeft), @"center": @(NSTextAlignmentCenter), @@ -278,7 +278,7 @@ + (NSDate *)NSDate:(id)json { }), NSTextAlignmentNatural, integerValue) -HP_ENUM_CONVERTER(NSUnderlineStyle, (@{ +HIPPY_ENUM_CONVERTER(NSUnderlineStyle, (@{ @"solid": @(NSUnderlineStyleSingle), @"double": @(NSUnderlineStyleDouble), @"dotted": @(NSUnderlinePatternDot | NSUnderlineStyleSingle), @@ -286,14 +286,14 @@ + (NSDate *)NSDate:(id)json { }), NSUnderlineStyleSingle, integerValue) -HP_ENUM_CONVERTER(NSWritingDirection, (@{ +HIPPY_ENUM_CONVERTER(NSWritingDirection, (@{ @"auto": @(NSWritingDirectionNatural), @"ltr": @(NSWritingDirectionLeftToRight), @"rtl": @(NSWritingDirectionRightToLeft), }), NSWritingDirectionNatural, integerValue) -HP_ENUM_CONVERTER(UITextAutocapitalizationType, (@{ +HIPPY_ENUM_CONVERTER(UITextAutocapitalizationType, (@{ @"none": @(UITextAutocapitalizationTypeNone), @"words": @(UITextAutocapitalizationTypeWords), @"sentences": @(UITextAutocapitalizationTypeSentences), @@ -301,7 +301,7 @@ + (NSDate *)NSDate:(id)json { }), UITextAutocapitalizationTypeSentences, integerValue) -HP_ENUM_CONVERTER(UITextFieldViewMode, (@{ +HIPPY_ENUM_CONVERTER(UITextFieldViewMode, (@{ @"never": @(UITextFieldViewModeNever), @"while-editing": @(UITextFieldViewModeWhileEditing), @"unless-editing": @(UITextFieldViewModeUnlessEditing), @@ -309,7 +309,7 @@ + (NSDate *)NSDate:(id)json { }), UITextFieldViewModeNever, integerValue) -HP_ENUM_CONVERTER(UIKeyboardType, (@{ +HIPPY_ENUM_CONVERTER(UIKeyboardType, (@{ @"default": @(UIKeyboardTypeDefault), @"phone-pad": @(UIKeyboardTypePhonePad), @"email": @(UIKeyboardTypeEmailAddress), @@ -329,7 +329,7 @@ + (NSDate *)NSDate:(id)json { }), UIKeyboardTypeDefault, integerValue) -HP_MULTI_ENUM_CONVERTER(UIDataDetectorTypes, (@{ +HIPPY_MULTI_ENUM_CONVERTER(UIDataDetectorTypes, (@{ @"phoneNumber": @(UIDataDetectorTypePhoneNumber), @"link": @(UIDataDetectorTypeLink), @"address": @(UIDataDetectorTypeAddress), @@ -339,14 +339,14 @@ + (NSDate *)NSDate:(id)json { }), UIDataDetectorTypePhoneNumber, unsignedIntegerValue) -HP_ENUM_CONVERTER(UIKeyboardAppearance, (@{ +HIPPY_ENUM_CONVERTER(UIKeyboardAppearance, (@{ @"default": @(UIKeyboardAppearanceDefault), @"light": @(UIKeyboardAppearanceLight), @"dark": @(UIKeyboardAppearanceDark), }), UIKeyboardAppearanceDefault, integerValue) -HP_ENUM_CONVERTER(UIReturnKeyType, (@{ +HIPPY_ENUM_CONVERTER(UIReturnKeyType, (@{ @"default": @(UIReturnKeyDefault), @"go": @(UIReturnKeyGo), @"google": @(UIReturnKeyGoogle), @@ -361,7 +361,7 @@ + (NSDate *)NSDate:(id)json { }), UIReturnKeyDefault, integerValue) -HP_ENUM_CONVERTER(UIViewContentMode, (@{ +HIPPY_ENUM_CONVERTER(UIViewContentMode, (@{ @"scale-to-fill": @(UIViewContentModeScaleToFill), @"scale-aspect-fit": @(UIViewContentModeScaleAspectFit), @"scale-aspect-fill": @(UIViewContentModeScaleAspectFill), @@ -382,7 +382,7 @@ + (NSDate *)NSDate:(id)json { }), UIViewContentModeScaleAspectFill, integerValue) -HP_ENUM_CONVERTER(UIBarStyle, (@{ +HIPPY_ENUM_CONVERTER(UIBarStyle, (@{ @"default": @(UIBarStyleDefault), @"black": @(UIBarStyleBlack), }), @@ -434,19 +434,19 @@ +(type)type : (id)json { return result; \ } -HP_CUSTOM_CONVERTER(CGFloat, CGFloat, [self double:json]) +HIPPY_CUSTOM_CONVERTER(CGFloat, CGFloat, [self double:json]) HP_CGSTRUCT_CONVERTER(CGPoint, (@[@"x", @"y"]), (@{ @"l": @"x", @"t": @"y" })) HP_CGSTRUCT_CONVERTER(CGSize, (@[@"width", @"height"]), (@{ @"w": @"width", @"h": @"height" })) HP_CGSTRUCT_CONVERTER(CGRect, (@[@"x", @"y", @"width", @"height"]), (@{ @"l": @"x", @"t": @"y", @"w": @"width", @"h": @"height" })) HP_CGSTRUCT_CONVERTER(UIEdgeInsets, (@[@"top", @"left", @"bottom", @"right"]), nil) -HP_ENUM_CONVERTER(CGLineJoin, (@{ +HIPPY_ENUM_CONVERTER(CGLineJoin, (@{ @"miter": @(kCGLineJoinMiter), @"round": @(kCGLineJoinRound), @"bevel": @(kCGLineJoinBevel), }), kCGLineJoinMiter, intValue) -HP_ENUM_CONVERTER(CGLineCap, (@{ +HIPPY_ENUM_CONVERTER(CGLineCap, (@{ @"butt": @(kCGLineCapButt), @"round": @(kCGLineCapRound), @"square": @(kCGLineCapSquare), @@ -520,15 +520,15 @@ SEL HippyConvertSelectorForType(NSString *type) { return NSSelectorFromString([HippyParseType(&input) stringByAppendingString:@":"]); } -HP_ARRAY_CONVERTER(NSURL) -HP_ARRAY_CONVERTER(UIColor) +HIPPY_ARRAY_CONVERTER(NSURL) +HIPPY_ARRAY_CONVERTER(UIColor) /** * This macro is used for creating converter functions for directly * representable json array values that require no conversion. */ #if HIPPY_DEBUG -#define HP_JSON_ARRAY_CONVERTER(type) HP_ARRAY_CONVERTER(type) +#define HP_JSON_ARRAY_CONVERTER(type) HIPPY_ARRAY_CONVERTER(type) #else #define HP_JSON_ARRAY_CONVERTER(type) \ +(NSArray *)type##Array : (id)json { \ @@ -544,7 +544,7 @@ +(NSArray *)type##Array : (id)json { \ HP_JSON_ARRAY_CONVERTER(NSDictionary) HP_JSON_ARRAY_CONVERTER(NSNumber) -// Can't use HP_ARRAY_CONVERTER due to bridged cast +// Can't use HIPPY_ARRAY_CONVERTER due to bridged cast + (NSArray *)CGColorArray : (id)json { NSMutableArray *colors = [NSMutableArray new]; for (id value in [self NSArray:json]) { @@ -603,6 +603,6 @@ + (NSPropertyList)NSPropertyList:(id)json { return HippyConvertPropertyListValue(json); } -HP_ENUM_CONVERTER(css_backface_visibility_t, (@{ @"hidden": @NO, @"visible": @YES }), YES, boolValue) +HIPPY_ENUM_CONVERTER(css_backface_visibility_t, (@{ @"hidden": @NO, @"visible": @YES }), YES, boolValue) @end diff --git a/modules/ios/base/HippyDefines.h b/modules/ios/base/HippyDefines.h index 35ce19ff605..2b12aff1569 100644 --- a/modules/ios/base/HippyDefines.h +++ b/modules/ios/base/HippyDefines.h @@ -20,6 +20,9 @@ * limitations under the License. */ +#ifndef __HIPPY_DEFINES__ +#define __HIPPY_DEFINES__ + #if __OBJC__ #import #endif @@ -80,3 +83,9 @@ method NS_UNAVAILABLE { @throw _HippyNotImplementedException(_cmd, [self class]); \ } \ _Pragma("clang diagnostic pop") + + +#define HIPPY_VERSION_3_0 300 + + +#endif /* __HIPPY_DEFINES__ */ diff --git a/renderer/native/ios/renderer/HippyFont.mm b/renderer/native/ios/renderer/HippyFont.mm index 4c0d7404f78..258215c8756 100644 --- a/renderer/native/ios/renderer/HippyFont.mm +++ b/renderer/native/ios/renderer/HippyFont.mm @@ -122,7 +122,7 @@ + (UIFont *)UIFont:(id)json { scaleMultiplier:1]; } -HP_ENUM_CONVERTER(NativeRenderFontWeight, (@{ +HIPPY_ENUM_CONVERTER(NativeRenderFontWeight, (@{ @"normal": @(UIFontWeightRegular), @"bold": @(UIFontWeightBold), @"100": @(UIFontWeightUltraLight), @@ -138,7 +138,7 @@ + (UIFont *)UIFont:(id)json { UIFontWeightRegular, doubleValue) typedef BOOL NativeRenderFontStyle; -HP_ENUM_CONVERTER(NativeRenderFontStyle, (@{ +HIPPY_ENUM_CONVERTER(NativeRenderFontStyle, (@{ @"normal": @NO, @"italic": @YES, @"oblique": @YES, @@ -181,7 +181,7 @@ + (NativeRenderFontVariantDescriptor *)NativeRenderFontVariantDescriptor:(id)jso return value; } -HP_ARRAY_CONVERTER(NativeRenderFontVariantDescriptor) +HIPPY_ARRAY_CONVERTER(NativeRenderFontVariantDescriptor) @end diff --git a/renderer/native/ios/renderer/UIView+Render.h b/renderer/native/ios/renderer/UIView+Render.h index a2b77e9bfa3..5b5fb2549ed 100644 --- a/renderer/native/ios/renderer/UIView+Render.h +++ b/renderer/native/ios/renderer/UIView+Render.h @@ -28,7 +28,7 @@ NS_ASSUME_NONNULL_BEGIN @interface UIView (Render) -- (HippyUIManager *)renderImpl; +- (HippyUIManager *)uiManager; @end diff --git a/renderer/native/ios/renderer/UIView+Render.mm b/renderer/native/ios/renderer/UIView+Render.mm index 79c77f641e7..4a271125469 100644 --- a/renderer/native/ios/renderer/UIView+Render.mm +++ b/renderer/native/ios/renderer/UIView+Render.mm @@ -29,7 +29,7 @@ @implementation UIView (Render) -- (HippyUIManager *)renderImpl { +- (HippyUIManager *)uiManager { auto renderManager = [self renderManager].lock(); if (renderManager) { auto nativeRenderManager = std::static_pointer_cast(renderManager); diff --git a/renderer/native/ios/renderer/component/image/HippyImageView.m b/renderer/native/ios/renderer/component/image/HippyImageView.m index 361f46e678f..642285fa7a0 100644 --- a/renderer/native/ios/renderer/component/image/HippyImageView.m +++ b/renderer/native/ios/renderer/component/image/HippyImageView.m @@ -679,7 +679,7 @@ - (BorderRadiusStruct)properBorderRadius { @implementation HippyConvert (HippyResizeMode) -HP_ENUM_CONVERTER(HippyResizeMode, (@{ +HIPPY_ENUM_CONVERTER(HippyResizeMode, (@{ @"cover": @(HippyResizeModeCover), @"contain": @(HippyResizeModeContain), @"stretch": @(HippyResizeModeStretch), @@ -688,7 +688,7 @@ @implementation HippyConvert (HippyResizeMode) }), HippyResizeModeStretch, integerValue) -HP_ENUM_CONVERTER(HippyShapeMode, (@{ +HIPPY_ENUM_CONVERTER(HippyShapeMode, (@{ @"normal": @(HippyResizeModeDefalt), @"circle": @(HippyResizeModeCircle) }), HippyResizeModeDefalt, integerValue) diff --git a/renderer/native/ios/renderer/component/listview/HippyNextBaseListView.mm b/renderer/native/ios/renderer/component/listview/HippyNextBaseListView.mm index 91732f6ec39..67897e2455d 100644 --- a/renderer/native/ios/renderer/component/listview/HippyNextBaseListView.mm +++ b/renderer/native/ios/renderer/component/listview/HippyNextBaseListView.mm @@ -222,7 +222,7 @@ - (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView forIndexPath:indexPath]; HippyShadowView *headerRenderObject = [self.dataSource headerForSection:section]; if (headerRenderObject && [headerRenderObject isKindOfClass:[HippyShadowView class]]) { - UIView *headerView = [self.renderImpl createViewForShadowListItem:headerRenderObject]; + UIView *headerView = [self.uiManager createViewForShadowListItem:headerRenderObject]; CGRect frame = headerView.frame; frame.origin = CGPointZero; headerView.frame = frame; @@ -277,7 +277,7 @@ - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cell cellView = cachedVisibleCellView; HippyLogTrace(@"🟢 use cached visible cellView at %@ for %@", indexPath, shadowView.hippyTag); } else { - cellView = [self.renderImpl createViewForShadowListItem:shadowView]; + cellView = [self.uiManager createViewForShadowListItem:shadowView]; [_cachedWeakCellViews setObject:cellView forKey:shadowView.hippyTag]; HippyLogTrace(@"🟡 create cellView at %@ for %@", indexPath, shadowView.hippyTag); } diff --git a/renderer/native/ios/renderer/component/scrollview/HippyScrollViewManager.mm b/renderer/native/ios/renderer/component/scrollview/HippyScrollViewManager.mm index 0252edec633..0511fd71dbc 100644 --- a/renderer/native/ios/renderer/component/scrollview/HippyScrollViewManager.mm +++ b/renderer/native/ios/renderer/component/scrollview/HippyScrollViewManager.mm @@ -28,7 +28,7 @@ @implementation HippyConvert (UIScrollView) -HP_ENUM_CONVERTER(UIScrollViewKeyboardDismissMode, (@{ +HIPPY_ENUM_CONVERTER(UIScrollViewKeyboardDismissMode, (@{ @"none": @(UIScrollViewKeyboardDismissModeNone), @"on-drag": @(UIScrollViewKeyboardDismissModeOnDrag), @"interactive": @(UIScrollViewKeyboardDismissModeInteractive), @@ -37,7 +37,7 @@ @implementation HippyConvert (UIScrollView) }), UIScrollViewKeyboardDismissModeNone, integerValue) -HP_ENUM_CONVERTER(UIScrollViewIndicatorStyle, (@{ +HIPPY_ENUM_CONVERTER(UIScrollViewIndicatorStyle, (@{ @"default": @(UIScrollViewIndicatorStyleDefault), @"black": @(UIScrollViewIndicatorStyleBlack), @"white": @(UIScrollViewIndicatorStyleWhite), diff --git a/renderer/native/ios/renderer/component/smartViewPager/NativeRenderSmartViewPagerView.mm b/renderer/native/ios/renderer/component/smartViewPager/NativeRenderSmartViewPagerView.mm index 19837cc5a8f..b84b78a48b3 100644 --- a/renderer/native/ios/renderer/component/smartViewPager/NativeRenderSmartViewPagerView.mm +++ b/renderer/native/ios/renderer/component/smartViewPager/NativeRenderSmartViewPagerView.mm @@ -356,7 +356,7 @@ - (void)collectionView:(UICollectionView *)collectionView NSIndexPath *adjustIndexPath = [NSIndexPath indexPathForRow:cellIndex inSection:indexPath.section]; HippyWaterfallViewCell *hpCell = (HippyWaterfallViewCell *)cell; HippyShadowView *renderObject = [_dataSource cellForIndexPath:adjustIndexPath]; - UIView *cellView = [self.renderImpl createViewForShadowListItem:renderObject]; + UIView *cellView = [self.uiManager createViewForShadowListItem:renderObject]; hpCell.cellView = cellView; cellView.parent = self; } diff --git a/renderer/native/ios/renderer/component/waterfalllist/HippyWaterfallView.mm b/renderer/native/ios/renderer/component/waterfalllist/HippyWaterfallView.mm index df539ed3276..9198a180712 100644 --- a/renderer/native/ios/renderer/component/waterfalllist/HippyWaterfallView.mm +++ b/renderer/native/ios/renderer/component/waterfalllist/HippyWaterfallView.mm @@ -268,7 +268,7 @@ - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cell !((HippyShadowWaterfallItem *)shadowView).layoutDirty) { cellView = cachedCellView; } else { - cellView = [self.renderImpl createViewForShadowListItem:shadowView]; + cellView = [self.uiManager createViewForShadowListItem:shadowView]; [_cachedWeakCellViews setObject:cellView forKey:shadowView.hippyTag]; } diff --git a/renderer/native/ios/utils/HippyConvert+NativeRender.m b/renderer/native/ios/utils/HippyConvert+NativeRender.m index fc175cd49f2..5e3c6e524c7 100644 --- a/renderer/native/ios/utils/HippyConvert+NativeRender.m +++ b/renderer/native/ios/utils/HippyConvert+NativeRender.m @@ -163,7 +163,7 @@ + (CATransform3D)CATransform3D:(id)json { @implementation HippyConvert (HippyAnimationType) -HP_ENUM_CONVERTER(HippyAnimationType, (@{ +HIPPY_ENUM_CONVERTER(HippyAnimationType, (@{ @"spring": @(HippyAnimationTypeSpring), @"linear": @(HippyAnimationTypeLinear), @"easeIn": @(HippyAnimationTypeEaseIn), @@ -177,7 +177,7 @@ @implementation HippyConvert (HippyAnimationType) @implementation HippyConvert (HippyPointerEvents) -HP_ENUM_CONVERTER(HippyPointerEvents, (@{ +HIPPY_ENUM_CONVERTER(HippyPointerEvents, (@{ @"none": @(HippyPointerEventsNone), @"box-only": @(HippyPointerEventsBoxOnly), @"box-none": @(HippyPointerEventsBoxNone), @@ -189,7 +189,7 @@ @implementation HippyConvert (HippyPointerEvents) @implementation HippyConvert (HippyBorderStyle) -HP_ENUM_CONVERTER(HippyBorderStyle, (@{ +HIPPY_ENUM_CONVERTER(HippyBorderStyle, (@{ @"solid": @(HippyBorderStyleSolid), @"dotted": @(HippyBorderStyleDotted), @"dashed": @(HippyBorderStyleDashed), @@ -201,7 +201,7 @@ @implementation HippyConvert (HippyBorderStyle) @implementation HippyConvert (HippyTextEnumDefines) -HP_ENUM_CONVERTER(HippyTextDecorationLineType, (@{ +HIPPY_ENUM_CONVERTER(HippyTextDecorationLineType, (@{ @"none": @(HippyTextDecorationLineTypeNone), @"underline": @(HippyTextDecorationLineTypeUnderline), @"line-through": @(HippyTextDecorationLineTypeStrikethrough), @@ -209,7 +209,7 @@ @implementation HippyConvert (HippyTextEnumDefines) }), HippyTextDecorationLineTypeNone, integerValue) -HP_ENUM_CONVERTER(HippyTextVerticalAlignType, (@{ +HIPPY_ENUM_CONVERTER(HippyTextVerticalAlignType, (@{ @"middle": @(HippyTextVerticalAlignMiddle), @"top": @(HippyTextVerticalAlignTop), @"bottom": @(HippyTextVerticalAlignBottom), From 69bb49dbb7cfb7c4ae114cc6b74195f2625a10bd Mon Sep 17 00:00:00 2001 From: wwwcg Date: Fri, 2 Feb 2024 17:28:05 +0800 Subject: [PATCH 3/8] chore(ios): revert rename symbol Prefix and fix compatibility issues --- hippy_backup.podspec | 453 ------------------ .../ios/renderer/HippyUIManager+Private.h | 1 + .../component/textinput/HippyTextField.h | 6 +- .../component/textinput/HippyTextField.m | 8 +- ...tiveRenderViewPager.h => HippyViewPager.h} | 2 +- ...veRenderViewPager.mm => HippyViewPager.mm} | 16 +- ...erViewPagerItem.h => HippyViewPagerItem.h} | 2 +- ...erViewPagerItem.m => HippyViewPagerItem.m} | 4 +- ...rManager.h => HippyViewPagerItemManager.h} | 2 +- ...Manager.mm => HippyViewPagerItemManager.m} | 8 +- ...rItemManager.h => HippyViewPagerManager.h} | 2 +- ...agerManager.mm => HippyViewPagerManager.m} | 12 +- 12 files changed, 32 insertions(+), 484 deletions(-) delete mode 100644 hippy_backup.podspec rename renderer/native/ios/renderer/component/viewPager/{NativeRenderViewPager.h => HippyViewPager.h} (95%) rename renderer/native/ios/renderer/component/viewPager/{NativeRenderViewPager.mm => HippyViewPager.mm} (97%) rename renderer/native/ios/renderer/component/viewPager/{NativeRenderViewPagerItem.h => HippyViewPagerItem.h} (93%) rename renderer/native/ios/renderer/component/viewPager/{NativeRenderViewPagerItem.m => HippyViewPagerItem.m} (92%) rename renderer/native/ios/renderer/component/viewPager/{NativeRenderViewPagerManager.h => HippyViewPagerItemManager.h} (93%) rename renderer/native/ios/renderer/component/viewPager/{NativeRenderViewPagerItemManager.mm => HippyViewPagerItemManager.m} (82%) rename renderer/native/ios/renderer/component/viewPager/{NativeRenderViewPagerItemManager.h => HippyViewPagerManager.h} (92%) rename renderer/native/ios/renderer/component/viewPager/{NativeRenderViewPagerManager.mm => HippyViewPagerManager.m} (87%) diff --git a/hippy_backup.podspec b/hippy_backup.podspec deleted file mode 100644 index 0e32cc620b9..00000000000 --- a/hippy_backup.podspec +++ /dev/null @@ -1,453 +0,0 @@ -# -# Be sure to run `pod lib lint hippy.podspec --verbose --use-libraries' to ensure this is a -# valid spec before submitting. -# -# Any lines starting with a # are optional, but their use is encouraged -# To learn more about a Podspec see https://guides.cocoapods.org/syntax/podspec.html -# - -layout_engine = "Taitank" -js_engine = "jsc" -use_frameworks = false; - -Pod::Spec.new do |s| - if ENV["layout_engine"] - layout_engine = ENV["layout_engine"] - end - if ENV["use_frameworks"] - use_frameworks = true - end - if ENV["js_engine"] - js_engine = ENV["js_engine"] - end - puts "layout engine is #{layout_engine}, js engine is #{js_engine}" - puts "use_frameworks trigger is #{use_frameworks}" - if use_frameworks - framework_header_path = '${PODS_CONFIGURATION_BUILD_DIR}/hippy/hippy.framework/Headers' - s.module_map = false; - end - - s.name = 'hippy' - s.version = '3.0.0' - s.summary = 'Hippy Cross Platform Framework' - s.description = <<-DESC - Hippy is designed for developers to easily build cross-platform and high-performance awesome apps. - DESC - s.homepage = 'https://hippyjs.org' - s.license = { :type => 'Apache2', :file => 'LICENSE' } - s.author = 'OpenHippy Team' - s.source = {:git => 'https://github.com/Tencent/Hippy.git', :tag => s.version} - s.platform = :ios - s.ios.deployment_target = '11.0' - - #prepare_command not working for subspecs,so we remove devtools script from devtools subspec to root - s.prepare_command = <<-CMD - ./xcodeinitscript.sh "#{layout_engine}" "#{js_engine}" - CMD - - s.subspec 'Framework' do |framework| - puts 'hippy subspec \'framework\' read begin' - framework.source_files = 'framework/ios/**/*.{h,m,c,mm,s,cpp,cc}' - framework.public_header_files = 'framework/ios/**/*.h' - if js_engine == "jsc" - framework.exclude_files = ['framework/ios/base/enginewrapper/v8', 'framework/ios/utils/v8'] - elsif js_engine == "v8" - framework.exclude_files = ['framework/ios/base/enginewrapper/jsc', 'framework/ios/utils/jsc'] - else - framework.exclude_files = ['framework/ios/base/enginewrapper/jsc', 'framework/ios/utils/jsc', 'framework/ios/base/enginewrapper/v8', 'framework/ios/utils/v8'] - end - framework.libraries = 'c++' - framework.pod_target_xcconfig = { - 'CLANG_CXX_LANGUAGE_STANDARD' => 'c++17', - 'GCC_ENABLE_CPP_EXCEPTIONS' => false, - 'GCC_ENABLE_CPP_RTTI' => false, - } - framework.dependency 'hippy/Base' - framework.dependency 'hippy/JSDriver' - framework.dependency 'hippy/Image' - framework.dependency 'hippy/iOSVFS' - framework.dependency 'hippy/NativeRenderer' - puts 'hippy subspec \'framework\' read end' - end - - s.subspec 'Footstone' do |footstone| - puts 'hippy subspec \'footstone\' read begin' - footstone.libraries = 'c++' - footstone.source_files = ['modules/footstone/**/*.{h,cc}'] - footstone.public_header_files = ['modules/footstone/**/*.h'] - footstone.exclude_files = ['modules/footstone/include/footstone/platform/adr', 'modules/footstone/src/platform/adr'] - if use_frameworks - header_search_paths = "#{framework_header_path}" + " #{framework_header_path}/include" - footstone.header_mappings_dir = 'modules/footstone' - else - header_search_paths = '${PODS_ROOT}/hippy/modules/footstone/include' + - ' ${PODS_ROOT}/hippy/modules/footstone' - end - footstone.pod_target_xcconfig = { - 'CLANG_CXX_LANGUAGE_STANDARD' => 'c++17', - 'GCC_PREPROCESSOR_DEFINITIONS[config=Release]' => '${inherited} NDEBUG=1', - 'GCC_ENABLE_CPP_EXCEPTIONS' => false, - 'GCC_ENABLE_CPP_RTTI' => false, - 'HEADER_SEARCH_PATHS' => header_search_paths - } - footstone.user_target_xcconfig = { - 'HEADER_SEARCH_PATHS' => header_search_paths - } - footstone.preserve_path = 'modules/footstone' - puts 'hippy subspec \'footstone\' read end' - end - - s.subspec 'FootstoneUtils' do |footstoneutils| - puts 'hippy subspec \'footstoneutils\' read begin' - footstoneutils.libraries = 'c++' - footstoneutils.source_files = ['modules/ios/footstoneutils/*.{h,mm}'] - footstoneutils.public_header_files = ['modules/ios/footstoneutils/*.h'] - footstoneutils.pod_target_xcconfig = { - 'CLANG_CXX_LANGUAGE_STANDARD' => 'c++17', - 'GCC_ENABLE_CPP_EXCEPTIONS' => false, - 'GCC_ENABLE_CPP_RTTI' => false, - } - footstoneutils.dependency 'hippy/Footstone' - footstoneutils.dependency 'hippy/Base' - puts 'hippy subspec \'footstoneutils\' read end' - end - - s.subspec 'Image' do |image| - puts 'hippy subspec \'image\' read begin' - image.libraries = 'c++' - image.frameworks = 'CoreServices' - image.public_header_files = 'modules/ios/image/*.h' - image.source_files = 'modules/ios/image/*.{h,m,mm}' - puts 'hippy subspec \'image\' read end' - end - - s.subspec 'Base' do |base| - puts 'hippy subspec \'base\' read begin' - base.libraries = 'c++' - base.source_files = ['modules/ios/base/*.{h,m,mm}', 'modules/ios/logutils/*.{h,mm}'] - base.public_header_files = ['modules/ios/base/*.h', 'modules/ios/logutils/*.h'] - base.dependency 'hippy/Footstone' - puts 'hippy subspec \'base\' read end' - end - - s.subspec 'VFS' do |vfs| - puts 'hippy subspec \'vfs\' read begin' - vfs.libraries = 'c++' - vfs.source_files = ['modules/vfs/native/**/*.{h,cc}'] - vfs.public_header_files = ['modules/vfs/native/include/vfs/**/*.h'] - if use_frameworks - header_search_paths = framework_header_path - vfs.header_mappings_dir = 'modules/vfs/native/include' - else - header_search_paths = '${PODS_ROOT}/hippy/modules/vfs/native/include' - end - vfs.pod_target_xcconfig = { - 'CLANG_CXX_LANGUAGE_STANDARD' => 'c++17', - 'HEADER_SEARCH_PATHS' => header_search_paths, - 'GCC_ENABLE_CPP_EXCEPTIONS' => false, - 'GCC_ENABLE_CPP_RTTI' => false, - } - vfs.user_target_xcconfig = { - 'HEADER_SEARCH_PATHS' => header_search_paths - } - vfs.preserve_path = 'modules/vfs/native' - vfs.dependency 'hippy/Footstone' - puts 'hippy subspec \'vfs\' read end' - end - - s.subspec 'iOSVFS' do |iosvfs| - puts 'hippy subspec \'iosvfs\' read begin' - iosvfs.libraries = 'c++' - iosvfs.source_files = ['modules/vfs/ios/*.{h,m,mm}'] - iosvfs.public_header_files = ['modules/vfs/ios/*.h'] - iosvfs.pod_target_xcconfig = { - 'CLANG_CXX_LANGUAGE_STANDARD' => 'c++17', - 'GCC_ENABLE_CPP_EXCEPTIONS' => false, - 'GCC_ENABLE_CPP_RTTI' => false, - } - iosvfs.dependency 'hippy/VFS' - iosvfs.dependency 'hippy/Footstone' - iosvfs.dependency 'hippy/FootstoneUtils' - puts 'hippy subspec \'iosvfs\' read end' - end - - s.subspec 'JSDriver' do |driver| - puts 'hippy subspec \'driver\' read begin' - driver.libraries = 'c++' - driver.frameworks = 'JavaScriptCore' - driver.source_files = ['driver/js/include/**/*.h', 'driver/js/src/**/*.cc'] - driver.public_header_files = 'driver/js/include/**/*.h' - if js_engine == "jsc" - driver.exclude_files = [ - 'driver/js/include/driver/napi/v8', - 'driver/js/src/napi/v8', - 'driver/js/include/driver/runtime', - 'driver/js/src/runtime', - 'driver/js/include/driver/vm/v8', - 'driver/js/src/vm/v8'] - elsif js_engine == "v8" - driver.exclude_files = [ - 'driver/js/include/driver/napi/jsc', - 'driver/js/src/napi/jsc', - 'driver/js/include/driver/vm/jsc', - 'driver/js/src/vm/jsc'] - else - driver.exclude_files = [ - 'driver/js/include/driver/napi/v8', - 'driver/js/src/napi/v8', - 'driver/js/include/driver/runtime', - 'driver/js/src/runtime', - 'driver/js/include/vm/v8', - 'driver/js/src/vm/v8', - 'driver/js/include/driver/napi/jsc', - 'driver/js/src/napi/jsc', - 'driver/js/include/vm/jsc', - 'driver/js/src/vm/jsc'] - end - - if use_frameworks - header_search_paths = framework_header_path - driver.header_mappings_dir = 'driver/js/include' - else - header_search_paths = '${PODS_ROOT}/hippy/driver/js/include/' - end - definition_engine = '' - if js_engine == "jsc" - definition_engine = 'JS_JSC=1' - elsif js_engine == "v8" - definition_engine = 'JS_V8=1' - else - end - driver.pod_target_xcconfig = { - 'HEADER_SEARCH_PATHS' => header_search_paths, - 'GCC_PREPROCESSOR_DEFINITIONS' => definition_engine, - 'CLANG_CXX_LANGUAGE_STANDARD' => 'c++17', - 'GCC_ENABLE_CPP_EXCEPTIONS' => false, - 'GCC_ENABLE_CPP_RTTI' => false, - } - driver.user_target_xcconfig = { - 'HEADER_SEARCH_PATHS' => header_search_paths, - } - driver.dependency 'hippy/Footstone' - driver.dependency 'hippy/Dom' - driver.dependency 'hippy/iOSVFS' - driver.preserve_path = 'driver/js' - puts 'hippy subspec \'driver\' read end' - end - - s.subspec 'NativeRenderer' do |renderer| - puts 'hippy subspec \'nativerenderer\' read begin' - renderer.libraries = 'c++' - renderer.source_files = 'renderer/native/ios/**/*.{h,m,mm}' - renderer.public_header_files = 'renderer/native/ios/**/*.h' - renderer.dependency 'hippy/Base' - renderer.dependency 'hippy/DomUtils' - renderer.dependency 'hippy/Image' - renderer.dependency 'hippy/iOSVFS' - puts 'hippy subspec \'nativerenderer\' read end' - end - - s.subspec 'Dom' do |dom| - puts 'hippy subspec \'dom\' read begin' - dom_source_files = Array['dom/include/**/*.h', 'dom/src/**/*.cc'] - dom_exclude_files = Array['dom/src/dom/*unittests.cc', - 'dom/src/dom/tools'] - if use_frameworks - dom_pod_target_header_path = framework_header_path - dom.header_mappings_dir = 'dom/include' - else - dom_pod_target_header_path = '${PODS_ROOT}/hippy/dom/include/' - end - if layout_engine == "Taitank" - dom_exclude_files.append('dom/include/dom/yoga_layout_node.h') - dom_exclude_files.append('dom/src/dom/yoga_layout_node.cc') - elsif layout_engine == "Yoga" - dom_exclude_files.append('dom/include/dom/taitank_layout_node.h') - dom_exclude_files.append('dom/src/dom/taitank_layout_node.cc') - end - - dom.libraries = 'c++' - dom.source_files = dom_source_files - dom.public_header_files = ['dom/include/**/*.h'] - dom.exclude_files = dom_exclude_files - dom.pod_target_xcconfig = { - 'CLANG_CXX_LANGUAGE_STANDARD' => 'c++17', - 'HEADER_SEARCH_PATHS' => dom_pod_target_header_path, - 'GCC_ENABLE_CPP_EXCEPTIONS' => false, - 'GCC_ENABLE_CPP_RTTI' => false, - } - dom.user_target_xcconfig = { - 'HEADER_SEARCH_PATHS' => dom_pod_target_header_path - } - dom.dependency 'hippy/Footstone' - if layout_engine == "Taitank" - dom.dependency 'hippy/Taitank' - elsif layout_engine == "Yoga" - dom.dependency 'hippy/Yoga' - end - dom.preserve_path = 'dom' - puts 'hippy subspec \'dom\' read end' - end - - s.subspec 'DomUtils' do |domutils| - puts 'hippy subspec \'domutils\' read begin' - dom_source_files = Array['modules/ios/domutils/*.{h,mm}'] - domutils.libraries = 'c++' - domutils.source_files = dom_source_files - domutils.public_header_files = ['modules/ios/domutils/*.h'] - domutils.pod_target_xcconfig = { - 'CLANG_CXX_LANGUAGE_STANDARD' => 'c++17', - 'GCC_ENABLE_CPP_EXCEPTIONS' => false, - 'GCC_ENABLE_CPP_RTTI' => false, - } - domutils.dependency 'hippy/Dom' - domutils.dependency 'hippy/FootstoneUtils' - domutils.dependency 'hippy/Base' - puts 'hippy subspec \'domutils\' read end' - end - - if layout_engine == "Taitank" - s.subspec 'Taitank' do |taitank| - puts 'hippy subspec \'Taitank\' read begin' - taitank.source_files = ['dom/dom_project/_deps/taitank-src/src/*.{h,cc}'] - taitank.public_header_files = ['dom/include/dom/taitank_layout_node.h', 'dom/dom_project/_deps/taitank-src/src/*.h'] - if use_frameworks - header_search_paths = framework_header_path - else - header_search_paths = '${PODS_ROOT}/hippy/dom/dom_project/_deps/taitank-src/src' - end - taitank.pod_target_xcconfig = { - 'CLANG_CXX_LANGUAGE_STANDARD' => 'c++17', - 'HEADER_SEARCH_PATHS' => header_search_paths, - 'GCC_ENABLE_CPP_EXCEPTIONS' => false, - 'GCC_ENABLE_CPP_RTTI' => false, - } - taitank.libraries = 'c++' - taitank.preserve_path = 'dom/dom_project' - puts 'hippy subspec \'Taitank\' read end' - end - elsif layout_engine == "Yoga" - s.subspec 'Yoga' do |yoga| - puts 'hippy subspec \'yoga\' read begin' - yoga.source_files = ['dom/dom_project/_deps/yoga-src/yoga/**/*.{c,h,cpp}'] - yoga.public_header_files = ['dom/include/dom/yoga_layout_node.h', 'dom/dom_project/_deps/yoga-src/yoga/**/*.h'] - if use_frameworks - header_search_paths = framework_header_path - else - header_search_paths = '${PODS_ROOT}/hippy/dom/dom_project/_deps/yoga-src' - end - yoga.pod_target_xcconfig = { - 'CLANG_CXX_LANGUAGE_STANDARD' => 'c++17', - 'HEADER_SEARCH_PATHS' => header_search_paths, - 'GCC_ENABLE_CPP_EXCEPTIONS' => false, - 'GCC_ENABLE_CPP_RTTI' => false, - } - yoga.libraries = 'c++' - yoga.preserve_path = 'dom/dom_project' - puts 'hippy subspec \'yoga\' read end' - end - end - - #devtools subspec - s.subspec 'DevTools' do |devtools| - puts 'hippy subspec \'devtools\' read begin' - devtools.libraries = 'c++' - devtools_exclude_files = Array.new; - if js_engine == "jsc" - devtools_exclude_files += ['devtools/devtools-integration/native/include/devtools/v8', 'devtools/devtools-integration/native/src/v8'] - elsif js_engine == "v8" - else - devtools_exclude_files += ['devtools/devtools-integration/native/include/devtools/v8', 'devtools/devtools-integration/native/src/v8'] - end - devtools.exclude_files = [ - #test files - 'devtools/devtools-integration/ios/DevtoolsBackend/_deps/**/*test*/**/*', - 'devtools/devtools-integration/ios/DevtoolsBackend/_deps/**/*test*', - #benchmark files - 'devtools/devtools-integration/ios/DevtoolsBackend/_deps/**/benchmark/**', - #js files - 'devtools/devtools-integration/ios/DevtoolsBackend/_deps/**/javascript/**', - #Dom includes all taitank or yoga files, and Devtools dependends on Dom, so let Dom does the including work, otherwise, 'duplicated symbols' error occurs - #taitank or yoga files - #currently Devtools specify taitank layout - 'devtools/devtools-integration/ios/DevtoolsBackend/_deps/taitank-*/**/*', - #other files - 'devtools/devtools-integration/ios/DevtoolsBackend/_deps/base64-src/lib/lib_openmp.c', - 'devtools/devtools-integration/ios/DevtoolsBackend/_deps/base64-src/lib/tables/table_generator.c', - 'devtools/devtools-integration/ios/DevtoolsBackend/_deps/base64-src/lib/arch/**/{dec,enc}_*.c', - 'devtools/devtools-integration/ios/DevtoolsBackend/_deps/base64-src/bin/base64.c', - ] + devtools_exclude_files - devtools.public_header_files = [ - 'devtools/devtools-integration/native/include/devtools/devtools_data_source.h', - #devtools_integration/native - 'devtools/devtools-integration/native/**/*.h', - #devtools_backend - 'devtools/devtools-backend/**/*.{h,hpp}', - 'devtools/devtools-integration/ios/DevtoolsBackend/_deps/*-src/**/*.{h,hpp,ipp}', - 'devtools/devtools-integration/ios/DevtoolsBackend/_deps/base64-src/lib/tables/*.h', - 'devtools/devtools-integration/ios/DevtoolsBackend/_deps/base64-build/config.h', - ] - devtools.source_files = [ - #devtools_integration/native - 'devtools/devtools-integration/native/**/*.{h,cc}', - #devtools_integration/ios - 'devtools/devtools-integration/ios/DevtoolsBackend/_deps/*-src/**/*.{h,hpp,c,cc,ipp}', - 'devtools/devtools-integration/ios/DevtoolsBackend/_deps/base64-build/config.h', - #devtools_backend - 'devtools/devtools-backend/**/*.{h,hpp,cc}', - ] - if use_frameworks - pod_search_path = "#{framework_header_path}/devtools-integration/ios/DevtoolsBackend/_deps/asio-src/asio/include" + - " #{framework_header_path}/devtools-integration/ios/DevtoolsBackend/_deps/json-src/include" + - " #{framework_header_path}/devtools-integration/ios/DevtoolsBackend/_deps/base64-src/include" + - " #{framework_header_path}/devtools-integration/ios/DevtoolsBackend/_deps/websocketpp-src" + - " #{framework_header_path}/devtools-integration/native/include" + - " #{framework_header_path}/devtools-backend/include" + - " #{framework_header_path}/devtools/devtools-integration/ios/DevtoolsBackend/_deps/base64-src/lib/arch" - - devtools.header_mappings_dir = 'devtools' - else - pod_search_path = '${PODS_ROOT}/hippy/devtools/devtools-integration/ios/DevtoolsBackend/_deps/asio-src/asio/include' + - ' ${PODS_ROOT}/hippy/devtools/devtools-integration/ios/DevtoolsBackend/_deps/json-src/include' + - ' ${PODS_ROOT}/hippy/devtools/devtools-integration/ios/DevtoolsBackend/_deps/base64-src/include' + - ' ${PODS_ROOT}/hippy/devtools/devtools-integration/ios/DevtoolsBackend/_deps/websocketpp-src' + - ' ${PODS_ROOT}/hippy/devtools/devtools-integration/native/include' + - ' ${PODS_ROOT}/hippy/devtools/devtools-backend/include' + - ' ${PODS_ROOT}/hippy/devtools/devtools-integration/ios/DevtoolsBackend/_deps/base64-src/lib/arch' - end - devtools.pod_target_xcconfig = { - 'HEADER_SEARCH_PATHS' => pod_search_path, - 'GCC_PREPROCESSOR_DEFINITIONS' => 'ENABLE_INSPECTOR=1 ASIO_NO_TYPEID ASIO_NO_EXCEPTIONS ASIO_DISABLE_ALIGNOF _WEBSOCKETPP_NO_EXCEPTIONS_ JSON_NOEXCEPTION BASE64_STATIC_DEFINE', - 'CLANG_CXX_LANGUAGE_STANDARD' => 'c++17', - 'GCC_ENABLE_CPP_EXCEPTIONS' => false, - 'GCC_ENABLE_CPP_RTTI' => false, - } - devtools.user_target_xcconfig = { - 'GCC_PREPROCESSOR_DEFINITIONS' => 'ENABLE_INSPECTOR=1' - } - devtools.dependency 'hippy/Footstone' - devtools.dependency 'hippy/Dom' - devtools.dependency 'hippy/VFS' - devtools.preserve_path = 'devtools' - puts 'hippy subspec \'devtools\' read end' - end - - if js_engine == "v8" - s.subspec 'v8' do |v8| - puts 'hippy subspec \'v8\' read begin' - v8.source_files = ['v8forios/v8/include'] - v8.public_header_files = ['v8forios/v8/include'] - v8.pod_target_xcconfig = { - 'CLANG_CXX_LANGUAGE_STANDARD' => 'c++17', - 'HEADER_SEARCH_PATHS' => '${PODS_ROOT}/hippy/v8forios/v8/include ${PODS_ROOT}/hippy/v8forios/v8/include/v8', - 'GCC_ENABLE_CPP_EXCEPTIONS' => false, - 'GCC_ENABLE_CPP_RTTI' => false, - } - v8.libraries = 'c++' - v8.vendored_library = 'v8forios/v8/libv8.a' - v8.preserve_path = 'v8forios/v8' - puts 'hippy subspec \'v8\' read end' - end - end - -end diff --git a/renderer/native/ios/renderer/HippyUIManager+Private.h b/renderer/native/ios/renderer/HippyUIManager+Private.h index 67bfeff24b3..a8a8b95ddfa 100644 --- a/renderer/native/ios/renderer/HippyUIManager+Private.h +++ b/renderer/native/ios/renderer/HippyUIManager+Private.h @@ -23,6 +23,7 @@ #ifndef HippyUIManager_Private_h #define HippyUIManager_Private_h +#import "HippyUIManager.h" #include #include #include diff --git a/renderer/native/ios/renderer/component/textinput/HippyTextField.h b/renderer/native/ios/renderer/component/textinput/HippyTextField.h index 096ab974285..4d586ceda52 100644 --- a/renderer/native/ios/renderer/component/textinput/HippyTextField.h +++ b/renderer/native/ios/renderer/component/textinput/HippyTextField.h @@ -25,15 +25,15 @@ #import "HippyComponent.h" #import "HippyBaseTextInput.h" -@protocol NativeRenderUITextFieldResponseDelegate +@protocol HippyUITextFieldResponseDelegate @required - (void)textview_becomeFirstResponder; - (void)textview_resignFirstResponder; @end -@interface NativeRenderUITextField : UITextField +@interface HippyUITextField : UITextField @property (nonatomic, assign) BOOL textWasPasted; -@property (nonatomic, weak) id responderDelegate; +@property (nonatomic, weak) id responderDelegate; @property (nonatomic, copy) HippyDirectEventBlock onBlur; @property (nonatomic, copy) HippyDirectEventBlock onFocus; diff --git a/renderer/native/ios/renderer/component/textinput/HippyTextField.m b/renderer/native/ios/renderer/component/textinput/HippyTextField.m index 18391889e4a..ddfd59ad589 100644 --- a/renderer/native/ios/renderer/component/textinput/HippyTextField.m +++ b/renderer/native/ios/renderer/component/textinput/HippyTextField.m @@ -27,7 +27,7 @@ #import "HippyTextSelection.h" #import "UIView+Hippy.h" -@implementation NativeRenderUITextField +@implementation HippyUITextField - (void)setKeyboardType:(UIKeyboardType)keyboardType { if(self.keyboardType == keyboardType){ @@ -111,12 +111,12 @@ - (void)dealloc { @end -@interface HippyTextField () +@interface HippyTextField () @end @implementation HippyTextField { UITextRange *_previousSelectionRange; - NativeRenderUITextField *_textView; + HippyUITextField *_textView; } - (void)keyboardWillShow:(NSNotification *)aNotification { @@ -140,7 +140,7 @@ - (void)keyboardWillHide:(NSNotification *)aNotification { - (instancetype)initWithFrame:(CGRect)frame { if ((self = [super initWithFrame:frame])) { [self setContentInset:UIEdgeInsetsZero]; - _textView = [[NativeRenderUITextField alloc] initWithFrame:CGRectZero]; + _textView = [[HippyUITextField alloc] initWithFrame:CGRectZero]; _textView.responderDelegate = self; _textView.backgroundColor = [UIColor clearColor]; _textView.textColor = [UIColor blackColor]; diff --git a/renderer/native/ios/renderer/component/viewPager/NativeRenderViewPager.h b/renderer/native/ios/renderer/component/viewPager/HippyViewPager.h similarity index 95% rename from renderer/native/ios/renderer/component/viewPager/NativeRenderViewPager.h rename to renderer/native/ios/renderer/component/viewPager/HippyViewPager.h index fd3a6a1f670..552813c6baa 100644 --- a/renderer/native/ios/renderer/component/viewPager/NativeRenderViewPager.h +++ b/renderer/native/ios/renderer/component/viewPager/HippyViewPager.h @@ -31,7 +31,7 @@ */ typedef void (^ViewPagerItemsCountChanged)(NSUInteger count); -@interface NativeRenderViewPager : UIScrollView +@interface HippyViewPager : UIScrollView @property (nonatomic, strong) HippyDirectEventBlock onPageSelected; @property (nonatomic, strong) HippyDirectEventBlock onPageScroll; @property (nonatomic, strong) HippyDirectEventBlock onPageScrollStateChanged; diff --git a/renderer/native/ios/renderer/component/viewPager/NativeRenderViewPager.mm b/renderer/native/ios/renderer/component/viewPager/HippyViewPager.mm similarity index 97% rename from renderer/native/ios/renderer/component/viewPager/NativeRenderViewPager.mm rename to renderer/native/ios/renderer/component/viewPager/HippyViewPager.mm index 23c3daf3999..a214b88835a 100644 --- a/renderer/native/ios/renderer/component/viewPager/NativeRenderViewPager.mm +++ b/renderer/native/ios/renderer/component/viewPager/HippyViewPager.mm @@ -20,8 +20,8 @@ * limitations under the License. */ -#import "NativeRenderViewPager.h" -#import "NativeRenderViewPagerItem.h" +#import "HippyViewPager.h" +#import "HippyViewPagerItem.h" #import "UIView+Hippy.h" #import "UIView+DirectionalLayout.h" #import "UIView+MountEvent.h" @@ -29,7 +29,7 @@ #include "float.h" -@interface NativeRenderViewPager () +@interface HippyViewPager () @property (nonatomic, strong) NSMutableArray *viewPagerItems; @property (nonatomic, assign) BOOL isScrolling; @property (nonatomic, assign) BOOL loadOnce; @@ -48,7 +48,7 @@ @interface NativeRenderViewPager () @end -@implementation NativeRenderViewPager +@implementation HippyViewPager #pragma mark life cycle - (instancetype)initWithFrame:(CGRect)frame { if ((self = [super initWithFrame:frame])) { @@ -100,13 +100,13 @@ - (void)insertHippySubview:(UIView *)view atIndex:(NSInteger)atIndex { [super insertHippySubview:view atIndex:(NSInteger)atIndex]; [self.viewPagerItems insertObject:view atIndex:atIndex]; - if ([view isKindOfClass:[NativeRenderViewPagerItem class]]) { - NativeRenderViewPagerItem *item = (NativeRenderViewPagerItem *)view; - __weak NativeRenderViewPager *weakPager = self; + if ([view isKindOfClass:[HippyViewPagerItem class]]) { + HippyViewPagerItem *item = (HippyViewPagerItem *)view; + __weak HippyViewPager *weakPager = self; __weak UIView *weakItem = item; item.frameSetBlock = ^CGRect(CGRect frame) { if (weakPager) { - NativeRenderViewPager *strongPager = weakPager; + HippyViewPager *strongPager = weakPager; UIView *strongItem = weakItem; if (strongItem) { NSUInteger index = [strongPager.viewPagerItems indexOfObject:strongItem]; diff --git a/renderer/native/ios/renderer/component/viewPager/NativeRenderViewPagerItem.h b/renderer/native/ios/renderer/component/viewPager/HippyViewPagerItem.h similarity index 93% rename from renderer/native/ios/renderer/component/viewPager/NativeRenderViewPagerItem.h rename to renderer/native/ios/renderer/component/viewPager/HippyViewPagerItem.h index 91211699019..3eba58d2515 100644 --- a/renderer/native/ios/renderer/component/viewPager/NativeRenderViewPagerItem.h +++ b/renderer/native/ios/renderer/component/viewPager/HippyViewPagerItem.h @@ -26,7 +26,7 @@ typedef CGRect(^FrameSetBlock)(CGRect frame); -@interface NativeRenderViewPagerItem : NativeRenderTouchesView +@interface HippyViewPagerItem : NativeRenderTouchesView @property (nonatomic, copy)FrameSetBlock frameSetBlock; diff --git a/renderer/native/ios/renderer/component/viewPager/NativeRenderViewPagerItem.m b/renderer/native/ios/renderer/component/viewPager/HippyViewPagerItem.m similarity index 92% rename from renderer/native/ios/renderer/component/viewPager/NativeRenderViewPagerItem.m rename to renderer/native/ios/renderer/component/viewPager/HippyViewPagerItem.m index b9b8f0539b6..4ab472e406b 100644 --- a/renderer/native/ios/renderer/component/viewPager/NativeRenderViewPagerItem.m +++ b/renderer/native/ios/renderer/component/viewPager/HippyViewPagerItem.m @@ -20,9 +20,9 @@ * limitations under the License. */ -#import "NativeRenderViewPagerItem.h" +#import "HippyViewPagerItem.h" -@implementation NativeRenderViewPagerItem +@implementation HippyViewPagerItem - (void)setFrame:(CGRect)frame { CGRect finalFrame = frame; diff --git a/renderer/native/ios/renderer/component/viewPager/NativeRenderViewPagerManager.h b/renderer/native/ios/renderer/component/viewPager/HippyViewPagerItemManager.h similarity index 93% rename from renderer/native/ios/renderer/component/viewPager/NativeRenderViewPagerManager.h rename to renderer/native/ios/renderer/component/viewPager/HippyViewPagerItemManager.h index bca2905cd6b..847d5cf51dd 100644 --- a/renderer/native/ios/renderer/component/viewPager/NativeRenderViewPagerManager.h +++ b/renderer/native/ios/renderer/component/viewPager/HippyViewPagerItemManager.h @@ -24,6 +24,6 @@ #import "HippyViewManager.h" -@interface NativeRenderViewPagerManager : HippyViewManager +@interface HippyViewPagerItemManager : HippyViewManager @end diff --git a/renderer/native/ios/renderer/component/viewPager/NativeRenderViewPagerItemManager.mm b/renderer/native/ios/renderer/component/viewPager/HippyViewPagerItemManager.m similarity index 82% rename from renderer/native/ios/renderer/component/viewPager/NativeRenderViewPagerItemManager.mm rename to renderer/native/ios/renderer/component/viewPager/HippyViewPagerItemManager.m index 18c59e8e69d..16d34781b17 100644 --- a/renderer/native/ios/renderer/component/viewPager/NativeRenderViewPagerItemManager.mm +++ b/renderer/native/ios/renderer/component/viewPager/HippyViewPagerItemManager.m @@ -20,15 +20,15 @@ * limitations under the License. */ -#import "NativeRenderViewPagerItemManager.h" -#import "NativeRenderViewPagerItem.h" +#import "HippyViewPagerItemManager.h" +#import "HippyViewPagerItem.h" -@implementation NativeRenderViewPagerItemManager +@implementation HippyViewPagerItemManager HIPPY_EXPORT_MODULE(ViewPagerItem) - (UIView *)view { - return [NativeRenderViewPagerItem new]; + return [HippyViewPagerItem new]; } @end diff --git a/renderer/native/ios/renderer/component/viewPager/NativeRenderViewPagerItemManager.h b/renderer/native/ios/renderer/component/viewPager/HippyViewPagerManager.h similarity index 92% rename from renderer/native/ios/renderer/component/viewPager/NativeRenderViewPagerItemManager.h rename to renderer/native/ios/renderer/component/viewPager/HippyViewPagerManager.h index 8900825a99b..a51bc994638 100644 --- a/renderer/native/ios/renderer/component/viewPager/NativeRenderViewPagerItemManager.h +++ b/renderer/native/ios/renderer/component/viewPager/HippyViewPagerManager.h @@ -24,6 +24,6 @@ #import "HippyViewManager.h" -@interface NativeRenderViewPagerItemManager : HippyViewManager +@interface HippyViewPagerManager : HippyViewManager @end diff --git a/renderer/native/ios/renderer/component/viewPager/NativeRenderViewPagerManager.mm b/renderer/native/ios/renderer/component/viewPager/HippyViewPagerManager.m similarity index 87% rename from renderer/native/ios/renderer/component/viewPager/NativeRenderViewPagerManager.mm rename to renderer/native/ios/renderer/component/viewPager/HippyViewPagerManager.m index 95a18448dbc..494a3fef16f 100644 --- a/renderer/native/ios/renderer/component/viewPager/NativeRenderViewPagerManager.mm +++ b/renderer/native/ios/renderer/component/viewPager/HippyViewPagerManager.m @@ -21,15 +21,15 @@ */ #import "HippyUIManager.h" -#import "NativeRenderViewPagerManager.h" -#import "NativeRenderViewPager.h" +#import "HippyViewPagerManager.h" +#import "HippyViewPager.h" -@implementation NativeRenderViewPagerManager +@implementation HippyViewPagerManager HIPPY_EXPORT_MODULE(ViewPager) - (UIView *)view { - return [NativeRenderViewPager new]; + return [HippyViewPager new]; } HIPPY_EXPORT_VIEW_PROPERTY(bounces, BOOL) @@ -45,11 +45,11 @@ - (void)setPage:(NSNumber *)pageNumber withTag:(NSNumber * _Nonnull)componentTag [self.bridge.uiManager addUIBlock:^(__unused HippyUIManager *uiManager, NSDictionary *viewRegistry){ UIView *view = viewRegistry[componentTag]; - if (![view isKindOfClass:[NativeRenderViewPager class]]) { + if (![view isKindOfClass:[HippyViewPager class]]) { HippyLogError(@"tried to setPage: on an error viewPager %@ with tag #%@", view, componentTag); } NSInteger pageNumberInteger = pageNumber.integerValue; - [(NativeRenderViewPager *)view setPage:pageNumberInteger animated:animated]; + [(HippyViewPager *)view setPage:pageNumberInteger animated:animated]; }]; } From 2a17ef811763661f8d967db75d77355d7d962c0e Mon Sep 17 00:00:00 2001 From: wwwcg Date: Fri, 1 Mar 2024 20:26:32 +0800 Subject: [PATCH 4/8] refactor(ios): normalize code and clean up some code problems --- .../native/ios/renderer/HippyUIManager.mm | 7 +- .../listview/HippyNextBaseListItemView.m | 4 -- .../listview/HippyNextBaseListView.h | 2 +- .../listview/HippyNextBaseListView.mm | 15 ++-- .../listview/HippyNextBaseListViewCell.h | 2 + .../HippyNextBaseListViewDataSource.mm | 72 ++++++++++--------- .../listview/HippyNextListTableView.h | 4 +- .../renderer/component/refresh/HippyRefresh.h | 6 +- .../NativeRenderSmartViewPagerView.h | 2 +- .../NativeRenderSmartViewPagerView.mm | 7 +- .../waterfalllist/HippyWaterfallView.h | 2 +- .../waterfalllist/HippyWaterfallView.mm | 2 +- .../HippyWaterfallViewDataSource.h | 37 ++++++++-- .../HippyWaterfallViewDataSource.mm | 32 ++++----- 14 files changed, 111 insertions(+), 83 deletions(-) diff --git a/renderer/native/ios/renderer/HippyUIManager.mm b/renderer/native/ios/renderer/HippyUIManager.mm index c0636a31d67..de15ee9b8ad 100644 --- a/renderer/native/ios/renderer/HippyUIManager.mm +++ b/renderer/native/ios/renderer/HippyUIManager.mm @@ -341,14 +341,17 @@ - (void)registerRootView:(UIView *)rootView asRootNode:(std::weak_ptr) - (void)unregisterRootViewFromTag:(NSNumber *)rootTag { AssertMainQueue(); UIView *rootView = [_viewRegistry rootComponentForTag:rootTag]; + NSDictionary *userInfo; if (rootView) { [rootView removeObserver:self forKeyPath:@"frame"]; + userInfo = @{ HippyUIManagerRootViewKey: rootView, + HippyUIManagerRootViewTagKey: rootTag }; + } else { + userInfo = @{ HippyUIManagerRootViewTagKey: rootTag }; } std::lock_guard lock([self renderQueueLock]); [_viewRegistry removeRootComponentWithTag:rootTag]; [_shadowViewRegistry removeRootComponentWithTag:rootTag]; - - NSDictionary *userInfo = @{ HippyUIManagerRootViewKey: rootView, HippyUIManagerRootViewTagKey: rootTag }; [[NSNotificationCenter defaultCenter] postNotificationName:HippyUIManagerDidRemoveRootViewNotification object:self userInfo:userInfo]; diff --git a/renderer/native/ios/renderer/component/listview/HippyNextBaseListItemView.m b/renderer/native/ios/renderer/component/listview/HippyNextBaseListItemView.m index 67577f54f6f..f2d4b34836a 100644 --- a/renderer/native/ios/renderer/component/listview/HippyNextBaseListItemView.m +++ b/renderer/native/ios/renderer/component/listview/HippyNextBaseListItemView.m @@ -50,8 +50,4 @@ - (void)cellAppearStateChanged:(CellAppearState)state { } } -- (void)setFrame:(CGRect)frame { - [super setFrame:frame]; -} - @end diff --git a/renderer/native/ios/renderer/component/listview/HippyNextBaseListView.h b/renderer/native/ios/renderer/component/listview/HippyNextBaseListView.h index 125e6c4265d..9b65fc9a6bc 100644 --- a/renderer/native/ios/renderer/component/listview/HippyNextBaseListView.h +++ b/renderer/native/ios/renderer/component/listview/HippyNextBaseListView.h @@ -28,7 +28,7 @@ @class HippyNextBaseListViewCell; -@interface HippyNextBaseListView : HippyWaterfallView +@interface HippyNextBaseListView : HippyWaterfallView /** * Hippy events diff --git a/renderer/native/ios/renderer/component/listview/HippyNextBaseListView.mm b/renderer/native/ios/renderer/component/listview/HippyNextBaseListView.mm index 67897e2455d..ef979e98405 100644 --- a/renderer/native/ios/renderer/component/listview/HippyNextBaseListView.mm +++ b/renderer/native/ios/renderer/component/listview/HippyNextBaseListView.mm @@ -38,7 +38,7 @@ static NSString *const kSupplementaryIdentifier = @"HippySupplementaryIdentifier"; static NSString *const kListViewItem = @"ListViewItem"; -@interface HippyNextBaseListView () { +@interface HippyNextBaseListView () { BOOL _isInitialListReady; NSArray *_previousVisibleCells; } @@ -53,7 +53,6 @@ - (instancetype)initWithFrame:(CGRect)frame { if (self = [super initWithFrame:frame]) { _isInitialListReady = NO; self.preloadItemNumber = 1; - self.dataSource.itemViewName = [self compoentItemName]; } return self; } @@ -145,8 +144,8 @@ - (void)setScrollEnabled:(BOOL)value { - (void)reloadData { NSArray *datasource = [self.hippyShadowView.subcomponents copy]; self->_dataSource = [[HippyNextBaseListViewDataSource alloc] initWithDataSource:datasource - itemViewName:[self compoentItemName] - containBannerView:NO]; + itemViewName:[self compoentItemName] + containBannerView:NO]; [self.collectionView reloadData]; if (self.initialContentOffset) { @@ -245,10 +244,10 @@ - (void)collectionView:(UICollectionView *)collectionView self.onRowWillDisplay(@{ @"index": @(index), @"frame": @ { - @"x": @(CGRectGetMinX(cellRenderObjectView.frame)), - @"y": @(CGRectGetMinY(cellRenderObjectView.frame)), - @"width": @(CGRectGetWidth(cellRenderObjectView.frame)), - @"height": @(CGRectGetHeight(cellRenderObjectView.frame)) + @"x": @(CGRectGetMinX(cell.frame)), + @"y": @(CGRectGetMinY(cell.frame)), + @"width": @(CGRectGetWidth(cell.frame)), + @"height": @(CGRectGetHeight(cell.frame)) } }); } diff --git a/renderer/native/ios/renderer/component/listview/HippyNextBaseListViewCell.h b/renderer/native/ios/renderer/component/listview/HippyNextBaseListViewCell.h index 196a5e6fbef..d45e66c96a3 100644 --- a/renderer/native/ios/renderer/component/listview/HippyNextBaseListViewCell.h +++ b/renderer/native/ios/renderer/component/listview/HippyNextBaseListViewCell.h @@ -38,6 +38,8 @@ typedef NS_ENUM(NSUInteger, CellShowState) { CellNotShowState, CellHalfShowState @protocol ViewAppearStateProtocol +/// Called when cell appear state changed +/// - Parameter state: CellAppearState - (void)cellAppearStateChanged:(CellAppearState)state; @end diff --git a/renderer/native/ios/renderer/component/listview/HippyNextBaseListViewDataSource.mm b/renderer/native/ios/renderer/component/listview/HippyNextBaseListViewDataSource.mm index e4f473cfd30..8bb04d095e4 100644 --- a/renderer/native/ios/renderer/component/listview/HippyNextBaseListViewDataSource.mm +++ b/renderer/native/ios/renderer/component/listview/HippyNextBaseListViewDataSource.mm @@ -25,8 +25,11 @@ #import "HippyShadowView.h" #import "HippyShadowListView.h" + +static NSString * const kStickyCellPropKey = @"sticky"; + @interface HippyNextBaseListViewDataSource () { - NSMutableArray *_headerRenderObjects; + NSMutableArray *_shadowHeaderViews; } @end @@ -34,43 +37,41 @@ @interface HippyNextBaseListViewDataSource () { @implementation HippyNextBaseListViewDataSource - (void)setDataSource:(NSArray *)dataSource containBannerView:(BOOL)containBannerView { - NSMutableArray *headerRenderObjects = [NSMutableArray array]; - NSMutableArray *> *cellRenderObjects = [NSMutableArray array]; - NSMutableArray *sectionCellRenderObject = nil; + NSMutableArray *shadowHeaders = [NSMutableArray array]; + NSMutableArray *> *shadowCells = [NSMutableArray array]; + NSMutableArray *shadowSectionCell = nil; BOOL isFirstIndex = YES; - for (HippyShadowView *renderObject in dataSource) { - NSString *viewName = [renderObject viewName]; - if ([self.itemViewName isEqualToString:viewName]) { - NSNumber *sticky = renderObject.props[@"sticky"]; + for (HippyShadowView *shadowView in dataSource) { + if ([self.itemViewName isEqualToString:shadowView.viewName]) { + NSNumber *sticky = shadowView.props[kStickyCellPropKey]; if ([sticky boolValue]) { - [headerRenderObjects addObject:renderObject]; - if (sectionCellRenderObject) { - [cellRenderObjects addObject:sectionCellRenderObject]; - sectionCellRenderObject = nil; + [shadowHeaders addObject:shadowView]; + if (shadowSectionCell) { + [shadowCells addObject:shadowSectionCell]; + shadowSectionCell = nil; } - } - else { - if (nil == sectionCellRenderObject) { - sectionCellRenderObject = [NSMutableArray array]; + } else { + if (nil == shadowSectionCell) { + shadowSectionCell = [NSMutableArray array]; } - [sectionCellRenderObject addObject:renderObject]; + [shadowSectionCell addObject:shadowView]; } - if (isFirstIndex && 0 == [headerRenderObjects count]) { - [headerRenderObjects addObject:[NSNull null]]; + if (isFirstIndex && 0 == [shadowHeaders count]) { + [shadowHeaders addObject:[NSNull null]]; isFirstIndex = NO; } } } - if (sectionCellRenderObject) { - [cellRenderObjects addObject:sectionCellRenderObject]; + if (shadowSectionCell) { + [shadowCells addObject:shadowSectionCell]; } - _headerRenderObjects = headerRenderObjects; - self.cellRenderObjectViews = [cellRenderObjects copy]; + _shadowHeaderViews = shadowHeaders; + self->_shadowCellViews = [shadowCells copy]; } - (HippyShadowView *)cellForIndexPath:(NSIndexPath *)indexPath { - if (self.cellRenderObjectViews.count > indexPath.section) { - NSArray *sectionCellRenderObject = [self.cellRenderObjectViews objectAtIndex:indexPath.section]; + if (self.shadowCellViews.count > indexPath.section) { + NSArray *sectionCellRenderObject = [self.shadowCellViews objectAtIndex:indexPath.section]; if (sectionCellRenderObject.count > indexPath.row) { return [sectionCellRenderObject objectAtIndex:indexPath.row]; } @@ -81,8 +82,8 @@ - (HippyShadowView *)cellForIndexPath:(NSIndexPath *)indexPath { - (NSIndexPath *)indexPathOfCell:(HippyShadowView *)cell { NSInteger section = 0; NSInteger row = 0; - for (NSInteger sec = 0; sec < [self.cellRenderObjectViews count]; sec++) { - NSArray *sectionCellRenderObjects = [self.cellRenderObjectViews objectAtIndex:sec]; + for (NSInteger sec = 0; sec < [self.shadowCellViews count]; sec++) { + NSArray *sectionCellRenderObjects = [self.shadowCellViews objectAtIndex:sec]; for (NSUInteger r = 0; r < [sectionCellRenderObjects count]; r++) { HippyShadowView *cellRenderObject = [sectionCellRenderObjects objectAtIndex:r]; if (cellRenderObject == cell) { @@ -95,20 +96,21 @@ - (NSIndexPath *)indexPathOfCell:(HippyShadowView *)cell { } - (HippyShadowView *)headerForSection:(NSInteger)section { - if (_headerRenderObjects.count > section) { - return [_headerRenderObjects objectAtIndex:section]; + if (_shadowHeaderViews.count > section) { + id shadowHeader = [_shadowHeaderViews objectAtIndex:section]; + return [shadowHeader isKindOfClass:HippyShadowView.class] ? shadowHeader : nil; } return nil; } - (NSInteger)numberOfSection { - NSInteger numberOfSection = self.cellRenderObjectViews.count; + NSInteger numberOfSection = self.shadowCellViews.count; return numberOfSection; } - (NSInteger)numberOfCellForSection:(NSInteger)section { - if (self.cellRenderObjectViews.count > section) { - return [[self.cellRenderObjectViews objectAtIndex:section] count]; + if (self.shadowCellViews.count > section) { + return [[self.shadowCellViews objectAtIndex:section] count]; } return 0; } @@ -117,8 +119,8 @@ - (NSIndexPath *)indexPathForFlatIndex:(NSInteger)index { NSInteger sectionIndex = 0; NSInteger rowIndex = 0; NSInteger selfIncreaseIndex = 0; - for (NSInteger sec = 0; sec < [self.cellRenderObjectViews count]; sec++) { - NSArray *sectionCellRenderObjects = [self.cellRenderObjectViews objectAtIndex:sec]; + for (NSInteger sec = 0; sec < [self.shadowCellViews count]; sec++) { + NSArray *sectionCellRenderObjects = [self.shadowCellViews objectAtIndex:sec]; for (NSUInteger r = 0; r < [sectionCellRenderObjects count]; r++) { if (index == selfIncreaseIndex) { sectionIndex = sec; @@ -140,7 +142,7 @@ - (NSInteger)flatIndexForIndexPath:(NSIndexPath *)indexPath { flatIndex += row; } else { - NSArray *sectionCellRenderObjects = [self.cellRenderObjectViews objectAtIndex:sec]; + NSArray *sectionCellRenderObjects = [self.shadowCellViews objectAtIndex:sec]; flatIndex += [sectionCellRenderObjects count]; } } diff --git a/renderer/native/ios/renderer/component/listview/HippyNextListTableView.h b/renderer/native/ios/renderer/component/listview/HippyNextListTableView.h index fa6d129ee8b..af83e54a19a 100644 --- a/renderer/native/ios/renderer/component/listview/HippyNextListTableView.h +++ b/renderer/native/ios/renderer/component/listview/HippyNextListTableView.h @@ -26,7 +26,7 @@ NS_ASSUME_NONNULL_BEGIN @class HippyNextListTableView; -@protocol HippyListTableViewLayoutProtocol +@protocol HippyNextListTableViewLayoutProtocol /** * Invoke when HippyNextListTableView layout its subviews @@ -37,7 +37,7 @@ NS_ASSUME_NONNULL_BEGIN @interface HippyNextListTableView : UICollectionView -@property (nonatomic, weak) id layoutDelegate; +@property (nonatomic, weak) id layoutDelegate; @end diff --git a/renderer/native/ios/renderer/component/refresh/HippyRefresh.h b/renderer/native/ios/renderer/component/refresh/HippyRefresh.h index d7e29900ea7..5e883901e57 100644 --- a/renderer/native/ios/renderer/component/refresh/HippyRefresh.h +++ b/renderer/native/ios/renderer/component/refresh/HippyRefresh.h @@ -31,7 +31,7 @@ typedef NS_ENUM(NSUInteger, HippyRefreshStatus) { }; @class HippyRefresh; -@protocol NativeRenderRefreshDelegate +@protocol HippyRefreshDelegate @optional - (void)refreshView:(HippyRefresh *)refreshView statusChanged:(HippyRefreshStatus)status; @@ -42,12 +42,12 @@ typedef NS_ENUM(NSUInteger, HippyRefreshStatus) { @protected __weak UIScrollView *_scrollView; HippyRefreshStatus _status; - __weak id _delegate; + __weak id _delegate; } @property (nonatomic, weak) UIScrollView *scrollView; @property (nonatomic, readonly) HippyRefreshStatus status; -@property (nonatomic, weak) id delegate; +@property (nonatomic, weak) id delegate; - (void)unsetFromScrollView; diff --git a/renderer/native/ios/renderer/component/smartViewPager/NativeRenderSmartViewPagerView.h b/renderer/native/ios/renderer/component/smartViewPager/NativeRenderSmartViewPagerView.h index 08b859cf21c..e5fb8d70fcb 100644 --- a/renderer/native/ios/renderer/component/smartViewPager/NativeRenderSmartViewPagerView.h +++ b/renderer/native/ios/renderer/component/smartViewPager/NativeRenderSmartViewPagerView.h @@ -29,7 +29,7 @@ NS_ASSUME_NONNULL_BEGIN @class HippyNextBaseListViewCell; -@interface NativeRenderSmartViewPagerView : HippyWaterfallView +@interface NativeRenderSmartViewPagerView : HippyWaterfallView /** * Hippy events diff --git a/renderer/native/ios/renderer/component/smartViewPager/NativeRenderSmartViewPagerView.mm b/renderer/native/ios/renderer/component/smartViewPager/NativeRenderSmartViewPagerView.mm index b84b78a48b3..abac1ef5f3e 100644 --- a/renderer/native/ios/renderer/component/smartViewPager/NativeRenderSmartViewPagerView.mm +++ b/renderer/native/ios/renderer/component/smartViewPager/NativeRenderSmartViewPagerView.mm @@ -39,7 +39,7 @@ static NSString *const kSupplementaryIdentifier = @"SupplementaryIdentifier"; static NSString *const kListViewItem = @"ListViewItem"; -@interface NativeRenderSmartViewPagerView () { +@interface NativeRenderSmartViewPagerView () { __weak UIView *_rootView; BOOL _isInitialListReady; NSTimeInterval _lastScrollDispatchTime; @@ -62,8 +62,9 @@ @implementation NativeRenderSmartViewPagerView - (instancetype)initWithFrame:(CGRect)frame { if (self = [super initWithFrame:frame]) { _isInitialListReady = NO; - _dataSource = [[HippyNextBaseListViewDataSource alloc] init]; - self.dataSource.itemViewName = [self compoentItemName]; + _dataSource = [[HippyNextBaseListViewDataSource alloc] initWithDataSource:nil + itemViewName:[self compoentItemName] + containBannerView:NO]; [self initialization]; self.collectionView.alwaysBounceVertical = NO; self.collectionView.alwaysBounceHorizontal = YES; diff --git a/renderer/native/ios/renderer/component/waterfalllist/HippyWaterfallView.h b/renderer/native/ios/renderer/component/waterfalllist/HippyWaterfallView.h index eaceb729376..7af72dc98d6 100644 --- a/renderer/native/ios/renderer/component/waterfalllist/HippyWaterfallView.h +++ b/renderer/native/ios/renderer/component/waterfalllist/HippyWaterfallView.h @@ -44,7 +44,7 @@ typedef NS_ENUM(NSInteger, NativeRenderScrollState) { */ @interface HippyWaterfallView : NativeRenderTouchesView { + HippyNextListTableViewLayoutProtocol, HippyScrollProtocol> { @protected HippyWaterfallViewDataSource *_dataSource; diff --git a/renderer/native/ios/renderer/component/waterfalllist/HippyWaterfallView.mm b/renderer/native/ios/renderer/component/waterfalllist/HippyWaterfallView.mm index 9198a180712..f46f7ddbf61 100644 --- a/renderer/native/ios/renderer/component/waterfalllist/HippyWaterfallView.mm +++ b/renderer/native/ios/renderer/component/waterfalllist/HippyWaterfallView.mm @@ -38,7 +38,7 @@ static NSString *kCellIdentifier = @"HippyWaterfallCellIdentifier"; static NSString *kWaterfallItemName = @"WaterfallItem"; -@interface HippyWaterfallView () { +@interface HippyWaterfallView () { NSHashTable> *_scrollListeners; BOOL _isInitialListReady; UIColor *_backgroundColor; diff --git a/renderer/native/ios/renderer/component/waterfalllist/HippyWaterfallViewDataSource.h b/renderer/native/ios/renderer/component/waterfalllist/HippyWaterfallViewDataSource.h index e0c91615059..e16810d10a4 100644 --- a/renderer/native/ios/renderer/component/waterfalllist/HippyWaterfallViewDataSource.h +++ b/renderer/native/ios/renderer/component/waterfalllist/HippyWaterfallViewDataSource.h @@ -27,18 +27,43 @@ NS_ASSUME_NONNULL_BEGIN @class HippyShadowView; -@interface HippyWaterfallViewDataSource : NSObject +/// The DataSource of Waterfall and ListView component +@interface HippyWaterfallViewDataSource : NSObject { +@protected + NSArray *> *_shadowCellViews; + +} -- (instancetype)initWithDataSource:(NSArray<__kindof HippyShadowView *> *)dataSource +/// Init Method. +/// - Parameters: +/// - dataSource: shadowView array +/// - itemViewName: view name +/// - containBannerView: bool value +- (instancetype)initWithDataSource:(nullable NSArray<__kindof HippyShadowView *> *)dataSource itemViewName:(NSString *)itemViewName - containBannerView:(BOOL)containBannerView; + containBannerView:(BOOL)containBannerView NS_DESIGNATED_INITIALIZER; +/// Use initWithDataSource instead ++ (instancetype)new NS_UNAVAILABLE; +/// Use initWithDataSource instead +- (instancetype)init NS_UNAVAILABLE; + +/// Whether contain bannerView, currently used by the waterfall component. @property(nonatomic, readonly) BOOL containBannerView; +/// The BannerView, currently waterfall component has. @property(nonatomic, readonly) HippyShadowView *bannerView; -@property(nonatomic, copy) NSArray *> *cellRenderObjectViews; -@property(nonatomic, copy) NSString *itemViewName; +/// The shadowViews of Cells +@property(nonatomic, readonly) NSArray *> *shadowCellViews; +/// The view name of cell item +@property(nonatomic, readonly) NSString *itemViewName; + +/// Update datasource +/// - Parameters: +/// - dataSource: shadowView array +/// - containBannerView: BOOL +- (void)setDataSource:(NSArray<__kindof HippyShadowView *> *)dataSource + containBannerView:(BOOL)containBannerView; -- (void)setDataSource:(NSArray<__kindof HippyShadowView *> *)dataSource containBannerView:(BOOL)containBannerView; - (HippyShadowView *)cellForIndexPath:(NSIndexPath *)indexPath; - (HippyShadowView *)headerForSection:(NSInteger)section; - (NSInteger)numberOfSection; diff --git a/renderer/native/ios/renderer/component/waterfalllist/HippyWaterfallViewDataSource.mm b/renderer/native/ios/renderer/component/waterfalllist/HippyWaterfallViewDataSource.mm index 3876f8ec343..5219e1509cf 100644 --- a/renderer/native/ios/renderer/component/waterfalllist/HippyWaterfallViewDataSource.mm +++ b/renderer/native/ios/renderer/component/waterfalllist/HippyWaterfallViewDataSource.mm @@ -29,8 +29,8 @@ @interface HippyWaterfallViewDataSource () { BOOL _containBannerView; - NSArray *> *_cellRenderObjectViews; HippyShadowView *_bannerView; + NSString *_itemViewName; } @end @@ -42,7 +42,7 @@ - (instancetype)initWithDataSource:(NSArray<__kindof HippyShadowView *> *)dataSo containBannerView:(BOOL)containBannerView { self = [super init]; if (self) { - self.itemViewName = itemViewName; + _itemViewName = itemViewName; [self setDataSource:dataSource containBannerView:containBannerView]; } return self; @@ -52,13 +52,13 @@ - (id)copyWithZone:(nullable NSZone *)zone { HippyWaterfallViewDataSource *dataSource = [[[self class] allocWithZone:zone] init]; dataSource->_containBannerView = self.containBannerView; dataSource->_bannerView = _bannerView; - NSMutableArray *> *objectSectionViews = [NSMutableArray arrayWithCapacity:[_cellRenderObjectViews count]]; - for (NSArray *objects in _cellRenderObjectViews) { + NSMutableArray *> *objectSectionViews = [NSMutableArray arrayWithCapacity:[_shadowCellViews count]]; + for (NSArray *objects in _shadowCellViews) { NSArray *copiedObjects = [objects copy]; [objectSectionViews addObject:copiedObjects]; } - dataSource->_cellRenderObjectViews = [objectSectionViews copy]; - dataSource.itemViewName = [self.itemViewName copy]; + dataSource->_shadowCellViews = [objectSectionViews copy]; + dataSource->_itemViewName = [self.itemViewName copy]; return dataSource; } @@ -89,10 +89,10 @@ - (void)setDataSource:(NSArray *)dataSource }); NSArray *objects = [candidateRenderObjectViews filteredArrayUsingPredicate:prediate]; if ([objects count]) { - _cellRenderObjectViews = [NSArray arrayWithObject:objects]; + _shadowCellViews = [NSArray arrayWithObject:objects]; } else { - _cellRenderObjectViews = nil; + _shadowCellViews = nil; } } } @@ -101,8 +101,8 @@ -(HippyShadowView *)bannerView { return _bannerView; } -- (NSArray *> *)cellRenderObjectViews { - return [_cellRenderObjectViews copy]; +- (NSArray *> *)shadowCellViews { + return [_shadowCellViews copy]; } - (HippyShadowView *)cellForIndexPath:(NSIndexPath *)indexPath { @@ -110,7 +110,7 @@ - (HippyShadowView *)cellForIndexPath:(NSIndexPath *)indexPath { return _bannerView; } else { - return [[_cellRenderObjectViews firstObject] objectAtIndex:[indexPath row]]; + return [[_shadowCellViews firstObject] objectAtIndex:[indexPath row]]; } } @@ -120,16 +120,16 @@ - (HippyShadowView *)headerForSection:(NSInteger)section { - (NSInteger)numberOfSection { NSInteger count = _containBannerView ? 1 : 0; - count += [[_cellRenderObjectViews firstObject] count] ? 1 : 0; + count += [[_shadowCellViews firstObject] count] ? 1 : 0; return count; } - (NSInteger)numberOfCellForSection:(NSInteger)section { if (_containBannerView) { - return 0 == section ? 1 : [[_cellRenderObjectViews firstObject] count]; + return 0 == section ? 1 : [[_shadowCellViews firstObject] count]; } else { - return [[_cellRenderObjectViews firstObject] count]; + return [[_shadowCellViews firstObject] count]; } } @@ -139,11 +139,11 @@ - (NSIndexPath *)indexPathOfCell:(HippyShadowView *)cell { if (_containBannerView) { if (_bannerView != cell) { section = 1; - row = [[_cellRenderObjectViews firstObject] indexOfObject:cell]; + row = [[_shadowCellViews firstObject] indexOfObject:cell]; } } else { - row = [[_cellRenderObjectViews firstObject] indexOfObject:cell]; + row = [[_shadowCellViews firstObject] indexOfObject:cell]; } return [NSIndexPath indexPathForRow:row inSection:section]; } From 240060276eb824e5d2246085c0ed8756c38e4109 Mon Sep 17 00:00:00 2001 From: wwwcg Date: Mon, 4 Mar 2024 21:15:08 +0800 Subject: [PATCH 5/8] feat(ios): add rootViewRunApplicationFinished delegate method for HippyRootViewDelegate --- renderer/native/ios/renderer/HippyRootView.mm | 10 ++++++++++ renderer/native/ios/renderer/HippyRootViewDelegate.h | 5 +++++ 2 files changed, 15 insertions(+) diff --git a/renderer/native/ios/renderer/HippyRootView.mm b/renderer/native/ios/renderer/HippyRootView.mm index 60947c36d86..84dc1341337 100644 --- a/renderer/native/ios/renderer/HippyRootView.mm +++ b/renderer/native/ios/renderer/HippyRootView.mm @@ -29,6 +29,7 @@ #import "HippyUIManager.h" #import "HippyDeviceBaseInfo.h" #import "HippyTouchHandler.h" +#import "HippyJSExecutor.h" #include // Sent when the first subviews are added to the root view @@ -231,7 +232,16 @@ - (void)runHippyApplication { // Register RootView [self.bridge setRootView:contentView]; + // Run Application [self.bridge loadInstanceForRootView:self.hippyTag withProperties:self.appProperties]; + // Call callback if needed + if ([self.delegate respondsToSelector:@selector(rootViewRunApplicationFinished:)]) { + __weak __typeof(self)weakSelf = self; + [self.bridge.javaScriptExecutor executeBlockOnJavaScriptQueue:^{ + __strong __typeof(weakSelf)strongSelf = weakSelf; + [strongSelf.delegate rootViewRunApplicationFinished:strongSelf]; + }]; + } self.contentView = contentView; [self insertSubview:contentView atIndex:0]; HippyLogInfo(@"[Hippy_OC_Log][Life_Circle],Running application %@ (%@)", self.moduleName, self.appProperties); diff --git a/renderer/native/ios/renderer/HippyRootViewDelegate.h b/renderer/native/ios/renderer/HippyRootViewDelegate.h index 7dad3386221..66526640b31 100644 --- a/renderer/native/ios/renderer/HippyRootViewDelegate.h +++ b/renderer/native/ios/renderer/HippyRootViewDelegate.h @@ -33,6 +33,11 @@ */ - (void)rootView:(HippyRootView *)rootView didLoadFinish:(BOOL)success; +/** + * Called after the JSAPI runApplication finished. + */ +- (void)rootViewRunApplicationFinished:(HippyRootView *)rootView; + /** * Called when rootview dealloc. */ From ace5988e022a70b3c53763914cc858acef3e0678 Mon Sep 17 00:00:00 2001 From: wwwcg Date: Mon, 4 Mar 2024 21:17:47 +0800 Subject: [PATCH 6/8] fix(ios): increase code robustness and compatibility for HippyRootView --- renderer/native/ios/renderer/HippyRootView.mm | 5 ++++- .../native/ios/renderer/component/view/HippyShadowView.h | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/renderer/native/ios/renderer/HippyRootView.mm b/renderer/native/ios/renderer/HippyRootView.mm index 84dc1341337..f9ed9123ed5 100644 --- a/renderer/native/ios/renderer/HippyRootView.mm +++ b/renderer/native/ios/renderer/HippyRootView.mm @@ -160,6 +160,9 @@ - (instancetype)initWithBridge:(HippyBridge *)bridge // Execute loadInstance first and then do call back, maintain compatibility with hippy2 dispatch_async(dispatch_get_main_queue(), ^{ __strong __typeof(weakSelf)strongSelf = weakSelf; + if (!strongSelf) { + return; + } if (!error && !strongSelf.disableAutoRunApplication) { [strongSelf runHippyApplication]; } @@ -408,7 +411,7 @@ - (void)insertHippySubview:(UIView *)subview atIndex:(NSInteger)atIndex { strongSelf->_contentHasAppeared = YES; // int64_t cost = [strongSelf.bridge.performanceLogger durationForTag:HippyPLTTI]; [[NSNotificationCenter defaultCenter] postNotificationName:HippyContentDidAppearNotification - object:self userInfo:@{ + object:self.superview userInfo:@{ // @"cost": @(cost) }]; } diff --git a/renderer/native/ios/renderer/component/view/HippyShadowView.h b/renderer/native/ios/renderer/component/view/HippyShadowView.h index c6c359053e7..eaf4d86fd49 100644 --- a/renderer/native/ios/renderer/component/view/HippyShadowView.h +++ b/renderer/native/ios/renderer/component/view/HippyShadowView.h @@ -124,7 +124,7 @@ typedef void (^HippyViewInsertionBlock)(UIView *container, NSArray *ch /** * Indicate how we create coresponding UIView - * HippyCreationTypeInstantly : create views instantly when NativeRenderObject is created + * HippyCreationTypeInstantly : create views instantly when HippyShadowView is created * HippyCreationTypeLazily: create views when UIView is needed */ @property (nonatomic, assign) HippyCreationType creationType; From ea562fad4da8b4b59759381451fcab7a89ee5196 Mon Sep 17 00:00:00 2001 From: wwwcg Date: Thu, 7 Mar 2024 15:21:55 +0800 Subject: [PATCH 7/8] refactor(ios): minor changes for compatibility --- .../native/ios/renderer/HippyComponentData.h | 30 +++++++++++++++++-- .../native/ios/renderer/HippyComponentData.mm | 2 +- .../native/ios/renderer/HippyUIManager.mm | 2 +- .../listview/HippyNextBaseListView.mm | 1 - 4 files changed, 29 insertions(+), 6 deletions(-) diff --git a/renderer/native/ios/renderer/HippyComponentData.h b/renderer/native/ios/renderer/HippyComponentData.h index 892d663b312..b5014a3b283 100644 --- a/renderer/native/ios/renderer/HippyComponentData.h +++ b/renderer/native/ios/renderer/HippyComponentData.h @@ -24,24 +24,48 @@ #import "HippyComponent.h" #import "HippyViewManager.h" -@class HippyShadowView, HippyViewManager; +@class HippyShadowView; @class UIView; @interface HippyComponentData : NSObject @property (nonatomic, readonly) Class managerClass; +/// The viewName @property (nonatomic, copy, readonly) NSString *name; +/// The corresponding viewManager @property (nonatomic, weak, readonly) HippyViewManager *manager; +/// Init method +/// - Parameters: +/// - viewManager: the corresponding viewManager +/// - viewName: name - (instancetype)initWithViewManager:(HippyViewManager *)viewManager viewName:(NSString *)viewName; +/// Create a view with the given HippyTag. +/// - Parameter tag: HippyTag - (UIView *)createViewWithTag:(NSNumber *)tag; +/// Similar to createViewWithTag, but with initialization props. +/// - Parameters: +/// - tag: hippyTag +/// - props: initial props - (UIView *)createViewWithTag:(NSNumber *)tag initProps:(NSDictionary *)props; -- (HippyShadowView *)createRenderObjectViewWithTag:(NSNumber *)tag; +/// Create a shadowView with a given tag. +/// - Parameter tag: hippyTag +- (HippyShadowView *)createShadowViewWithTag:(NSNumber *)tag; + +/// Set props for given view. +/// - Parameters: +/// - props: dictionary object +/// - view: UIView object - (void)setProps:(NSDictionary *)props forView:(id)view; -- (void)setProps:(NSDictionary *)props forShadowView:(HippyShadowView *)renderObject; + +/// Set props for given shadowView. +/// - Parameters: +/// - props: dictionary object +/// - shadowView: shadowView object +- (void)setProps:(NSDictionary *)props forShadowView:(HippyShadowView *)shadowView; - (NSDictionary *)eventNameMap; diff --git a/renderer/native/ios/renderer/HippyComponentData.mm b/renderer/native/ios/renderer/HippyComponentData.mm index 518171f627c..6b4c32352c9 100644 --- a/renderer/native/ios/renderer/HippyComponentData.mm +++ b/renderer/native/ios/renderer/HippyComponentData.mm @@ -118,7 +118,7 @@ - (UIView *)createViewWithTag:(NSNumber *)tag initProps:(NSDictionary *)props { return view; } -- (HippyShadowView *)createRenderObjectViewWithTag:(NSNumber *)tag { +- (HippyShadowView *)createShadowViewWithTag:(NSNumber *)tag { HippyShadowView *renderObject = [self.manager hippyShadowView]; renderObject.hippyTag = tag; renderObject.viewName = _name; diff --git a/renderer/native/ios/renderer/HippyUIManager.mm b/renderer/native/ios/renderer/HippyUIManager.mm index de15ee9b8ad..1317b55eab4 100644 --- a/renderer/native/ios/renderer/HippyUIManager.mm +++ b/renderer/native/ios/renderer/HippyUIManager.mm @@ -612,7 +612,7 @@ - (HippyShadowView *)createRenderObjectFromNode:(const std::shared_ptrGetTagName().c_str()]; NSMutableDictionary *props = [StylesFromDomNode(domNode) mutableCopy]; HippyComponentData *componentData = [self componentDataForViewName:viewName]; - HippyShadowView *renderObject = [componentData createRenderObjectViewWithTag:componentTag]; + HippyShadowView *renderObject = [componentData createShadowViewWithTag:componentTag]; renderObject.rootNode = rootNode; NSAssert(componentData && renderObject, @"componentData and renderObject must not be nil"); [props setValue: rootTag forKey: @"rootTag"]; diff --git a/renderer/native/ios/renderer/component/listview/HippyNextBaseListView.mm b/renderer/native/ios/renderer/component/listview/HippyNextBaseListView.mm index ef979e98405..a3b6070b121 100644 --- a/renderer/native/ios/renderer/component/listview/HippyNextBaseListView.mm +++ b/renderer/native/ios/renderer/component/listview/HippyNextBaseListView.mm @@ -238,7 +238,6 @@ - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSe - (void)collectionView:(UICollectionView *)collectionView willDisplayCell:(UICollectionViewCell *)cell forItemAtIndexPath:(NSIndexPath *)indexPath { - HippyShadowView *cellRenderObjectView = [self.dataSource cellForIndexPath:indexPath]; NSInteger index = [self.dataSource flatIndexForIndexPath:indexPath]; if (self.onRowWillDisplay) { self.onRowWillDisplay(@{ From 8139a6dc53418551c9325d46e2679daa61a2a66b Mon Sep 17 00:00:00 2001 From: wwwcg Date: Thu, 7 Mar 2024 15:23:34 +0800 Subject: [PATCH 8/8] build(ios): fix std::function build error on Xcode15.3 --- .../include/api/adapter/devtools_screen_adapter.h | 1 + .../include/api/adapter/devtools_tracing_adapter.h | 1 + devtools/devtools-backend/include/tunnel/net_channel.h | 1 + dom/include/dom/layout_node.h | 1 + modules/footstone/include/footstone/logging.h | 1 + 5 files changed, 5 insertions(+) diff --git a/devtools/devtools-backend/include/api/adapter/devtools_screen_adapter.h b/devtools/devtools-backend/include/api/adapter/devtools_screen_adapter.h index 91bde420dab..d40b1985812 100644 --- a/devtools/devtools-backend/include/api/adapter/devtools_screen_adapter.h +++ b/devtools/devtools-backend/include/api/adapter/devtools_screen_adapter.h @@ -22,6 +22,7 @@ #include #include +#include namespace hippy::devtools { /** diff --git a/devtools/devtools-backend/include/api/adapter/devtools_tracing_adapter.h b/devtools/devtools-backend/include/api/adapter/devtools_tracing_adapter.h index 42763756cd9..33d436ae73e 100644 --- a/devtools/devtools-backend/include/api/adapter/devtools_tracing_adapter.h +++ b/devtools/devtools-backend/include/api/adapter/devtools_tracing_adapter.h @@ -21,6 +21,7 @@ #pragma once #include +#include namespace hippy::devtools { /** diff --git a/devtools/devtools-backend/include/tunnel/net_channel.h b/devtools/devtools-backend/include/tunnel/net_channel.h index cb3a747d09b..9637261bec4 100644 --- a/devtools/devtools-backend/include/tunnel/net_channel.h +++ b/devtools/devtools-backend/include/tunnel/net_channel.h @@ -20,6 +20,7 @@ #pragma once #include +#include #include "api/devtools_config.h" #include "api/devtools_define.h" diff --git a/dom/include/dom/layout_node.h b/dom/include/dom/layout_node.h index 75ac510bc51..003e9ecc821 100644 --- a/dom/include/dom/layout_node.h +++ b/dom/include/dom/layout_node.h @@ -20,6 +20,7 @@ #pragma once +#include #include #include "footstone/hippy_value.h" diff --git a/modules/footstone/include/footstone/logging.h b/modules/footstone/include/footstone/logging.h index f4694117ace..dcf4a9cdfb0 100644 --- a/modules/footstone/include/footstone/logging.h +++ b/modules/footstone/include/footstone/logging.h @@ -26,6 +26,7 @@ #include #include #include +#include #include "footstone/log_level.h" #include "footstone/macros.h"