mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2024-11-05 10:36:30 +01:00
50 lines
1.2 KiB
C#
50 lines
1.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using Xamarin.Forms;
|
|
|
|
namespace TINK.Services.ThemeNS
|
|
{
|
|
/// <summary>
|
|
/// Manges themeing functionalty.
|
|
/// Objects ResourceDictionary, Themes.Konrad, ... need Xamarin.Forms framework to be initialized which might break tests.
|
|
/// </summary>
|
|
public class Theme : ITheme
|
|
{
|
|
private ICollection<ResourceDictionary> _MergedDictionaries;
|
|
|
|
public Theme(ICollection<ResourceDictionary> mergedDictionaries)
|
|
{
|
|
_MergedDictionaries = mergedDictionaries ?? throw new ArgumentNullException(nameof(mergedDictionaries));
|
|
}
|
|
|
|
/// <summary>
|
|
/// Sets active theme.
|
|
/// </summary>
|
|
/// <param name="themeName">Name of the new active theme.</param>
|
|
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;
|
|
}
|
|
}
|
|
}
|
|
}
|