import { ref, onMounted } from 'vue'

export function useSystemInfo() {
  const statusBarHeight = ref(0)
  const safeAreaBottom = ref(0)
  const screenWidth = ref(375)

  onMounted(() => {
    try {
      const info = uni.getSystemInfoSync()
      statusBarHeight.value = info.statusBarHeight || 0
      safeAreaBottom.value = info.safeAreaInsets?.bottom || 0
      screenWidth.value = info.screenWidth || 375
    } catch (e) {
      statusBarHeight.value = 0
      safeAreaBottom.value = 0
    }
  })

  return {
    statusBarHeight,
    safeAreaBottom,
    screenWidth,
  }
}
