/**
 * usePlatform Hook
 * 平台检测 - 检测当前运行平台
 */

import { useMemo } from 'react';
import { Platform } from 'react-native';
import type { PlatformInfo } from './types';

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

export default usePlatform;
