add glassy effect to headers

This commit is contained in:
Samuel Newman
2025-03-04 00:02:44 +00:00
parent 95ab4fa0a1
commit a94a99bb40
9 changed files with 62 additions and 16 deletions
@@ -0,0 +1,13 @@
import {View} from 'react-native'
import {atoms as a, useTheme} from '#/alf'
/**
* GlassyBackdrop component
* On web, it applies a backdrop filter to create a glassy effect.
* On native and non-safari mobile web, it's just a solid color.
*/
export function GlassyBackdrop() {
const t = useTheme()
return <View style={[a.absolute, a.inset_0, t.atoms.bg]} />
}
@@ -0,0 +1,31 @@
import {View} from 'react-native'
import {isAndroidWeb} from '#/lib/browser'
import {atoms as a, useTheme} from '#/alf'
/**
* GlassyBackdrop component
* On web, it applies a backdrop filter to create a glassy effect.
* On native and non-safari mobile web, it's just a solid color.
*/
export function GlassyBackdrop() {
const t = useTheme()
if (isAndroidWeb) {
return <View style={[a.absolute, a.inset_0, t.atoms.bg]} />
}
return (
<>
<View style={[a.absolute, a.inset_0, t.atoms.bg, {opacity: 0.9}]} />
<View
style={[
a.absolute,
a.inset_0,
a.pointer_events_none,
{backdropFilter: 'blur(16px)'},
]}
/>
</>
)
}
+4 -6
View File
@@ -29,6 +29,7 @@ import {
} from '#/components/Layout/const'
import {ScrollbarOffsetContext} from '#/components/Layout/context'
import {Text} from '#/components/Typography'
import {GlassyBackdrop} from './GlassyBackdrop'
export function Outer({
children,
@@ -56,7 +57,7 @@ export function Outer({
a.flex_row,
a.align_center,
a.gap_sm,
sticky && web([a.sticky, {top: 0}, a.z_10, t.atoms.bg]),
sticky && web([a.sticky, {top: 0}, a.z_10]),
gutters,
platform({
native: [a.pb_xs, {minHeight: 48}],
@@ -71,6 +72,7 @@ export function Outer({
],
},
]}>
{sticky && <GlassyBackdrop />}
{children}
</View>
)
@@ -131,11 +133,7 @@ export function BackButton({onPress, style, ...props}: Partial<ButtonProps>) {
shape="square"
onPress={onPressBack}
hitSlop={HITSLOP_30}
style={[
{marginLeft: -BUTTON_VISUAL_ALIGNMENT_OFFSET},
a.bg_transparent,
style,
]}
style={[{marginLeft: -BUTTON_VISUAL_ALIGNMENT_OFFSET}, style]}
{...props}>
<ButtonIcon icon={ArrowLeft} size="lg" />
</Button>