mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 11:56:30 +00:00
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:
1 parent
2a34381926
commit
e21edd0ed6
13 files changed
+75
-223
No files matched your search
@@ -3,9 +3,14 @@
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:search="clr-namespace:Artemis.UI.Screens.Workshop.Search"
|
||||
xmlns:il="clr-namespace:AsyncImageLoader;assembly=AsyncImageLoader.Avalonia"
|
||||
xmlns:converters="clr-namespace:Artemis.UI.Converters"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="80"
|
||||
x:Class="Artemis.UI.Screens.Workshop.Search.SearchResultView"
|
||||
x:DataType="search:SearchResultViewModel">
|
||||
<UserControl.Resources>
|
||||
<converters:EntryIconUriConverter x:Key="EntryIconUriConverter" />
|
||||
</UserControl.Resources>
|
||||
<Grid ColumnDefinitions="Auto,*,Auto" Margin="0 5">
|
||||
<!-- Icon -->
|
||||
<Border Grid.Column="0"
|
||||
@@ -16,16 +21,13 @@
|
||||
Width="50"
|
||||
Height="50"
|
||||
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>
|
||||
|
||||
<!-- Body -->
|
||||
<Grid Grid.Column="1" VerticalAlignment="Stretch" RowDefinitions="Auto,*,Auto">
|
||||
<TextBlock Grid.Row="0" TextTrimming="CharacterEllipsis">
|
||||
<Run Text="{CompiledBinding Entry.Name, FallbackValue=Title}" />
|
||||
<Run Text="{CompiledBinding Entry.Name, FallbackValue=Title}" />
|
||||
<Run Classes="subtitle" FontSize="12">by</Run>
|
||||
<Run Classes="subtitle" FontSize="12" Text="{CompiledBinding Entry.Author, FallbackValue=Author}" />
|
||||
</TextBlock>
|
||||
|
||||
@@ -1,32 +1,14 @@
|
||||
using System.Reactive.Disposables;
|
||||
using System.Reactive.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Artemis.UI.Shared;
|
||||
using Artemis.WebClient.Workshop;
|
||||
using Artemis.WebClient.Workshop.Services;
|
||||
using Avalonia.Media.Imaging;
|
||||
using ReactiveUI;
|
||||
|
||||
namespace Artemis.UI.Screens.Workshop.Search;
|
||||
|
||||
public class SearchResultViewModel : ActivatableViewModelBase
|
||||
{
|
||||
private readonly IWorkshopService _workshopService;
|
||||
private ObservableAsPropertyHelper<Bitmap?>? _entryIcon;
|
||||
|
||||
public SearchResultViewModel(ISearchEntries_SearchEntries entry, IWorkshopService workshopService)
|
||||
public SearchResultViewModel(ISearchEntries_SearchEntries entry)
|
||||
{
|
||||
_workshopService = workshopService;
|
||||
|
||||
Entry = entry;
|
||||
this.WhenActivated(d =>
|
||||
{
|
||||
_entryIcon = Observable.FromAsync(c => _workshopService.GetEntryIcon(Entry.Id, c)).ToProperty(this, vm => vm.EntryIcon);
|
||||
_entryIcon.DisposeWith(d);
|
||||
});
|
||||
}
|
||||
|
||||
public ISearchEntries_SearchEntries Entry { get; }
|
||||
public Bitmap? EntryIcon => _entryIcon?.Value;
|
||||
}
|
||||
@@ -19,16 +19,14 @@ public class SearchViewModel : ViewModelBase
|
||||
private readonly ILogger _logger;
|
||||
private readonly IRouter _router;
|
||||
private readonly IWorkshopClient _workshopClient;
|
||||
private readonly IWorkshopService _workshopService;
|
||||
private EntryType? _entryType;
|
||||
private bool _isLoading;
|
||||
private SearchResultViewModel? _selectedEntry;
|
||||
|
||||
public SearchViewModel(ILogger logger, IWorkshopClient workshopClient, IWorkshopService workshopService, IRouter router, CurrentUserViewModel currentUserViewModel)
|
||||
public SearchViewModel(ILogger logger, IWorkshopClient workshopClient, IRouter router, CurrentUserViewModel currentUserViewModel)
|
||||
{
|
||||
_logger = logger;
|
||||
_workshopClient = workshopClient;
|
||||
_workshopService = workshopService;
|
||||
_router = router;
|
||||
CurrentUserViewModel = currentUserViewModel;
|
||||
SearchAsync = ExecuteSearchAsync;
|
||||
@@ -79,7 +77,7 @@ public class SearchViewModel : ViewModelBase
|
||||
|
||||
IsLoading = true;
|
||||
IOperationResult<ISearchEntriesResult> results = await _workshopClient.SearchEntries.ExecuteAsync(input, EntryType, cancellationToken);
|
||||
return results.Data?.SearchEntries.Select(e => new SearchResultViewModel(e, _workshopService) as object) ?? new List<object>();
|
||||
return results.Data?.SearchEntries.Select(e => new SearchResultViewModel(e) as object) ?? new List<object>();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user