mirror of
https://github.com/bitwarden/mobile
synced 2025-12-18 17:23:18 +00:00
theming with resource dictionary
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
using System.Reflection;
|
||||
using Bit.App.Styles;
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using Xamarin.Forms;
|
||||
using Xamarin.Forms.StyleSheets;
|
||||
|
||||
@@ -21,5 +23,35 @@ namespace Bit.App.Utilities
|
||||
Application.Current.Resources.Add(StyleSheet.FromAssemblyResource(assembly,
|
||||
string.Format(themeFormat, "styles")));
|
||||
}
|
||||
|
||||
public static void SetThemeStyle(string name)
|
||||
{
|
||||
// Reset styles
|
||||
Application.Current.Resources.Clear();
|
||||
Application.Current.Resources.MergedDictionaries.Clear();
|
||||
|
||||
// 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());
|
||||
}
|
||||
|
||||
// Theme styles
|
||||
if(name == "dark")
|
||||
{
|
||||
Application.Current.Resources.MergedDictionaries.Add(new Dark());
|
||||
}
|
||||
else
|
||||
{
|
||||
Application.Current.Resources.MergedDictionaries.Add(new Light());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user