diff options
author | Paul Frazee <pfrazee@gmail.com> | 2023-01-26 18:15:43 -0600 |
---|---|---|
committer | Paul Frazee <pfrazee@gmail.com> | 2023-01-26 18:15:43 -0600 |
commit | 20ccb03427f5be5b640fb72eb0b0e5bdc1f4103e (patch) | |
tree | bdbe51529f3ba2b9f4fd9e595ce15b59374eeccc /src/view/com/util/BlurView.web.tsx | |
parent | d04a6d7539c53ec3510175459c1ca8c8e7e994da (diff) | |
download | voidsky-20ccb03427f5be5b640fb72eb0b0e5bdc1f4103e.tar.zst |
Fix to blurviews
Diffstat (limited to 'src/view/com/util/BlurView.web.tsx')
-rw-r--r-- | src/view/com/util/BlurView.web.tsx | 39 |
1 files changed, 36 insertions, 3 deletions
diff --git a/src/view/com/util/BlurView.web.tsx b/src/view/com/util/BlurView.web.tsx index a6097bf85..5adf0d1c0 100644 --- a/src/view/com/util/BlurView.web.tsx +++ b/src/view/com/util/BlurView.web.tsx @@ -1,4 +1,37 @@ -import {View} from 'react-native' +import React from 'react' +import {StyleSheet, View, ViewProps} from 'react-native' +import {addStyle} from '../../lib/addStyle' -// TODO can actually support this, see https://github.com/Kureev/react-native-blur/issues/417 -export const BlurBiew = View +type BlurViewProps = ViewProps & { + blurType?: 'dark' | 'light' + blurAmount?: number +} + +export const BlurView = ({ + style, + blurType, + blurAmount, + ...props +}: React.PropsWithChildren<BlurViewProps>) => { + // @ts-ignore using an RNW-specific attribute here -prf + style = addStyle(style, {backdropFilter: `blur(${blurAmount || 10}px`}) + if (blurType === 'dark') { + style = addStyle(style, styles.dark) + } else { + style = addStyle(style, styles.light) + } + return <View style={style} {...props} /> +} + +const styles = StyleSheet.create({ + blur: { + // @ts-ignore using an RNW-specific attribute here -prf + backdropFilter: 'blur(5px)', + }, + dark: { + backgroundColor: '#0008', + }, + light: { + backgroundColor: '#fff8', + }, +}) |