Skip to content

Commit

Permalink
fix(ios): sync all changes.fix some bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
ozonelmy authored and xuqingkuang committed Dec 23, 2019
1 parent b7837fe commit c2cec3b
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 39 deletions.
8 changes: 0 additions & 8 deletions ios/sdk/base/HippyBridge.mm
Original file line number Diff line number Diff line change
Expand Up @@ -245,14 +245,6 @@ - (void)bindKeys
return self.batchedBridge.moduleClasses;
}

- (void)setModuleName:(NSString *)moduleName {
_moduleName = moduleName;
if ([self.batchedBridge isKindOfClass:[HippyBatchedBridge class]]) {
HippyBatchedBridge* batch = (HippyBatchedBridge*)self.batchedBridge;
[batch.javaScriptExecutor setBusinessName:moduleName];
}
}

- (id)moduleForName:(NSString *)moduleName
{
if ([self isKindOfClass: [HippyBatchedBridge class]]) {
Expand Down
1 change: 0 additions & 1 deletion ios/sdk/base/HippyJavaScriptExecutor.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ typedef void (^HippyJavaScriptCallback)(id result, NSError *error);
@property (nonatomic, assign) std::weak_ptr<Environment> pEnv;
@property (nonatomic, assign) hippy::napi::napi_context napi_ctx;
@property (readonly) JSGlobalContextRef JSGlobalContextRef;
@property (nonatomic, copy) NSString *businessName;
/**
* Executes BatchedBridge.flushedQueue on JS thread and calls the given callback
* with JSValue, containing the next queue, and JSContext.
Expand Down
18 changes: 3 additions & 15 deletions ios/sdk/base/executors/HippyJSCExecutor.mm
Original file line number Diff line number Diff line change
Expand Up @@ -152,15 +152,7 @@ @implementation HippyJSCExecutor
@synthesize pEnv = _pEnv;
@synthesize napi_ctx = _napi_ctx;
@synthesize JSGlobalContextRef = _JSGlobalContextRef;
@synthesize businessName = _businessName;
HIPPY_EXPORT_MODULE()
- (void) setBusinessName:(NSString *)businessName {
_businessName = businessName;
if (nil == [self contextName] && businessName) {
[self setContextName:[NSString stringWithFormat:@"HippyJSContext(%@)", businessName]];
}
}

- (void)setBridge:(HippyBridge *)bridge
{
_bridge = bridge;
Expand Down Expand Up @@ -195,7 +187,9 @@ - (instancetype)initWithUseCustomJSCLibrary:(BOOL)useCustomJSCLibrary
__weak typeof(self) weakSelf = self;
hippy::base::RegisterFunction function = [weakSelf](void *){
typeof(self) strongSelf = weakSelf;
[strongSelf->_bridge handleBuffer:nil batchEnded:YES];
if (strongSelf) {
[strongSelf->_bridge handleBuffer:nil batchEnded:YES];
}
};
std::unique_ptr<Engine::RegisterMap> ptr(new Engine::RegisterMap());
ptr->insert(std::make_pair("ASYNC_TASK_END", function));
Expand Down Expand Up @@ -228,9 +222,6 @@ - (instancetype)initWithJSContextData:(const HippyJSContextData &)data
self->_pEngine = data.weak_engine_;
_jscWrapper = data.jscWrapper;
_context = [[HippyJavaScriptContext alloc] initWithJSContext:data.context onThread:self->_pEngine];
if (_businessName) {
[self setContextName:[NSString stringWithFormat:@"HippyJSContext(%@)", _businessName]];
}
}
return self;
}
Expand Down Expand Up @@ -291,9 +282,6 @@ - (void)setUp
context = js_context;
self->_JSGlobalContextRef = context.JSGlobalContextRef;
self->_context = [[HippyJavaScriptContext alloc] initWithJSContext:context onThread:self->_pEngine];
if (self.businessName) {
[self setContextName:[NSString stringWithFormat:@"HippyJSContext(%@)", self.businessName]];
}
[[NSNotificationCenter defaultCenter] postNotificationName:HippyJavaScriptContextCreatedNotification
object:context];

Expand Down
3 changes: 3 additions & 0 deletions ios/sdk/component/image/HippyImageView.m
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,9 @@ - (void) updateCornerRadius {
_borderWidthLayer = borderLayer;
[self.layer addSublayer:borderLayer];
}
else {
self.layer.mask = nil;
}
}

- (BOOL) needsUpdateCornerRadius {
Expand Down
16 changes: 8 additions & 8 deletions ios/sdk/component/viewPager/HippyViewPager.m
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ - (void)hippySetFrame:(CGRect)frame {

- (void)didUpdateHippySubviews {
[super didUpdateHippySubviews];
[self refreshViewPager:NO];
[self refreshViewPager:NO invokeOnPageSelectd:NO];
}

- (void)invalidate {
Expand Down Expand Up @@ -268,11 +268,11 @@ - (void)hippyBridgeDidFinishTransaction {
if (!isContentSizeEqual || !isFrameEqual) {
self.previousFrame = self.frame;
self.previousSize = self.contentSize;
[self refreshViewPager:YES];
[self refreshViewPager:YES invokeOnPageSelectd:YES];
}
}

- (void)refreshViewPager:(BOOL)needResetToInitialPage {
- (void)refreshViewPager:(BOOL)needResetToInitialPage invokeOnPageSelectd:(BOOL)invokeOnPageSelectd{
if (!self.viewPagerItems.count) return;
for (int i = 1; i < self.viewPagerItems.count; ++i) {
UIView *lastViewPagerItem = self.viewPagerItems[i - 1];
Expand Down Expand Up @@ -314,17 +314,17 @@ - (void)refreshViewPager:(BOOL)needResetToInitialPage {
return;
}

if (self.onPageSelected && NO == CGSizeEqualToSize(CGSizeZero, self.contentSize)) {
self.contentSize = CGSizeMake(
lastViewPagerItem.frame.origin.x + lastViewPagerItem.frame.size.width,
lastViewPagerItem.frame.origin.y + lastViewPagerItem.frame.size.height);

if (self.onPageSelected && NO == CGSizeEqualToSize(CGSizeZero, self.contentSize) && invokeOnPageSelectd) {
NSUInteger currentPageIndex = self.contentOffset.x / CGRectGetWidth(self.bounds);
if (currentPageIndex != _lastPageIndex) {
_lastPageIndex = currentPageIndex;
self.onPageSelected(@{@"position": @(currentPageIndex)});
}
}

self.contentSize = CGSizeMake(
lastViewPagerItem.frame.origin.x + lastViewPagerItem.frame.size.width,
lastViewPagerItem.frame.origin.y + lastViewPagerItem.frame.size.height);
}

- (NSUInteger)nowPage {
Expand Down
2 changes: 1 addition & 1 deletion ios/sdk/debug/websocket/HippyWebSocketExecutor.mm
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ @implementation HippyWebSocketExecutor
@synthesize pEnv = _pEnv;
@synthesize napi_ctx = _napi_ctx;
@synthesize JSGlobalContextRef = _JSGlobalContextRef;
@synthesize businessName = _businessName;

- (instancetype)initWithURL:(NSURL *)URL
{
HippyAssertParam(URL);
Expand Down
6 changes: 1 addition & 5 deletions ios/sdk/module/animation/HippyExtAnimationModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -374,11 +374,7 @@ - (void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag
}

[p setValue: @(ani.endValue) forProp: key];
if (flag) {
ani.state = HippyExtAnimationFinishState;
} else {
ani.state = HippyExtAnimationReadyState;
}
ani.state = HippyExtAnimationFinishState;
HippyLogInfo(@"animationDidStop:%@ finish:%@ prop:%@ value:%@", animationId, @(flag), key, @(ani.endValue));
}];
}];
Expand Down
2 changes: 1 addition & 1 deletion ios/sdk/module/animation/HippyExtAnimationViewParams.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ - (instancetype)initWithParams:(NSDictionary *)params viewTag:(NSNumber *)viewTa
_animationIdWithPropDictionary = [NSMutableDictionary new];
_valuesByKey = [NSMutableDictionary new];
_hippyTag = viewTag;
_rootTag = rootTag;
_rootTag = rootTag;
_originParams = params;
}
return self;
Expand Down

0 comments on commit c2cec3b

Please sign in to comment.