Run CLANGFORMAT on plugins
Summary: This diff runs CLANGFORMAT lint on plugins. I have added CLANGFORMAT as the lint engined for objc files in xplat/sonar. Right now the iOS folder is not formatted according to CLANGFORMAT. Ran `arc lint -a --paths-cmd "find ./iOS/Plugins -type f" --verbose` Reviewed By: passy Differential Revision: D19942173 fbshipit-source-id: 8b975b0a344df073b02d69cd1f9ee5629af2799d
This commit is contained in:
committed by
Facebook Github Bot
parent
a19a430eee
commit
e8b20d5b15
@@ -9,6 +9,6 @@
|
||||
|
||||
#import "SKNodeDescriptor.h"
|
||||
|
||||
@interface SKApplicationDescriptor : SKNodeDescriptor<UIApplication *>
|
||||
@interface SKApplicationDescriptor : SKNodeDescriptor<UIApplication*>
|
||||
|
||||
@end
|
||||
|
||||
@@ -9,38 +9,40 @@
|
||||
|
||||
#import "SKApplicationDescriptor.h"
|
||||
|
||||
#import <objc/runtime.h>
|
||||
#import "SKDescriptorMapper.h"
|
||||
#import "SKHiddenWindow.h"
|
||||
#import <objc/runtime.h>
|
||||
|
||||
@implementation SKApplicationDescriptor
|
||||
|
||||
- (NSString *)identifierForNode:(UIApplication *)node {
|
||||
return [NSString stringWithFormat: @"%p", node];
|
||||
- (NSString*)identifierForNode:(UIApplication*)node {
|
||||
return [NSString stringWithFormat:@"%p", node];
|
||||
}
|
||||
|
||||
- (NSUInteger)childCountForNode:(UIApplication *)node {
|
||||
return [[self visibleChildrenForNode: node] count];
|
||||
- (NSUInteger)childCountForNode:(UIApplication*)node {
|
||||
return [[self visibleChildrenForNode:node] count];
|
||||
}
|
||||
|
||||
- (id)childForNode:(UIApplication *)node atIndex:(NSUInteger)index {
|
||||
return [self visibleChildrenForNode: node][index];
|
||||
- (id)childForNode:(UIApplication*)node atIndex:(NSUInteger)index {
|
||||
return [self visibleChildrenForNode:node][index];
|
||||
}
|
||||
|
||||
- (void)setHighlighted:(BOOL)highlighted forNode:(UIApplication *)node {
|
||||
SKNodeDescriptor *windowDescriptor = [self descriptorForClass: [UIWindow class]];
|
||||
[windowDescriptor setHighlighted: highlighted forNode: [node keyWindow]];
|
||||
- (void)setHighlighted:(BOOL)highlighted forNode:(UIApplication*)node {
|
||||
SKNodeDescriptor* windowDescriptor =
|
||||
[self descriptorForClass:[UIWindow class]];
|
||||
[windowDescriptor setHighlighted:highlighted forNode:[node keyWindow]];
|
||||
}
|
||||
|
||||
- (void)hitTest:(SKTouch *)touch forNode:(UIApplication *)node {
|
||||
for (NSInteger index = [self childCountForNode: node] - 1; index >= 0; index--) {
|
||||
UIWindow *child = [self childForNode: node atIndex: index];
|
||||
- (void)hitTest:(SKTouch*)touch forNode:(UIApplication*)node {
|
||||
for (NSInteger index = [self childCountForNode:node] - 1; index >= 0;
|
||||
index--) {
|
||||
UIWindow* child = [self childForNode:node atIndex:index];
|
||||
if (child.isHidden || child.alpha <= 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ([touch containedIn: child.frame]) {
|
||||
[touch continueWithChildIndex: index withOffset: child.frame.origin];
|
||||
if ([touch containedIn:child.frame]) {
|
||||
[touch continueWithChildIndex:index withOffset:child.frame.origin];
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -48,16 +50,17 @@
|
||||
[touch finish];
|
||||
}
|
||||
|
||||
- (NSArray<UIWindow *> *)visibleChildrenForNode:(UIApplication *)node {
|
||||
NSMutableArray<UIWindow *> *children = [NSMutableArray new];
|
||||
for (UIWindow *window in node.windows) {
|
||||
if ([window isKindOfClass: [SKHiddenWindow class]]
|
||||
|| [window isKindOfClass:objc_lookUpClass("FBAccessibilityOverlayWindow")]
|
||||
|| [window isKindOfClass:objc_lookUpClass("UITextEffectsWindow")]
|
||||
|| [window isKindOfClass:objc_lookUpClass("FBStatusBarTrackingWindow")]) {
|
||||
- (NSArray<UIWindow*>*)visibleChildrenForNode:(UIApplication*)node {
|
||||
NSMutableArray<UIWindow*>* children = [NSMutableArray new];
|
||||
for (UIWindow* window in node.windows) {
|
||||
if ([window isKindOfClass:[SKHiddenWindow class]] ||
|
||||
[window
|
||||
isKindOfClass:objc_lookUpClass("FBAccessibilityOverlayWindow")] ||
|
||||
[window isKindOfClass:objc_lookUpClass("UITextEffectsWindow")] ||
|
||||
[window isKindOfClass:objc_lookUpClass("FBStatusBarTrackingWindow")]) {
|
||||
continue;
|
||||
}
|
||||
[children addObject: window];
|
||||
[children addObject:window];
|
||||
}
|
||||
return children;
|
||||
}
|
||||
|
||||
@@ -11,6 +11,6 @@
|
||||
|
||||
@class UIButton;
|
||||
|
||||
@interface SKButtonDescriptor : SKNodeDescriptor<UIButton *>
|
||||
@interface SKButtonDescriptor : SKNodeDescriptor<UIButton*>
|
||||
|
||||
@end
|
||||
|
||||
@@ -15,44 +15,48 @@
|
||||
|
||||
@implementation SKButtonDescriptor
|
||||
|
||||
- (NSString *)identifierForNode:(UIButton *)node {
|
||||
return [NSString stringWithFormat: @"%p", node];
|
||||
- (NSString*)identifierForNode:(UIButton*)node {
|
||||
return [NSString stringWithFormat:@"%p", node];
|
||||
}
|
||||
|
||||
- (NSUInteger)childCountForNode:(UIButton *)node {
|
||||
- (NSUInteger)childCountForNode:(UIButton*)node {
|
||||
return 0;
|
||||
}
|
||||
|
||||
- (id)childForNode:(UIButton *)node atIndex:(NSUInteger)index {
|
||||
- (id)childForNode:(UIButton*)node atIndex:(NSUInteger)index {
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NSArray<SKNamed<NSDictionary *> *> *)dataForNode:(UIButton *)node {
|
||||
SKNodeDescriptor *viewDescriptor = [self descriptorForClass: [UIView class]];
|
||||
auto *viewData = [viewDescriptor dataForNode: node];
|
||||
- (NSArray<SKNamed<NSDictionary*>*>*)dataForNode:(UIButton*)node {
|
||||
SKNodeDescriptor* viewDescriptor = [self descriptorForClass:[UIView class]];
|
||||
auto* viewData = [viewDescriptor dataForNode:node];
|
||||
|
||||
NSMutableArray *data = [NSMutableArray new];
|
||||
[data addObjectsFromArray: viewData];
|
||||
[data addObject:
|
||||
[SKNamed newWithName: @"UIButton"
|
||||
withValue: @{
|
||||
@"focused": @(node.focused),
|
||||
@"enabled": SKMutableObject(@(node.enabled)),
|
||||
@"highlighted": SKMutableObject(@(node.highlighted)),
|
||||
@"titleEdgeInsets": SKObject(node.titleEdgeInsets),
|
||||
@"titleLabel": SKMutableObject(node.titleLabel.attributedText.string.stringByStandardizingPath),
|
||||
@"currentTitleColor": SKMutableObject(node.currentTitleColor),
|
||||
}]
|
||||
];
|
||||
NSMutableArray* data = [NSMutableArray new];
|
||||
[data addObjectsFromArray:viewData];
|
||||
[data addObject:[SKNamed
|
||||
newWithName:@"UIButton"
|
||||
withValue:@{
|
||||
@"focused" : @(node.focused),
|
||||
@"enabled" : SKMutableObject(@(node.enabled)),
|
||||
@"highlighted" : SKMutableObject(@(node.highlighted)),
|
||||
@"titleEdgeInsets" : SKObject(node.titleEdgeInsets),
|
||||
@"titleLabel" : SKMutableObject(
|
||||
node.titleLabel.attributedText.string
|
||||
.stringByStandardizingPath),
|
||||
@"currentTitleColor" :
|
||||
SKMutableObject(node.currentTitleColor),
|
||||
}]];
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
- (NSDictionary<NSString *, SKNodeUpdateData> *)dataMutationsForNode:(UIButton *)node {
|
||||
NSDictionary *buttonMutations = @{
|
||||
@"UIButton.titleLabel": ^(NSString *newValue) {
|
||||
[node setTitle: newValue forState: node.state];
|
||||
},
|
||||
- (NSDictionary<NSString*, SKNodeUpdateData>*)dataMutationsForNode:
|
||||
(UIButton*)node {
|
||||
NSDictionary* buttonMutations =
|
||||
@{@"UIButton.titleLabel" : ^(NSString* newValue){
|
||||
[node setTitle:newValue forState:node.state];
|
||||
}
|
||||
,
|
||||
@"UIButton.currentTitleColor": ^(NSNumber *newValue) {
|
||||
[node setTitleColor: [UIColor fromSonarValue: newValue] forState: node.state];
|
||||
},
|
||||
@@ -62,29 +66,30 @@
|
||||
@"UIButton.enabled": ^(NSNumber *enabled) {
|
||||
[node setEnabled: [enabled boolValue]];
|
||||
}
|
||||
};
|
||||
}
|
||||
;
|
||||
|
||||
SKNodeDescriptor *viewDescriptor = [self descriptorForClass: [UIView class]];
|
||||
NSDictionary *viewMutations = [viewDescriptor dataMutationsForNode: node];
|
||||
SKNodeDescriptor* viewDescriptor = [self descriptorForClass:[UIView class]];
|
||||
NSDictionary* viewMutations = [viewDescriptor dataMutationsForNode:node];
|
||||
|
||||
NSMutableDictionary *mutations = [NSMutableDictionary new];
|
||||
[mutations addEntriesFromDictionary: buttonMutations];
|
||||
[mutations addEntriesFromDictionary: viewMutations];
|
||||
NSMutableDictionary* mutations = [NSMutableDictionary new];
|
||||
[mutations addEntriesFromDictionary:buttonMutations];
|
||||
[mutations addEntriesFromDictionary:viewMutations];
|
||||
|
||||
return mutations;
|
||||
return mutations;
|
||||
}
|
||||
|
||||
- (NSArray<SKNamed<NSString *> *> *)attributesForNode:(UIScrollView *)node {
|
||||
SKNodeDescriptor *descriptor = [self descriptorForClass: [UIView class]];
|
||||
return [descriptor attributesForNode: node];
|
||||
- (NSArray<SKNamed<NSString*>*>*)attributesForNode:(UIScrollView*)node {
|
||||
SKNodeDescriptor* descriptor = [self descriptorForClass:[UIView class]];
|
||||
return [descriptor attributesForNode:node];
|
||||
}
|
||||
|
||||
- (void)setHighlighted:(BOOL)highlighted forNode:(UIButton *)node {
|
||||
SKNodeDescriptor *viewDescriptor = [self descriptorForClass: [UIView class]];
|
||||
[viewDescriptor setHighlighted: highlighted forNode: node];
|
||||
- (void)setHighlighted:(BOOL)highlighted forNode:(UIButton*)node {
|
||||
SKNodeDescriptor* viewDescriptor = [self descriptorForClass:[UIView class]];
|
||||
[viewDescriptor setHighlighted:highlighted forNode:node];
|
||||
}
|
||||
|
||||
- (void)hitTest:(SKTouch *)touch forNode:(UIButton *)node {
|
||||
- (void)hitTest:(SKTouch*)touch forNode:(UIButton*)node {
|
||||
[touch finish];
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,6 @@
|
||||
|
||||
#import "SKNodeDescriptor.h"
|
||||
|
||||
@interface SKScrollViewDescriptor : SKNodeDescriptor<UIScrollView *>
|
||||
@interface SKScrollViewDescriptor : SKNodeDescriptor<UIScrollView*>
|
||||
|
||||
@end
|
||||
|
||||
@@ -13,55 +13,56 @@
|
||||
|
||||
@implementation SKScrollViewDescriptor
|
||||
|
||||
- (NSString *)identifierForNode:(UIScrollView *)node {
|
||||
SKNodeDescriptor *descriptor = [self descriptorForClass: [UIView class]];
|
||||
return [descriptor identifierForNode: node];
|
||||
- (NSString*)identifierForNode:(UIScrollView*)node {
|
||||
SKNodeDescriptor* descriptor = [self descriptorForClass:[UIView class]];
|
||||
return [descriptor identifierForNode:node];
|
||||
}
|
||||
|
||||
- (NSUInteger)childCountForNode:(UIScrollView *)node {
|
||||
SKNodeDescriptor *descriptor = [self descriptorForClass: [UIView class]];
|
||||
return [descriptor childCountForNode: node];
|
||||
- (NSUInteger)childCountForNode:(UIScrollView*)node {
|
||||
SKNodeDescriptor* descriptor = [self descriptorForClass:[UIView class]];
|
||||
return [descriptor childCountForNode:node];
|
||||
}
|
||||
|
||||
- (id)childForNode:(UIScrollView *)node atIndex:(NSUInteger)index {
|
||||
SKNodeDescriptor *descriptor = [self descriptorForClass: [UIView class]];
|
||||
return [descriptor childForNode: node atIndex: index];
|
||||
- (id)childForNode:(UIScrollView*)node atIndex:(NSUInteger)index {
|
||||
SKNodeDescriptor* descriptor = [self descriptorForClass:[UIView class]];
|
||||
return [descriptor childForNode:node atIndex:index];
|
||||
}
|
||||
|
||||
- (id)dataForNode:(UIScrollView *)node {
|
||||
SKNodeDescriptor *descriptor = [self descriptorForClass: [UIView class]];
|
||||
- (id)dataForNode:(UIScrollView*)node {
|
||||
SKNodeDescriptor* descriptor = [self descriptorForClass:[UIView class]];
|
||||
return [descriptor dataForNode:node];
|
||||
}
|
||||
|
||||
- (id)dataMutationsForNode:(UIScrollView *)node {
|
||||
SKNodeDescriptor *descriptor = [self descriptorForClass: [UIView class]];
|
||||
- (id)dataMutationsForNode:(UIScrollView*)node {
|
||||
SKNodeDescriptor* descriptor = [self descriptorForClass:[UIView class]];
|
||||
return [descriptor dataMutationsForNode:node];
|
||||
}
|
||||
|
||||
- (NSArray<SKNamed<NSString *> *> *)attributesForNode:(UIScrollView *)node {
|
||||
SKNodeDescriptor *descriptor = [self descriptorForClass: [UIView class]];
|
||||
return [descriptor attributesForNode: node];
|
||||
- (NSArray<SKNamed<NSString*>*>*)attributesForNode:(UIScrollView*)node {
|
||||
SKNodeDescriptor* descriptor = [self descriptorForClass:[UIView class]];
|
||||
return [descriptor attributesForNode:node];
|
||||
}
|
||||
|
||||
- (void)setHighlighted:(BOOL)highlighted forNode:(UIScrollView *)node {
|
||||
SKNodeDescriptor *descriptor = [self descriptorForClass: [UIView class]];
|
||||
[descriptor setHighlighted: highlighted forNode: node];
|
||||
- (void)setHighlighted:(BOOL)highlighted forNode:(UIScrollView*)node {
|
||||
SKNodeDescriptor* descriptor = [self descriptorForClass:[UIView class]];
|
||||
[descriptor setHighlighted:highlighted forNode:node];
|
||||
}
|
||||
|
||||
- (void)hitTest:(SKTouch *)touch forNode:(UIScrollView *)node {
|
||||
for (NSInteger index = [self childCountForNode: node] - 1; index >= 0; index--) {
|
||||
id<NSObject> childNode = [self childForNode: node atIndex: index];
|
||||
- (void)hitTest:(SKTouch*)touch forNode:(UIScrollView*)node {
|
||||
for (NSInteger index = [self childCountForNode:node] - 1; index >= 0;
|
||||
index--) {
|
||||
id<NSObject> childNode = [self childForNode:node atIndex:index];
|
||||
CGRect frame;
|
||||
|
||||
if ([childNode isKindOfClass: [UIViewController class]]) {
|
||||
UIViewController *child = (UIViewController *)childNode;
|
||||
if ([childNode isKindOfClass:[UIViewController class]]) {
|
||||
UIViewController* child = (UIViewController*)childNode;
|
||||
if (child.view.isHidden) {
|
||||
continue;
|
||||
}
|
||||
|
||||
frame = child.view.frame;
|
||||
} else {
|
||||
UIView *child = (UIView *)childNode;
|
||||
UIView* child = (UIView*)childNode;
|
||||
if (child.isHidden) {
|
||||
continue;
|
||||
}
|
||||
@@ -72,8 +73,8 @@
|
||||
frame.origin.x -= node.contentOffset.x;
|
||||
frame.origin.y -= node.contentOffset.y;
|
||||
|
||||
if ([touch containedIn: frame]) {
|
||||
[touch continueWithChildIndex: index withOffset: frame.origin];
|
||||
if ([touch containedIn:frame]) {
|
||||
[touch continueWithChildIndex:index withOffset:frame.origin];
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,6 @@
|
||||
|
||||
#import "SKNodeDescriptor.h"
|
||||
|
||||
@interface SKViewControllerDescriptor : SKNodeDescriptor<UIViewController *>
|
||||
@interface SKViewControllerDescriptor : SKNodeDescriptor<UIViewController*>
|
||||
|
||||
@end
|
||||
|
||||
@@ -13,38 +13,35 @@
|
||||
|
||||
@implementation SKViewControllerDescriptor
|
||||
|
||||
- (NSString *)identifierForNode:(UIViewController *)node {
|
||||
return [NSString stringWithFormat: @"%p", node];
|
||||
- (NSString*)identifierForNode:(UIViewController*)node {
|
||||
return [NSString stringWithFormat:@"%p", node];
|
||||
}
|
||||
|
||||
- (NSUInteger)childCountForNode:(UIViewController *)node {
|
||||
- (NSUInteger)childCountForNode:(UIViewController*)node {
|
||||
return 1;
|
||||
}
|
||||
|
||||
- (id)childForNode:(UIViewController *)node atIndex:(NSUInteger)index {
|
||||
- (id)childForNode:(UIViewController*)node atIndex:(NSUInteger)index {
|
||||
return node.view;
|
||||
}
|
||||
|
||||
- (void)setHighlightedForNode:(UIViewController *)node {
|
||||
- (void)setHighlightedForNode:(UIViewController*)node {
|
||||
}
|
||||
|
||||
- (NSArray<SKNamed<NSString *> *> *)attributesForNode:(UIViewController *)node {
|
||||
return @[
|
||||
[SKNamed newWithName: @"addr"
|
||||
withValue: [NSString stringWithFormat: @"%p", node]]
|
||||
];
|
||||
- (NSArray<SKNamed<NSString*>*>*)attributesForNode:(UIViewController*)node {
|
||||
return @[ [SKNamed newWithName:@"addr"
|
||||
withValue:[NSString stringWithFormat:@"%p", node]] ];
|
||||
}
|
||||
|
||||
- (void)setHighlighted:(BOOL)highlighted forNode:(UIViewController *)node {
|
||||
SKNodeDescriptor *descriptor = [self descriptorForClass: [UIView class]];
|
||||
[descriptor setHighlighted: highlighted forNode: node.view];
|
||||
- (void)setHighlighted:(BOOL)highlighted forNode:(UIViewController*)node {
|
||||
SKNodeDescriptor* descriptor = [self descriptorForClass:[UIView class]];
|
||||
[descriptor setHighlighted:highlighted forNode:node.view];
|
||||
}
|
||||
|
||||
- (void)hitTest:(SKTouch *)touch forNode:(UIViewController *)node {
|
||||
[touch continueWithChildIndex: 0 withOffset: (CGPoint){ 0, 0}];
|
||||
- (void)hitTest:(SKTouch*)touch forNode:(UIViewController*)node {
|
||||
[touch continueWithChildIndex:0 withOffset:(CGPoint){0, 0}];
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
#import "SKNodeDescriptor.h"
|
||||
|
||||
@interface SKViewDescriptor : SKNodeDescriptor<UIView *>
|
||||
@interface SKViewDescriptor : SKNodeDescriptor<UIView*>
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@@ -9,59 +9,61 @@
|
||||
|
||||
#import "SKViewDescriptor.h"
|
||||
|
||||
#import <FlipperKitHighlightOverlay/SKHighlightOverlay.h>
|
||||
#import <YogaKit/UIView+Yoga.h>
|
||||
#import "SKDescriptorMapper.h"
|
||||
#import "SKNamed.h"
|
||||
#import "SKObject.h"
|
||||
#import "SKYogaKitHelper.h"
|
||||
#import "UIColor+SKSonarValueCoder.h"
|
||||
#import <YogaKit/UIView+Yoga.h>
|
||||
#import <FlipperKitHighlightOverlay/SKHighlightOverlay.h>
|
||||
|
||||
@implementation SKViewDescriptor
|
||||
|
||||
static NSDictionary *YGDirectionEnumMap = nil;
|
||||
static NSDictionary *YGFlexDirectionEnumMap = nil;
|
||||
static NSDictionary *YGJustifyEnumMap = nil;
|
||||
static NSDictionary *YGAlignEnumMap = nil;
|
||||
static NSDictionary *YGPositionTypeEnumMap = nil;
|
||||
static NSDictionary *YGWrapEnumMap = nil;
|
||||
static NSDictionary *YGOverflowEnumMap = nil;
|
||||
static NSDictionary *YGDisplayEnumMap = nil;
|
||||
static NSDictionary *YGUnitEnumMap = nil;
|
||||
static NSDictionary* YGDirectionEnumMap = nil;
|
||||
static NSDictionary* YGFlexDirectionEnumMap = nil;
|
||||
static NSDictionary* YGJustifyEnumMap = nil;
|
||||
static NSDictionary* YGAlignEnumMap = nil;
|
||||
static NSDictionary* YGPositionTypeEnumMap = nil;
|
||||
static NSDictionary* YGWrapEnumMap = nil;
|
||||
static NSDictionary* YGOverflowEnumMap = nil;
|
||||
static NSDictionary* YGDisplayEnumMap = nil;
|
||||
static NSDictionary* YGUnitEnumMap = nil;
|
||||
|
||||
- (instancetype)initWithDescriptorMapper:(SKDescriptorMapper *)mapper {
|
||||
if (self = [super initWithDescriptorMapper: mapper]) {
|
||||
- (instancetype)initWithDescriptorMapper:(SKDescriptorMapper*)mapper {
|
||||
if (self = [super initWithDescriptorMapper:mapper]) {
|
||||
initEnumDictionaries();
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (NSString *)identifierForNode:(UIView *)node {
|
||||
return [NSString stringWithFormat: @"%p", node];
|
||||
- (NSString*)identifierForNode:(UIView*)node {
|
||||
return [NSString stringWithFormat:@"%p", node];
|
||||
}
|
||||
|
||||
- (NSUInteger)childCountForNode:(UIView *)node {
|
||||
return [[self validChildrenForNode: node] count];
|
||||
- (NSUInteger)childCountForNode:(UIView*)node {
|
||||
return [[self validChildrenForNode:node] count];
|
||||
}
|
||||
|
||||
- (id)childForNode:(UIView *)node atIndex:(NSUInteger)index {
|
||||
return [[self validChildrenForNode:node] objectAtIndex: index];
|
||||
- (id)childForNode:(UIView*)node atIndex:(NSUInteger)index {
|
||||
return [[self validChildrenForNode:node] objectAtIndex:index];
|
||||
}
|
||||
|
||||
- (NSArray *)validChildrenForNode:(UIView *)node {
|
||||
NSMutableArray *validChildren = [NSMutableArray new];
|
||||
- (NSArray*)validChildrenForNode:(UIView*)node {
|
||||
NSMutableArray* validChildren = [NSMutableArray new];
|
||||
|
||||
// Use UIViewControllers for children which responds to a different
|
||||
// viewController than their parent
|
||||
for (UIView *child in node.subviews) {
|
||||
BOOL responderIsUIViewController = [child.nextResponder isKindOfClass: [UIViewController class]];
|
||||
for (UIView* child in node.subviews) {
|
||||
BOOL responderIsUIViewController =
|
||||
[child.nextResponder isKindOfClass:[UIViewController class]];
|
||||
|
||||
if (!child.isHidden) {
|
||||
if (responderIsUIViewController && child.nextResponder != node.nextResponder) {
|
||||
[validChildren addObject: child.nextResponder];
|
||||
if (responderIsUIViewController &&
|
||||
child.nextResponder != node.nextResponder) {
|
||||
[validChildren addObject:child.nextResponder];
|
||||
} else {
|
||||
[validChildren addObject: child];
|
||||
[validChildren addObject:child];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -69,121 +71,165 @@ static NSDictionary *YGUnitEnumMap = nil;
|
||||
return validChildren;
|
||||
}
|
||||
|
||||
- (NSArray<SKNamed<NSDictionary *> *> *)dataForNode:(UIView *)node {
|
||||
return [NSArray arrayWithObjects:
|
||||
[SKNamed newWithName: @"UIView"
|
||||
withValue: @{
|
||||
@"frame": SKMutableObject(node.frame),
|
||||
@"bounds": SKObject(node.bounds),
|
||||
@"center": SKObject(node.center),
|
||||
@"layoutMargins": SKObject(node.layoutMargins),
|
||||
@"clipsToBounds": @(node.clipsToBounds),
|
||||
@"alpha": SKMutableObject(@(node.alpha)),
|
||||
@"tag": @(node.tag),
|
||||
@"backgroundColor": SKMutableObject(node.backgroundColor)
|
||||
}],
|
||||
[SKNamed newWithName: @"CALayer"
|
||||
withValue: @{
|
||||
@"shadowColor": SKMutableObject([UIColor colorWithCGColor:node.layer.shadowColor]),
|
||||
@"shadowOpacity": SKMutableObject(@(node.layer.shadowOpacity)),
|
||||
@"shadowRadius": SKMutableObject(@(node.layer.shadowRadius)),
|
||||
@"shadowOffset": SKMutableObject(node.layer.shadowOffset),
|
||||
@"backgroundColor": SKMutableObject([UIColor colorWithCGColor:node.layer.backgroundColor]),
|
||||
@"borderColor": SKMutableObject([UIColor colorWithCGColor:node.layer.borderColor]),
|
||||
@"borderWidth": SKMutableObject(@(node.layer.borderWidth)),
|
||||
@"cornerRadius": SKMutableObject(@(node.layer.cornerRadius)),
|
||||
@"masksToBounds": SKMutableObject(@(node.layer.masksToBounds)),
|
||||
}],
|
||||
[SKNamed newWithName: @"Accessibility"
|
||||
withValue: @{
|
||||
@"isAccessibilityElement": SKMutableObject(@(node.isAccessibilityElement)),
|
||||
@"accessibilityLabel": SKMutableObject(node.accessibilityLabel ?: @""),
|
||||
@"accessibilityIdentifier": SKMutableObject(node.accessibilityIdentifier ?: @""),
|
||||
@"accessibilityValue": SKMutableObject(node.accessibilityValue ?: @""),
|
||||
@"accessibilityHint": SKMutableObject(node.accessibilityHint ?: @""),
|
||||
@"accessibilityTraits": AccessibilityTraitsDict(node.accessibilityTraits),
|
||||
@"accessibilityViewIsModal": SKMutableObject(@(node.accessibilityViewIsModal)),
|
||||
@"shouldGroupAccessibilityChildren": SKMutableObject(@(node.shouldGroupAccessibilityChildren)),
|
||||
}],
|
||||
!node.isYogaEnabled ? nil :
|
||||
[SKNamed newWithName: @"YGLayout"
|
||||
withValue: @{
|
||||
@"direction": SKMutableObject(YGDirectionEnumMap[@(node.yoga.direction)]),
|
||||
@"justifyContent": SKMutableObject(YGJustifyEnumMap[@(node.yoga.justifyContent)]),
|
||||
@"aligns": @{
|
||||
@"alignContent": SKMutableObject(YGAlignEnumMap[@(node.yoga.alignContent)]),
|
||||
@"alignItems": SKMutableObject(YGAlignEnumMap[@(node.yoga.alignItems)]),
|
||||
@"alignSelf": SKMutableObject(YGAlignEnumMap[@(node.yoga.alignSelf)]),
|
||||
},
|
||||
@"position": @{
|
||||
@"type": SKMutableObject(YGPositionTypeEnumMap[@(node.yoga.position)]),
|
||||
@"left": SKYGValueObject(node.yoga.left),
|
||||
@"top": SKYGValueObject(node.yoga.top),
|
||||
@"right": SKYGValueObject(node.yoga.right),
|
||||
@"bottom": SKYGValueObject(node.yoga.bottom),
|
||||
@"start": SKYGValueObject(node.yoga.start),
|
||||
@"end": SKYGValueObject(node.yoga.end),
|
||||
},
|
||||
@"overflow": SKMutableObject(YGOverflowEnumMap[@(node.yoga.overflow)]),
|
||||
@"display": SKMutableObject(YGDisplayEnumMap[@(node.yoga.display)]),
|
||||
@"flex": @{
|
||||
@"flexDirection": SKMutableObject(YGFlexDirectionEnumMap[@(node.yoga.flexDirection)]),
|
||||
@"flexWrap": SKMutableObject(YGWrapEnumMap[@(node.yoga.flexWrap)]),
|
||||
@"flexGrow": SKMutableObject(@(node.yoga.flexGrow)),
|
||||
@"flexShrink": SKMutableObject(@(node.yoga.flexShrink)),
|
||||
@"flexBasis": SKYGValueObject(node.yoga.flexBasis),
|
||||
},
|
||||
@"margin": @{
|
||||
@"left": SKYGValueObject(node.yoga.marginLeft),
|
||||
@"top": SKYGValueObject(node.yoga.marginTop),
|
||||
@"right": SKYGValueObject(node.yoga.marginRight),
|
||||
@"bottom": SKYGValueObject(node.yoga.marginBottom),
|
||||
@"start": SKYGValueObject(node.yoga.marginStart),
|
||||
@"end": SKYGValueObject(node.yoga.marginEnd),
|
||||
@"horizontal": SKYGValueObject(node.yoga.marginHorizontal),
|
||||
@"vertical": SKYGValueObject(node.yoga.marginVertical),
|
||||
@"all": SKYGValueObject(node.yoga.margin),
|
||||
},
|
||||
@"padding": @{
|
||||
@"left": SKYGValueObject(node.yoga.paddingLeft),
|
||||
@"top": SKYGValueObject(node.yoga.paddingTop),
|
||||
@"right": SKYGValueObject(node.yoga.paddingRight),
|
||||
@"bottom": SKYGValueObject(node.yoga.paddingBottom),
|
||||
@"start": SKYGValueObject(node.yoga.paddingStart),
|
||||
@"end": SKYGValueObject(node.yoga.paddingEnd),
|
||||
@"horizontal": SKYGValueObject(node.yoga.paddingHorizontal),
|
||||
@"vertical": SKYGValueObject(node.yoga.paddingVertical),
|
||||
@"all": SKYGValueObject(node.yoga.padding),
|
||||
},
|
||||
@"border": @{
|
||||
@"leftWidth": SKMutableObject(@(node.yoga.borderLeftWidth)),
|
||||
@"topWidth": SKMutableObject(@(node.yoga.borderTopWidth)),
|
||||
@"rightWidth": SKMutableObject(@(node.yoga.borderRightWidth)),
|
||||
@"bottomWidth": SKMutableObject(@(node.yoga.borderBottomWidth)),
|
||||
@"startWidth": SKMutableObject(@(node.yoga.borderStartWidth)),
|
||||
@"endWidth": SKMutableObject(@(node.yoga.borderEndWidth)),
|
||||
@"all": SKMutableObject(@(node.yoga.borderWidth)),
|
||||
},
|
||||
@"dimensions": @{
|
||||
@"width": SKYGValueObject(node.yoga.width),
|
||||
@"height": SKYGValueObject(node.yoga.height),
|
||||
@"minWidth": SKYGValueObject(node.yoga.minWidth),
|
||||
@"minHeight": SKYGValueObject(node.yoga.minHeight),
|
||||
@"maxWidth": SKYGValueObject(node.yoga.maxWidth),
|
||||
@"maxHeight": SKYGValueObject(node.yoga.maxHeight),
|
||||
},
|
||||
@"aspectRatio": SKMutableObject(@(node.yoga.aspectRatio)),
|
||||
@"resolvedDirection": SKObject(YGDirectionEnumMap[@(node.yoga.resolvedDirection)]),
|
||||
}],
|
||||
- (NSArray<SKNamed<NSDictionary*>*>*)dataForNode:(UIView*)node {
|
||||
return [NSArray
|
||||
arrayWithObjects:
|
||||
[SKNamed
|
||||
newWithName:@"UIView"
|
||||
withValue:@{
|
||||
@"frame" : SKMutableObject(node.frame),
|
||||
@"bounds" : SKObject(node.bounds),
|
||||
@"center" : SKObject(node.center),
|
||||
@"layoutMargins" : SKObject(node.layoutMargins),
|
||||
@"clipsToBounds" : @(node.clipsToBounds),
|
||||
@"alpha" : SKMutableObject(@(node.alpha)),
|
||||
@"tag" : @(node.tag),
|
||||
@"backgroundColor" : SKMutableObject(node.backgroundColor)
|
||||
}],
|
||||
[SKNamed
|
||||
newWithName:@"CALayer"
|
||||
withValue:@{
|
||||
@"shadowColor" : SKMutableObject(
|
||||
[UIColor colorWithCGColor:node.layer.shadowColor]),
|
||||
@"shadowOpacity" :
|
||||
SKMutableObject(@(node.layer.shadowOpacity)),
|
||||
@"shadowRadius" : SKMutableObject(@(node.layer.shadowRadius)),
|
||||
@"shadowOffset" : SKMutableObject(node.layer.shadowOffset),
|
||||
@"backgroundColor" : SKMutableObject(
|
||||
[UIColor colorWithCGColor:node.layer.backgroundColor]),
|
||||
@"borderColor" : SKMutableObject(
|
||||
[UIColor colorWithCGColor:node.layer.borderColor]),
|
||||
@"borderWidth" : SKMutableObject(@(node.layer.borderWidth)),
|
||||
@"cornerRadius" : SKMutableObject(@(node.layer.cornerRadius)),
|
||||
@"masksToBounds" :
|
||||
SKMutableObject(@(node.layer.masksToBounds)),
|
||||
}],
|
||||
[SKNamed newWithName:@"Accessibility"
|
||||
withValue:@{
|
||||
@"isAccessibilityElement" :
|
||||
SKMutableObject(@(node.isAccessibilityElement)),
|
||||
@"accessibilityLabel" :
|
||||
SKMutableObject(node.accessibilityLabel ?: @""),
|
||||
@"accessibilityIdentifier" :
|
||||
SKMutableObject(node.accessibilityIdentifier ?: @""),
|
||||
@"accessibilityValue" :
|
||||
SKMutableObject(node.accessibilityValue ?: @""),
|
||||
@"accessibilityHint" :
|
||||
SKMutableObject(node.accessibilityHint ?: @""),
|
||||
@"accessibilityTraits" :
|
||||
AccessibilityTraitsDict(node.accessibilityTraits),
|
||||
@"accessibilityViewIsModal" :
|
||||
SKMutableObject(@(node.accessibilityViewIsModal)),
|
||||
@"shouldGroupAccessibilityChildren" : SKMutableObject(
|
||||
@(node.shouldGroupAccessibilityChildren)),
|
||||
}],
|
||||
!node.isYogaEnabled
|
||||
? nil
|
||||
: [SKNamed
|
||||
newWithName:@"YGLayout"
|
||||
withValue:@{
|
||||
@"direction" : SKMutableObject(
|
||||
YGDirectionEnumMap[@(node.yoga.direction)]),
|
||||
@"justifyContent" : SKMutableObject(
|
||||
YGJustifyEnumMap[@(node.yoga.justifyContent)]),
|
||||
@"aligns" : @{
|
||||
@"alignContent" : SKMutableObject(
|
||||
YGAlignEnumMap[@(node.yoga.alignContent)]),
|
||||
@"alignItems" : SKMutableObject(
|
||||
YGAlignEnumMap[@(node.yoga.alignItems)]),
|
||||
@"alignSelf" : SKMutableObject(
|
||||
YGAlignEnumMap[@(node.yoga.alignSelf)]),
|
||||
},
|
||||
@"position" : @{
|
||||
@"type" : SKMutableObject(
|
||||
YGPositionTypeEnumMap[@(node.yoga.position)]),
|
||||
@"left" : SKYGValueObject(node.yoga.left),
|
||||
@"top" : SKYGValueObject(node.yoga.top),
|
||||
@"right" : SKYGValueObject(node.yoga.right),
|
||||
@"bottom" : SKYGValueObject(node.yoga.bottom),
|
||||
@"start" : SKYGValueObject(node.yoga.start),
|
||||
@"end" : SKYGValueObject(node.yoga.end),
|
||||
},
|
||||
@"overflow" : SKMutableObject(
|
||||
YGOverflowEnumMap[@(node.yoga.overflow)]),
|
||||
@"display" : SKMutableObject(
|
||||
YGDisplayEnumMap[@(node.yoga.display)]),
|
||||
@"flex" : @{
|
||||
@"flexDirection" :
|
||||
SKMutableObject(YGFlexDirectionEnumMap[
|
||||
@(node.yoga.flexDirection)]),
|
||||
@"flexWrap" : SKMutableObject(
|
||||
YGWrapEnumMap[@(node.yoga.flexWrap)]),
|
||||
@"flexGrow" : SKMutableObject(@(node.yoga.flexGrow)),
|
||||
@"flexShrink" :
|
||||
SKMutableObject(@(node.yoga.flexShrink)),
|
||||
@"flexBasis" : SKYGValueObject(node.yoga.flexBasis),
|
||||
},
|
||||
@"margin" : @{
|
||||
@"left" : SKYGValueObject(node.yoga.marginLeft),
|
||||
@"top" : SKYGValueObject(node.yoga.marginTop),
|
||||
@"right" : SKYGValueObject(node.yoga.marginRight),
|
||||
@"bottom" : SKYGValueObject(node.yoga.marginBottom),
|
||||
@"start" : SKYGValueObject(node.yoga.marginStart),
|
||||
@"end" : SKYGValueObject(node.yoga.marginEnd),
|
||||
@"horizontal" :
|
||||
SKYGValueObject(node.yoga.marginHorizontal),
|
||||
@"vertical" :
|
||||
SKYGValueObject(node.yoga.marginVertical),
|
||||
@"all" : SKYGValueObject(node.yoga.margin),
|
||||
},
|
||||
@"padding" : @{
|
||||
@"left" : SKYGValueObject(node.yoga.paddingLeft),
|
||||
@"top" : SKYGValueObject(node.yoga.paddingTop),
|
||||
@"right" : SKYGValueObject(node.yoga.paddingRight),
|
||||
@"bottom" : SKYGValueObject(node.yoga.paddingBottom),
|
||||
@"start" : SKYGValueObject(node.yoga.paddingStart),
|
||||
@"end" : SKYGValueObject(node.yoga.paddingEnd),
|
||||
@"horizontal" :
|
||||
SKYGValueObject(node.yoga.paddingHorizontal),
|
||||
@"vertical" :
|
||||
SKYGValueObject(node.yoga.paddingVertical),
|
||||
@"all" : SKYGValueObject(node.yoga.padding),
|
||||
},
|
||||
@"border" : @{
|
||||
@"leftWidth" :
|
||||
SKMutableObject(@(node.yoga.borderLeftWidth)),
|
||||
@"topWidth" :
|
||||
SKMutableObject(@(node.yoga.borderTopWidth)),
|
||||
@"rightWidth" :
|
||||
SKMutableObject(@(node.yoga.borderRightWidth)),
|
||||
@"bottomWidth" :
|
||||
SKMutableObject(@(node.yoga.borderBottomWidth)),
|
||||
@"startWidth" :
|
||||
SKMutableObject(@(node.yoga.borderStartWidth)),
|
||||
@"endWidth" :
|
||||
SKMutableObject(@(node.yoga.borderEndWidth)),
|
||||
@"all" : SKMutableObject(@(node.yoga.borderWidth)),
|
||||
},
|
||||
@"dimensions" : @{
|
||||
@"width" : SKYGValueObject(node.yoga.width),
|
||||
@"height" : SKYGValueObject(node.yoga.height),
|
||||
@"minWidth" : SKYGValueObject(node.yoga.minWidth),
|
||||
@"minHeight" : SKYGValueObject(node.yoga.minHeight),
|
||||
@"maxWidth" : SKYGValueObject(node.yoga.maxWidth),
|
||||
@"maxHeight" : SKYGValueObject(node.yoga.maxHeight),
|
||||
},
|
||||
@"aspectRatio" :
|
||||
SKMutableObject(@(node.yoga.aspectRatio)),
|
||||
@"resolvedDirection" : SKObject(
|
||||
YGDirectionEnumMap[@(node.yoga.resolvedDirection)]),
|
||||
}],
|
||||
nil];
|
||||
}
|
||||
|
||||
- (NSDictionary<NSString *, SKNodeUpdateData> *)dataMutationsForNode:(UIView *)node {
|
||||
- (NSDictionary<NSString*, SKNodeUpdateData>*)dataMutationsForNode:
|
||||
(UIView*)node {
|
||||
return @{
|
||||
// UIView
|
||||
@"UIView.alpha": ^(NSNumber *value) {
|
||||
node.alpha = [value floatValue];
|
||||
},
|
||||
@"UIView.alpha" : ^(NSNumber* value){
|
||||
node.alpha = [value floatValue];
|
||||
}
|
||||
,
|
||||
@"UIView.backgroundColor": ^(NSNumber *value) {
|
||||
node.backgroundColor = [UIColor fromSonarValue: value];
|
||||
},
|
||||
@@ -415,43 +461,43 @@ static NSDictionary *YGUnitEnumMap = nil;
|
||||
@"Accessibility.shouldGroupAccessibilityChildren": ^(NSNumber *value) {
|
||||
node.shouldGroupAccessibilityChildren = [value boolValue];
|
||||
},
|
||||
};
|
||||
}
|
||||
;
|
||||
}
|
||||
|
||||
- (NSArray<SKNamed<NSString *> *> *)attributesForNode:(UIView *)node {
|
||||
return @[
|
||||
[SKNamed newWithName: @"addr"
|
||||
withValue: [NSString stringWithFormat: @"%p", node]]
|
||||
];
|
||||
- (NSArray<SKNamed<NSString*>*>*)attributesForNode:(UIView*)node {
|
||||
return @[ [SKNamed newWithName:@"addr"
|
||||
withValue:[NSString stringWithFormat:@"%p", node]] ];
|
||||
}
|
||||
|
||||
- (void)setHighlighted:(BOOL)highlighted forNode:(UIView *)node {
|
||||
SKHighlightOverlay *overlay = [SKHighlightOverlay sharedInstance];
|
||||
- (void)setHighlighted:(BOOL)highlighted forNode:(UIView*)node {
|
||||
SKHighlightOverlay* overlay = [SKHighlightOverlay sharedInstance];
|
||||
if (highlighted == YES) {
|
||||
[overlay mountInView: node withFrame: node.bounds];
|
||||
[overlay mountInView:node withFrame:node.bounds];
|
||||
} else {
|
||||
[overlay unmount];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)hitTest:(SKTouch *)touch forNode:(UIView *)node {
|
||||
for (NSInteger index = [self childCountForNode: node] - 1; index >= 0; index--) {
|
||||
id<NSObject> childNode = [self childForNode: node atIndex: index];
|
||||
UIView *viewForNode = nil;
|
||||
- (void)hitTest:(SKTouch*)touch forNode:(UIView*)node {
|
||||
for (NSInteger index = [self childCountForNode:node] - 1; index >= 0;
|
||||
index--) {
|
||||
id<NSObject> childNode = [self childForNode:node atIndex:index];
|
||||
UIView* viewForNode = nil;
|
||||
|
||||
if ([childNode isKindOfClass: [UIViewController class]]) {
|
||||
UIViewController *child = (UIViewController *)childNode;
|
||||
if ([childNode isKindOfClass:[UIViewController class]]) {
|
||||
UIViewController* child = (UIViewController*)childNode;
|
||||
viewForNode = child.view;
|
||||
} else {
|
||||
viewForNode = (UIView *)childNode;
|
||||
viewForNode = (UIView*)childNode;
|
||||
}
|
||||
|
||||
if (viewForNode.isHidden || viewForNode.alpha <= 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ([touch containedIn: viewForNode.frame]) {
|
||||
[touch continueWithChildIndex: index withOffset: viewForNode.frame.origin ];
|
||||
if ([touch containedIn:viewForNode.frame]) {
|
||||
[touch continueWithChildIndex:index withOffset:viewForNode.frame.origin];
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -463,73 +509,73 @@ static void initEnumDictionaries() {
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
YGDirectionEnumMap = @{
|
||||
@(YGDirectionInherit): @"inherit",
|
||||
@(YGDirectionLTR): @"LTR",
|
||||
@(YGDirectionRTL): @"RTL",
|
||||
};
|
||||
@(YGDirectionInherit) : @"inherit",
|
||||
@(YGDirectionLTR) : @"LTR",
|
||||
@(YGDirectionRTL) : @"RTL",
|
||||
};
|
||||
|
||||
YGFlexDirectionEnumMap = @{
|
||||
@(YGFlexDirectionColumn): @"column",
|
||||
@(YGFlexDirectionColumnReverse): @"column-reverse",
|
||||
@(YGFlexDirectionRow): @"row",
|
||||
@(YGFlexDirectionRowReverse): @"row-reverse",
|
||||
};
|
||||
@(YGFlexDirectionColumn) : @"column",
|
||||
@(YGFlexDirectionColumnReverse) : @"column-reverse",
|
||||
@(YGFlexDirectionRow) : @"row",
|
||||
@(YGFlexDirectionRowReverse) : @"row-reverse",
|
||||
};
|
||||
|
||||
YGJustifyEnumMap = @{
|
||||
@(YGJustifyFlexStart): @"flex-start",
|
||||
@(YGJustifyCenter): @"center",
|
||||
@(YGJustifyFlexEnd): @"flex-end",
|
||||
@(YGJustifySpaceBetween): @"space-between",
|
||||
@(YGJustifySpaceAround): @"space-around",
|
||||
};
|
||||
@(YGJustifyFlexStart) : @"flex-start",
|
||||
@(YGJustifyCenter) : @"center",
|
||||
@(YGJustifyFlexEnd) : @"flex-end",
|
||||
@(YGJustifySpaceBetween) : @"space-between",
|
||||
@(YGJustifySpaceAround) : @"space-around",
|
||||
};
|
||||
|
||||
YGAlignEnumMap = @{
|
||||
@(YGAlignAuto): @"auto",
|
||||
@(YGAlignFlexStart): @"flex-start",
|
||||
@(YGAlignCenter): @"end",
|
||||
@(YGAlignFlexEnd): @"flex-end",
|
||||
@(YGAlignStretch): @"stretch",
|
||||
@(YGAlignBaseline): @"baseline",
|
||||
@(YGAlignSpaceBetween): @"space-between",
|
||||
@(YGAlignSpaceAround): @"space-around",
|
||||
};
|
||||
@(YGAlignAuto) : @"auto",
|
||||
@(YGAlignFlexStart) : @"flex-start",
|
||||
@(YGAlignCenter) : @"end",
|
||||
@(YGAlignFlexEnd) : @"flex-end",
|
||||
@(YGAlignStretch) : @"stretch",
|
||||
@(YGAlignBaseline) : @"baseline",
|
||||
@(YGAlignSpaceBetween) : @"space-between",
|
||||
@(YGAlignSpaceAround) : @"space-around",
|
||||
};
|
||||
|
||||
YGPositionTypeEnumMap = @{
|
||||
@(YGPositionTypeRelative): @"relative",
|
||||
@(YGPositionTypeAbsolute): @"absolute",
|
||||
};
|
||||
@(YGPositionTypeRelative) : @"relative",
|
||||
@(YGPositionTypeAbsolute) : @"absolute",
|
||||
};
|
||||
|
||||
YGWrapEnumMap = @{
|
||||
@(YGWrapNoWrap): @"no-wrap",
|
||||
@(YGWrapWrap): @"wrap",
|
||||
@(YGWrapWrapReverse): @"wrap-reverse",
|
||||
};
|
||||
@(YGWrapNoWrap) : @"no-wrap",
|
||||
@(YGWrapWrap) : @"wrap",
|
||||
@(YGWrapWrapReverse) : @"wrap-reverse",
|
||||
};
|
||||
|
||||
YGOverflowEnumMap = @{
|
||||
@(YGOverflowVisible): @"visible",
|
||||
@(YGOverflowHidden): @"hidden",
|
||||
@(YGOverflowScroll): @"scroll",
|
||||
};
|
||||
@(YGOverflowVisible) : @"visible",
|
||||
@(YGOverflowHidden) : @"hidden",
|
||||
@(YGOverflowScroll) : @"scroll",
|
||||
};
|
||||
|
||||
YGDisplayEnumMap = @{
|
||||
@(YGDisplayFlex): @"flex",
|
||||
@(YGDisplayNone): @"none",
|
||||
};
|
||||
@(YGDisplayFlex) : @"flex",
|
||||
@(YGDisplayNone) : @"none",
|
||||
};
|
||||
|
||||
YGUnitEnumMap = @{
|
||||
@(YGUnitUndefined): @"undefined",
|
||||
@(YGUnitPoint): @"point",
|
||||
@(YGUnitPercent): @"percent",
|
||||
@(YGUnitAuto): @"auto",
|
||||
};
|
||||
@(YGUnitUndefined) : @"undefined",
|
||||
@(YGUnitPoint) : @"point",
|
||||
@(YGUnitPercent) : @"percent",
|
||||
@(YGUnitAuto) : @"auto",
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
static NSDictionary *SKYGValueObject(YGValue value) {
|
||||
static NSDictionary* SKYGValueObject(YGValue value) {
|
||||
return @{
|
||||
@"value": SKMutableObject(@(value.value)),
|
||||
@"unit": SKMutableObject(YGUnitEnumMap[@(value.unit)]),
|
||||
};
|
||||
@"value" : SKMutableObject(@(value.value)),
|
||||
@"unit" : SKMutableObject(YGUnitEnumMap[@(value.unit)]),
|
||||
};
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -537,36 +583,60 @@ static NSDictionary *SKYGValueObject(YGValue value) {
|
||||
e.g. originalTraits = UIAccessibilityTraitButton | UIAccessibilityTraitSelected
|
||||
toggleTraits = UIAccessibilityTraitImage
|
||||
toggleValue = YES
|
||||
return value = UIAccessibilityTraitButton | UIAccessibilityTraitSelected | UIAccessibilityTraitImage
|
||||
return value = UIAccessibilityTraitButton | UIAccessibilityTraitSelected |
|
||||
UIAccessibilityTraitImage
|
||||
*/
|
||||
static UIAccessibilityTraits AccessibilityTraitsToggle(UIAccessibilityTraits originalTraits, UIAccessibilityTraits toggleTraits, BOOL toggleValue) {
|
||||
// NEGATE all bits of toggleTraits from originalTraits and OR it against either toggleTraits or 0 (UIAccessibilityTraitNone) based on toggleValue
|
||||
UIAccessibilityTraits bitsValue = toggleValue ? toggleTraits : UIAccessibilityTraitNone;
|
||||
static UIAccessibilityTraits AccessibilityTraitsToggle(
|
||||
UIAccessibilityTraits originalTraits,
|
||||
UIAccessibilityTraits toggleTraits,
|
||||
BOOL toggleValue) {
|
||||
// NEGATE all bits of toggleTraits from originalTraits and OR it against
|
||||
// either toggleTraits or 0 (UIAccessibilityTraitNone) based on toggleValue
|
||||
UIAccessibilityTraits bitsValue =
|
||||
toggleValue ? toggleTraits : UIAccessibilityTraitNone;
|
||||
return (originalTraits & ~(toggleTraits)) | bitsValue;
|
||||
}
|
||||
|
||||
static NSDictionary *AccessibilityTraitsDict(UIAccessibilityTraits accessibilityTraits) {
|
||||
NSMutableDictionary *traitsDict = [NSMutableDictionary new];
|
||||
static NSDictionary* AccessibilityTraitsDict(
|
||||
UIAccessibilityTraits accessibilityTraits) {
|
||||
NSMutableDictionary* traitsDict = [NSMutableDictionary new];
|
||||
[traitsDict addEntriesFromDictionary:@{
|
||||
@"UIAccessibilityTraitButton": SKMutableObject(@(!!(accessibilityTraits & UIAccessibilityTraitButton))),
|
||||
@"UIAccessibilityTraitLink": SKMutableObject(@(!!(accessibilityTraits & UIAccessibilityTraitLink))),
|
||||
@"UIAccessibilityTraitHeader": SKMutableObject(@(!!(accessibilityTraits & UIAccessibilityTraitHeader))),
|
||||
@"UIAccessibilityTraitSearchField": SKMutableObject(@(!!(accessibilityTraits & UIAccessibilityTraitSearchField))),
|
||||
@"UIAccessibilityTraitImage": SKMutableObject(@(!!(accessibilityTraits & UIAccessibilityTraitImage))),
|
||||
@"UIAccessibilityTraitSelected": SKMutableObject(@(!!(accessibilityTraits & UIAccessibilityTraitSelected))),
|
||||
@"UIAccessibilityTraitPlaysSound": SKMutableObject(@(!!(accessibilityTraits & UIAccessibilityTraitPlaysSound))),
|
||||
@"UIAccessibilityTraitKeyboardKey": SKMutableObject(@(!!(accessibilityTraits & UIAccessibilityTraitKeyboardKey))),
|
||||
@"UIAccessibilityTraitStaticText": SKMutableObject(@(!!(accessibilityTraits & UIAccessibilityTraitStaticText))),
|
||||
@"UIAccessibilityTraitSummaryElement": SKMutableObject(@(!!(accessibilityTraits & UIAccessibilityTraitSummaryElement))),
|
||||
@"UIAccessibilityTraitNotEnabled": SKMutableObject(@(!!(accessibilityTraits & UIAccessibilityTraitNotEnabled))),
|
||||
@"UIAccessibilityTraitUpdatesFrequently": SKMutableObject(@(!!(accessibilityTraits & UIAccessibilityTraitUpdatesFrequently))),
|
||||
@"UIAccessibilityTraitStartsMediaSession": SKMutableObject(@(!!(accessibilityTraits & UIAccessibilityTraitStartsMediaSession))),
|
||||
@"UIAccessibilityTraitAdjustable": SKMutableObject(@(!!(accessibilityTraits & UIAccessibilityTraitAdjustable))),
|
||||
@"UIAccessibilityTraitAllowsDirectInteraction": SKMutableObject(@(!!(accessibilityTraits & UIAccessibilityTraitAllowsDirectInteraction))),
|
||||
@"UIAccessibilityTraitCausesPageTurn": SKMutableObject(@(!!(accessibilityTraits & UIAccessibilityTraitCausesPageTurn))),
|
||||
}];
|
||||
@"UIAccessibilityTraitButton" : SKMutableObject(
|
||||
@(!!(accessibilityTraits & UIAccessibilityTraitButton))),
|
||||
@"UIAccessibilityTraitLink" :
|
||||
SKMutableObject(@(!!(accessibilityTraits & UIAccessibilityTraitLink))),
|
||||
@"UIAccessibilityTraitHeader" : SKMutableObject(
|
||||
@(!!(accessibilityTraits & UIAccessibilityTraitHeader))),
|
||||
@"UIAccessibilityTraitSearchField" : SKMutableObject(
|
||||
@(!!(accessibilityTraits & UIAccessibilityTraitSearchField))),
|
||||
@"UIAccessibilityTraitImage" :
|
||||
SKMutableObject(@(!!(accessibilityTraits & UIAccessibilityTraitImage))),
|
||||
@"UIAccessibilityTraitSelected" : SKMutableObject(
|
||||
@(!!(accessibilityTraits & UIAccessibilityTraitSelected))),
|
||||
@"UIAccessibilityTraitPlaysSound" : SKMutableObject(
|
||||
@(!!(accessibilityTraits & UIAccessibilityTraitPlaysSound))),
|
||||
@"UIAccessibilityTraitKeyboardKey" : SKMutableObject(
|
||||
@(!!(accessibilityTraits & UIAccessibilityTraitKeyboardKey))),
|
||||
@"UIAccessibilityTraitStaticText" : SKMutableObject(
|
||||
@(!!(accessibilityTraits & UIAccessibilityTraitStaticText))),
|
||||
@"UIAccessibilityTraitSummaryElement" : SKMutableObject(
|
||||
@(!!(accessibilityTraits & UIAccessibilityTraitSummaryElement))),
|
||||
@"UIAccessibilityTraitNotEnabled" : SKMutableObject(
|
||||
@(!!(accessibilityTraits & UIAccessibilityTraitNotEnabled))),
|
||||
@"UIAccessibilityTraitUpdatesFrequently" : SKMutableObject(
|
||||
@(!!(accessibilityTraits & UIAccessibilityTraitUpdatesFrequently))),
|
||||
@"UIAccessibilityTraitStartsMediaSession" : SKMutableObject(
|
||||
@(!!(accessibilityTraits & UIAccessibilityTraitStartsMediaSession))),
|
||||
@"UIAccessibilityTraitAdjustable" : SKMutableObject(
|
||||
@(!!(accessibilityTraits & UIAccessibilityTraitAdjustable))),
|
||||
@"UIAccessibilityTraitAllowsDirectInteraction" : SKMutableObject(@(
|
||||
!!(accessibilityTraits & UIAccessibilityTraitAllowsDirectInteraction))),
|
||||
@"UIAccessibilityTraitCausesPageTurn" : SKMutableObject(
|
||||
@(!!(accessibilityTraits & UIAccessibilityTraitCausesPageTurn))),
|
||||
}];
|
||||
if (@available(iOS 10.0, *)) {
|
||||
traitsDict[@"UIAccessibilityTraitTabBar"] = SKMutableObject(@(!!(accessibilityTraits & UIAccessibilityTraitTabBar)));
|
||||
traitsDict[@"UIAccessibilityTraitTabBar"] = SKMutableObject(
|
||||
@(!!(accessibilityTraits & UIAccessibilityTraitTabBar)));
|
||||
}
|
||||
return traitsDict;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user