61 lines
1.2 KiB
C#
61 lines
1.2 KiB
C#
using Billing.Languages;
|
|
using Billing.Themes;
|
|
using Xamarin.Essentials;
|
|
using Xamarin.Forms;
|
|
|
|
namespace Billing;
|
|
|
|
public class App : Application
|
|
{
|
|
public static AppTheme CurrentTheme { get; private set; }
|
|
public static PlatformCulture CurrentCulture { get; private set; }
|
|
|
|
public App()
|
|
{
|
|
CurrentCulture = new PlatformCulture();
|
|
InitResources();
|
|
|
|
MainPage = new MainShell();
|
|
Shell.Current.GoToAsync("//Bills");
|
|
}
|
|
|
|
protected override void OnStart()
|
|
{
|
|
}
|
|
|
|
protected override void OnResume()
|
|
{
|
|
SetTheme(AppInfo.RequestedTheme);
|
|
}
|
|
|
|
private void InitResources()
|
|
{
|
|
var theme = AppInfo.RequestedTheme;
|
|
SetTheme(theme, true);
|
|
}
|
|
|
|
private void SetTheme(AppTheme theme, bool force = false)
|
|
{
|
|
if (force || theme != CurrentTheme)
|
|
{
|
|
CurrentTheme = theme;
|
|
}
|
|
else
|
|
{
|
|
return;
|
|
}
|
|
Helper.Debug($"application theme: {theme}");
|
|
|
|
BaseTheme instance;
|
|
if (theme == AppTheme.Dark)
|
|
{
|
|
instance = Dark.Instance;
|
|
}
|
|
else
|
|
{
|
|
instance = Light.Instance;
|
|
}
|
|
// TODO: status bar
|
|
Resources = instance;
|
|
}
|
|
} |