2019-05-29 22:50:20 +03:00
|
|
|
|
using Bit.App.Services;
|
|
|
|
|
using Bit.App.Styles;
|
|
|
|
|
using Bit.Core;
|
2019-03-30 04:23:34 +03:00
|
|
|
|
using Xamarin.Forms;
|
|
|
|
|
|
|
|
|
|
namespace Bit.App.Utilities
|
|
|
|
|
{
|
|
|
|
|
public static class ThemeManager
|
|
|
|
|
{
|
2019-04-22 18:32:17 +03:00
|
|
|
|
public static void SetThemeStyle(string name)
|
|
|
|
|
{
|
|
|
|
|
// Reset styles
|
|
|
|
|
Application.Current.Resources.Clear();
|
|
|
|
|
Application.Current.Resources.MergedDictionaries.Clear();
|
|
|
|
|
|
2019-04-22 21:17:33 +03:00
|
|
|
|
// Variables
|
|
|
|
|
Application.Current.Resources.MergedDictionaries.Add(new Variables());
|
|
|
|
|
|
|
|
|
|
// Themed variables
|
|
|
|
|
if(name == "dark")
|
|
|
|
|
{
|
|
|
|
|
Application.Current.Resources.MergedDictionaries.Add(new Dark());
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Application.Current.Resources.MergedDictionaries.Add(new Light());
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-22 18:32:17 +03:00
|
|
|
|
// Base styles
|
|
|
|
|
Application.Current.Resources.MergedDictionaries.Add(new Base());
|
|
|
|
|
|
|
|
|
|
// Platform styles
|
|
|
|
|
if(Device.RuntimePlatform == Device.Android)
|
|
|
|
|
{
|
|
|
|
|
Application.Current.Resources.MergedDictionaries.Add(new Android());
|
|
|
|
|
}
|
|
|
|
|
else if(Device.RuntimePlatform == Device.iOS)
|
|
|
|
|
{
|
|
|
|
|
Application.Current.Resources.MergedDictionaries.Add(new iOS());
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-05-29 22:50:20 +03:00
|
|
|
|
|
|
|
|
|
public static void SetTheme()
|
|
|
|
|
{
|
|
|
|
|
SetThemeStyle(GetTheme());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static string GetTheme()
|
|
|
|
|
{
|
|
|
|
|
return Xamarin.Essentials.Preferences.Get(
|
|
|
|
|
string.Format(PreferencesStorageService.KeyFormat, Constants.ThemeKey), default(string));
|
|
|
|
|
}
|
2019-03-30 04:23:34 +03:00
|
|
|
|
}
|
|
|
|
|
}
|