Skip to content

Commit

Permalink
fix(ios): relayout dom when rootView frame change
Browse files Browse the repository at this point in the history
  • Loading branch information
wwwcg committed Oct 20, 2023
1 parent 7b088a7 commit c2a2353
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 12 deletions.
3 changes: 3 additions & 0 deletions framework/ios/base/bridge/HippyBridge.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1182,6 +1182,9 @@ - (void)resetRootSize:(CGSize)size {
auto strongRootNode = rootNode.lock();
auto strongDomManager = weakDomManager.lock();
if (strongRootNode && strongDomManager) {
if (strongRootNode->GetRootSize() == std::tuple(size.width, size.height)) {
return;
}
strongRootNode->SetRootSize(size.width, size.height);
strongDomManager->DoLayout(strongRootNode);
strongDomManager->EndBatch(strongRootNode);
Expand Down
2 changes: 1 addition & 1 deletion renderer/native/ios/renderer/HippyRootView.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ extern NSString *const HippyContentDidAppearNotification;

/// Business bundle loading completion notification
/// This notification is for compatibility with hippy2 and is not recommended for further use
extern NSString *const HippySecondaryBundleDidLoadNotification DEPRECATED_MSG_ATTRIBUTE("Use HippyRootView's delegate");
extern NSString *const HippySecondaryBundleDidLoadNotification;



Expand Down
29 changes: 18 additions & 11 deletions renderer/native/ios/renderer/HippyRootView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,16 @@
#import "NativeRenderDefines.h"
#import "HippyInvalidating.h"
#import "HippyBridge.h"
#import "HippyUIManager.h"
#import "HippyDeviceBaseInfo.h"
#include <objc/runtime.h>


// Sent when the first subviews are added to the root view
NSString *const HippyContentDidAppearNotification = @"HippyContentDidAppearNotification";

// In hippy2 there are two concepts: common package and business package;
// After the success of the business package loading will send a `SecondaryBundleDidLoad` notification;
// For compatibility, hippy3 retains this notice and its actual meaning.
NSString *const HippySecondaryBundleDidLoadNotification = @"HippySecondaryBundleDidLoadNotification";

NSNumber *AllocRootViewTag(void) {
Expand Down Expand Up @@ -302,16 +307,18 @@ - (instancetype)initWithFrame:(CGRect)frame
HIPPY_NOT_IMPLEMENTED(-(instancetype)initWithCoder : (nonnull NSCoder *)aDecoder)


// FIXME: check
//- (void)setFrame:(CGRect)frame {
// CGRect originFrame = self.frame;
// if (!CGRectEqualToRect(originFrame, frame)) {
// super.frame = frame;
// if (self.hippyTag && _bridge.isValid) {
// [_bridge.uiManager setFrame:frame fromOriginFrame:originFrame forView:self];
// }
// }
//}
- (void)setFrame:(CGRect)frame {
CGRect originFrame = self.frame;
if (!CGRectEqualToRect(originFrame, frame)) {
super.frame = frame;
if (self.hippyTag && _bridge.isValid) {
// TODO: check
// hippy2 使用[_bridge.uiManager setFrame:frame fromOriginFrame:originFrame forView:self];
// 进行frame更新时的UI重布局及刷新,有待检查hippy3此处架构合理性
[_bridge resetRootSize:frame.size];
}
}
}

#pragma mark - HippyComponent Method

Expand Down

0 comments on commit c2a2353

Please sign in to comment.