using System;
using Xamarin.Essentials;

namespace Navigator.Services
{
  public class DeviceScreenInfo : IDeviceScreenInfo
  {
    public (double Width, double Height, double Density) GetScreenDimensions()
    {
      return (DeviceDisplay.MainDisplayInfo.Width, DeviceDisplay.MainDisplayInfo.Height, DeviceDisplay.MainDisplayInfo.Density);
    }

    public bool IsDeviceTablet()
    {
//      return DeviceInfo.Idiom.Equals(DeviceIdiom.Tablet);  // Idiom not working
//      return GetDiagonalScreenSize()<=8.0?true:false;      // Diagonal not working
      return DeviceDisplay.MainDisplayInfo.Density<=2.00?true:false;
    }

    /// <summary>
    /// Get android device default orientation diagonal screen size 
    /// </summary>
    /// <returns>Return diagonal screen size in inches</returns>
    //private double GetDiagonalScreenSize()
    //{         
    //   double width = DeviceDisplay.MainDisplayInfo.Width;
    //   double height = DeviceDisplay.MainDisplayInfo.Height;
    //   double density = DeviceDisplay.MainDisplayInfo.Density*100.00;
    //   double sizeDiagonal=0.00;

    //   height/=density;
    //   height=Math.Pow(height, 2.00);

    //   width/=density;
    //   width=Math.Pow(width, 2.00);

    //   sizeDiagonal = Math.Sqrt(width + height);
    //   return sizeDiagonal;
    //}
  }
}
