Workshop list progress

This commit is contained in:
Robert committed 2023-07-14 23:05:44 +02:00
1 parent 2a3fd30313
commit 07d4539add
18 files changed
+258 -145

No files matched your search

@@ -0,0 +1,61 @@
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
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"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="120"
x:Class="Artemis.UI.Screens.Workshop.Entries.EntryListView"
x:DataType="entries1:EntryListViewModel">
<Border Classes="card" MinHeight="120">
<Grid ColumnDefinitions="Auto,*,Auto">
<Border Grid.Column="0"
Cursor="Hand"
CornerRadius="12"
Background="{StaticResource ControlStrokeColorOnAccentDefault}"
VerticalAlignment="Center"
Margin="0 0 10 0"
Width="90"
Height="90"
PointerReleased="InputElement_OnPointerReleased">
<avalonia:MaterialIcon Kind="HandOkay" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Width="80" Height="80"/>
</Border>
<Grid Grid.Column="1" VerticalAlignment="Stretch" RowDefinitions="Auto,*,Auto">
<TextBlock Grid.Row="0" Margin="0 0 0 5" Cursor="Hand" PointerReleased="InputElement_OnPointerReleased">
<Run Classes="h4" 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" FontSize="15" Classes="subtitle" Text="{CompiledBinding Entry.Summary, FallbackValue=Summary}"></TextBlock>
<ItemsControl Grid.Row="2" ItemsSource="{CompiledBinding Entry.Categories}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal" Spacing="8"></StackPanel>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<avalonia:MaterialIcon Kind="{CompiledBinding Icon}" Margin="0 0 3 0"></avalonia:MaterialIcon>
<TextBlock Text="{CompiledBinding Name}" />
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Grid>
<StackPanel Grid.Column="2">
<TextBlock TextAlignment="Right" Text="{CompiledBinding Entry.CreatedAt, StringFormat={}{0:g}, FallbackValue=01-01-1337}" />
<TextBlock TextAlignment="Right">
<avalonia:MaterialIcon Kind="Downloads" />
<Run Classes="h5" Text="{CompiledBinding Entry.Downloads, FallbackValue=0}" />
<Run>downloads</Run>
</TextBlock>
</StackPanel>
</Grid>
</Border>
</UserControl>
@@ -0,0 +1,24 @@
using Avalonia.Controls;
using Avalonia.Input;
using Avalonia.Markup.Xaml;
using Avalonia.ReactiveUI;
namespace Artemis.UI.Screens.Workshop.Entries;
public partial class EntryListView : ReactiveUserControl<EntryListViewModel>
{
public EntryListView()
{
InitializeComponent();
}
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
}
private async void InputElement_OnPointerReleased(object? sender, PointerReleasedEventArgs e)
{
await ViewModel.NavigateToEntry();
}
}
@@ -0,0 +1,37 @@
using System;
using System.Threading.Tasks;
using Artemis.UI.Shared;
using Artemis.UI.Shared.Routing;
using Artemis.WebClient.Workshop;
namespace Artemis.UI.Screens.Workshop.Entries;
public class EntryListViewModel : ViewModelBase
{
private readonly IRouter _router;
public EntryListViewModel(IGetEntries_Entries_Nodes entry, IRouter router)
{
_router = router;
Entry = entry;
}
public IGetEntries_Entries_Nodes Entry { get; }
public async Task NavigateToEntry()
{
switch (Entry.EntryType)
{
case EntryType.Layout:
await _router.Navigate($"workshop/layouts/{Entry.Id}");
break;
case EntryType.Profile:
await _router.Navigate($"workshop/profiles/{Entry.Id}");
break;
case EntryType.Plugin:
break;
default:
throw new ArgumentOutOfRangeException();
}
}
}