using System;
using System.Collections.Generic;
using Xamarin.Forms;
namespace TINK.Services.ThemeNS
{
///
/// Manges themeing functionalty.
/// Objects ResourceDictionary, Themes.Konrad, ... need Xamarin.Forms framework to be initialized which might break tests.
///
public class Theme : ITheme
{
private ICollection _MergedDictionaries;
public Theme(ICollection mergedDictionaries)
{
_MergedDictionaries = mergedDictionaries ?? throw new ArgumentNullException(nameof(mergedDictionaries));
}
///
/// Sets active theme.
///
/// Name of the new active theme.
public void SetActiveTheme(string themeName)
{
if (!Enum.TryParse(themeName, false, out ThemeSet theme))
return;
if (_MergedDictionaries == null)
return;
_MergedDictionaries.Clear();
switch (theme)
{
case ThemeSet.Konrad:
_MergedDictionaries.Add(new Themes.Konrad());
break;
case ThemeSet.LastenradBayern:
_MergedDictionaries.Add(new Themes.LastenradBayern());
break;
default:
_MergedDictionaries.Add(new Themes.ShareeBike());
break;
}
}
}
}