feat:add Rotation for iOS
This commit is contained in:
parent
2fbf4602e8
commit
3c04e7cde1
@ -25,8 +25,6 @@
|
|||||||
#import "DoricUtil.h"
|
#import "DoricUtil.h"
|
||||||
#import "Doric.h"
|
#import "Doric.h"
|
||||||
|
|
||||||
#import <JavaScriptCore/JavaScriptCore.h>
|
|
||||||
|
|
||||||
#import <objc/runtime.h>
|
#import <objc/runtime.h>
|
||||||
|
|
||||||
@implementation DoricShaderPlugin
|
@implementation DoricShaderPlugin
|
||||||
@ -110,9 +108,13 @@ - (id)findClass:(Class)clz target:(id)target method:(NSString *)name promise:(Do
|
|||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
void *retValue;
|
void *retValue;
|
||||||
block();
|
block();
|
||||||
[invocation getReturnValue:&retValue];
|
const char *retType = methodSignature.methodReturnType;
|
||||||
id returnValue = (__bridge id) retValue;
|
if (!strcmp(retType, @encode(void))) {
|
||||||
[promise resolve:returnValue];
|
} else {
|
||||||
|
[invocation getReturnValue:&retValue];
|
||||||
|
id returnValue = (__bridge id) retValue;
|
||||||
|
[promise resolve:returnValue];
|
||||||
|
}
|
||||||
});
|
});
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -109,4 +109,11 @@ - (void)blendView:(DoricScrollView *)view forPropName:(NSString *)name propValue
|
|||||||
- (void)blendSubNode:(NSDictionary *)subModel {
|
- (void)blendSubNode:(NSDictionary *)subModel {
|
||||||
[self.childNode blend:subModel[@"props"]];
|
[self.childNode blend:subModel[@"props"]];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (DoricViewNode *)subNodeWithViewId:(NSString *)viewId {
|
||||||
|
if ([viewId isEqualToString:self.childViewId]) {
|
||||||
|
return self.childNode;
|
||||||
|
}
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
@end
|
@end
|
||||||
|
@ -150,9 +150,11 @@ - (void)clearSubModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (DoricViewNode *)subNodeWithViewId:(NSString *)viewId {
|
- (DoricViewNode *)subNodeWithViewId:(NSString *)viewId {
|
||||||
|
NSAssert(NO, @"Should override class:%@ ,method:%@.", NSStringFromClass([self class]),
|
||||||
|
NSStringFromSelector(_cmd));
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
- (void)requestLayout {
|
- (void)requestLayout {
|
||||||
[self.view setNeedsLayout];
|
[self.view setNeedsLayout];
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
@ -232,4 +232,14 @@ - (NSNumber *)getHeight {
|
|||||||
return @(self.view.height);
|
return @(self.view.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)setRotation:(NSNumber *)rotation {
|
||||||
|
self.view.transform = CGAffineTransformRotate(self.view.transform, M_PI * rotation.floatValue * 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSNumber *)getRotation {
|
||||||
|
float radius = atan2f((float) self.view.transform.b, (float) self.view.transform.a);
|
||||||
|
float degree = (float) (radius / M_PI / 2);
|
||||||
|
return @(degree);
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
Reference in New Issue
Block a user