import { useTheme } from 'tamagui'

// Returns the platform-correct tint props for a neutral-grey pull-to-
// refresh spinner. Spread onto a `<RefreshControl>`:
//
//   const refreshProps = useAccentRefreshControlProps()
//   <RefreshControl refreshing={…} onRefresh={…} {...refreshProps} />
//
// iOS reads `tintColor`; Android reads `colors`. The shorthand
// `<FlashList refreshing onRefresh />` form picks up neither — switch to the
// explicit `refreshControl={<RefreshControl … />}` shape so the tint applies.
//
// Where the screen renders inside ScreenScrollContainer, also pass
// `progressViewOffset={scrollProps.topInset}` so the spinner doesn't
// appear under the sticky header / status bar.
export function useAccentRefreshControlProps(): {
  tintColor: string
  colors: [string]
} {
  const theme = useTheme()
  const color = theme.colorTertiary.val as string
  return { tintColor: color, colors: [color] }
}
