About tab - Fixed my icon being smoll, lmao

About tab - Use async image loader instead of manual bitmaps
Workshop - Use async image loader for entry icons
This commit is contained in:
Robert committed 2023-08-24 19:38:47 +02:00
1 parent 2a34381926
commit e21edd0ed6
13 files changed
+75 -223

No files matched your search

@@ -4,9 +4,14 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:profile="clr-namespace:Artemis.UI.Screens.Workshop.Profile"
xmlns:avalonia="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia"
xmlns:il="clr-namespace:AsyncImageLoader;assembly=AsyncImageLoader.Avalonia"
xmlns:converters="clr-namespace:Artemis.UI.Converters"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="Artemis.UI.Screens.Workshop.Profile.ProfileDetailsView"
x:DataType="profile:ProfileDetailsViewModel">
<UserControl.Resources>
<converters:EntryIconUriConverter x:Key="EntryIconUriConverter" />
</UserControl.Resources>
<Border Classes="router-container">
<Grid ColumnDefinitions="300,*" RowDefinitions="Auto,*" Margin="10">
<Border Classes="card" Grid.Row="1" Grid.Column="0" Margin="0 0 10 0">
@@ -18,10 +23,7 @@
Width="80"
Height="80"
ClipToBounds="True">
<Image Source="{CompiledBinding EntryIcon}"
Stretch="UniformToFill"
Classes="fade-in"
Classes.faded-in="{CompiledBinding EntryIcon, Converter={x:Static ObjectConverters.IsNotNull}}" />
<Image Stretch="UniformToFill" il:ImageLoader.Source="{CompiledBinding Entry.Id, Converter={StaticResource EntryIconUriConverter}, Mode=OneWay}" />
</Border>
<TextBlock Theme="{StaticResource TitleTextBlockStyle}"
@@ -5,7 +5,6 @@ using Artemis.UI.Screens.Workshop.Parameters;
using Artemis.UI.Shared;
using Artemis.UI.Shared.Routing;
using Artemis.WebClient.Workshop;
using Artemis.WebClient.Workshop.Services;
using Avalonia.Media.Imaging;
using StrawberryShake;
@@ -14,14 +13,12 @@ namespace Artemis.UI.Screens.Workshop.Profile;
public class ProfileDetailsViewModel : RoutableScreen<ActivatableViewModelBase, WorkshopDetailParameters>, IWorkshopViewModel
{
private readonly IWorkshopClient _client;
private readonly IWorkshopService _workshopService;
private IGetEntryById_Entry? _entry;
private Bitmap? _entryIcon;
public ProfileDetailsViewModel(IWorkshopClient client, IWorkshopService workshopService)
public ProfileDetailsViewModel(IWorkshopClient client)
{
_client = client;
_workshopService = workshopService;
}
public EntryType? EntryType => null;
@@ -29,13 +26,7 @@ public class ProfileDetailsViewModel : RoutableScreen<ActivatableViewModelBase,
public IGetEntryById_Entry? Entry
{
get => _entry;
set => RaiseAndSetIfChanged(ref _entry, value);
}
public Bitmap? EntryIcon
{
get => _entryIcon;
set => RaiseAndSetIfChanged(ref _entryIcon, value);
private set => RaiseAndSetIfChanged(ref _entry, value);
}
public override async Task OnNavigating(WorkshopDetailParameters parameters, NavigationArguments args, CancellationToken cancellationToken)
@@ -48,11 +39,7 @@ public class ProfileDetailsViewModel : RoutableScreen<ActivatableViewModelBase,
IOperationResult<IGetEntryByIdResult> result = await _client.GetEntryById.ExecuteAsync(entryId, cancellationToken);
if (result.IsErrorResult())
return;
Bitmap? oldEntryIcon = EntryIcon;
Entry = result.Data?.Entry;
EntryIcon = await _workshopService.GetEntryIcon(entryId, cancellationToken);
oldEntryIcon?.Dispose();
}
}