Fix handlers to match decompiled production code

- ButtonHandler: Removed MapText/TextColor/Font (not in production), fixed namespace
- LabelHandler: Added CharacterSpacing/LayoutAlignment/FormattedText, ConnectHandler gesture logic
- EntryHandler: Added CharacterSpacing/ClearButtonVisibility/VerticalTextAlignment
- EditorHandler: Created from decompiled (was missing)
- SliderHandler: Fixed namespace, added ConnectHandler init calls
- SwitchHandler: Added OffTrackColor logic, fixed namespace
- CheckBoxHandler: Added VerticalLayoutAlignment/HorizontalLayoutAlignment
- ProgressBarHandler: Added ConnectHandler/DisconnectHandler IsVisible tracking
- PickerHandler: Created from decompiled with collection changed tracking
- ActivityIndicatorHandler: Removed IsEnabled/BackgroundColor (not in production)
- All handlers now use namespace Microsoft.Maui.Platform.Linux.Handlers
- All handlers have proper null checks on PlatformView
- Updated MERGE_TRACKING.md with accurate status

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-01 13:51:12 -05:00
parent fd9043f749
commit 6f0d10935c
26 changed files with 2502 additions and 1594 deletions

View File

@@ -1,33 +1,44 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using Microsoft.Maui.Graphics;
using Microsoft.Maui.Handlers;
namespace Microsoft.Maui.Platform;
namespace Microsoft.Maui.Platform.Linux.Handlers;
/// <summary>
/// Linux handler for Slider control.
/// </summary>
public partial class SliderHandler : ViewHandler<ISlider, SkiaSlider>
public class SliderHandler : ViewHandler<ISlider, SkiaSlider>
{
public static IPropertyMapper<ISlider, SliderHandler> Mapper = new PropertyMapper<ISlider, SliderHandler>(ViewHandler.ViewMapper)
{
[nameof(ISlider.Minimum)] = MapMinimum,
[nameof(ISlider.Maximum)] = MapMaximum,
[nameof(ISlider.Value)] = MapValue,
[nameof(ISlider.MinimumTrackColor)] = MapMinimumTrackColor,
[nameof(ISlider.MaximumTrackColor)] = MapMaximumTrackColor,
[nameof(ISlider.ThumbColor)] = MapThumbColor,
[nameof(IView.IsEnabled)] = MapIsEnabled,
[nameof(IView.Background)] = MapBackground,
["BackgroundColor"] = MapBackgroundColor,
["Minimum"] = MapMinimum,
["Maximum"] = MapMaximum,
["Value"] = MapValue,
["MinimumTrackColor"] = MapMinimumTrackColor,
["MaximumTrackColor"] = MapMaximumTrackColor,
["ThumbColor"] = MapThumbColor,
["Background"] = MapBackground,
["IsEnabled"] = MapIsEnabled
};
public static CommandMapper<ISlider, SliderHandler> CommandMapper = new(ViewHandler.ViewCommandMapper);
public SliderHandler() : base(Mapper, CommandMapper) { }
public SliderHandler() : base(Mapper, CommandMapper)
{
}
protected override SkiaSlider CreatePlatformView() => new SkiaSlider();
public SliderHandler(IPropertyMapper? mapper, CommandMapper? commandMapper = null)
: base(mapper ?? Mapper, commandMapper ?? CommandMapper)
{
}
protected override SkiaSlider CreatePlatformView()
{
return new SkiaSlider();
}
protected override void ConnectHandler(SkiaSlider platformView)
{
@@ -35,6 +46,14 @@ public partial class SliderHandler : ViewHandler<ISlider, SkiaSlider>
platformView.ValueChanged += OnValueChanged;
platformView.DragStarted += OnDragStarted;
platformView.DragCompleted += OnDragCompleted;
if (VirtualView != null)
{
MapMinimum(this, VirtualView);
MapMaximum(this, VirtualView);
MapValue(this, VirtualView);
MapIsEnabled(this, VirtualView);
}
}
protected override void DisconnectHandler(SkiaSlider platformView)
@@ -47,30 +66,41 @@ public partial class SliderHandler : ViewHandler<ISlider, SkiaSlider>
private void OnValueChanged(object? sender, SliderValueChangedEventArgs e)
{
if (VirtualView != null && Math.Abs(VirtualView.Value - e.NewValue) > 0.001)
if (VirtualView != null && PlatformView != null && Math.Abs(VirtualView.Value - e.NewValue) > 0.0001)
{
VirtualView.Value = e.NewValue;
}
}
private void OnDragStarted(object? sender, EventArgs e) => VirtualView?.DragStarted();
private void OnDragCompleted(object? sender, EventArgs e) => VirtualView?.DragCompleted();
private void OnDragStarted(object? sender, EventArgs e)
{
VirtualView?.DragStarted();
}
private void OnDragCompleted(object? sender, EventArgs e)
{
VirtualView?.DragCompleted();
}
public static void MapMinimum(SliderHandler handler, ISlider slider)
{
handler.PlatformView.Minimum = slider.Minimum;
handler.PlatformView.Invalidate();
if (handler.PlatformView != null)
{
handler.PlatformView.Minimum = slider.Minimum;
}
}
public static void MapMaximum(SliderHandler handler, ISlider slider)
{
handler.PlatformView.Maximum = slider.Maximum;
handler.PlatformView.Invalidate();
if (handler.PlatformView != null)
{
handler.PlatformView.Maximum = slider.Maximum;
}
}
public static void MapValue(SliderHandler handler, ISlider slider)
{
if (Math.Abs(handler.PlatformView.Value - slider.Value) > 0.001)
if (handler.PlatformView != null && Math.Abs(handler.PlatformView.Value - slider.Value) > 0.0001)
{
handler.PlatformView.Value = slider.Value;
}
@@ -78,45 +108,44 @@ public partial class SliderHandler : ViewHandler<ISlider, SkiaSlider>
public static void MapMinimumTrackColor(SliderHandler handler, ISlider slider)
{
if (slider.MinimumTrackColor != null)
if (handler.PlatformView != null && slider.MinimumTrackColor != null)
{
handler.PlatformView.ActiveTrackColor = slider.MinimumTrackColor.ToSKColor();
handler.PlatformView.Invalidate();
}
}
public static void MapMaximumTrackColor(SliderHandler handler, ISlider slider)
{
if (slider.MaximumTrackColor != null)
if (handler.PlatformView != null && slider.MaximumTrackColor != null)
{
handler.PlatformView.TrackColor = slider.MaximumTrackColor.ToSKColor();
handler.PlatformView.Invalidate();
}
}
public static void MapThumbColor(SliderHandler handler, ISlider slider)
{
if (slider.ThumbColor != null)
if (handler.PlatformView != null && slider.ThumbColor != null)
{
handler.PlatformView.ThumbColor = slider.ThumbColor.ToSKColor();
handler.PlatformView.Invalidate();
}
public static void MapIsEnabled(SliderHandler handler, ISlider slider)
{
handler.PlatformView.IsEnabled = slider.IsEnabled;
handler.PlatformView.Invalidate();
}
}
public static void MapBackground(SliderHandler handler, ISlider slider)
{
if (slider.Background is SolidColorBrush solidBrush && solidBrush.Color != null)
if (handler.PlatformView != null)
{
handler.PlatformView.BackgroundColor = solidBrush.Color.ToSKColor();
handler.PlatformView.Invalidate();
if (slider.Background is SolidPaint solidPaint && solidPaint.Color != null)
{
handler.PlatformView.BackgroundColor = solidPaint.Color.ToSKColor();
}
}
}
public static void MapBackgroundColor(SliderHandler handler, ISlider slider)
public static void MapIsEnabled(SliderHandler handler, ISlider slider)
{
if (slider is Microsoft.Maui.Controls.VisualElement ve && ve.BackgroundColor != null)
if (handler.PlatformView != null)
{
handler.PlatformView.BackgroundColor = ve.BackgroundColor.ToSKColor();
handler.PlatformView.IsEnabled = slider.IsEnabled;
handler.PlatformView.Invalidate();
}
}