import { useColorScheme } from 'react-native'
import {
  TamaguiProvider,
  type TamaguiProviderProps,
  config,
  isWeb,
  ToastProvider,
} from '@junwon/aesthetics'

export function Provider({ children, ...rest }: Omit<TamaguiProviderProps, 'config'>) {
  const colorScheme = useColorScheme()

  return (
    <TamaguiProvider
      config={config}
      defaultTheme={colorScheme === 'dark' ? 'dark' : 'light'}
      {...rest}
    >
      <ToastProvider
        swipeDirection="horizontal"
        duration={3000}
        native={isWeb ? [] : ['mobile']}
      >
        {children}
      </ToastProvider>
    </TamaguiProvider>
  )
}
