feat:rename animator to animate

This commit is contained in:
pengfei.zhou
2019-11-29 13:27:02 +08:00
parent ed7e071a01
commit dd69a3f150
8 changed files with 111 additions and 77 deletions

View File

@@ -41,6 +41,7 @@
#import "DoricFlowLayoutItemNode.h"
#import "DoricFlowLayoutNode.h"
#import "DoricPopoverPlugin.h"
#import "DoricAnimatePlugin.h"
@interface DoricRegistry ()
@@ -70,6 +71,7 @@ - (void)innerRegister {
[self registerNativePlugin:DoricNavigatorPlugin.class withName:@"navigator"];
[self registerNativePlugin:DoricNavBarPlugin.class withName:@"navbar"];
[self registerNativePlugin:DoricPopoverPlugin.class withName:@"popover"];
[self registerNativePlugin:DoricAnimatePlugin.class withName:@"animate"];
[self registerViewNode:DoricStackNode.class withName:@"Stack"];
[self registerViewNode:DoricVLayoutNode.class withName:@"VLayout"];

View File

@@ -0,0 +1,10 @@
//
// Created by pengfei.zhou on 2019/11/29.
//
#import <Foundation/Foundation.h>
#import "DoricNativePlugin.h"
@interface DoricAnimatePlugin : DoricNativePlugin
@end

View File

@@ -0,0 +1,33 @@
//
// Created by pengfei.zhou on 2019/11/29.
//
#import "DoricAnimatePlugin.h"
#import "DoricRootNode.h"
@implementation DoricAnimatePlugin
- (void)submit:(NSDictionary *)args withPromise:(DoricPromise *)promise {
[promise resolve:nil];
}
- (void)animateRender:(NSDictionary *)args withPromise:(DoricPromise *)promise {
NSNumber *duration = args[@"duration"];
dispatch_async(dispatch_get_main_queue(), ^{
NSString *viewId = args[@"id"];
[UIView animateWithDuration:[duration floatValue] / 1000
animations:^{
if (self.doricContext.rootNode.viewId == nil) {
self.doricContext.rootNode.viewId = viewId;
[self.doricContext.rootNode blend:args[@"props"]];
} else {
DoricViewNode *viewNode = [self.doricContext targetViewNode:viewId];
[viewNode blend:args[@"props"]];
}
}
completion:^(BOOL finished) {
[promise resolve:nil];
}];
});
}
@end

View File

@@ -140,27 +140,4 @@ - (id)findClass:(Class)clz target:(id)target method:(NSString *)name promise:(Do
return ret;
}
- (void)animator:(NSDictionary *)args withPromise:(DoricPromise *)promise {
[promise resolve:nil];
}
- (void)animateRender:(NSDictionary *)args withPromise:(DoricPromise *)promise {
NSNumber *duration = args[@"duration"];
dispatch_async(dispatch_get_main_queue(), ^{
NSString *viewId = args[@"id"];
[UIView animateWithDuration:[duration floatValue] / 1000
animations:^{
if (self.doricContext.rootNode.viewId == nil) {
self.doricContext.rootNode.viewId = viewId;
[self.doricContext.rootNode blend:args[@"props"]];
} else {
DoricViewNode *viewNode = [self.doricContext targetViewNode:viewId];
[viewNode blend:args[@"props"]];
}
}
completion:^(BOOL finished) {
[promise resolve:nil];
}];
});
}
@end