diff --git a/mobile/src/components/nav-bar/NavBar.tsx b/mobile/src/components/nav-bar/NavBar.tsx index 0c019786570..0424350ba42 100644 --- a/mobile/src/components/nav-bar/NavBar.tsx +++ b/mobile/src/components/nav-bar/NavBar.tsx @@ -9,9 +9,11 @@ import { type ViewStyle } from 'react-native' import { ChevronDown } from 'lucide-react-native' +import { useReducedMotionEnabled } from '../../platform/use-reduced-motion' import { colors, pressedStyle, spacing } from '../../theme/mobile-theme' import { themedStyleSheet } from '../../theme/themed-styles' import { useMobileColorScheme } from '../../theme/use-mobile-color-scheme' +import { useWorkingSweep } from '../use-working-motion' export const NAV_BAR_HEIGHT = 52 @@ -31,6 +33,8 @@ type NavBarProps = { /** From useCollapsingTitle: the title waits until the list's PageTitle has scrolled under the bar. */ titleOpacity?: Animated.AnimatedInterpolation dividerOpacity?: Animated.AnimatedInterpolation + /** From useRefreshHint: shown data is refreshing in the background. */ + refreshing?: boolean } // The one top bar: leading button, a centred compact title, and up to two trailing buttons. @@ -43,7 +47,8 @@ export function NavBar({ accessory, style, titleOpacity, - dividerOpacity + dividerOpacity, + refreshing = false }: NavBarProps) { useMobileColorScheme() return ( @@ -78,6 +83,31 @@ export function NavBar({ {dividerOpacity ? ( ) : null} + {refreshing ? : null} + + ) +} + +// Sits on the bar's bottom edge so the title, subtitle and accessory never move. +function NavBarRefreshLine() { + const reducedMotion = useReducedMotionEnabled() + const sweep = useWorkingSweep(reducedMotion === false) + // Draw nothing until the preference is known, so a reveal never swaps shapes. + if (reducedMotion === null) { + return null + } + return ( + + ) } @@ -154,6 +184,24 @@ const styles = themedStyleSheet(() => ({ height: StyleSheet.hairlineWidth, backgroundColor: colors.borderSubtle }, + refreshTrack: { + position: 'absolute', + left: 0, + right: 0, + bottom: -StyleSheet.hairlineWidth, + height: 2, + overflow: 'hidden' + }, + refreshSegment: { + width: '28%', + height: '100%', + borderRadius: 1, + backgroundColor: colors.textSecondary + }, + refreshSegmentStill: { + width: '100%', + opacity: 0.45 + }, // Equal sides keep the title centred whatever the buttons on either side. side: { flex: 1, diff --git a/mobile/src/components/use-working-motion.ts b/mobile/src/components/use-working-motion.ts index ab80cbf9f8f..faeb4bf08ac 100644 --- a/mobile/src/components/use-working-motion.ts +++ b/mobile/src/components/use-working-motion.ts @@ -1,5 +1,5 @@ -import { useEffect, useRef } from 'react' -import { Animated, Easing } from 'react-native' +import { useEffect, useMemo, useRef, useState } from 'react' +import { Animated, Easing, type LayoutChangeEvent } from 'react-native' // The page runs these as compositor animations instead (use-working-motion.web.ts). export type WorkingMotion