2017-01-05 17:12:00 +00:00
|
|
|
#import <React/RCTComponent.h>
|
2017-04-15 09:55:46 +00:00
|
|
|
#import "BlurView.h"
|
|
|
|
#import "VibrancyView.h"
|
2015-10-05 20:41:32 +00:00
|
|
|
|
2017-04-10 15:24:39 +00:00
|
|
|
@interface VibrancyView ()
|
|
|
|
|
2017-04-15 09:55:46 +00:00
|
|
|
@property (nonatomic, strong) UIVibrancyEffect *vibrancyEffect;
|
|
|
|
@property (nonatomic, strong) UIVisualEffectView *vibrancyEffectView;
|
2017-04-10 15:24:39 +00:00
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation VibrancyView
|
|
|
|
|
|
|
|
- (instancetype)initWithFrame:(CGRect)frame {
|
|
|
|
if (self = [super initWithFrame:frame]) {
|
2017-04-15 09:55:46 +00:00
|
|
|
self.vibrancyEffectView = [[UIVisualEffectView alloc] init];
|
|
|
|
self.vibrancyEffectView.frame = frame;
|
|
|
|
[self updateVibrancyEffect];
|
2017-04-10 15:24:39 +00:00
|
|
|
|
2017-04-15 09:55:46 +00:00
|
|
|
[self.blurEffectView.contentView addSubview:self.vibrancyEffectView];
|
2017-04-10 15:24:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return self;
|
2015-10-05 20:41:32 +00:00
|
|
|
}
|
|
|
|
|
2017-04-15 09:55:46 +00:00
|
|
|
- (void)layoutSubviews
|
2015-10-05 20:41:32 +00:00
|
|
|
{
|
2017-04-10 15:24:39 +00:00
|
|
|
[super layoutSubviews];
|
2017-04-15 09:55:46 +00:00
|
|
|
self.vibrancyEffectView.frame = self.bounds;
|
|
|
|
}
|
2015-10-05 20:41:32 +00:00
|
|
|
|
2017-04-15 09:55:46 +00:00
|
|
|
- (void)insertReactSubview:(id<RCTComponent>)subview atIndex:(NSInteger)atIndex {
|
2019-08-21 06:19:31 +00:00
|
|
|
if ([self useReduceTransparencyFallback]) {
|
|
|
|
[self addSubview:(UIView*)subview];
|
|
|
|
} else {
|
2017-04-15 09:55:46 +00:00
|
|
|
[self.vibrancyEffectView.contentView addSubview:(UIView*)subview];
|
2019-08-21 06:19:31 +00:00
|
|
|
}
|
2015-10-05 20:41:32 +00:00
|
|
|
}
|
|
|
|
|
2017-04-15 09:55:46 +00:00
|
|
|
- (void)updateBlurEffect
|
|
|
|
{
|
|
|
|
[super updateBlurEffect];
|
|
|
|
[self updateVibrancyEffect];
|
2015-10-05 20:41:32 +00:00
|
|
|
}
|
|
|
|
|
2017-04-15 09:55:46 +00:00
|
|
|
- (void)updateVibrancyEffect
|
|
|
|
{
|
|
|
|
self.vibrancyEffect = [UIVibrancyEffect effectForBlurEffect:self.blurEffect];
|
|
|
|
self.vibrancyEffectView.effect = self.vibrancyEffect;
|
2015-10-05 20:41:32 +00:00
|
|
|
}
|
|
|
|
|
2019-08-21 06:19:31 +00:00
|
|
|
- (void)updateFallbackView
|
|
|
|
{
|
|
|
|
[super updateFallbackView];
|
|
|
|
|
|
|
|
if ([self useReduceTransparencyFallback]) {
|
|
|
|
for (UIView *subview in self.blurEffectView.contentView.subviews) {
|
|
|
|
[subview removeFromSuperview];
|
|
|
|
[self addSubview:subview];
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for (UIView *subview in self.subviews) {
|
|
|
|
if (subview == self.blurEffectView) continue;
|
|
|
|
if (subview == self.reducedTransparencyFallbackView) continue;
|
|
|
|
|
|
|
|
[subview removeFromSuperview];
|
|
|
|
[self.blurEffectView.contentView addSubview:subview];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-05 20:41:32 +00:00
|
|
|
@end
|