// components/social/SocialOfflineState.tsx import React from 'react'; import { View, TouchableOpacity } from 'react-native'; import { Text } from '@/components/ui/text'; import { WifiOffIcon, RefreshCwIcon } from 'lucide-react-native'; import { useConnectivity } from '@/lib/db/services/ConnectivityService'; /** * A component to display when social features are unavailable due to offline status */ export default function SocialOfflineState() { const { isOnline, lastOnlineTime, checkConnection } = useConnectivity(); // Format last online time const lastOnlineText = lastOnlineTime ? `Last online: ${new Date(lastOnlineTime).toLocaleDateString()} at ${new Date(lastOnlineTime).toLocaleTimeString([], {hour: '2-digit', minute:'2-digit'})}` : 'Not connected recently'; // Handle manual refresh attempt const handleRefresh = () => { checkConnection(); }; return ( You're offline Social features require an internet connection. Your workouts are still being saved locally and will sync when you're back online. {lastOnlineText} Check Connection ); } /** * A component to display an offline banner at the top of social screens */ export function OfflineBanner() { const { isOnline, checkConnection } = useConnectivity(); if (isOnline) return null; return ( You're offline. Viewing cached content. Check ); } /** * A higher-order component that wraps social screens to handle offline state * Now shows an offline banner instead of replacing the entire component */ export function withOfflineState

( Component: React.ComponentType

): React.FC

{ return (props: P) => { return ( ); }; }