-
Notifications
You must be signed in to change notification settings - Fork 258
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make BlurBackground's background tint consistent across platforms
We remove the overlayColor property from BlurBackground which is Android-only. Instead, we add a backgroundColor to the blur view to match the light/dark modes in iOS.
- Loading branch information
Showing
10 changed files
with
136 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,29 @@ | ||
import React from 'react' | ||
import { Platform, StyleSheet } from 'react-native' | ||
import { Platform, StyleSheet, View } from 'react-native' | ||
import { BlurView } from 'rn-id-blurview' | ||
|
||
import { cacheStyles, useTheme } from '../services/ThemeContext' | ||
import { cacheStyles, Theme, useTheme } from '../services/ThemeContext' | ||
|
||
const isAndroid = Platform.OS === 'android' | ||
|
||
export interface BlurBackgroundProps { | ||
overlayColor?: string | ||
} | ||
|
||
export const BlurBackground = (props: BlurBackgroundProps) => { | ||
const { overlayColor = 'rgba(0, 0, 0, 0)' } = props | ||
export const BlurBackground = () => { | ||
const theme = useTheme() | ||
const styles = getStyles(theme) | ||
|
||
return <BlurView blurType={theme.isDark ? 'dark' : 'light'} style={styles.blurView} overlayColor={overlayColor} /> | ||
return ( | ||
<View style={[StyleSheet.absoluteFill, { overflow: 'hidden' }]}> | ||
<BlurView blurType={theme.isDark ? 'dark' : 'light'} style={styles.blurView} overlayColor="rgba(0, 0, 0, 0)" /> | ||
</View> | ||
) | ||
} | ||
|
||
const getStyles = cacheStyles(() => ({ | ||
const getStyles = cacheStyles((theme: Theme) => ({ | ||
blurView: { | ||
...StyleSheet.absoluteFillObject, | ||
backgroundColor: isAndroid ? '#00000055' : undefined | ||
// We need this backgroundColor because Android applies an overlay to the | ||
// entire screen for the BlurView by default. We change this default | ||
// behavior with the transparent overlayColor, so we add this background | ||
// color to compensate. | ||
backgroundColor: isAndroid ? (theme.isDark ? '#161616aa' : '#ffffff55') : undefined | ||
} | ||
})) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters