Add ActivityIndicator component
This commit is contained in:
Родитель
a0dba14ded
Коммит
41896ad124
|
@ -0,0 +1,33 @@
|
|||
using Blaxamarin.Framework.Elements.Handlers;
|
||||
using Emblazon;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using XF = Xamarin.Forms;
|
||||
|
||||
namespace Blaxamarin.Framework.Elements
|
||||
{
|
||||
public class ActivityIndicator : View
|
||||
{
|
||||
static ActivityIndicator()
|
||||
{
|
||||
ElementHandlerRegistry
|
||||
.RegisterElementHandler<ActivityIndicator>(renderer => new ActivityIndicatorHandler(renderer, new XF.ActivityIndicator()));
|
||||
}
|
||||
|
||||
[Parameter] public bool? IsRunning { get; set; }
|
||||
[Parameter] public XF.Color? Color { get; set; }
|
||||
|
||||
protected override void RenderAttributes(AttributesBuilder builder)
|
||||
{
|
||||
base.RenderAttributes(builder);
|
||||
|
||||
if (IsRunning != null)
|
||||
{
|
||||
builder.AddAttribute(nameof(IsRunning), IsRunning.Value);
|
||||
}
|
||||
if (Color != null)
|
||||
{
|
||||
builder.AddAttribute(nameof(Color), AttributeHelper.ColorToString(Color.Value));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
using Emblazon;
|
||||
using System;
|
||||
using XF = Xamarin.Forms;
|
||||
|
||||
namespace Blaxamarin.Framework.Elements.Handlers
|
||||
{
|
||||
public class ActivityIndicatorHandler : ViewHandler
|
||||
{
|
||||
public ActivityIndicatorHandler(EmblazonRenderer renderer, XF.ActivityIndicator activityIndicatorControl) : base(renderer, activityIndicatorControl)
|
||||
{
|
||||
ActivityIndicatorControl = activityIndicatorControl ?? throw new ArgumentNullException(nameof(activityIndicatorControl));
|
||||
}
|
||||
|
||||
public XF.ActivityIndicator ActivityIndicatorControl { get; }
|
||||
|
||||
public override void ApplyAttribute(ulong attributeEventHandlerId, string attributeName, object attributeValue, string attributeEventUpdatesAttributeName)
|
||||
{
|
||||
switch (attributeName)
|
||||
{
|
||||
case nameof(ActivityIndicator.IsRunning):
|
||||
ActivityIndicatorControl.IsRunning = (bool)(attributeValue ?? (bool)XF.ActivityIndicator.IsRunningProperty.DefaultValue);
|
||||
break;
|
||||
case nameof(ActivityIndicator.Color):
|
||||
ActivityIndicatorControl.Color = AttributeHelper.StringToColor((string)attributeValue);
|
||||
break;
|
||||
default:
|
||||
base.ApplyAttribute(attributeEventHandlerId, attributeName, attributeValue, attributeEventUpdatesAttributeName);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче