diff --git a/package.json b/package.json index db568be14..24ce258e3 100644 --- a/package.json +++ b/package.json @@ -121,7 +121,7 @@ "@atproto/syntax": "0.7.5", "@bitdrift/react-native": "^0.6.8", "@braintree/sanitize-url": "^6.0.2", - "@bsky.app/alf": "^0.1.15", + "@bsky.app/alf": "^0.2.2", "@bsky.app/bottom-sheet": "link:./modules/bottom-sheet", "@bsky.app/expo-background-notification-handler": "link:./modules/expo-background-notification-handler", "@bsky.app/expo-bluesky-gif-view": "link:./modules/expo-bluesky-gif-view", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a95046903..008b349d0 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -252,8 +252,8 @@ importers: specifier: ^6.0.2 version: 6.0.4 '@bsky.app/alf': - specifier: ^0.1.15 - version: 0.1.15(react-native@0.88.1(patch_hash=905e68a17bb8b11f9e555f6c8dea94e2738f48b2c6e5f88e42ed2ef4e4778019)(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.1(@babel/core@7.29.7(supports-color@8.1.1))(supports-color@8.1.1))(@types/react@19.3.0)(react@19.3.0)(supports-color@8.1.1))(react@19.3.0) + specifier: ^0.2.2 + version: 0.2.2(react-native@0.88.1(patch_hash=905e68a17bb8b11f9e555f6c8dea94e2738f48b2c6e5f88e42ed2ef4e4778019)(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.1(@babel/core@7.29.7(supports-color@8.1.1))(supports-color@8.1.1))(@types/react@19.3.0)(react@19.3.0)(supports-color@8.1.1))(react@19.3.0) '@bsky.app/bottom-sheet': specifier: link:./modules/bottom-sheet version: link:modules/bottom-sheet @@ -1789,11 +1789,16 @@ packages: '@braintree/sanitize-url@6.0.4': resolution: {integrity: sha512-s3jaWicZd0pkP0jf5ysyHUI/RE7MHos6qlToFcGWXVp+ykHOy77OUMrfbgJ9it2C5bow7OIQwYYaHjk9XlBQ2A==} - '@bsky.app/alf@0.1.15': - resolution: {integrity: sha512-e6blt+oZ2klv+Cp7u11FeZckoILdXOtUZ11ATERgjZgb4zX3y7rt4e2fI03JkJO31wTvXHG8A1LnM96Az+ndJg==} + '@bsky.app/alf@0.2.2': + resolution: {integrity: sha512-AcPBk8urMKTXrr7lV4bGeyuneeD3Vgk3QIq7bcwiKuk74vxJk31+ARwxCkSlXov1QPLJdo/nTidQFmue4SzJpQ==} peerDependencies: react: '*' react-native: '*' + peerDependenciesMeta: + react: + optional: true + react-native: + optional: true '@bsky.app/expo-dynamic-app-icon@1.8.5': resolution: {integrity: sha512-yLpd7XEEiXWpVrh81mhpZx2WrX2WwrJFEV81lNxnX61Cp6yG+ZKX3Oz1v58vpyL5p0I38njVUJ9s+n5NR4EjNw==} @@ -11086,11 +11091,10 @@ snapshots: '@braintree/sanitize-url@6.0.4': {} - '@bsky.app/alf@0.1.15(react-native@0.88.1(patch_hash=905e68a17bb8b11f9e555f6c8dea94e2738f48b2c6e5f88e42ed2ef4e4778019)(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.1(@babel/core@7.29.7(supports-color@8.1.1))(supports-color@8.1.1))(@types/react@19.3.0)(react@19.3.0)(supports-color@8.1.1))(react@19.3.0)': - dependencies: + '@bsky.app/alf@0.2.2(react-native@0.88.1(patch_hash=905e68a17bb8b11f9e555f6c8dea94e2738f48b2c6e5f88e42ed2ef4e4778019)(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.1(@babel/core@7.29.7(supports-color@8.1.1))(supports-color@8.1.1))(@types/react@19.3.0)(react@19.3.0)(supports-color@8.1.1))(react@19.3.0)': + optionalDependencies: react: 19.3.0 react-native: 0.88.1(patch_hash=905e68a17bb8b11f9e555f6c8dea94e2738f48b2c6e5f88e42ed2ef4e4778019)(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.1(@babel/core@7.29.7(supports-color@8.1.1))(supports-color@8.1.1))(@types/react@19.3.0)(react@19.3.0)(supports-color@8.1.1) - react-responsive: 10.0.1(react@19.3.0) '@bsky.app/expo-dynamic-app-icon@1.8.5(@typescript/typescript6@6.0.2)(expo@58.0.23)(react-native@0.88.1(patch_hash=905e68a17bb8b11f9e555f6c8dea94e2738f48b2c6e5f88e42ed2ef4e4778019)(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.1(@babel/core@7.29.7(supports-color@8.1.1))(supports-color@8.1.1))(@types/react@19.3.0)(react@19.3.0)(supports-color@8.1.1))(react@19.3.0)(supports-color@8.1.1)': dependencies: diff --git a/src/alf/util/__tests__/colors.test.ts b/src/alf/util/__tests__/colors.test.ts deleted file mode 100644 index 1ecb7394b..000000000 --- a/src/alf/util/__tests__/colors.test.ts +++ /dev/null @@ -1,40 +0,0 @@ -import {jest} from '@jest/globals' - -import {transparentifyColor} from '../colorGeneration' - -describe('transparentifyColor', () => { - beforeEach(() => { - jest.clearAllMocks() - }) - - it('converts hsl() to hsla()', () => { - const result = transparentifyColor('hsl(120 100% 50%)', 0.5) - expect(result).toBe('hsla(120 100% 50%, 0.5)') - }) - - it('converts hsl() to hsla() - fully transparent', () => { - const result = transparentifyColor('hsl(120 100% 50%)', 0) - expect(result).toBe('hsla(120 100% 50%, 0)') - }) - - it('converts rgb() to rgba()', () => { - const result = transparentifyColor('rgb(255 0 0)', 0.75) - expect(result).toBe('rgba(255 0 0, 0.75)') - }) - - it('expands 3-digit hex and appends alpha channel', () => { - const result = transparentifyColor('#abc', 0.4) - expect(result).toBe('#aabbcc66') - }) - - it('appends alpha to 6-digit hex', () => { - const result = transparentifyColor('#aabbcc', 0.4) - expect(result).toBe('#aabbcc66') - }) - - it('returns the original string and warns for unsupported formats', () => { - const unsupported = 'blue' - const result = transparentifyColor(unsupported, 0.5) - expect(result).toBe(unsupported) - }) -}) diff --git a/src/components/hooks/useHeaderOffset.ts b/src/components/hooks/useHeaderOffset.ts index 9c8c2a0f7..445e7910b 100644 --- a/src/components/hooks/useHeaderOffset.ts +++ b/src/components/hooks/useHeaderOffset.ts @@ -2,7 +2,7 @@ import {useWindowDimensions} from 'react-native' import {useSafeAreaInsets} from 'react-native-safe-area-context' import {useBreakpoints} from '#/alf' -import {IS_LIQUID_GLASS, IS_WEB} from '#/env' +import {IS_NATIVE, IS_WEB} from '#/env' export function useHeaderOffset() { const {gtMobile} = useBreakpoints() @@ -11,7 +11,7 @@ export function useHeaderOffset() { if (gtMobile && IS_WEB) { return 0 } - const navBarHeight = 52 + (IS_LIQUID_GLASS ? insets.top : 0) + const navBarHeight = 52 + (IS_NATIVE ? insets.top : 0) const tabBarPad = 10 + 10 + 3 // padding + border const normalLineHeight = 20 // matches tab bar const tabBarText = normalLineHeight * fontScale diff --git a/src/features/followingV2/home/Home.tsx b/src/features/followingV2/home/Home.tsx index 210d52dd0..6c6c610d9 100644 --- a/src/features/followingV2/home/Home.tsx +++ b/src/features/followingV2/home/Home.tsx @@ -47,7 +47,7 @@ import { import {NoFeedsPinned} from '#/screens/Home/NoFeedsPinned' import * as Layout from '#/components/Layout' import {useAnalytics} from '#/analytics' -import {IS_LIQUID_GLASS, IS_WEB} from '#/env' +import {IS_NATIVE, IS_WEB} from '#/env' import {useDemoMode} from '#/storage/hooks/demo-mode' import {FeedPage} from './FeedPage' import {type FeedDescriptor} from './queries/postFeed' @@ -92,7 +92,7 @@ export function HomeScreen(props: Props) { if (preferences && pinnedFeedInfos && !isPinnedFeedsLoading) { return ( - + { const height = headerHeight.get() diff --git a/src/screens/Notifications/components/RefreshPill.tsx b/src/screens/Notifications/components/RefreshPill.tsx index 25cb2acfe..4a28ef687 100644 --- a/src/screens/Notifications/components/RefreshPill.tsx +++ b/src/screens/Notifications/components/RefreshPill.tsx @@ -10,7 +10,7 @@ import {useHomeHeaderMode} from '#/view/com/util/MainScrollProvider' import {atoms as a} from '#/alf' import * as Layout from '#/components/Layout' import {NewPostsPill} from '#/components/NewPostsPill' -import {IS_LIQUID_GLASS, IS_WEB} from '#/env' +import {IS_WEB} from '#/env' /** * Space between the bottom edge of the header and the pill. @@ -74,7 +74,7 @@ export function RefreshPill({ const mode = useHomeHeaderMode() const {top: topInset} = useSafeAreaInsets() // As `NotificationsHeader` has it - const pinnedHeight = IS_LIQUID_GLASS ? topInset : 0 + const pinnedHeight = topInset // Translate only: a transform moves it without a layout pass every frame const follow = useAnimatedStyle(() => ({ transform: [ diff --git a/src/screens/Notifications/index.tsx b/src/screens/Notifications/index.tsx index 6d5fd508c..840e5c839 100644 --- a/src/screens/Notifications/index.tsx +++ b/src/screens/Notifications/index.tsx @@ -63,7 +63,7 @@ import {Link} from '#/components/Link' import {Loader} from '#/components/Loader' import {type Metrics, useAnalytics} from '#/analytics' import {Features, isOnForBetaUser} from '#/analytics/features' -import {IS_INTERNAL, IS_LIQUID_GLASS, IS_WEB} from '#/env' +import {IS_INTERNAL, IS_NATIVE, IS_WEB} from '#/env' type Props = NativeStackScreenProps< NotificationsTabNavigatorParams, @@ -89,7 +89,7 @@ export function NewNotificationsScreen({}: Props) { const {openComposer} = useOpenComposer() return ( - + @@ -561,7 +561,7 @@ function NotificationsHeader({ const {selectedPage} = Pager.usePager() const {gtMobile} = useBreakpoints() const insets = useSafeAreaInsets() - const headerPinnedHeight = IS_LIQUID_GLASS ? insets.top : 0 + const headerPinnedHeight = IS_NATIVE ? insets.top : 0 const titleStyle = useAnimatedStyle(() => { if (IS_WEB) return {} @@ -646,7 +646,7 @@ function NotificationsHeader({ )} {IS_WEB && ( () const {gtMobile} = useBreakpoints() - return ( - - - - - + /* + * On tablets, stay inside the center column like `NativeCenterBorders`, so + * the header doesn't cover the column's borders or swallow touches on either + * side of it + */ + const widthStyle = gtMobile + ? [a.w_full, a.self_center, {maxWidth: Layout.CENTER_COLUMN_WIDTH}] + : {left: 0, right: 0} - - { - if (IS_DEV) { - navigate('Debug') - } else { - haptics.tap() - emitSoftReset() - } - }}> - - - + return ( + <> + {/* + * The feed scrolls under the status bar, where liquid glass blurs it with + * a scroll edge effect (see `HomeTabNavigator`). Elsewhere, fade it out + * so the status bar stays legible once the header hides. The header + * covers it while shown + */} + {IS_NATIVE && !IS_LIQUID_GLASS && } + + + + + - - {hasSession && ( - + { - ax.metric('nav:click', {item: 'feeds', surface: 'topBar'}) - }} - style={[ - a.justify_center, - {marginRight: -Layout.BUTTON_VISUAL_ALIGNMENT_OFFSET}, - a.bg_transparent, - ]}> - - - )} - - - {children} - + if (IS_DEV) { + navigate('Debug') + } else { + haptics.tap() + emitSoftReset() + } + }}> + + + + + + {hasSession && ( + { + ax.metric('nav:click', {item: 'feeds', surface: 'topBar'}) + }} + style={[ + a.justify_center, + {marginRight: -Layout.BUTTON_VISUAL_ALIGNMENT_OFFSET}, + a.bg_transparent, + ]}> + + + )} + + + {children} + + + ) +} + +/** + * Opacity of the fade behind the status bar, down its height: e^(-4x^2), + * rescaled to reach 0 at the bottom. It holds up behind the status bar's icons, + * then tails off with no visible edge. Sampled, as a gradient only + * interpolates linearly between its stops + */ +const STATUS_BAR_FADE_STOPS = Array.from({length: 11}, (_, i) => { + const x = i / 10 + const end = Math.exp(-4) + return {location: x, opacity: (Math.exp(-4 * x * x) - end) / (1 - end)} +}) + +/** + * The background fading out from behind the status bar, as far below it as + * it is tall. + */ +function StatusBarFade({style}: ViewStyleProp) { + const t = useTheme() + const {top} = useSafeAreaInsets() + return ( + + utils.alpha(t.atoms.bg.backgroundColor, stop.opacity), + ) as [string, string, ...string[]] + } + locations={ + STATUS_BAR_FADE_STOPS.map(stop => stop.location) as [ + number, + number, + ...number[], + ] + } + /> ) } diff --git a/src/view/com/util/MainScrollProvider.tsx b/src/view/com/util/MainScrollProvider.tsx index c35df1c8c..6656626e5 100644 --- a/src/view/com/util/MainScrollProvider.tsx +++ b/src/view/com/util/MainScrollProvider.tsx @@ -49,7 +49,7 @@ export function useHomeHeaderTransform() { const {headerHeight} = useShellLayout() const {top: topInset} = useSafeAreaInsets() - const headerPinnedHeight = IS_LIQUID_GLASS ? topInset : 0 + const headerPinnedHeight = IS_NATIVE ? topInset : 0 return useAnimatedStyle(() => { const headerModeValue = headerMode.get() @@ -85,7 +85,11 @@ export function useHomeHeaderTransform() { opacity: Math.pow(1 - headerModeValue, 2), transform: [ { - translateY: interpolate(headerModeValue, [0, 1], [0, -hHeight]), + translateY: interpolate( + headerModeValue, + [0, 1], + [0, headerPinnedHeight - hHeight], + ), }, ], } @@ -96,7 +100,7 @@ export function MainScrollProvider({children}: {children: React.ReactNode}) { const {headerHeight} = useShellLayout() const headerMode = useHomeHeaderMode() const {top: topInset} = useSafeAreaInsets() - const headerPinnedHeight = IS_LIQUID_GLASS ? topInset : 0 + const headerPinnedHeight = IS_NATIVE ? topInset : 0 const startDragOffset = useSharedValue(null) const startMode = useSharedValue(null) const didJustRestoreScroll = useSharedValue(false) diff --git a/src/view/screens/Home.tsx b/src/view/screens/Home.tsx index 5111165e6..d01e5df62 100644 --- a/src/view/screens/Home.tsx +++ b/src/view/screens/Home.tsx @@ -49,7 +49,7 @@ import { import {NoFeedsPinned} from '#/screens/Home/NoFeedsPinned' import * as Layout from '#/components/Layout' import {useAnalytics} from '#/analytics' -import {IS_LIQUID_GLASS, IS_WEB} from '#/env' +import {IS_NATIVE, IS_WEB} from '#/env' import {useDemoMode} from '#/storage/hooks/demo-mode' type Props = NativeStackScreenProps @@ -92,7 +92,7 @@ export function HomeScreen(props: Props) { if (preferences && pinnedFeedInfos && !isPinnedFeedsLoading) { return ( - +