From c2cec3bf62da524ecb90a992675c1b6fd5869830 Mon Sep 17 00:00:00 2001 From: mengyanluo Date: Mon, 23 Dec 2019 15:48:24 +0800 Subject: [PATCH] fix(ios): sync all changes.fix some bugs --- ios/sdk/base/HippyBridge.mm | 8 -------- ios/sdk/base/HippyJavaScriptExecutor.h | 1 - ios/sdk/base/executors/HippyJSCExecutor.mm | 18 +++--------------- ios/sdk/component/image/HippyImageView.m | 3 +++ ios/sdk/component/viewPager/HippyViewPager.m | 16 ++++++++-------- .../debug/websocket/HippyWebSocketExecutor.mm | 2 +- .../module/animation/HippyExtAnimationModule.m | 6 +----- .../animation/HippyExtAnimationViewParams.m | 2 +- 8 files changed, 17 insertions(+), 39 deletions(-) diff --git a/ios/sdk/base/HippyBridge.mm b/ios/sdk/base/HippyBridge.mm index 2c244cbbf4b..661048c21b3 100644 --- a/ios/sdk/base/HippyBridge.mm +++ b/ios/sdk/base/HippyBridge.mm @@ -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]]) { diff --git a/ios/sdk/base/HippyJavaScriptExecutor.h b/ios/sdk/base/HippyJavaScriptExecutor.h index 3f917f947b9..ae39bca3182 100644 --- a/ios/sdk/base/HippyJavaScriptExecutor.h +++ b/ios/sdk/base/HippyJavaScriptExecutor.h @@ -55,7 +55,6 @@ typedef void (^HippyJavaScriptCallback)(id result, NSError *error); @property (nonatomic, assign) std::weak_ptr 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. diff --git a/ios/sdk/base/executors/HippyJSCExecutor.mm b/ios/sdk/base/executors/HippyJSCExecutor.mm index a0b042c90a5..5145670fd4f 100644 --- a/ios/sdk/base/executors/HippyJSCExecutor.mm +++ b/ios/sdk/base/executors/HippyJSCExecutor.mm @@ -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; @@ -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 ptr(new Engine::RegisterMap()); ptr->insert(std::make_pair("ASYNC_TASK_END", function)); @@ -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; } @@ -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]; diff --git a/ios/sdk/component/image/HippyImageView.m b/ios/sdk/component/image/HippyImageView.m index cd9123b2811..2b1bfd7b825 100644 --- a/ios/sdk/component/image/HippyImageView.m +++ b/ios/sdk/component/image/HippyImageView.m @@ -608,6 +608,9 @@ - (void) updateCornerRadius { _borderWidthLayer = borderLayer; [self.layer addSublayer:borderLayer]; } + else { + self.layer.mask = nil; + } } - (BOOL) needsUpdateCornerRadius { diff --git a/ios/sdk/component/viewPager/HippyViewPager.m b/ios/sdk/component/viewPager/HippyViewPager.m index 8d4794c8655..12f86281a47 100644 --- a/ios/sdk/component/viewPager/HippyViewPager.m +++ b/ios/sdk/component/viewPager/HippyViewPager.m @@ -99,7 +99,7 @@ - (void)hippySetFrame:(CGRect)frame { - (void)didUpdateHippySubviews { [super didUpdateHippySubviews]; - [self refreshViewPager:NO]; + [self refreshViewPager:NO invokeOnPageSelectd:NO]; } - (void)invalidate { @@ -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]; @@ -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 { diff --git a/ios/sdk/debug/websocket/HippyWebSocketExecutor.mm b/ios/sdk/debug/websocket/HippyWebSocketExecutor.mm index 7ab37b81c3d..be8941d86e7 100644 --- a/ios/sdk/debug/websocket/HippyWebSocketExecutor.mm +++ b/ios/sdk/debug/websocket/HippyWebSocketExecutor.mm @@ -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); diff --git a/ios/sdk/module/animation/HippyExtAnimationModule.m b/ios/sdk/module/animation/HippyExtAnimationModule.m index df5fe526c30..a1e33797eb4 100644 --- a/ios/sdk/module/animation/HippyExtAnimationModule.m +++ b/ios/sdk/module/animation/HippyExtAnimationModule.m @@ -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)); }]; }]; diff --git a/ios/sdk/module/animation/HippyExtAnimationViewParams.m b/ios/sdk/module/animation/HippyExtAnimationViewParams.m index f04f52133de..175005206a2 100644 --- a/ios/sdk/module/animation/HippyExtAnimationViewParams.m +++ b/ios/sdk/module/animation/HippyExtAnimationViewParams.m @@ -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;