mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2025-06-21 21:46:27 +02:00
Version 3.0.381
This commit is contained in:
parent
f963c0a219
commit
3a363acf3a
1525 changed files with 60589 additions and 125098 deletions
17
SharedBusinessLogic/Services/ThemeNS/ITheme.cs
Normal file
17
SharedBusinessLogic/Services/ThemeNS/ITheme.cs
Normal file
|
@ -0,0 +1,17 @@
|
|||
|
||||
namespace ShareeBike.Services.ThemeNS
|
||||
{
|
||||
/// <summary>
|
||||
/// Set of available app themes
|
||||
/// </summary>
|
||||
public enum ThemeSet
|
||||
{
|
||||
ShareeBike,
|
||||
LastenradBayern
|
||||
}
|
||||
|
||||
public interface ITheme
|
||||
{
|
||||
void SetActiveTheme(string themeName);
|
||||
}
|
||||
}
|
46
SharedBusinessLogic/Services/ThemeNS/Theme.cs
Normal file
46
SharedBusinessLogic/Services/ThemeNS/Theme.cs
Normal file
|
@ -0,0 +1,46 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace ShareeBike.Services.ThemeNS
|
||||
{
|
||||
/// <summary>
|
||||
/// Manges themeing functionalty.
|
||||
/// Objects ResourceDictionary, Themes.ShareeBike, ... 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.LastenradBayern:
|
||||
_MergedDictionaries.Add(new Themes.LastenradBayern());
|
||||
break;
|
||||
|
||||
default:
|
||||
_MergedDictionaries.Add(new Themes.ShareeBike());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue