1
0
mirror of https://github.com/bitwarden/mobile synced 2025-12-18 09:13:15 +00:00

theme manager

This commit is contained in:
Kyle Spearrin
2019-03-29 21:23:34 -04:00
parent fe52324eea
commit 3a90b3beb6
2 changed files with 27 additions and 16 deletions

View File

@@ -0,0 +1,25 @@
using System.Reflection;
using Xamarin.Forms;
using Xamarin.Forms.StyleSheets;
namespace Bit.App.Utilities
{
public static class ThemeManager
{
public static void SetTheme(string name)
{
var themeFormat = "Bit.App.Css.{0}.css";
var assembly = IntrospectionExtensions.GetTypeInfo(typeof(App)).Assembly;
// Other supported theme names can be added here.
if(name == "dark")
{
Application.Current.Resources.Add(StyleSheet.FromAssemblyResource(assembly,
string.Format(themeFormat, name)));
}
Application.Current.Resources.Add(StyleSheet.FromAssemblyResource(assembly,
string.Format(themeFormat, Device.RuntimePlatform.ToLowerInvariant())));
Application.Current.Resources.Add(StyleSheet.FromAssemblyResource(assembly,
string.Format(themeFormat, "styles")));
}
}
}