Pixiview/Pixiview.iOS/Services/EnvironmentService.cs
2020-05-05 12:13:50 +08:00

57 lines
1.7 KiB
C#

using System.Diagnostics.CodeAnalysis;
using Pixiview.iOS.Services;
using Pixiview.Utils;
using UIKit;
using Xamarin.Essentials;
using Xamarin.Forms;
[assembly: Dependency(typeof(EnvironmentService))]
namespace Pixiview.iOS.Services
{
public class EnvironmentService : IEnvironmentService
{
[SuppressMessage("Code Notifications", "XI0002:Notifies you from using newer Apple APIs when targeting an older OS version", Justification = "<Pending>")]
public Theme GetApplicationTheme()
{
if (UIDevice.CurrentDevice.CheckSystemVersion(12, 0))
{
var currentController = Platform.GetCurrentUIViewController();
if (currentController == null)
{
return Theme.Light;
}
var style = currentController.TraitCollection.UserInterfaceStyle;
if (style == UIUserInterfaceStyle.Dark)
{
return Theme.Dark;
}
else
{
return Theme.Light;
}
}
else
{
return Theme.Light;
}
}
public EnvironmentParameter GetEnvironment()
{
return new EnvironmentParameter
{
IconLightFontFamily = "FontAwesome5Pro-Light",
IconRegularFontFamily = "FontAwesome5Pro-Regular",
IconSolidFontFamily = "FontAwesome5Pro-Solid",
IconLeft = "\uf104" // for android, it's "\uf060"
};
}
public void SetStatusBarColor(Color color)
{
// nothing need to do
}
}
}