From 3f762628c533da5492df696370d6d597c852dd00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Both=C3=A9n?= Date: Mon, 25 Jul 2022 11:35:09 +0200 Subject: [PATCH] feat: extend android properties --- .../blurview/BlurViewManager.java | 11 +++++++ src/components/BlurView.android.tsx | 29 ++++++++++++------- 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/android/src/main/java/com/reactnativecommunity/blurview/BlurViewManager.java b/android/src/main/java/com/reactnativecommunity/blurview/BlurViewManager.java index 7c2e1dea..c1f34a39 100644 --- a/android/src/main/java/com/reactnativecommunity/blurview/BlurViewManager.java +++ b/android/src/main/java/com/reactnativecommunity/blurview/BlurViewManager.java @@ -65,4 +65,15 @@ public void setColor(BlurView view, int color) { @ReactProp(name = "downsampleFactor", defaultInt = defaultSampling) public void setDownsampleFactor(BlurView view, int factor) {} + + @ReactProp(name = "autoUpdate", defaultBoolean = true) + public void setAutoUpdate(BlurView view, boolean autoUpdate) { + view.setBlurAutoUpdate(autoUpdate); + view.invalidate(); + } + + @ReactProp(name = "enabled", defaultBoolean = true) + public void setBlurEnabled(BlurView view, boolean enabled) { + view.setBlurEnabled(enabled); + } } diff --git a/src/components/BlurView.android.tsx b/src/components/BlurView.android.tsx index eac819e8..e4ab05fd 100644 --- a/src/components/BlurView.android.tsx +++ b/src/components/BlurView.android.tsx @@ -20,19 +20,26 @@ export type BlurViewProps = ViewProps & { blurRadius?: number; downsampleFactor?: number; overlayColor?: string; + enabled?: boolean; + autoUpdate?: boolean; }; const BlurView = forwardRef( - ({ - downsampleFactor, - blurRadius, - blurAmount = 10, - blurType = 'dark', - overlayColor, - children, - style, - ...rest - }, ref) => { + ( + { + downsampleFactor, + blurRadius, + blurAmount = 10, + blurType = 'dark', + overlayColor, + enabled, + autoUpdate, + children, + style, + ...rest + }, + ref + ) => { useEffect(() => { DeviceEventEmitter.addListener('ReactNativeBlurError', (message) => { throw new Error(`[ReactNativeBlur]: ${message}`); @@ -88,6 +95,8 @@ const BlurView = forwardRef( overlayColor={getOverlayColor()} blurAmount={blurAmount} blurType={blurType} + enabled={enabled} + autoUpdate={autoUpdate} pointerEvents="none" style={StyleSheet.compose(styles.transparent, style)} >