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:
@@ -1,30 +1,41 @@
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
|
||||
using Microsoft.Maui.Graphics;
|
||||
using Microsoft.Maui.Handlers;
|
||||
using SkiaSharp;
|
||||
|
||||
namespace Microsoft.Maui.Platform;
|
||||
namespace Microsoft.Maui.Platform.Linux.Handlers;
|
||||
|
||||
/// <summary>
|
||||
/// Linux handler for Switch control.
|
||||
/// </summary>
|
||||
public partial class SwitchHandler : ViewHandler<ISwitch, SkiaSwitch>
|
||||
public class SwitchHandler : ViewHandler<ISwitch, SkiaSwitch>
|
||||
{
|
||||
public static IPropertyMapper<ISwitch, SwitchHandler> Mapper = new PropertyMapper<ISwitch, SwitchHandler>(ViewHandler.ViewMapper)
|
||||
{
|
||||
[nameof(ISwitch.IsOn)] = MapIsOn,
|
||||
[nameof(ISwitch.TrackColor)] = MapTrackColor,
|
||||
[nameof(ISwitch.ThumbColor)] = MapThumbColor,
|
||||
[nameof(IView.IsEnabled)] = MapIsEnabled,
|
||||
[nameof(IView.Background)] = MapBackground,
|
||||
["BackgroundColor"] = MapBackgroundColor,
|
||||
["IsOn"] = MapIsOn,
|
||||
["TrackColor"] = MapTrackColor,
|
||||
["ThumbColor"] = MapThumbColor,
|
||||
["Background"] = MapBackground,
|
||||
["IsEnabled"] = MapIsEnabled
|
||||
};
|
||||
|
||||
public static CommandMapper<ISwitch, SwitchHandler> CommandMapper = new(ViewHandler.ViewCommandMapper);
|
||||
|
||||
public SwitchHandler() : base(Mapper, CommandMapper) { }
|
||||
public SwitchHandler() : base(Mapper, CommandMapper)
|
||||
{
|
||||
}
|
||||
|
||||
protected override SkiaSwitch CreatePlatformView() => new SkiaSwitch();
|
||||
public SwitchHandler(IPropertyMapper? mapper, CommandMapper? commandMapper = null)
|
||||
: base(mapper ?? Mapper, commandMapper ?? CommandMapper)
|
||||
{
|
||||
}
|
||||
|
||||
protected override SkiaSwitch CreatePlatformView()
|
||||
{
|
||||
return new SkiaSwitch();
|
||||
}
|
||||
|
||||
protected override void ConnectHandler(SkiaSwitch platformView)
|
||||
{
|
||||
@@ -48,7 +59,7 @@ public partial class SwitchHandler : ViewHandler<ISwitch, SkiaSwitch>
|
||||
|
||||
public static void MapIsOn(SwitchHandler handler, ISwitch @switch)
|
||||
{
|
||||
if (handler.PlatformView.IsOn != @switch.IsOn)
|
||||
if (handler.PlatformView != null)
|
||||
{
|
||||
handler.PlatformView.IsOn = @switch.IsOn;
|
||||
}
|
||||
@@ -56,39 +67,38 @@ public partial class SwitchHandler : ViewHandler<ISwitch, SkiaSwitch>
|
||||
|
||||
public static void MapTrackColor(SwitchHandler handler, ISwitch @switch)
|
||||
{
|
||||
if (@switch.TrackColor != null)
|
||||
handler.PlatformView.OnTrackColor = @switch.TrackColor.ToSKColor();
|
||||
handler.PlatformView.Invalidate();
|
||||
if (handler.PlatformView != null && @switch.TrackColor != null)
|
||||
{
|
||||
var onTrackColor = @switch.TrackColor.ToSKColor();
|
||||
handler.PlatformView.OnTrackColor = onTrackColor;
|
||||
handler.PlatformView.OffTrackColor = onTrackColor.WithAlpha(128);
|
||||
}
|
||||
}
|
||||
|
||||
public static void MapThumbColor(SwitchHandler handler, ISwitch @switch)
|
||||
{
|
||||
if (@switch.ThumbColor != null)
|
||||
if (handler.PlatformView != null && @switch.ThumbColor != null)
|
||||
{
|
||||
handler.PlatformView.ThumbColor = @switch.ThumbColor.ToSKColor();
|
||||
handler.PlatformView.Invalidate();
|
||||
}
|
||||
|
||||
public static void MapIsEnabled(SwitchHandler handler, ISwitch @switch)
|
||||
{
|
||||
handler.PlatformView.IsEnabled = @switch.IsEnabled;
|
||||
handler.PlatformView.Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
public static void MapBackground(SwitchHandler handler, ISwitch @switch)
|
||||
{
|
||||
if (@switch.Background is SolidColorBrush solidBrush && solidBrush.Color != null)
|
||||
if (handler.PlatformView != null)
|
||||
{
|
||||
handler.PlatformView.BackgroundColor = solidBrush.Color.ToSKColor();
|
||||
handler.PlatformView.Invalidate();
|
||||
if (@switch.Background is SolidPaint solidPaint && solidPaint.Color != null)
|
||||
{
|
||||
handler.PlatformView.BackgroundColor = solidPaint.Color.ToSKColor();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void MapBackgroundColor(SwitchHandler handler, ISwitch @switch)
|
||||
public static void MapIsEnabled(SwitchHandler handler, ISwitch @switch)
|
||||
{
|
||||
if (@switch is Microsoft.Maui.Controls.VisualElement ve && ve.BackgroundColor != null)
|
||||
if (handler.PlatformView != null)
|
||||
{
|
||||
handler.PlatformView.BackgroundColor = ve.BackgroundColor.ToSKColor();
|
||||
handler.PlatformView.Invalidate();
|
||||
handler.PlatformView.IsEnabled = @switch.IsEnabled;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user