Skip to content

Commit c99d905

Browse files
feat: extend android properties (#481)
1 parent af4974a commit c99d905

File tree

2 files changed

+30
-10
lines changed

2 files changed

+30
-10
lines changed

android/src/main/java/com/reactnativecommunity/blurview/BlurViewManager.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,15 @@ public void setColor(BlurView view, int color) {
6565

6666
@ReactProp(name = "downsampleFactor", defaultInt = defaultSampling)
6767
public void setDownsampleFactor(BlurView view, int factor) {}
68+
69+
@ReactProp(name = "autoUpdate", defaultBoolean = true)
70+
public void setAutoUpdate(BlurView view, boolean autoUpdate) {
71+
view.setBlurAutoUpdate(autoUpdate);
72+
view.invalidate();
73+
}
74+
75+
@ReactProp(name = "enabled", defaultBoolean = true)
76+
public void setBlurEnabled(BlurView view, boolean enabled) {
77+
view.setBlurEnabled(enabled);
78+
}
6879
}

src/components/BlurView.android.tsx

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,26 @@ export type BlurViewProps = ViewProps & {
2020
blurRadius?: number;
2121
downsampleFactor?: number;
2222
overlayColor?: string;
23+
enabled?: boolean;
24+
autoUpdate?: boolean;
2325
};
2426

2527
const BlurView = forwardRef<View, BlurViewProps>(
26-
({
27-
downsampleFactor,
28-
blurRadius,
29-
blurAmount = 10,
30-
blurType = 'dark',
31-
overlayColor,
32-
children,
33-
style,
34-
...rest
35-
}, ref) => {
28+
(
29+
{
30+
downsampleFactor,
31+
blurRadius,
32+
blurAmount = 10,
33+
blurType = 'dark',
34+
overlayColor,
35+
enabled,
36+
autoUpdate,
37+
children,
38+
style,
39+
...rest
40+
},
41+
ref
42+
) => {
3643
useEffect(() => {
3744
DeviceEventEmitter.addListener('ReactNativeBlurError', (message) => {
3845
throw new Error(`[ReactNativeBlur]: ${message}`);
@@ -88,6 +95,8 @@ const BlurView = forwardRef<View, BlurViewProps>(
8895
overlayColor={getOverlayColor()}
8996
blurAmount={blurAmount}
9097
blurType={blurType}
98+
enabled={enabled}
99+
autoUpdate={autoUpdate}
91100
pointerEvents="none"
92101
style={StyleSheet.compose(styles.transparent, style)}
93102
>

0 commit comments

Comments
 (0)