Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: extend android properties #481

Merged
merged 1 commit into from
Jul 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
29 changes: 19 additions & 10 deletions src/components/BlurView.android.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,26 @@ export type BlurViewProps = ViewProps & {
blurRadius?: number;
downsampleFactor?: number;
overlayColor?: string;
enabled?: boolean;
autoUpdate?: boolean;
};

const BlurView = forwardRef<View, BlurViewProps>(
({
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}`);
Expand Down Expand Up @@ -88,6 +95,8 @@ const BlurView = forwardRef<View, BlurViewProps>(
overlayColor={getOverlayColor()}
blurAmount={blurAmount}
blurType={blurType}
enabled={enabled}
autoUpdate={autoUpdate}
pointerEvents="none"
style={StyleSheet.compose(styles.transparent, style)}
>
Expand Down