Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
72 changes: 0 additions & 72 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue23074.cs

This file was deleted.

This file was deleted.

Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

This file was deleted.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ public override void SetImageSource(Drawable? platformImage)
if (platformImage is not null)
{
var iconSize = GetIconSize(Handler);
var textColor = item.GetTextColor()?.ToPlatform();
int drawableWidth = platformImage.IntrinsicWidth;
int drawableHeight = platformImage.IntrinsicHeight;

Expand All @@ -184,22 +185,8 @@ public override void SetImageSource(Drawable? platformImage)
platformImage.SetBounds(0, 0, iconWidth, iconHeight);
}

if (item.Source is IFontImageSource fontImageSource)
{
if (fontImageSource.Color is not null)
{
platformImage.SetColorFilter(fontImageSource.Color.ToPlatform(), FilterMode.SrcAtop);
}
else
{
var textColor = item.GetTextColor()?.ToPlatform();

if (textColor is not null)
{
platformImage.SetColorFilter(textColor.Value, FilterMode.SrcAtop);
}
}
}
if (textColor != null)
platformImage.SetColorFilter(textColor.Value, FilterMode.SrcAtop);
}

button.SetCompoundDrawables(null, platformImage, null, null);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
using System;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Input;
using Microsoft.UI.Xaml.Media;
using WImageSource = Microsoft.UI.Xaml.Media.ImageSource;
using WSwipeItem = Microsoft.UI.Xaml.Controls.SwipeItem;

namespace Microsoft.Maui.Handlers
Expand Down Expand Up @@ -93,38 +88,6 @@ void OnSwipeItemInvoked(WSwipeItem sender, Microsoft.UI.Xaml.Controls.SwipeItemI
VirtualView.OnInvoked();
}

internal static async Task LoadFileIconAsync(ISwipeItemMenuItemHandler handler, ISwipeItemMenuItem item)
{
if (handler.PlatformView is not WSwipeItem swipeItem || handler.MauiContext is null)
{
return;
}

if (item.Source is null)
{
swipeItem.IconSource = null;
return;
}

var imageSourceServiceProvider = handler.MauiContext.Services.GetRequiredService<IImageSourceServiceProvider>();
var scale = handler.MauiContext.GetOptionalPlatformWindow()?.GetDisplayDensity() ?? 1.0f;
var source = item.Source;
try
{
var service = imageSourceServiceProvider.GetRequiredImageSourceService(source);
// Do not use ConfigureAwait(false): WinUI DependencyProperty writes require the UI thread.
var result = await service.GetImageSourceAsync(source, scale);
if (item.Source == source)
{
swipeItem.IconSource = result?.Value is WImageSource platformImage ? new ImageIconSource { ImageSource = platformImage } : null;
}
}
catch (System.Exception ex)
{
handler.MauiContext?.CreateLogger<SwipeItemMenuItemHandler>()?.Log(LogLevel.Warning, new EventId(), "Cannot load SwipeItem Icon", ex, static (state, _) => state);
}
}

partial class SwipeItemMenuItemImageSourcePartSetter
{
public override void SetImageSource(ImageSource? platformImage)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ public static void MapSource(ISwipeItemMenuItemHandler handler, ISwipeItemMenuIt
public static Task MapSourceAsync(ISwipeItemMenuItemHandler handler, ISwipeItemMenuItem image)
{
#if WINDOWS
return LoadFileIconAsync(handler, image);
// TODO: make the mapper use the loader and the image if this is a stream source
handler.PlatformView.IconSource = image.Source?.ToIconSource(handler.MauiContext!);
#else
if (handler.SourceLoader is ImageSourcePartLoader loader)
return loader.UpdateImageSourceAsync();

return Task.CompletedTask;
#endif
return Task.CompletedTask;
}

partial class SwipeItemMenuItemImageSourcePartSetter : ImageSourcePartSetter<ISwipeItemMenuItemHandler>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,30 +119,15 @@ public override void SetImageSource(UIImage? platformImage)

try
{
// Font glyphs are single-color vectors so template rendering + tint makes sense.
// Regular raster images should use AlwaysOriginal to preserve their own colors.
var fontImageSource = item.Source as IFontImageSource;
var renderingMode = fontImageSource is not null ? UIImageRenderingMode.AlwaysTemplate : UIImageRenderingMode.AlwaysOriginal;
button.SetImage(resizedImage.ImageWithRenderingMode(renderingMode), UIControlState.Normal);
button.SetImage(resizedImage.ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate), UIControlState.Normal);

if (fontImageSource is not null)
{
if (fontImageSource.Color is not null)
{
button.TintColor = fontImageSource.Color.ToPlatform();
}
else
{
var tintColor = item.GetTextColor();
if (tintColor is not null)
{
button.TintColor = tintColor.ToPlatform();
}
}
}
if (item.Source is IFontImageSource fontImageSource && fontImageSource.Color != null)
button.TintColor = fontImageSource.Color.ToPlatform();
else
{
button.TintColor = null;
var tintColor = item.GetTextColor();
if (tintColor != null)
button.TintColor = tintColor.ToPlatform();
}
}
catch (Exception)
Expand Down
Loading