Skip to content

Commit

Permalink
Merge branch 'ONE-2810_fix_dark_mode' into 'main'
Browse files Browse the repository at this point in the history
ONE-2810: fixed blur dark mode

Closes ONE-2810

See merge request procivis/one/one-react-native-components!130
  • Loading branch information
procivisAG committed Aug 19, 2024
2 parents ba5dfed + c13c757 commit 9c3b7e5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@procivis/one-react-native-components",
"version": "0.1.28",
"version": "0.1.29",
"description": "Common Procivis ONE UI components for react-native",
"main": "lib/commonjs/index",
"module": "lib/module/index",
Expand Down
21 changes: 11 additions & 10 deletions src/blur/blur-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ export interface BlurViewProps extends ViewProps {
blurStyle: 'soft' | 'strong' | 'header';
}

const BACKGROUND_COLOR = {
light: 'rgba(255, 255, 255, 0.8)',
dark: 'rgba(16, 12, 12, 0.8)',
thickMaterialLight: 'rgba(255, 255, 255, 0.95)',
thickMaterialDark: 'rgba(16, 12, 12, 0.95)',
thinMaterialLight: 'rgba(255, 255, 255, 0.8)',
thinMaterialDark: 'rgba(16, 12, 12, 0.8)',
};

const BlurView: FC<PropsWithChildren<BlurViewProps>> = ({
blurAmount = 50,
blurStyle,
Expand All @@ -27,7 +36,7 @@ const BlurView: FC<PropsWithChildren<BlurViewProps>> = ({

const blurType: RNBlurViewProps['blurType'] = useMemo(() => {
if (blurStyle === 'header') {
return 'regular';
return dark ? 'dark' : 'light';
} else if (blurStyle === 'soft') {
return dark ? 'thinMaterialDark' : 'thinMaterialLight';
} else {
Expand Down Expand Up @@ -55,15 +64,7 @@ const BlurView: FC<PropsWithChildren<BlurViewProps>> = ({
);
}

const backgroundColors = {
regular: 'rgba(255, 255, 255, 0.8)',
thickMaterialLight: 'rgba(255, 255, 255, 0.95)',
thickMaterialDark: 'rgba(16, 12, 12, 0.95)',
thinMaterialLight: 'rgba(255, 255, 255, 0.8)',
thinMaterialDark: 'rgba(16, 12, 12, 0.8)',
};

const backgroundColor = color ? colorWithAlphaComponent(color, 0.9) : backgroundColors[blurType];
const backgroundColor = color ? colorWithAlphaComponent(color, 0.9) : BACKGROUND_COLOR[blurType];

return (
<View style={[{ backgroundColor }, style]} {...props}>
Expand Down

0 comments on commit 9c3b7e5

Please sign in to comment.