Moving SKHighlightOverlay

Summary: Moving FlipperKitLayoutPlugin/FlipperKitPluginUtils/SKHighlightOverlay to shared folder, so Layout and WorkingRange plugins can depend on it

Reviewed By: kevin0571

Differential Revision: D17156396

fbshipit-source-id: 3f17371f2ab4818924d61e6cfb243f60ad1f2892
This commit is contained in:
Roman Gorbunov
2019-09-05 07:28:35 -07:00
committed by Facebook Github Bot
parent 26c9bf3853
commit eff95991c6
6 changed files with 13 additions and 4 deletions

View File

@@ -0,0 +1,17 @@
/*
* 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.
*/
#import <UIKit/UIKit.h>
@interface SKHighlightOverlay : NSObject
+ (instancetype)sharedInstance;
+ (UIColor*)overlayColor;
- (void)mountInView:(UIView *)view withFrame:(CGRect)frame;
- (void)unmount;
@end

View File

@@ -0,0 +1,54 @@
/*
* Copyright (c) 2018-present, 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 FB_SONARKIT_ENABLED
#import "SKHighlightOverlay.h"
@implementation SKHighlightOverlay
{
CALayer *_overlayLayer;
}
+ (instancetype)sharedInstance {
static SKHighlightOverlay *sharedInstance = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
sharedInstance = [self new];
});
return sharedInstance;
}
- (instancetype)init {
if (self = [super init]) {
_overlayLayer = [CALayer layer];
_overlayLayer.backgroundColor = [SKHighlightOverlay overlayColor].CGColor;
}
return self;
}
- (void)mountInView:(UIView *)view withFrame:(CGRect)frame {
[CATransaction begin];
[CATransaction setValue:(id)kCFBooleanTrue
forKey:kCATransactionDisableActions];
_overlayLayer.frame = frame;
[view.layer addSublayer: _overlayLayer];
[CATransaction commit];
}
- (void)unmount {
[_overlayLayer removeFromSuperlayer];
}
+ (UIColor*)overlayColor {
return [UIColor colorWithRed:136.0 / 255.0 green:117.0 / 255.0 blue:197.0 / 255.0 alpha:0.6];
}
@end
#endif