You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by ac...@apache.org on 2017/08/30 03:29:09 UTC

incubator-weex git commit: * [ios] add handle Style on main thread method

Repository: incubator-weex
Updated Branches:
  refs/heads/0.16-dev 1295c9095 -> 1b6544833


* [ios] add handle Style on main thread method


Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/1b654483
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/1b654483
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/1b654483

Branch: refs/heads/0.16-dev
Commit: 1b6544833b076cf877c5ddbc2aa63ca57fa3587f
Parents: 1295c90
Author: acton393 <zh...@gmail.com>
Authored: Wed Aug 30 11:28:21 2017 +0800
Committer: acton393 <zh...@gmail.com>
Committed: Wed Aug 30 11:28:21 2017 +0800

----------------------------------------------------------------------
 .../WeexSDK/Sources/Manager/WXComponentManager.h |  8 ++++++++
 .../WeexSDK/Sources/Manager/WXComponentManager.m | 19 +++++++++++++++++++
 2 files changed, 27 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/1b654483/ios/sdk/WeexSDK/Sources/Manager/WXComponentManager.h
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Manager/WXComponentManager.h b/ios/sdk/WeexSDK/Sources/Manager/WXComponentManager.h
index 53c5a38..1af1834 100644
--- a/ios/sdk/WeexSDK/Sources/Manager/WXComponentManager.h
+++ b/ios/sdk/WeexSDK/Sources/Manager/WXComponentManager.h
@@ -181,4 +181,12 @@ extern void WXPerformBlockOnComponentThread(void (^block)());
 - (void)_addUITask:(void (^)())block;
 
 - (void)excutePrerenderUITask:(NSString *)url;
+
+/**
+ * @param styles a NSDictionary value, styles which will resolve
+ * @param ref a NSString value, the component ref of target which you want to resolve
+ * @param isUpdateStyles a BOOL value, YES will udpate the component style property, NO will notifiy the lifeStyle of compoenent to handle, default value is NO.
+ * @abstract handleStyle will be add to a queue to be executed every frame, but handleStyleOnMainThread will switch to main thread and execute imediately, you can call this for your execution time sequence.
+ */
+- (void)handleStyleOnMainThread:(NSDictionary*)styles forComponent:(NSString *)ref isUpdateStyles:(BOOL)isUpdateStyles;
 @end

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/1b654483/ios/sdk/WeexSDK/Sources/Manager/WXComponentManager.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Manager/WXComponentManager.m b/ios/sdk/WeexSDK/Sources/Manager/WXComponentManager.m
index 7916c68..a4e0593 100644
--- a/ios/sdk/WeexSDK/Sources/Manager/WXComponentManager.m
+++ b/ios/sdk/WeexSDK/Sources/Manager/WXComponentManager.m
@@ -426,6 +426,25 @@ static css_node_t * rootNodeGetChild(void *context, int i)
     [self handleStyles:styles forComponent:ref isUpdateStyles:NO];
 }
 
+- (void)handleStyleOnMainThread:(NSDictionary*)styles forComponent:(NSString *)ref isUpdateStyles:(BOOL)isUpdateStyles
+{
+    WXAssertParam(styles);
+    WXAssertParam(ref);
+    WXAssertComponentThread();
+    
+    WXComponent *component = [_indexDict objectForKey:ref];
+    WXAssertComponentExist(component);
+    
+    NSMutableDictionary *normalStyles = [NSMutableDictionary new];
+    NSMutableArray *resetStyles = [NSMutableArray new];
+    [self filterStyles:styles normalStyles:normalStyles resetStyles:resetStyles];
+    [component _updateStylesOnComponentThread:normalStyles resetStyles:resetStyles isUpdateStyles:isUpdateStyles];
+    WXPerformBlockOnMainThread(^{
+        [component _updateStylesOnMainThread:normalStyles resetStyles:resetStyles];
+        [component readyToRender];
+    });
+}
+
 - (void)handleStyles:(NSDictionary *)styles forComponent:(NSString *)ref isUpdateStyles:(BOOL)isUpdateStyles
 {
     WXAssertParam(styles);