mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2024-09-26 00:46:28 +02:00
62 lines
1.6 KiB
C#
62 lines
1.6 KiB
C#
using TINK.Model;
|
|
|
|
namespace TINK.ViewModel.Settings
|
|
{
|
|
/// <summary>Holds filter item incluting full state (avaialble, activated, name, ...). </summary>
|
|
public class FilterItemMutable
|
|
{
|
|
/// <summary> Switch value</summary>
|
|
private bool m_bIsActivatedSwitch;
|
|
|
|
/// <summary> Constructs a filter object. </summary>
|
|
/// <param name="key">Key of the filter state.</param>
|
|
/// <param name="filterState">State of filter, on or off.</param>
|
|
/// <param name="isEnabled">If filter does not apply because user does not belong to group (TINK, Konrad, ...) filter is deactivated.</param>
|
|
/// <param name="labelText">Text of the switch describing the filter.</param>
|
|
public FilterItemMutable(
|
|
string key,
|
|
FilterState filterState,
|
|
bool isEnabled,
|
|
string labelText)
|
|
{
|
|
Text = labelText;
|
|
IsEnabled = isEnabled;
|
|
State = filterState;
|
|
Key = key;
|
|
m_bIsActivatedSwitch = isEnabled && filterState == FilterState.On;
|
|
}
|
|
|
|
/// <summary> Text describing the filter. </summary>
|
|
public string Text { get; }
|
|
|
|
/// <summary> True if switch can be toggeled.</summary>
|
|
public bool IsEnabled { get; }
|
|
|
|
/// <summary> True if switch is on.</summary>
|
|
public bool IsActivated
|
|
{
|
|
get
|
|
{
|
|
return m_bIsActivatedSwitch;
|
|
}
|
|
|
|
set
|
|
{
|
|
m_bIsActivatedSwitch = value;
|
|
if (!IsEnabled)
|
|
{
|
|
// Nothing to do if filter does not apply to user account.
|
|
return;
|
|
}
|
|
|
|
State = m_bIsActivatedSwitch ? FilterState.On : FilterState.Off;
|
|
}
|
|
}
|
|
|
|
/// <summary> Key of the filter.</summary>
|
|
public string Key { get; }
|
|
|
|
/// <summary> State of the filter.</summary>
|
|
public FilterState State { get; private set; }
|
|
}
|
|
}
|