2025-12-19 09:30:16 +00:00
|
|
|
// Licensed to the .NET Foundation under one or more agreements.
|
|
|
|
|
// The .NET Foundation licenses this file to you under the MIT license.
|
|
|
|
|
|
2026-01-01 13:51:12 -05:00
|
|
|
using Microsoft.Maui.Graphics;
|
2025-12-19 09:30:16 +00:00
|
|
|
using Microsoft.Maui.Handlers;
|
|
|
|
|
|
2026-01-01 13:51:12 -05:00
|
|
|
namespace Microsoft.Maui.Platform.Linux.Handlers;
|
2025-12-19 09:30:16 +00:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Linux handler for ActivityIndicator control.
|
|
|
|
|
/// </summary>
|
2026-01-01 13:51:12 -05:00
|
|
|
public class ActivityIndicatorHandler : ViewHandler<IActivityIndicator, SkiaActivityIndicator>
|
2025-12-19 09:30:16 +00:00
|
|
|
{
|
|
|
|
|
public static IPropertyMapper<IActivityIndicator, ActivityIndicatorHandler> Mapper = new PropertyMapper<IActivityIndicator, ActivityIndicatorHandler>(ViewHandler.ViewMapper)
|
|
|
|
|
{
|
2026-01-01 13:51:12 -05:00
|
|
|
["IsRunning"] = MapIsRunning,
|
|
|
|
|
["Color"] = MapColor,
|
|
|
|
|
["Background"] = MapBackground
|
2025-12-19 09:30:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
public static CommandMapper<IActivityIndicator, ActivityIndicatorHandler> CommandMapper = new(ViewHandler.ViewCommandMapper);
|
|
|
|
|
|
2026-01-01 13:51:12 -05:00
|
|
|
public ActivityIndicatorHandler() : base(Mapper, CommandMapper)
|
|
|
|
|
{
|
|
|
|
|
}
|
2025-12-19 09:30:16 +00:00
|
|
|
|
2026-01-01 13:51:12 -05:00
|
|
|
public ActivityIndicatorHandler(IPropertyMapper? mapper, CommandMapper? commandMapper = null)
|
|
|
|
|
: base(mapper ?? Mapper, commandMapper ?? CommandMapper)
|
2025-12-19 09:30:16 +00:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-01 13:51:12 -05:00
|
|
|
protected override SkiaActivityIndicator CreatePlatformView()
|
2025-12-19 09:30:16 +00:00
|
|
|
{
|
2026-01-01 13:51:12 -05:00
|
|
|
return new SkiaActivityIndicator();
|
2025-12-19 09:30:16 +00:00
|
|
|
}
|
|
|
|
|
|
2026-01-01 13:51:12 -05:00
|
|
|
public static void MapIsRunning(ActivityIndicatorHandler handler, IActivityIndicator activityIndicator)
|
2025-12-19 09:30:16 +00:00
|
|
|
{
|
2026-01-01 13:51:12 -05:00
|
|
|
if (handler.PlatformView != null)
|
|
|
|
|
{
|
|
|
|
|
handler.PlatformView.IsRunning = activityIndicator.IsRunning;
|
|
|
|
|
}
|
2025-12-19 09:30:16 +00:00
|
|
|
}
|
2025-12-21 13:26:56 -05:00
|
|
|
|
2026-01-01 13:51:12 -05:00
|
|
|
public static void MapColor(ActivityIndicatorHandler handler, IActivityIndicator activityIndicator)
|
2025-12-21 13:26:56 -05:00
|
|
|
{
|
2026-01-01 13:51:12 -05:00
|
|
|
if (handler.PlatformView != null && activityIndicator.Color != null)
|
2025-12-21 13:26:56 -05:00
|
|
|
{
|
2026-01-01 13:51:12 -05:00
|
|
|
handler.PlatformView.Color = activityIndicator.Color.ToSKColor();
|
2025-12-21 13:26:56 -05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-01 13:51:12 -05:00
|
|
|
public static void MapBackground(ActivityIndicatorHandler handler, IActivityIndicator activityIndicator)
|
2025-12-21 13:26:56 -05:00
|
|
|
{
|
2026-01-01 13:51:12 -05:00
|
|
|
if (handler.PlatformView != null)
|
2025-12-21 13:26:56 -05:00
|
|
|
{
|
2026-01-01 13:51:12 -05:00
|
|
|
if (activityIndicator.Background is SolidPaint solidPaint && solidPaint.Color != null)
|
|
|
|
|
{
|
2026-01-17 03:10:29 +00:00
|
|
|
handler.PlatformView.BackgroundColor = solidPaint.Color;
|
2026-01-01 13:51:12 -05:00
|
|
|
}
|
2025-12-21 13:26:56 -05:00
|
|
|
}
|
|
|
|
|
}
|
2025-12-19 09:30:16 +00:00
|
|
|
}
|