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,17 +3,21 @@
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:avalonia="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia"
|
||||
xmlns:entries="clr-namespace:Artemis.UI.Screens.Workshop.Profile"
|
||||
xmlns:entries1="clr-namespace:Artemis.UI.Screens.Workshop.Entries"
|
||||
xmlns:il="clr-namespace:AsyncImageLoader;assembly=AsyncImageLoader.Avalonia"
|
||||
xmlns:converters="clr-namespace:Artemis.UI.Converters"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="110"
|
||||
x:Class="Artemis.UI.Screens.Workshop.Entries.EntryListView"
|
||||
x:DataType="entries1:EntryListViewModel">
|
||||
<Button MinHeight="110"
|
||||
MaxHeight="140"
|
||||
<UserControl.Resources>
|
||||
<converters:EntryIconUriConverter x:Key="EntryIconUriConverter" />
|
||||
</UserControl.Resources>
|
||||
<Button MinHeight="110"
|
||||
MaxHeight="140"
|
||||
Padding="16"
|
||||
CornerRadius="8"
|
||||
HorizontalAlignment="Stretch"
|
||||
HorizontalContentAlignment="Stretch"
|
||||
HorizontalContentAlignment="Stretch"
|
||||
Command="{CompiledBinding NavigateToEntry}"
|
||||
IsVisible="{CompiledBinding Entry, Converter={x:Static ObjectConverters.IsNotNull}}">
|
||||
<Grid ColumnDefinitions="Auto,*,Auto">
|
||||
@@ -26,24 +30,22 @@
|
||||
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>
|
||||
|
||||
|
||||
<!-- Body -->
|
||||
<Grid Grid.Column="1" VerticalAlignment="Stretch" RowDefinitions="Auto,*,Auto">
|
||||
<TextBlock Grid.Row="0" Margin="0 0 0 5" TextTrimming="CharacterEllipsis" >
|
||||
<TextBlock Grid.Row="0" Margin="0 0 0 5" TextTrimming="CharacterEllipsis">
|
||||
<Run Classes="h5" Text="{CompiledBinding Entry.Name, FallbackValue=Title}" />
|
||||
<Run Classes="subtitle">by</Run>
|
||||
<Run Classes="subtitle" Text="{CompiledBinding Entry.Author, FallbackValue=Author}" />
|
||||
</TextBlock>
|
||||
<TextBlock Grid.Row="1"
|
||||
Classes="subtitle"
|
||||
<TextBlock Grid.Row="1"
|
||||
Classes="subtitle"
|
||||
TextWrapping="Wrap"
|
||||
TextTrimming="CharacterEllipsis"
|
||||
Text="{CompiledBinding Entry.Summary, FallbackValue=Summary}"></TextBlock>
|
||||
TextTrimming="CharacterEllipsis"
|
||||
Text="{CompiledBinding Entry.Summary, FallbackValue=Summary}">
|
||||
</TextBlock>
|
||||
|
||||
<ItemsControl Grid.Row="2" ItemsSource="{CompiledBinding Entry.Categories}">
|
||||
<ItemsControl.ItemsPanel>
|
||||
@@ -61,7 +63,7 @@
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
</Grid>
|
||||
|
||||
|
||||
<!-- Info -->
|
||||
<StackPanel Grid.Column="2">
|
||||
<TextBlock TextAlignment="Right" Text="{CompiledBinding Entry.CreatedAt, StringFormat={}{0:g}, FallbackValue=01-01-1337}" />
|
||||
|
||||
@@ -16,26 +16,16 @@ namespace Artemis.UI.Screens.Workshop.Entries;
|
||||
public class EntryListViewModel : ActivatableViewModelBase
|
||||
{
|
||||
private readonly IRouter _router;
|
||||
private readonly IWorkshopService _workshopService;
|
||||
private ObservableAsPropertyHelper<Bitmap?>? _entryIcon;
|
||||
|
||||
public EntryListViewModel(IGetEntries_Entries_Items entry, IRouter router, IWorkshopService workshopService)
|
||||
public EntryListViewModel(IGetEntries_Entries_Items entry, IRouter router)
|
||||
{
|
||||
_router = router;
|
||||
_workshopService = workshopService;
|
||||
|
||||
Entry = entry;
|
||||
NavigateToEntry = ReactiveCommand.CreateFromTask(ExecuteNavigateToEntry);
|
||||
|
||||
this.WhenActivated(d =>
|
||||
{
|
||||
_entryIcon = Observable.FromAsync(GetIcon).ToProperty(this, vm => vm.EntryIcon);
|
||||
_entryIcon.DisposeWith(d);
|
||||
});
|
||||
}
|
||||
|
||||
public IGetEntries_Entries_Items Entry { get; }
|
||||
public Bitmap? EntryIcon => _entryIcon?.Value;
|
||||
public ReactiveCommand<Unit, Unit> NavigateToEntry { get; }
|
||||
|
||||
private async Task ExecuteNavigateToEntry()
|
||||
@@ -54,12 +44,4 @@ public class EntryListViewModel : ActivatableViewModelBase
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<Bitmap?> GetIcon(CancellationToken cancellationToken)
|
||||
{
|
||||
// Take at least 100ms to allow the UI to load and make the whole thing smooth
|
||||
Task<Bitmap?> iconTask = _workshopService.GetEntryIcon(Entry.Id, cancellationToken);
|
||||
await Task.Delay(100, cancellationToken);
|
||||
return await iconTask;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user