Blur effect on home screen (iOS 26) (#9935)
This commit is contained in:
+22
-3
@@ -138,7 +138,7 @@ import {
|
|||||||
} from '#/components/dialogs/EmailDialog'
|
} from '#/components/dialogs/EmailDialog'
|
||||||
import {useAnalytics} from '#/analytics'
|
import {useAnalytics} from '#/analytics'
|
||||||
import {setNavigationMetadata} from '#/analytics/metadata'
|
import {setNavigationMetadata} from '#/analytics/metadata'
|
||||||
import {IS_NATIVE, IS_WEB} from '#/env'
|
import {IS_LIQUID_GLASS, IS_NATIVE, IS_WEB} from '#/env'
|
||||||
import {router} from '#/routes'
|
import {router} from '#/routes'
|
||||||
import {Referrer} from '../modules/expo-bluesky-swiss-army'
|
import {Referrer} from '../modules/expo-bluesky-swiss-army'
|
||||||
|
|
||||||
@@ -685,10 +685,29 @@ function screenOptions(t: Theme) {
|
|||||||
function HomeTabNavigator() {
|
function HomeTabNavigator() {
|
||||||
const t = useTheme()
|
const t = useTheme()
|
||||||
|
|
||||||
|
const BLURRED_SCROLL_EDGE_EFFECT = IS_LIQUID_GLASS
|
||||||
|
? ({
|
||||||
|
headerShown: true,
|
||||||
|
headerTransparent: true,
|
||||||
|
headerTitle: '',
|
||||||
|
scrollEdgeEffects: {
|
||||||
|
top: 'soft',
|
||||||
|
},
|
||||||
|
} as const)
|
||||||
|
: {}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<HomeTab.Navigator screenOptions={screenOptions(t)} initialRouteName="Home">
|
<HomeTab.Navigator screenOptions={screenOptions(t)} initialRouteName="Home">
|
||||||
<HomeTab.Screen name="Home" getComponent={() => HomeScreen} />
|
<HomeTab.Screen
|
||||||
<HomeTab.Screen name="Start" getComponent={() => HomeScreen} />
|
name="Home"
|
||||||
|
getComponent={() => HomeScreen}
|
||||||
|
options={BLURRED_SCROLL_EDGE_EFFECT}
|
||||||
|
/>
|
||||||
|
<HomeTab.Screen
|
||||||
|
name="Start"
|
||||||
|
getComponent={() => HomeScreen}
|
||||||
|
options={BLURRED_SCROLL_EDGE_EFFECT}
|
||||||
|
/>
|
||||||
{commonScreens(HomeTab as typeof Flat)}
|
{commonScreens(HomeTab as typeof Flat)}
|
||||||
</HomeTab.Navigator>
|
</HomeTab.Navigator>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,14 +1,17 @@
|
|||||||
import {useWindowDimensions} from 'react-native'
|
import {useWindowDimensions} from 'react-native'
|
||||||
|
import {useSafeAreaInsets} from 'react-native-safe-area-context'
|
||||||
|
|
||||||
import {useWebMediaQueries} from '#/lib/hooks/useWebMediaQueries'
|
import {useBreakpoints} from '#/alf'
|
||||||
|
import {IS_LIQUID_GLASS} from '#/env'
|
||||||
|
|
||||||
export function useHeaderOffset() {
|
export function useHeaderOffset() {
|
||||||
const {isDesktop, isTablet} = useWebMediaQueries()
|
const {gtMobile} = useBreakpoints()
|
||||||
const {fontScale} = useWindowDimensions()
|
const {fontScale} = useWindowDimensions()
|
||||||
if (isDesktop || isTablet) {
|
const insets = useSafeAreaInsets()
|
||||||
|
if (gtMobile) {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
const navBarHeight = 52
|
const navBarHeight = 52 + (IS_LIQUID_GLASS ? insets.top : 0)
|
||||||
const tabBarPad = 10 + 10 + 3 // padding + border
|
const tabBarPad = 10 + 10 + 3 // padding + border
|
||||||
const normalLineHeight = 20 // matches tab bar
|
const normalLineHeight = 20 // matches tab bar
|
||||||
const tabBarText = normalLineHeight * fontScale
|
const tabBarText = normalLineHeight * fontScale
|
||||||
|
|||||||
@@ -1,13 +1,18 @@
|
|||||||
import {interpolate, useAnimatedStyle} from 'react-native-reanimated'
|
import {interpolate, useAnimatedStyle} from 'react-native-reanimated'
|
||||||
|
import {useSafeAreaInsets} from 'react-native-safe-area-context'
|
||||||
|
|
||||||
import {useMinimalShellMode} from '#/state/shell/minimal-mode'
|
import {useMinimalShellMode} from '#/state/shell/minimal-mode'
|
||||||
import {useShellLayout} from '#/state/shell/shell-layout'
|
import {useShellLayout} from '#/state/shell/shell-layout'
|
||||||
|
import {IS_LIQUID_GLASS} from '#/env'
|
||||||
|
|
||||||
// Keep these separated so that we only pay for useAnimatedStyle that gets used.
|
// Keep these separated so that we only pay for useAnimatedStyle that gets used.
|
||||||
|
|
||||||
export function useMinimalShellHeaderTransform() {
|
export function useMinimalShellHeaderTransform() {
|
||||||
const {headerMode} = useMinimalShellMode()
|
const {headerMode} = useMinimalShellMode()
|
||||||
const {headerHeight} = useShellLayout()
|
const {headerHeight} = useShellLayout()
|
||||||
|
const {top: topInset} = useSafeAreaInsets()
|
||||||
|
|
||||||
|
const headerPinnedHeight = IS_LIQUID_GLASS ? topInset : 0
|
||||||
|
|
||||||
const headerTransform = useAnimatedStyle(() => {
|
const headerTransform = useAnimatedStyle(() => {
|
||||||
const headerModeValue = headerMode.get()
|
const headerModeValue = headerMode.get()
|
||||||
@@ -19,7 +24,7 @@ export function useMinimalShellHeaderTransform() {
|
|||||||
translateY: interpolate(
|
translateY: interpolate(
|
||||||
headerModeValue,
|
headerModeValue,
|
||||||
[0, 1],
|
[0, 1],
|
||||||
[0, -headerHeight.get()],
|
[0, headerPinnedHeight - headerHeight.get()],
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import {type JSX} from 'react'
|
|
||||||
import {View} from 'react-native'
|
import {View} from 'react-native'
|
||||||
import Animated from 'react-native-reanimated'
|
import Animated from 'react-native-reanimated'
|
||||||
|
import {useSafeAreaInsets} from 'react-native-safe-area-context'
|
||||||
import {msg} from '@lingui/core/macro'
|
import {msg} from '@lingui/core/macro'
|
||||||
import {useLingui} from '@lingui/react'
|
import {useLingui} from '@lingui/react'
|
||||||
|
|
||||||
@@ -17,16 +17,18 @@ import {ButtonIcon} from '#/components/Button'
|
|||||||
import {Hashtag_Stroke2_Corner0_Rounded as FeedsIcon} from '#/components/icons/Hashtag'
|
import {Hashtag_Stroke2_Corner0_Rounded as FeedsIcon} from '#/components/icons/Hashtag'
|
||||||
import * as Layout from '#/components/Layout'
|
import * as Layout from '#/components/Layout'
|
||||||
import {Link} from '#/components/Link'
|
import {Link} from '#/components/Link'
|
||||||
|
import {IS_LIQUID_GLASS} from '#/env'
|
||||||
|
|
||||||
export function HomeHeaderLayoutMobile({
|
export function HomeHeaderLayoutMobile({
|
||||||
children,
|
children,
|
||||||
}: {
|
}: {
|
||||||
children: React.ReactNode
|
children: React.ReactNode
|
||||||
tabBarAnchor: JSX.Element | null | undefined
|
tabBarAnchor: React.ReactElement | null | undefined
|
||||||
}) {
|
}) {
|
||||||
const t = useTheme()
|
const t = useTheme()
|
||||||
const {_} = useLingui()
|
const {_} = useLingui()
|
||||||
const {headerHeight} = useShellLayout()
|
const {headerHeight} = useShellLayout()
|
||||||
|
const insets = useSafeAreaInsets()
|
||||||
const headerMinimalShellTransform = useMinimalShellHeaderTransform()
|
const headerMinimalShellTransform = useMinimalShellHeaderTransform()
|
||||||
const {hasSession} = useSession()
|
const {hasSession} = useSession()
|
||||||
const playHaptic = useHaptics()
|
const playHaptic = useHaptics()
|
||||||
@@ -42,6 +44,7 @@ export function HomeHeaderLayoutMobile({
|
|||||||
left: 0,
|
left: 0,
|
||||||
right: 0,
|
right: 0,
|
||||||
},
|
},
|
||||||
|
IS_LIQUID_GLASS && {paddingTop: insets.top},
|
||||||
headerMinimalShellTransform,
|
headerMinimalShellTransform,
|
||||||
]}
|
]}
|
||||||
onLayout={e => {
|
onLayout={e => {
|
||||||
|
|||||||
@@ -6,18 +6,21 @@ import {
|
|||||||
useSharedValue,
|
useSharedValue,
|
||||||
withSpring,
|
withSpring,
|
||||||
} from 'react-native-reanimated'
|
} from 'react-native-reanimated'
|
||||||
|
import {useSafeAreaInsets} from 'react-native-safe-area-context'
|
||||||
import EventEmitter from 'eventemitter3'
|
import EventEmitter from 'eventemitter3'
|
||||||
|
|
||||||
import {ScrollProvider} from '#/lib/ScrollContext'
|
import {ScrollProvider} from '#/lib/ScrollContext'
|
||||||
import {useMinimalShellMode} from '#/state/shell'
|
import {useMinimalShellMode} from '#/state/shell'
|
||||||
import {useShellLayout} from '#/state/shell/shell-layout'
|
import {useShellLayout} from '#/state/shell/shell-layout'
|
||||||
import {IS_NATIVE, IS_WEB} from '#/env'
|
import {IS_LIQUID_GLASS, IS_NATIVE, IS_WEB} from '#/env'
|
||||||
|
|
||||||
const WEB_HIDE_SHELL_THRESHOLD = 200
|
const WEB_HIDE_SHELL_THRESHOLD = 200
|
||||||
|
|
||||||
export function MainScrollProvider({children}: {children: React.ReactNode}) {
|
export function MainScrollProvider({children}: {children: React.ReactNode}) {
|
||||||
const {headerHeight} = useShellLayout()
|
const {headerHeight} = useShellLayout()
|
||||||
const {headerMode} = useMinimalShellMode()
|
const {headerMode} = useMinimalShellMode()
|
||||||
|
const {top: topInset} = useSafeAreaInsets()
|
||||||
|
const headerPinnedHeight = IS_LIQUID_GLASS ? topInset : 0
|
||||||
const startDragOffset = useSharedValue<number | null>(null)
|
const startDragOffset = useSharedValue<number | null>(null)
|
||||||
const startMode = useSharedValue<number | null>(null)
|
const startMode = useSharedValue<number | null>(null)
|
||||||
const didJustRestoreScroll = useSharedValue<boolean>(false)
|
const didJustRestoreScroll = useSharedValue<boolean>(false)
|
||||||
@@ -126,9 +129,10 @@ export function MainScrollProvider({children}: {children: React.ReactNode}) {
|
|||||||
// The "mode" value is always between 0 and 1.
|
// The "mode" value is always between 0 and 1.
|
||||||
// Figure out how much to move it based on the current dragged distance.
|
// Figure out how much to move it based on the current dragged distance.
|
||||||
const dy = offsetY - startDragOffsetValue
|
const dy = offsetY - startDragOffsetValue
|
||||||
|
const hideDistance = headerHeight.get() - headerPinnedHeight
|
||||||
const dProgress = interpolate(
|
const dProgress = interpolate(
|
||||||
dy,
|
dy,
|
||||||
[-headerHeight.get(), headerHeight.get()],
|
[-hideDistance, hideDistance],
|
||||||
[-1, 1],
|
[-1, 1],
|
||||||
)
|
)
|
||||||
const newValue = clamp(startModeValue + dProgress, 0, 1)
|
const newValue = clamp(startModeValue + dProgress, 0, 1)
|
||||||
@@ -156,6 +160,7 @@ export function MainScrollProvider({children}: {children: React.ReactNode}) {
|
|||||||
},
|
},
|
||||||
[
|
[
|
||||||
headerHeight,
|
headerHeight,
|
||||||
|
headerPinnedHeight,
|
||||||
headerMode,
|
headerMode,
|
||||||
setMode,
|
setMode,
|
||||||
startDragOffset,
|
startDragOffset,
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ import {FollowingEndOfFeed} from '#/view/com/posts/FollowingEndOfFeed'
|
|||||||
import {NoFeedsPinned} from '#/screens/Home/NoFeedsPinned'
|
import {NoFeedsPinned} from '#/screens/Home/NoFeedsPinned'
|
||||||
import * as Layout from '#/components/Layout'
|
import * as Layout from '#/components/Layout'
|
||||||
import {useAnalytics} from '#/analytics'
|
import {useAnalytics} from '#/analytics'
|
||||||
import {IS_WEB} from '#/env'
|
import {IS_LIQUID_GLASS, IS_WEB} from '#/env'
|
||||||
import {useDemoMode} from '#/storage/hooks/demo-mode'
|
import {useDemoMode} from '#/storage/hooks/demo-mode'
|
||||||
|
|
||||||
type Props = NativeStackScreenProps<HomeTabNavigatorParams, 'Home' | 'Start'>
|
type Props = NativeStackScreenProps<HomeTabNavigatorParams, 'Home' | 'Start'>
|
||||||
@@ -79,7 +79,7 @@ export function HomeScreen(props: Props) {
|
|||||||
|
|
||||||
if (preferences && pinnedFeedInfos && !isPinnedFeedsLoading) {
|
if (preferences && pinnedFeedInfos && !isPinnedFeedsLoading) {
|
||||||
return (
|
return (
|
||||||
<Layout.Screen testID="HomeScreen">
|
<Layout.Screen testID="HomeScreen" noInsetTop={IS_LIQUID_GLASS}>
|
||||||
<HomeScreenReady
|
<HomeScreenReady
|
||||||
{...props}
|
{...props}
|
||||||
preferences={preferences}
|
preferences={preferences}
|
||||||
|
|||||||
Reference in New Issue
Block a user