mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2024-11-05 10:36:30 +01:00
35 lines
1.4 KiB
C#
35 lines
1.4 KiB
C#
|
using System;
|
|||
|
using System.Globalization;
|
|||
|
using Xamarin.Forms;
|
|||
|
using TINK.Model.User.Account;
|
|||
|
|
|||
|
namespace TINK.View.Settings
|
|||
|
{
|
|||
|
/// <summary> Translates user permissions into visibility state. </summary>
|
|||
|
public class PermissionToVisibleConverter : BindableObject, IValueConverter
|
|||
|
{
|
|||
|
static readonly BindableProperty VisibleFlagProperty =
|
|||
|
BindableProperty.Create(nameof(VisibleFlag), typeof(Permissions), typeof(BindableObject));
|
|||
|
|
|||
|
/// <summary> Property set from XAML determinig for which permission value object is visible.</summary>
|
|||
|
public Permissions VisibleFlag
|
|||
|
{
|
|||
|
get => (Permissions)GetValue(VisibleFlagProperty);
|
|||
|
set => SetValue(VisibleFlagProperty, value);
|
|||
|
}
|
|||
|
|
|||
|
/// <summary> Converts permission value into visible state.</summary>
|
|||
|
/// <param name="value">Permission value from view model used to derive whether object is visible or not.</param>
|
|||
|
/// <returns>Boolean value indicating whether object is visible or not.</returns>
|
|||
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
|||
|
{
|
|||
|
return ((Permissions)value).HasFlag(VisibleFlag);
|
|||
|
}
|
|||
|
|
|||
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
|||
|
{
|
|||
|
return Permissions.None;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|