2017-04-10 15:24:39 +00:00
|
|
|
#import <UIKit/UIKit.h>
|
2015-10-05 20:41:32 +00:00
|
|
|
#import "VibrancyView.h"
|
|
|
|
#import "BlurView.h"
|
2017-01-05 17:12:00 +00:00
|
|
|
#import <React/RCTComponent.h>
|
2015-10-05 20:41:32 +00:00
|
|
|
|
2017-04-10 15:24:39 +00:00
|
|
|
@interface VibrancyView ()
|
|
|
|
|
|
|
|
@property (nonatomic, strong) UIVisualEffectView *visualEffectView;
|
|
|
|
@property (nonatomic, strong) UIVisualEffectView *vibrancyView;
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation VibrancyView
|
|
|
|
|
|
|
|
- (instancetype)initWithFrame:(CGRect)frame {
|
|
|
|
if (self = [super initWithFrame:frame]) {
|
|
|
|
UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark];
|
|
|
|
self.visualEffectView = [[UIVisualEffectView alloc] initWithEffect:blurEffect];
|
|
|
|
|
|
|
|
UIVibrancyEffect *vibrancyEffect = [UIVibrancyEffect effectForBlurEffect:blurEffect];
|
|
|
|
self.vibrancyView = [[UIVisualEffectView alloc] initWithEffect:vibrancyEffect];
|
|
|
|
|
|
|
|
self.visualEffectView.frame = frame;
|
|
|
|
self.vibrancyView.frame = frame;
|
|
|
|
|
|
|
|
[self addSubview:self.visualEffectView];
|
|
|
|
[self.visualEffectView.contentView addSubview:self.vibrancyView];
|
|
|
|
}
|
|
|
|
|
|
|
|
return self;
|
2015-10-05 20:41:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
-(void)layoutSubviews
|
|
|
|
{
|
2017-04-10 15:24:39 +00:00
|
|
|
[super layoutSubviews];
|
2015-10-05 20:41:32 +00:00
|
|
|
|
2017-04-10 15:24:39 +00:00
|
|
|
self.visualEffectView.frame = self.bounds;
|
|
|
|
self.vibrancyView.frame = self.bounds;
|
2015-10-05 20:41:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setBlurType:(NSString *)blurType {
|
2017-04-10 15:24:39 +00:00
|
|
|
UIBlurEffect *blurEffect;
|
|
|
|
|
|
|
|
self.clipsToBounds = true;
|
|
|
|
if ([blurType isEqual: @"xlight"]) {
|
|
|
|
blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleExtraLight];
|
|
|
|
} else if ([blurType isEqual: @"light"]) {
|
|
|
|
blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
|
|
|
|
} else if ([blurType isEqual: @"dark"]) {
|
|
|
|
blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark];
|
|
|
|
} else {
|
|
|
|
blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark];
|
2015-10-05 20:41:32 +00:00
|
|
|
}
|
2017-04-10 15:24:39 +00:00
|
|
|
self.visualEffectView.effect = blurEffect;
|
2015-10-05 20:41:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)insertReactSubview:(id<RCTComponent>)subview atIndex:(NSInteger)atIndex {
|
2017-04-10 15:24:39 +00:00
|
|
|
[self.vibrancyView.contentView addSubview:(UIView*)subview];
|
2015-10-05 20:41:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@end
|