Skip to content

Commit ce5b661

Browse files
committed
Fix icon transparency issues (Shelf and Tags)
1 parent a39e0f4 commit ce5b661

File tree

4 files changed

+24
-7
lines changed

4 files changed

+24
-7
lines changed

src/Files.App/Data/Contracts/ImagingService.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,12 @@ internal sealed class ImagingService : IImageService
1313
/// <inheritdoc/>
1414
public async Task<IImage?> GetIconAsync(IStorable storable, CancellationToken cancellationToken)
1515
{
16-
if (storable is not ILocatableStorable locatableStorable)
17-
return null;
18-
19-
var iconData = await FileThumbnailHelper.LoadIconFromPathAsync(locatableStorable.Path, 24u, ThumbnailMode.ListView, ThumbnailOptions.ResizeThumbnail);
16+
var iconData = await FileThumbnailHelper.GetIconAsync(storable.Id, 24u, storable is IFolder, IconOptions.ReturnIconOnly | IconOptions.UseCurrentScale);
2017
if (iconData is null)
2118
return null;
2219

2320
var bitmapImage = await iconData.ToBitmapAsync();
24-
return new BitmapImageModel(bitmapImage);
21+
return bitmapImage is null ? null : new BitmapImageModel(bitmapImage);
2522
}
2623

2724
public async Task<IImage?> GetImageModelFromDataAsync(byte[] rawData)

src/Files.App/Data/Items/ShelfItem.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ namespace Files.App.Data.Items
66
public sealed partial class ShelfItem : ObservableObject, IWrapper<IStorable>, IAsyncInitialize
77
{
88
private readonly IImageService _imageService;
9+
private readonly ICollection<ShelfItem> _sourceCollection;
910

1011
[ObservableProperty] private IImage? _Icon;
1112
[ObservableProperty] private string? _Name;
@@ -14,9 +15,10 @@ public sealed partial class ShelfItem : ObservableObject, IWrapper<IStorable>, I
1415
/// <inheritdoc/>
1516
public IStorable Inner { get; }
1617

17-
public ShelfItem(IStorable storable, IImage? icon = null)
18+
public ShelfItem(IStorable storable, ICollection<ShelfItem> sourceCollection, IImage? icon = null)
1819
{
1920
_imageService = Ioc.Default.GetRequiredService<IImageService>();
21+
_sourceCollection = sourceCollection;
2022
Inner = storable;
2123
Icon = icon;
2224
Name = storable.Name;
@@ -28,5 +30,11 @@ public async Task InitAsync(CancellationToken cancellationToken = default)
2830
{
2931
Icon = await _imageService.GetIconAsync(Inner, cancellationToken);
3032
}
33+
34+
[RelayCommand]
35+
private void Remove()
36+
{
37+
_sourceCollection.Remove(this);
38+
}
3139
}
3240
}

src/Files.App/UserControls/Pane/ShelfPane.xaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
Grid.Row="0"
3636
Padding="12"
3737
Spacing="8">
38+
3839
<!-- Title -->
3940
<TextBlock
4041
HorizontalAlignment="Center"
@@ -55,6 +56,16 @@
5556
<StackPanel Orientation="Horizontal" Spacing="8">
5657
<Image Height="20" Source="{x:Bind Icon, Mode=OneWay, Converter={StaticResource ImageModelToImageConverter}}" />
5758
<TextBlock Text="{x:Bind Name, Mode=OneWay}" />
59+
60+
<StackPanel.ContextFlyout>
61+
<MenuFlyout>
62+
<MenuFlyoutItem Command="{x:Bind RemoveCommand}" Text="Remove">
63+
<MenuFlyoutItem.Icon>
64+
<FontIcon Glyph="&#xE738;" />
65+
</MenuFlyoutItem.Icon>
66+
</MenuFlyoutItem>
67+
</MenuFlyout>
68+
</StackPanel.ContextFlyout>
5869
</StackPanel>
5970
</DataTemplate>
6071
</ListView.ItemTemplate>
@@ -66,6 +77,7 @@
6677
Grid.Row="1"
6778
Padding="12,8,12,8"
6879
Spacing="4">
80+
6981
<!-- (Divider) -->
7082
<Border Height="1" Background="{ThemeResource DividerStrokeColorDefaultBrush}" />
7183

src/Files.App/UserControls/Pane/ShelfPane.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ private async void Shelf_Drop(object sender, DragEventArgs e)
5252
if (storable is null)
5353
continue;
5454

55-
var shelfItem = new ShelfItem(storable);
55+
var shelfItem = new ShelfItem(storable, ItemsSource);
5656
_ = shelfItem.InitAsync();
5757

5858
ItemsSource.Add(shelfItem);

0 commit comments

Comments
 (0)