-
-
Notifications
You must be signed in to change notification settings - Fork 733
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
980 additions
and
413 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
45 changes: 45 additions & 0 deletions
45
example/src/components/appearanceProvider/AppearanceProvider.tsx
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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import React, { | ||
ReactNode, | ||
useCallback, | ||
useEffect, | ||
useMemo, | ||
useState, | ||
} from 'react'; | ||
// @ts-ignore | ||
import { Appearance } from 'react-native'; | ||
import { AppearanceContext } from '../../contexts'; | ||
|
||
interface AppearanceProviderProps { | ||
children?: ReactNode; | ||
} | ||
|
||
const _colorScheme = Appearance.getColorScheme(); | ||
|
||
const AppearanceProvider = ({ children }: AppearanceProviderProps) => { | ||
// state | ||
const [appearance, setAppearance] = useState(_colorScheme); | ||
|
||
// variables | ||
const contextValue = useMemo(() => ({ appearance }), [appearance]); | ||
|
||
// callback | ||
const handleAppearanceChange = useCallback(({ colorScheme }) => { | ||
setAppearance(colorScheme); | ||
}, []); | ||
|
||
// effects | ||
useEffect(() => { | ||
Appearance.addChangeListener(handleAppearanceChange); | ||
|
||
return () => { | ||
Appearance.removeChangeListener(handleAppearanceChange); | ||
}; | ||
}, [handleAppearanceChange]); | ||
return ( | ||
<AppearanceContext.Provider value={contextValue}> | ||
{children} | ||
</AppearanceContext.Provider> | ||
); | ||
}; | ||
|
||
export default AppearanceProvider; |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from './AppearanceProvider'; |
29 changes: 29 additions & 0 deletions
29
example/src/components/blurredBackground/BlurredBackground.tsx
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import React from 'react'; | ||
import { Platform, StyleSheet, View } from 'react-native'; | ||
import { BlurView } from '@react-native-community/blur'; | ||
|
||
const BlurredBackground = () => | ||
Platform.OS === 'ios' ? ( | ||
<View style={styles.container}> | ||
<BlurView blurType="chromeMaterial" style={styles.blurView} /> | ||
</View> | ||
) : ( | ||
<View style={[styles.container, styles.androidContainer]} /> | ||
); | ||
|
||
const styles = StyleSheet.create({ | ||
blurView: { | ||
...StyleSheet.absoluteFillObject, | ||
}, | ||
container: { | ||
...StyleSheet.absoluteFillObject, | ||
borderTopLeftRadius: 10, | ||
borderTopRightRadius: 10, | ||
overflow: 'hidden', | ||
}, | ||
androidContainer: { | ||
backgroundColor: 'rgba(255,255,255, 0.95)', | ||
}, | ||
}); | ||
|
||
export default BlurredBackground; |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from './BlurredBackground'; |
Oops, something went wrong.