forked from
jollywhoppers.com/witchsky.app
Bluesky app fork with some witchin' additions 馃挮
1import {type StyleProp, View, type ViewStyle} from 'react-native'
2import {
3 GlassView as ExpoGlassView,
4 type GlassViewProps as ExpoGlassViewProps,
5 isGlassEffectAPIAvailable,
6 isLiquidGlassAvailable,
7} from 'expo-glass-effect'
8
9import {useTheme} from '#/alf'
10
11export const IS_GLASS_AVAILABLE =
12 isLiquidGlassAvailable() && isGlassEffectAPIAvailable()
13
14/**
15 * Liquid Glass View that uses `expo-glass-effect`
16 *
17 * If unavailable, falls back to a regular `View`. Use `fallbackStyle` to customize the fallback appearance.
18 */
19export const GlassView = IS_GLASS_AVAILABLE ? InnerGlassView : FallbackView
20
21export type GlassViewProps = ExpoGlassViewProps & {
22 fallbackStyle?: StyleProp<ViewStyle>
23}
24
25function InnerGlassView({
26 fallbackStyle: _fallbackStyle,
27 ...props
28}: GlassViewProps) {
29 const t = useTheme()
30 return <ExpoGlassView colorScheme={t.scheme} {...props} />
31}
32
33function FallbackView({fallbackStyle, style, ...props}: GlassViewProps) {
34 return <View style={[fallbackStyle, style]} {...props} />
35}