/**
 * 平台检测 Hook
 */

import { useMemo } from 'react';
import { Platform } from 'react-native';

export interface PlatformInfo {
  OS: 'ios' | 'android' | 'windows' | 'macos' | 'web';
  isWeb: boolean;
  isIOS: boolean;
  isAndroid: boolean;
  isNative: boolean;
}

/**
 * 平台检测 Hook
 * 提供便捷的平台检测方法
 * 
 * @example
 * const { isWeb, isIOS, isAndroid, isNative } = usePlatform();
 */
export function usePlatform(): PlatformInfo {
  return useMemo(() => ({
    OS: Platform.OS,
    isWeb: Platform.OS === 'web',
    isIOS: Platform.OS === 'ios',
    isAndroid: Platform.OS === 'android',
    isNative: Platform.OS !== 'web',
  }), []);
}
