sharee.bike-App/SharedBusinessLogic/View/Settings/BackendPermissionsToVisibleConverter.cs

31 lines
1.2 KiB
C#
Raw Permalink Normal View History

2021-05-13 20:16:41 +02:00
using System;
using System.Globalization;
2024-04-09 12:53:23 +02:00
using ShareeBike.Model.User.Account;
2022-08-30 15:42:25 +02:00
using Xamarin.Forms;
2021-05-13 20:16:41 +02:00
2024-04-09 12:53:23 +02:00
namespace ShareeBike.View.Settings
2021-05-13 20:16:41 +02:00
{
2022-09-06 16:08:19 +02:00
/// <summary>
/// Translates user permissions into visibility state.
/// Used for container which holds a bunch of GUI elemets which migth all/ partly/ none be visible
/// If all childs are invisible frame must be invisible as well. As soon as one child is visible frame must be visible as well.
/// </summary>
public class BackendPermissionsToVisibleConverter : IValueConverter
{
/// <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)
{
var enumValue = (Permissions)value;
return enumValue.HasFlag(Permissions.PickCopriServer) | enumValue.HasFlag(Permissions.ManagePolling) | enumValue.HasFlag(Permissions.ManageCopriCacheExpiration);
}
2021-05-13 20:16:41 +02:00
2022-09-06 16:08:19 +02:00
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return Permissions.None;
}
}
2021-05-13 20:16:41 +02:00
}