Skip to content

Commit

Permalink
SwipeView Fix #22580 (#22741)
Browse files Browse the repository at this point in the history
Co-authored-by: Javier Suárez <javiersuarezruiz@hotmail.com>
  • Loading branch information
kubaflo and jsuarezruiz committed Jun 12, 2024
1 parent a0a4152 commit b01e163
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
39 changes: 39 additions & 0 deletions src/Controls/src/Core/SwipeView/SwipeView.Mapper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using System;
using Microsoft.Maui.Controls.Compatibility;

namespace Microsoft.Maui.Controls
{
public partial class SwipeView
{
[Obsolete("Use SwipeViewHandler.Mapper instead.")]
internal static IPropertyMapper<ISwipeView, ISwipeViewHandler> ControlsSwipeMapper =
new ControlsMapper<SwipeView, SwipeViewHandler>(SwipeViewHandler.Mapper);

internal static new void RemapForControls()
{
// Adjusted the mapping to preserve SwipeView.Entry legacy behavior
SwipeViewHandler.Mapper.AppendToMapping<SwipeView, ISwipeViewHandler>(nameof(Background), MapBackground);
}

static void MapBackground(ISwipeViewHandler handler, SwipeView swipeView)
{
if (swipeView.Content is not null)
{
var contentBackgroundIsNull = Brush.IsNullOrEmpty(swipeView.Content.Background);
var contentBackgroundColorIsNull = swipeView.Content.BackgroundColor == null;

if (contentBackgroundIsNull && contentBackgroundColorIsNull)
{
if (!Brush.IsNullOrEmpty(swipeView.Background))
{
swipeView.Content.Background = swipeView.Background;
}
else if (swipeView.BackgroundColor != null)
{
swipeView.Content.BackgroundColor = swipeView.BackgroundColor;
}
}
}
}
}
}
1 change: 1 addition & 0 deletions src/Controls/src/Xaml/Hosting/AppHostBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ internal static MauiAppBuilder RemapForControls(this MauiAppBuilder builder)
Window.RemapForControls();
Editor.RemapForControls();
Entry.RemapForControls();
SwipeView.RemapForControls();
Picker.RemapForControls();
SearchBar.RemapForControls();
TabbedPage.RemapForControls();
Expand Down

0 comments on commit b01e163

Please sign in to comment.