Version 3.0.337

This commit is contained in:
Anja Müller-Meißner 2022-08-30 15:42:25 +02:00
parent fd0e63cf10
commit 573fe77e12
2336 changed files with 33688 additions and 86082 deletions

View file

@ -0,0 +1,18 @@

namespace TINK.Services.ThemeNS
{
/// <summary>
/// Set of available app themes
/// </summary>
public enum ThemeSet
{
ShareeBike,
Konrad,
LastenradBayern
}
public interface ITheme
{
void SetActiveTheme(string themeName);
}
}

View file

@ -0,0 +1,50 @@
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;
}
}
}
}