Billing/Billing.Shared/UI/Definition.cs

87 lines
2.2 KiB
C#

using System;
using Xamarin.Forms;
namespace Billing.UI
{
public static partial class Definition
{
public static partial string GetCascadiaRegularFontFamily();
public static partial string GetCascadiaBoldFontFamily();
public static partial string GetRobotoCondensedRegularFontFamily();
public static partial string GetRobotoCondensedBoldFontFamily();
}
public static class ExtensionHelper
{
public static T Binding<T>(this T obj, BindableProperty property, string path, BindingMode mode = BindingMode.Default, IValueConverter converter = null) where T : BindableObject
{
obj.SetBinding(property, path, mode, converter);
return obj;
}
public static View DynamicResource(this View view, BindableProperty property, string key)
{
view.SetDynamicResource(property, key);
return view;
}
public static View GridColumn(this View view, int column)
{
Grid.SetColumn(view, column);
return view;
}
public static View GridRow(this View view, int row)
{
Grid.SetRow(view, row);
return view;
}
public static View GridColumnSpan(this View view, int columnSpan)
{
Grid.SetColumnSpan(view, columnSpan);
return view;
}
public static View GridRowSpan(this View view, int rowSpan)
{
Grid.SetRowSpan(view, rowSpan);
return view;
}
public static View Margin(this View view, Thickness margin)
{
view.Margin = margin;
return view;
}
}
public class Tap : IDisposable
{
private readonly static object sync = new();
private static Tap instance;
private bool busy = false;
private Tap() { }
public static bool IsBusy => instance?.busy ?? false;
public static Tap Start()
{
lock (sync)
{
(instance ??= new Tap()).busy = true;
}
return instance;
}
public void Dispose()
{
lock (sync)
{
busy = false;
}
}
}
}