add macOS deps to shared libraries
Summary: Add macOS dependencies and alternative classes to the libraries that FlipperKitLayoutPlugin needs to function. Reviewed By: priteshrnandgaonkar Differential Revision: D27328277 fbshipit-source-id: f22d1e9f6a5415cee0bae8eaada653be5f5467b3
This commit is contained in:
committed by
Facebook GitHub Bot
parent
ec603255fe
commit
7c44d4d4f0
@@ -5,7 +5,14 @@
|
|||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#import <TargetConditionals.h>
|
||||||
|
|
||||||
|
#if TARGET_OS_IPHONE
|
||||||
#import <UIKit/UIKit.h>
|
#import <UIKit/UIKit.h>
|
||||||
|
#elif TARGET_OS_OSX
|
||||||
|
#import <AppKit/AppKit.h>
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
@protocol FKTextSearchable<NSObject>
|
@protocol FKTextSearchable<NSObject>
|
||||||
|
|
||||||
|
|||||||
@@ -5,14 +5,32 @@
|
|||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#import <TargetConditionals.h>
|
||||||
|
|
||||||
|
#if TARGET_OS_IPHONE
|
||||||
#import <UIKit/UIKit.h>
|
#import <UIKit/UIKit.h>
|
||||||
|
#elif TARGET_OS_OSX
|
||||||
|
#import <AppKit/AppKit.h>
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#import <QuartzCore/QuartzCore.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
@interface SKHighlightOverlay : NSObject
|
@interface SKHighlightOverlay : NSObject
|
||||||
|
|
||||||
+ (instancetype)sharedInstance;
|
+ (instancetype)sharedInstance;
|
||||||
+ (UIColor*)overlayColor;
|
|
||||||
|
|
||||||
|
#if TARGET_OS_IPHONE
|
||||||
|
|
||||||
|
+ (UIColor*)overlayColor;
|
||||||
- (void)mountInView:(UIView*)view withFrame:(CGRect)frame;
|
- (void)mountInView:(UIView*)view withFrame:(CGRect)frame;
|
||||||
|
|
||||||
|
#elif TARGET_OS_OSX
|
||||||
|
|
||||||
|
+ (NSColor*)overlayColor;
|
||||||
|
- (void)mountInView:(NSView*)view withFrame:(CGRect)frame;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
- (void)unmount;
|
- (void)unmount;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@@ -31,6 +31,8 @@
|
|||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if TARGET_OS_IPHONE
|
||||||
|
|
||||||
- (void)mountInView:(UIView*)view withFrame:(CGRect)frame {
|
- (void)mountInView:(UIView*)view withFrame:(CGRect)frame {
|
||||||
[CATransaction begin];
|
[CATransaction begin];
|
||||||
[CATransaction setValue:(id)kCFBooleanTrue
|
[CATransaction setValue:(id)kCFBooleanTrue
|
||||||
@@ -40,10 +42,25 @@
|
|||||||
[CATransaction commit];
|
[CATransaction commit];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#elif TARGET_OS_OSX
|
||||||
|
|
||||||
|
- (void)mountInView:(NSView*)view withFrame:(CGRect)frame {
|
||||||
|
[CATransaction begin];
|
||||||
|
[CATransaction setValue:(id)kCFBooleanTrue
|
||||||
|
forKey:kCATransactionDisableActions];
|
||||||
|
_overlayLayer.frame = frame;
|
||||||
|
[view.layer addSublayer:_overlayLayer];
|
||||||
|
[CATransaction commit];
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
- (void)unmount {
|
- (void)unmount {
|
||||||
[_overlayLayer removeFromSuperlayer];
|
[_overlayLayer removeFromSuperlayer];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if TARGET_OS_IPHONE
|
||||||
|
|
||||||
+ (UIColor*)overlayColor {
|
+ (UIColor*)overlayColor {
|
||||||
return [UIColor colorWithRed:136.0 / 255.0
|
return [UIColor colorWithRed:136.0 / 255.0
|
||||||
green:117.0 / 255.0
|
green:117.0 / 255.0
|
||||||
@@ -51,6 +68,17 @@
|
|||||||
alpha:0.6];
|
alpha:0.6];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#elif TARGET_OS_OSX
|
||||||
|
|
||||||
|
+ (NSColor*)overlayColor {
|
||||||
|
return [NSColor colorWithRed:136.0 / 255.0
|
||||||
|
green:117.0 / 255.0
|
||||||
|
blue:197.0 / 255.0
|
||||||
|
alpha:0.6];
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if TARGET_OS_OSX
|
||||||
|
|
||||||
|
#import <AppKit/AppKit.h>
|
||||||
|
|
||||||
|
#import <FlipperKit/SKMacros.h>
|
||||||
|
|
||||||
|
FB_LINK_REQUIRE_CATEGORY(NSCollectionView_SKInvalidation)
|
||||||
|
@interface NSCollectionView (SKInvalidation)
|
||||||
|
|
||||||
|
+ (void)enableInvalidations;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if TARGET_OS_OSX
|
||||||
|
#if FB_SONARKIT_ENABLED
|
||||||
|
|
||||||
|
#import "NSCollectionView+SKInvalidation.h"
|
||||||
|
|
||||||
|
#import "SKInvalidation.h"
|
||||||
|
#import "SKSwizzle.h"
|
||||||
|
|
||||||
|
FB_LINKABLE(NSCollectionView_SKInvalidation)
|
||||||
|
@implementation NSCollectionView (SKInvalidation)
|
||||||
|
|
||||||
|
+ (void)enableInvalidations {
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
#endif // FB_SONARKIT_ENABLED
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if TARGET_OS_OSX
|
||||||
|
|
||||||
|
#import <AppKit/AppKit.h>
|
||||||
|
|
||||||
|
#import <FlipperKit/SKMacros.h>
|
||||||
|
|
||||||
|
#import "SKObject.h"
|
||||||
|
|
||||||
|
FB_LINK_REQUIRE_CATEGORY(NSColor_SonarValueCoder)
|
||||||
|
@interface NSColor (SonarValueCoder)<SKSonarValueCoder>
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if TARGET_OS_OSX
|
||||||
|
#if FB_SONARKIT_ENABLED
|
||||||
|
|
||||||
|
#import "NSColor+SKSonarValueCoder.h"
|
||||||
|
|
||||||
|
FB_LINKABLE(NSColor_SonarValueCoder)
|
||||||
|
@implementation NSColor (SonarValueCoder)
|
||||||
|
|
||||||
|
+ (instancetype)fromSonarValue:(NSNumber*)sonarValue {
|
||||||
|
NSUInteger intColor = [sonarValue integerValue];
|
||||||
|
|
||||||
|
CGFloat r, g, b, a;
|
||||||
|
|
||||||
|
b = CGFloat(intColor & 0xFF) / 255;
|
||||||
|
g = CGFloat((intColor >> 8) & 0xFF) / 255;
|
||||||
|
r = CGFloat((intColor >> 16) & 0xFF) / 255;
|
||||||
|
a = CGFloat((intColor >> 24) & 0xFF) / 255;
|
||||||
|
|
||||||
|
return [NSColor colorWithRed:r green:g blue:b alpha:a];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSDictionary<NSString*, id<NSObject>>*)sonarValue {
|
||||||
|
CGColorSpaceRef colorSpace = CGColorGetColorSpace([self CGColor]);
|
||||||
|
CGColorSpaceModel colorSpaceModel = CGColorSpaceGetModel(colorSpace);
|
||||||
|
|
||||||
|
NSUInteger red, green, blue, alpha;
|
||||||
|
|
||||||
|
switch (colorSpaceModel) {
|
||||||
|
case kCGColorSpaceModelUnknown:
|
||||||
|
case kCGColorSpaceModelRGB: {
|
||||||
|
CGFloat r, g, b, a;
|
||||||
|
[self getRed:&r green:&g blue:&b alpha:&a];
|
||||||
|
|
||||||
|
red = (NSUInteger)(r * 255) & 0xFF;
|
||||||
|
green = (NSUInteger)(g * 255) & 0xFF;
|
||||||
|
blue = (NSUInteger)(b * 255) & 0xFF;
|
||||||
|
alpha = (NSUInteger)(a * 255) & 0xFF;
|
||||||
|
} break;
|
||||||
|
|
||||||
|
case kCGColorSpaceModelMonochrome: {
|
||||||
|
CGFloat a, w;
|
||||||
|
[self getWhite:&w alpha:&a];
|
||||||
|
|
||||||
|
red = green = blue = (NSUInteger)(w * 255) & 0xFF;
|
||||||
|
alpha = (NSUInteger)(a * 255) & 0xFF;
|
||||||
|
} break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
red = green = blue = alpha = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
NSUInteger intColor = (alpha << 24) | (red << 16) | (green << 8) | blue;
|
||||||
|
return
|
||||||
|
@{@"__type__" : @"color", @"__mutable__" : @NO, @"value" : @(intColor)};
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
#endif // FB_SONARKIT_ENABLED
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if TARGET_OS_OSX
|
||||||
|
|
||||||
|
#import <FlipperKit/SKMacros.h>
|
||||||
|
|
||||||
|
FB_LINK_REQUIRE_CATEGORY(NSView_SKInvalidation)
|
||||||
|
@interface NSView (SKInvalidation)
|
||||||
|
|
||||||
|
+ (void)enableInvalidation;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if TARGET_OS_OSX
|
||||||
|
#if FB_SONARKIT_ENABLED
|
||||||
|
|
||||||
|
#import <AppKit/AppKit.h>
|
||||||
|
#import <objc/runtime.h>
|
||||||
|
#import "NSView+SKInvalidation.h"
|
||||||
|
#import "SKInvalidation.h"
|
||||||
|
#import "SKSwizzle.h"
|
||||||
|
|
||||||
|
FB_LINKABLE(NSView_SKInvalidation)
|
||||||
|
@implementation NSView (SKInvalidation)
|
||||||
|
|
||||||
|
+ (void)enableInvalidation {
|
||||||
|
static dispatch_once_t onceToken;
|
||||||
|
dispatch_once(&onceToken, ^{
|
||||||
|
swizzleMethods(
|
||||||
|
[self class], @selector(setHidden:), @selector(swizzle_setHidden:));
|
||||||
|
swizzleMethods(
|
||||||
|
[self class], @selector(addSubview:), @selector(swizzle_addSubview:));
|
||||||
|
swizzleMethods(
|
||||||
|
[self class],
|
||||||
|
@selector(removeFromSuperview),
|
||||||
|
@selector(swizzle_removeFromSuperview));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)swizzle_setHidden:(BOOL)hidden {
|
||||||
|
[self swizzle_setHidden:hidden];
|
||||||
|
|
||||||
|
id<SKInvalidationDelegate> delegate =
|
||||||
|
[SKInvalidation sharedInstance].delegate;
|
||||||
|
if (delegate != nil) {
|
||||||
|
[delegate invalidateNode:self.superview];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)swizzle_addSubview:(NSView*)view {
|
||||||
|
[self swizzle_addSubview:view];
|
||||||
|
[[SKInvalidation sharedInstance].delegate invalidateNode:self];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)swizzle_removeFromSuperview {
|
||||||
|
NSView* oldSuperview = self.superview;
|
||||||
|
// Be careful that we always call the swizzled implementation
|
||||||
|
// before any early returns or mischief below!
|
||||||
|
[self swizzle_removeFromSuperview];
|
||||||
|
|
||||||
|
if (oldSuperview) {
|
||||||
|
[[SKInvalidation sharedInstance].delegate invalidateNode:oldSuperview];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
#endif // FB_SONARKIT_ENABLED
|
||||||
|
#endif
|
||||||
@@ -7,12 +7,22 @@
|
|||||||
|
|
||||||
#if FB_SONARKIT_ENABLED
|
#if FB_SONARKIT_ENABLED
|
||||||
|
|
||||||
#import <UIKit/UIKit.h>
|
|
||||||
|
|
||||||
#import "SKInvalidation.h"
|
#import "SKInvalidation.h"
|
||||||
|
|
||||||
|
#if TARGET_OS_IPHONE
|
||||||
|
|
||||||
|
#import <UIKit/UIKit.h>
|
||||||
#import "UICollectionView+SKInvalidation.h"
|
#import "UICollectionView+SKInvalidation.h"
|
||||||
#import "UIView+SKInvalidation.h"
|
#import "UIView+SKInvalidation.h"
|
||||||
|
|
||||||
|
#elif TARGET_OS_OSX
|
||||||
|
|
||||||
|
#import <AppKit/AppKit.h>
|
||||||
|
#import "NSCollectionView+SKInvalidation.h"
|
||||||
|
#import "NSView+SKInvalidation.h"
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
@implementation SKInvalidation
|
@implementation SKInvalidation
|
||||||
|
|
||||||
+ (instancetype)sharedInstance {
|
+ (instancetype)sharedInstance {
|
||||||
@@ -29,6 +39,7 @@
|
|||||||
+ (void)enableInvalidations {
|
+ (void)enableInvalidations {
|
||||||
static dispatch_once_t onceToken;
|
static dispatch_once_t onceToken;
|
||||||
dispatch_once(&onceToken, ^{
|
dispatch_once(&onceToken, ^{
|
||||||
|
#if TARGET_OS_IPHONE
|
||||||
[UIView enableInvalidation];
|
[UIView enableInvalidation];
|
||||||
[UICollectionView enableInvalidations];
|
[UICollectionView enableInvalidations];
|
||||||
|
|
||||||
@@ -43,6 +54,13 @@
|
|||||||
selector:@selector(windowDidBecomeHidden:)
|
selector:@selector(windowDidBecomeHidden:)
|
||||||
name:UIWindowDidBecomeHiddenNotification
|
name:UIWindowDidBecomeHiddenNotification
|
||||||
object:nil];
|
object:nil];
|
||||||
|
|
||||||
|
#elif TARGET_OS_OSX
|
||||||
|
|
||||||
|
[NSView enableInvalidation];
|
||||||
|
[NSCollectionView enableInvalidations];
|
||||||
|
|
||||||
|
#endif
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,14 @@
|
|||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#import <TargetConditionals.h>
|
||||||
|
|
||||||
|
#if TARGET_OS_IPHONE
|
||||||
#import <UIKit/UIKit.h>
|
#import <UIKit/UIKit.h>
|
||||||
|
#elif TARGET_OS_OSX
|
||||||
|
#import <AppKit/AppKit.h>
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#import <FlipperKitLayoutHelpers/FlipperKitLayoutDescriptorMapperProtocol.h>
|
#import <FlipperKitLayoutHelpers/FlipperKitLayoutDescriptorMapperProtocol.h>
|
||||||
#import "SKNamed.h"
|
#import "SKNamed.h"
|
||||||
|
|||||||
@@ -5,7 +5,14 @@
|
|||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#import <TargetConditionals.h>
|
||||||
|
|
||||||
|
#if TARGET_OS_IPHONE
|
||||||
#import <UIKit/UIKit.h>
|
#import <UIKit/UIKit.h>
|
||||||
|
#elif TARGET_OS_OSX
|
||||||
|
#import <AppKit/AppKit.h>
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
@protocol SKSonarValueCoder
|
@protocol SKSonarValueCoder
|
||||||
|
|
||||||
@@ -20,7 +27,11 @@ class SKObject {
|
|||||||
SKObject(CGRect rect);
|
SKObject(CGRect rect);
|
||||||
SKObject(CGSize size);
|
SKObject(CGSize size);
|
||||||
SKObject(CGPoint point);
|
SKObject(CGPoint point);
|
||||||
|
#if TARGET_OS_IPHONE
|
||||||
SKObject(UIEdgeInsets insets);
|
SKObject(UIEdgeInsets insets);
|
||||||
|
#elif TARGET_OS_OSX
|
||||||
|
SKObject(NSEdgeInsets insets);
|
||||||
|
#endif
|
||||||
SKObject(CGAffineTransform transform);
|
SKObject(CGAffineTransform transform);
|
||||||
SKObject(id<SKSonarValueCoder> value);
|
SKObject(id<SKSonarValueCoder> value);
|
||||||
SKObject(id value);
|
SKObject(id value);
|
||||||
@@ -38,7 +49,11 @@ class SKMutableObject : public SKObject {
|
|||||||
SKMutableObject(CGRect rect) : SKObject(rect) {}
|
SKMutableObject(CGRect rect) : SKObject(rect) {}
|
||||||
SKMutableObject(CGSize size) : SKObject(size){};
|
SKMutableObject(CGSize size) : SKObject(size){};
|
||||||
SKMutableObject(CGPoint point) : SKObject(point){};
|
SKMutableObject(CGPoint point) : SKObject(point){};
|
||||||
|
#if TARGET_OS_IPHONE
|
||||||
SKMutableObject(UIEdgeInsets insets) : SKObject(insets){};
|
SKMutableObject(UIEdgeInsets insets) : SKObject(insets){};
|
||||||
|
#elif TARGET_OS_OSX
|
||||||
|
SKMutableObject(NSEdgeInsets insets) : SKObject(insets){};
|
||||||
|
#endif
|
||||||
SKMutableObject(CGAffineTransform transform) : SKObject(transform){};
|
SKMutableObject(CGAffineTransform transform) : SKObject(transform){};
|
||||||
SKMutableObject(id<SKSonarValueCoder> value) : SKObject(value){};
|
SKMutableObject(id<SKSonarValueCoder> value) : SKObject(value){};
|
||||||
SKMutableObject(id value) : SKObject(value){};
|
SKMutableObject(id value) : SKObject(value){};
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ SKObject::SKObject(CGPoint point) {
|
|||||||
_actual = @{@"x" : @(point.x), @"y" : @(point.y)};
|
_actual = @{@"x" : @(point.x), @"y" : @(point.y)};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if TARGET_OS_IPHONE
|
||||||
|
|
||||||
SKObject::SKObject(UIEdgeInsets insets) {
|
SKObject::SKObject(UIEdgeInsets insets) {
|
||||||
_actual = @{
|
_actual = @{
|
||||||
@"top" : @(insets.top),
|
@"top" : @(insets.top),
|
||||||
@@ -30,6 +32,19 @@ SKObject::SKObject(UIEdgeInsets insets) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#elif TARGET_OS_OSX
|
||||||
|
|
||||||
|
SKObject::SKObject(NSEdgeInsets insets) {
|
||||||
|
_actual = @{
|
||||||
|
@"top" : @(insets.top),
|
||||||
|
@"bottom" : @(insets.bottom),
|
||||||
|
@"left" : @(insets.left),
|
||||||
|
@"right" : @(insets.right),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
SKObject::SKObject(CGAffineTransform transform) {
|
SKObject::SKObject(CGAffineTransform transform) {
|
||||||
_actual = @{
|
_actual = @{
|
||||||
@"a" : @(transform.a),
|
@"a" : @(transform.a),
|
||||||
|
|||||||
@@ -5,7 +5,14 @@
|
|||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#import <TargetConditionals.h>
|
||||||
|
|
||||||
|
#if TARGET_OS_IPHONE
|
||||||
#import <UIKit/UIKit.h>
|
#import <UIKit/UIKit.h>
|
||||||
|
#elif TARGET_OS_OSX
|
||||||
|
#import <AppKit/AppKit.h>
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef void (^SKTapReceiver)(CGPoint touchPoint);
|
typedef void (^SKTapReceiver)(CGPoint touchPoint);
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,16 @@
|
|||||||
|
|
||||||
#import "SKTapListener.h"
|
#import "SKTapListener.h"
|
||||||
|
|
||||||
|
#if TARGET_OS_IPHONE
|
||||||
|
|
||||||
@interface SKTapListenerImpl
|
@interface SKTapListenerImpl
|
||||||
: NSObject<SKTapListener, UIGestureRecognizerDelegate>
|
: NSObject<SKTapListener, UIGestureRecognizerDelegate>
|
||||||
|
|
||||||
|
#elif TARGET_OS_OSX
|
||||||
|
|
||||||
|
@interface SKTapListenerImpl
|
||||||
|
: NSObject<SKTapListener, NSGestureRecognizerDelegate>
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <TargetConditionals.h>
|
||||||
#if FB_SONARKIT_ENABLED
|
#if FB_SONARKIT_ENABLED
|
||||||
|
|
||||||
#import "SKTapListenerImpl.h"
|
#import "SKTapListenerImpl.h"
|
||||||
@@ -15,9 +16,14 @@
|
|||||||
|
|
||||||
@implementation SKTapListenerImpl {
|
@implementation SKTapListenerImpl {
|
||||||
NSMutableArray<SKTapReceiver>* _receiversWaitingForInput;
|
NSMutableArray<SKTapReceiver>* _receiversWaitingForInput;
|
||||||
UITapGestureRecognizer* _gestureRecognizer;
|
|
||||||
|
|
||||||
|
#if TARGET_OS_IPHONE
|
||||||
|
UITapGestureRecognizer* _gestureRecognizer;
|
||||||
SKHiddenWindow* _overlayWindow;
|
SKHiddenWindow* _overlayWindow;
|
||||||
|
#elif TARGET_OS_OSX
|
||||||
|
NSClickGestureRecognizer* _gestureRecognizer;
|
||||||
|
SKHiddenWindow* _overlayView;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@synthesize isMounted = _isMounted;
|
@synthesize isMounted = _isMounted;
|
||||||
@@ -26,6 +32,7 @@
|
|||||||
if (self = [super init]) {
|
if (self = [super init]) {
|
||||||
_receiversWaitingForInput = [NSMutableArray new];
|
_receiversWaitingForInput = [NSMutableArray new];
|
||||||
|
|
||||||
|
#if TARGET_OS_IPHONE
|
||||||
_gestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self
|
_gestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self
|
||||||
action:nil];
|
action:nil];
|
||||||
_gestureRecognizer.delegate = self;
|
_gestureRecognizer.delegate = self;
|
||||||
@@ -38,6 +45,21 @@
|
|||||||
_overlayWindow.backgroundColor = [SKHighlightOverlay overlayColor];
|
_overlayWindow.backgroundColor = [SKHighlightOverlay overlayColor];
|
||||||
|
|
||||||
[_overlayWindow addGestureRecognizer:_gestureRecognizer];
|
[_overlayWindow addGestureRecognizer:_gestureRecognizer];
|
||||||
|
|
||||||
|
#elif TARGET_OS_OSX
|
||||||
|
_gestureRecognizer = [[NSClickGestureRecognizer alloc] initWithTarget:self
|
||||||
|
action:nil];
|
||||||
|
_gestureRecognizer.delegate = self;
|
||||||
|
|
||||||
|
_isMounted = NO;
|
||||||
|
|
||||||
|
_overlayView = [SKHiddenWindow new];
|
||||||
|
|
||||||
|
_overlayView.hidden = YES;
|
||||||
|
_overlayView.window.level = NSStatusWindowLevel;
|
||||||
|
_overlayView.window.backgroundColor = [SKHighlightOverlay overlayColor];
|
||||||
|
[_overlayView addGestureRecognizer:_gestureRecognizer];
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
@@ -48,10 +70,20 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if TARGET_OS_IPHONE
|
||||||
[_overlayWindow setFrame:frame];
|
[_overlayWindow setFrame:frame];
|
||||||
[_overlayWindow makeKeyAndVisible];
|
[_overlayWindow makeKeyAndVisible];
|
||||||
_overlayWindow.hidden = NO;
|
_overlayWindow.hidden = NO;
|
||||||
[[UIApplication sharedApplication].delegate.window addSubview:_overlayWindow];
|
[[UIApplication sharedApplication].delegate.window addSubview:_overlayWindow];
|
||||||
|
|
||||||
|
#elif TARGET_OS_OSX
|
||||||
|
_overlayView.hidden = NO;
|
||||||
|
[[NSApplication sharedApplication].mainWindow.contentView
|
||||||
|
addSubview:_overlayView];
|
||||||
|
_overlayView.frame = frame;
|
||||||
|
_overlayView.needsDisplay = YES;
|
||||||
|
#endif
|
||||||
|
|
||||||
_isMounted = YES;
|
_isMounted = YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,8 +93,15 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
[_receiversWaitingForInput removeAllObjects];
|
[_receiversWaitingForInput removeAllObjects];
|
||||||
|
|
||||||
|
#if TARGET_OS_IPHONE
|
||||||
[_overlayWindow removeFromSuperview];
|
[_overlayWindow removeFromSuperview];
|
||||||
_overlayWindow.hidden = YES;
|
_overlayWindow.hidden = YES;
|
||||||
|
#elif TARGET_OS_OSX
|
||||||
|
[_overlayView removeFromSuperview];
|
||||||
|
_overlayView.hidden = YES;
|
||||||
|
#endif
|
||||||
|
|
||||||
_isMounted = NO;
|
_isMounted = NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,6 +109,7 @@
|
|||||||
[_receiversWaitingForInput addObject:receiver];
|
[_receiversWaitingForInput addObject:receiver];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if TARGET_OS_IPHONE
|
||||||
- (BOOL)gestureRecognizer:(UIGestureRecognizer*)gestureRecognizer
|
- (BOOL)gestureRecognizer:(UIGestureRecognizer*)gestureRecognizer
|
||||||
shouldReceiveTouch:(UITouch*)touch {
|
shouldReceiveTouch:(UITouch*)touch {
|
||||||
if ([_receiversWaitingForInput count] == 0) {
|
if ([_receiversWaitingForInput count] == 0) {
|
||||||
@@ -87,6 +127,25 @@
|
|||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#elif TARGET_OS_OSX
|
||||||
|
- (BOOL)gestureRecognizer:(NSGestureRecognizer*)gestureRecognizer
|
||||||
|
shouldReceiveTouch:(NSTouch*)touch {
|
||||||
|
if ([_receiversWaitingForInput count] == 0) {
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
if (@available(macOS 10.12.2, *)) {
|
||||||
|
CGPoint touchPoint = [touch locationInView:_overlayView];
|
||||||
|
for (SKTapReceiver recv in _receiversWaitingForInput) {
|
||||||
|
recv(touchPoint);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[_receiversWaitingForInput removeAllObjects];
|
||||||
|
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -5,8 +5,14 @@
|
|||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#import <FlipperKitLayoutHelpers/FlipperKitLayoutDescriptorMapperProtocol.h>
|
#import <TargetConditionals.h>
|
||||||
|
#if TARGET_OS_IPHONE
|
||||||
#import <UIKit/UIKit.h>
|
#import <UIKit/UIKit.h>
|
||||||
|
#elif TARGET_OS_OSX
|
||||||
|
#import <AppKit/AppKit.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#import <FlipperKitLayoutHelpers/FlipperKitLayoutDescriptorMapperProtocol.h>
|
||||||
|
|
||||||
typedef void (^SKTouchFinishDelegate)(id<NSObject> currentNode);
|
typedef void (^SKTouchFinishDelegate)(id<NSObject> currentNode);
|
||||||
typedef void (^SKProcessFinishDelegate)(NSDictionary* tree);
|
typedef void (^SKProcessFinishDelegate)(NSDictionary* tree);
|
||||||
|
|||||||
@@ -5,6 +5,8 @@
|
|||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#if TARGET_OS_IPHONE
|
||||||
|
|
||||||
#import <UIKit/UIKit.h>
|
#import <UIKit/UIKit.h>
|
||||||
|
|
||||||
#import <FlipperKit/SKMacros.h>
|
#import <FlipperKit/SKMacros.h>
|
||||||
@@ -15,3 +17,5 @@ FB_LINK_REQUIRE_CATEGORY(UICollectionView_SKInvalidation)
|
|||||||
+ (void)enableInvalidations;
|
+ (void)enableInvalidations;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#if TARGET_OS_IPHONE
|
||||||
#if FB_SONARKIT_ENABLED
|
#if FB_SONARKIT_ENABLED
|
||||||
|
|
||||||
#import "UICollectionView+SKInvalidation.h"
|
#import "UICollectionView+SKInvalidation.h"
|
||||||
@@ -36,4 +37,5 @@ FB_LINKABLE(UICollectionView_SKInvalidation)
|
|||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
#endif // FB_SONARKIT_ENABLED
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -5,6 +5,8 @@
|
|||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#if TARGET_OS_IPHONE
|
||||||
|
|
||||||
#import <UIKit/UIKit.h>
|
#import <UIKit/UIKit.h>
|
||||||
|
|
||||||
#import <FlipperKit/SKMacros.h>
|
#import <FlipperKit/SKMacros.h>
|
||||||
@@ -15,3 +17,5 @@ FB_LINK_REQUIRE_CATEGORY(UIColor_SonarValueCoder)
|
|||||||
@interface UIColor (SonarValueCoder)<SKSonarValueCoder>
|
@interface UIColor (SonarValueCoder)<SKSonarValueCoder>
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#if TARGET_OS_IPHONE
|
||||||
#if FB_SONARKIT_ENABLED
|
#if FB_SONARKIT_ENABLED
|
||||||
|
|
||||||
#import "UIColor+SKSonarValueCoder.h"
|
#import "UIColor+SKSonarValueCoder.h"
|
||||||
@@ -62,4 +63,5 @@ FB_LINKABLE(UIColor_SonarValueCoder)
|
|||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
#endif // FB_SONARKIT_ENABLED
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -5,6 +5,8 @@
|
|||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#if TARGET_OS_IPHONE
|
||||||
|
|
||||||
#import <FlipperKit/SKMacros.h>
|
#import <FlipperKit/SKMacros.h>
|
||||||
|
|
||||||
FB_LINK_REQUIRE_CATEGORY(UIView_SKInvalidation)
|
FB_LINK_REQUIRE_CATEGORY(UIView_SKInvalidation)
|
||||||
@@ -13,3 +15,5 @@ FB_LINK_REQUIRE_CATEGORY(UIView_SKInvalidation)
|
|||||||
+ (void)enableInvalidation;
|
+ (void)enableInvalidation;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#if TARGET_OS_IPHONE
|
||||||
#if FB_SONARKIT_ENABLED
|
#if FB_SONARKIT_ENABLED
|
||||||
|
|
||||||
#import <UIKit/UIKit.h>
|
#import <UIKit/UIKit.h>
|
||||||
@@ -115,4 +116,5 @@ FB_LINKABLE(UIView_SKInvalidation)
|
|||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
#endif // FB_SONARKIT_ENABLED
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -5,7 +5,23 @@
|
|||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#import <TargetConditionals.h>
|
||||||
|
|
||||||
|
#if TARGET_OS_IPHONE
|
||||||
#import <UIKit/UIKit.h>
|
#import <UIKit/UIKit.h>
|
||||||
|
#elif TARGET_OS_OSX
|
||||||
|
#import <AppKit/AppKit.h>
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if TARGET_OS_IPHONE
|
||||||
|
|
||||||
@interface SKHiddenWindow : UIWindow
|
@interface SKHiddenWindow : UIWindow
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
#elif TARGET_OS_OSX
|
||||||
|
|
||||||
|
@interface SKHiddenWindow : NSView
|
||||||
|
@end
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user