/**
 * 响应式设计 Hook（重构版）
 * 提供屏幕尺寸、断点、方向、平台检测等响应式信息
 * 
 * 注意：此 Hook 现在作为各个专注 Hook 的组合，保持向后兼容
 * 新项目建议直接使用专注的 Hooks
 */

import { useMemo } from 'react';
import { useWindowDimensions } from './useWindowDimensions';
import { useBreakpoint } from './useBreakpoint';
import { useOrientation } from './useOrientation';
import { usePlatform } from './usePlatform';

// ==================== 返回值类型 ====================
export interface ResponsiveInfo {
  // 基础尺寸
  width: number;
  height: number;
  
  // 基础断点
  breakpoint: import('./constants').BreakpointKey;
  isMobile: boolean;
  isTablet: boolean;
  isDesktop: boolean;
  isWide: boolean;
  isWideScreen: boolean;
  
  // 细粒度断点
  fineBreakpoint: import('./constants').FineBreakpointKey;
  isXS: boolean;
  isSM: boolean;
  isMD: boolean;
  isLG: boolean;
  isXL: boolean;
  is2XL: boolean;
  is3XL: boolean;
  is4XL: boolean;
  
  // 方向
  orientation: 'portrait' | 'landscape';
  isPortrait: boolean;
  isLandscape: boolean;
  
  // 平台检测
  platform: {
    OS: 'ios' | 'android' | 'windows' | 'macos' | 'web';
    isWeb: boolean;
    isIOS: boolean;
    isAndroid: boolean;
    isNative: boolean;
  };
}

/**
 * 响应式设计 Hook
 * 提供屏幕尺寸、断点、方向、平台检测等响应式信息
 * 
 * @returns ResponsiveInfo 响应式信息对象
 * 
 * @example
 * const { 
 *   width, height, 
 *   breakpoint, isMobile, isTablet, isDesktop, isWide,
 *   fineBreakpoint, isXS, isSM, isMD, isLG, isXL,
 *   orientation, isPortrait, isLandscape,
 *   platform: { isWeb, isIOS, isAndroid }
 * } = useResponsive();
 * 
 * @deprecated 建议使用专注的 Hooks：useBreakpoint, useOrientation, usePlatform, useScreenSize
 */
export function useResponsive(): ResponsiveInfo {
  const { width, height } = useWindowDimensions();
  const breakpointInfo = useBreakpoint();
  const orientationInfo = useOrientation();
  const platformInfo = usePlatform();

  return useMemo(() => ({
    width,
    height,
    breakpoint: breakpointInfo.breakpoint,
    isMobile: breakpointInfo.isMobile,
    isTablet: breakpointInfo.isTablet,
    isDesktop: breakpointInfo.isDesktop,
    isWide: breakpointInfo.isWide,
    isWideScreen: breakpointInfo.isWideScreen,
    fineBreakpoint: breakpointInfo.fineBreakpoint,
    isXS: breakpointInfo.isXS,
    isSM: breakpointInfo.isSM,
    isMD: breakpointInfo.isMD,
    isLG: breakpointInfo.isLG,
    isXL: breakpointInfo.isXL,
    is2XL: breakpointInfo.is2XL,
    is3XL: breakpointInfo.is3XL,
    is4XL: breakpointInfo.is4XL,
    orientation: orientationInfo.orientation,
    isPortrait: orientationInfo.isPortrait,
    isLandscape: orientationInfo.isLandscape,
    platform: platformInfo,
  }), [width, height, breakpointInfo, orientationInfo, platformInfo]);
}

export default useResponsive;
