mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2025-07-04 10:56:28 +02:00
Version 3.0.338
This commit is contained in:
parent
573fe77e12
commit
0468955d49
751 changed files with 62747 additions and 60672 deletions
|
@ -7,78 +7,78 @@ using Xamarin.Forms;
|
|||
|
||||
namespace TINK.ViewModel.Map
|
||||
{
|
||||
/// <remarks> Old name: MapPageFilter. </remarks>
|
||||
public class TinkKonradToggleViewModel : ITinkKonradToggleViewModel
|
||||
{
|
||||
/// <summary> Constructs a map page filter view model object from values.</summary>
|
||||
/// <param name="currentFilter">Filters and options dictionary.</param>
|
||||
public TinkKonradToggleViewModel(IGroupFilterMapPage currentFilter)
|
||||
{
|
||||
FilterDictionary = currentFilter ?? new GroupFilterMapPage();
|
||||
}
|
||||
/// <remarks> Old name: MapPageFilter. </remarks>
|
||||
public class TinkKonradToggleViewModel : ITinkKonradToggleViewModel
|
||||
{
|
||||
/// <summary> Constructs a map page filter view model object from values.</summary>
|
||||
/// <param name="currentFilter">Filters and options dictionary.</param>
|
||||
public TinkKonradToggleViewModel(IGroupFilterMapPage currentFilter)
|
||||
{
|
||||
FilterDictionary = currentFilter ?? new GroupFilterMapPage();
|
||||
}
|
||||
|
||||
/// <summary> Gets the filter values.</summary>
|
||||
public IGroupFilterMapPage FilterDictionary { get; }
|
||||
/// <summary> Gets the filter values.</summary>
|
||||
public IGroupFilterMapPage FilterDictionary { get; }
|
||||
|
||||
/// <summary> Gets the activated filter.</summary>
|
||||
public string CurrentFilter
|
||||
{
|
||||
get
|
||||
{
|
||||
return FilterDictionary.FirstOrDefault(x => x.Value == FilterState.On).Key ?? string.Empty;
|
||||
}
|
||||
}
|
||||
/// <summary> Gets the activated filter.</summary>
|
||||
public string CurrentFilter
|
||||
{
|
||||
get
|
||||
{
|
||||
return FilterDictionary.FirstOrDefault(x => x.Value == FilterState.On).Key ?? string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Gets value whether TINK is enabled or not. </summary>
|
||||
public bool IsTinkEnabled => !string.IsNullOrEmpty(CurrentFilter) && CurrentFilter.GetBikeCategory() != FilterHelper.CARGOBIKE;
|
||||
/// <summary> Gets value whether TINK is enabled or not. </summary>
|
||||
public bool IsTinkEnabled => !string.IsNullOrEmpty(CurrentFilter) && CurrentFilter.GetBikeCategory() != FilterHelper.CARGOBIKE;
|
||||
|
||||
/// <summary> Gets color of the TINK button. </summary>
|
||||
public Color TinkColor => CurrentFilter.GetBikeCategory() == FilterHelper.CARGOBIKE ? Color.White : Color.FromRgba(0, 0, 0, 0);
|
||||
public Color NoTinkColor => CurrentFilter.GetBikeCategory() == FilterHelper.CARGOBIKE ? Color.FromRgb(210, 17, 20) : Color.White;
|
||||
/// <summary> Gets value whether Konrad is enabled or not. </summary>
|
||||
public bool IsKonradEnabled => !string.IsNullOrEmpty(CurrentFilter) && CurrentFilter.GetBikeCategory() != FilterHelper.CITYBIKE;
|
||||
/// <summary> Gets color of the TINK button. </summary>
|
||||
public Color TinkColor => CurrentFilter.GetBikeCategory() == FilterHelper.CARGOBIKE ? Color.White : Color.FromRgba(0, 0, 0, 0);
|
||||
public Color NoTinkColor => CurrentFilter.GetBikeCategory() == FilterHelper.CARGOBIKE ? Color.FromRgb(210, 17, 20) : Color.White;
|
||||
/// <summary> Gets value whether Konrad is enabled or not. </summary>
|
||||
public bool IsKonradEnabled => !string.IsNullOrEmpty(CurrentFilter) && CurrentFilter.GetBikeCategory() != FilterHelper.CITYBIKE;
|
||||
|
||||
/// <summary> Gets color of the Konrad button. </summary>
|
||||
public Color KonradColor => CurrentFilter.GetBikeCategory() == FilterHelper.CITYBIKE ? Color.White : Color.FromRgba(0, 0, 0, 0);
|
||||
public Color NoKonradColor => CurrentFilter.GetBikeCategory() == FilterHelper.CITYBIKE ? Color.FromRgb(210, 17, 20) : Color.White;
|
||||
/// <summary> Gets color of the Konrad button. </summary>
|
||||
public Color KonradColor => CurrentFilter.GetBikeCategory() == FilterHelper.CITYBIKE ? Color.White : Color.FromRgba(0, 0, 0, 0);
|
||||
public Color NoKonradColor => CurrentFilter.GetBikeCategory() == FilterHelper.CITYBIKE ? Color.FromRgb(210, 17, 20) : Color.White;
|
||||
|
||||
/// <summary> Gets whether toggle functionality is visible or not. </summary>
|
||||
public bool IsToggleVisible =>
|
||||
FilterDictionary.Select(x => x.Key).ContainsGroupId(FilterHelper.CITYBIKE)
|
||||
&& FilterDictionary.Select(x => x.Key).ContainsGroupId(FilterHelper.CARGOBIKE)
|
||||
&& (IsTinkEnabled || IsKonradEnabled);
|
||||
/// <summary> Gets whether toggle functionality is visible or not. </summary>
|
||||
public bool IsToggleVisible =>
|
||||
FilterDictionary.Select(x => x.Key).ContainsGroupId(FilterHelper.CITYBIKE)
|
||||
&& FilterDictionary.Select(x => x.Key).ContainsGroupId(FilterHelper.CARGOBIKE)
|
||||
&& (IsTinkEnabled || IsKonradEnabled);
|
||||
|
||||
/// <summary>
|
||||
/// Toggles from bike group TINK to Konrad or vice versa.
|
||||
/// Toggling means one of
|
||||
/// - TINK => Konrad or
|
||||
/// - TINK => Konrad.
|
||||
/// </summary>
|
||||
/// <param name="p_strCurrentFilterSet">Filter set to toggle.</param>
|
||||
/// <returns></returns>
|
||||
public TinkKonradToggleViewModel DoToggle()
|
||||
{
|
||||
var currentFilterSet = FilterDictionary.ToArray();
|
||||
/// <summary>
|
||||
/// Toggles from bike group TINK to Konrad or vice versa.
|
||||
/// Toggling means one of
|
||||
/// - TINK => Konrad or
|
||||
/// - TINK => Konrad.
|
||||
/// </summary>
|
||||
/// <param name="p_strCurrentFilterSet">Filter set to toggle.</param>
|
||||
/// <returns></returns>
|
||||
public TinkKonradToggleViewModel DoToggle()
|
||||
{
|
||||
var currentFilterSet = FilterDictionary.ToArray();
|
||||
|
||||
if (currentFilterSet.Length < 2)
|
||||
{
|
||||
// There is nothing to toggle because filter set contains only one element.
|
||||
return new TinkKonradToggleViewModel(FilterDictionary);
|
||||
}
|
||||
if (currentFilterSet.Length < 2)
|
||||
{
|
||||
// There is nothing to toggle because filter set contains only one element.
|
||||
return new TinkKonradToggleViewModel(FilterDictionary);
|
||||
}
|
||||
|
||||
var currentState = currentFilterSet[currentFilterSet.Length - 1].Value == FilterState.On
|
||||
? FilterState.On
|
||||
: FilterState.Off;
|
||||
var currentState = currentFilterSet[currentFilterSet.Length - 1].Value == FilterState.On
|
||||
? FilterState.On
|
||||
: FilterState.Off;
|
||||
|
||||
var toggledFilterSet = new Dictionary<string, FilterState>();
|
||||
var toggledFilterSet = new Dictionary<string, FilterState>();
|
||||
|
||||
foreach (var filterElement in currentFilterSet)
|
||||
{
|
||||
toggledFilterSet.Add(filterElement.Key, currentState);
|
||||
currentState = filterElement.Value;
|
||||
}
|
||||
foreach (var filterElement in currentFilterSet)
|
||||
{
|
||||
toggledFilterSet.Add(filterElement.Key, currentState);
|
||||
currentState = filterElement.Value;
|
||||
}
|
||||
|
||||
return new TinkKonradToggleViewModel(new GroupFilterMapPage(toggledFilterSet));
|
||||
}
|
||||
}
|
||||
return new TinkKonradToggleViewModel(new GroupFilterMapPage(toggledFilterSet));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue