mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 11:56:30 +00:00
Workshop list progress
This commit is contained in:
1 parent
2a3fd30313
commit
07d4539add
18 files changed
+258
-145
No files matched your search
@@ -1,39 +0,0 @@
|
||||
<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:profile="clr-namespace:Artemis.UI.Screens.Workshop.Profile"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="120"
|
||||
x:Class="Artemis.UI.Screens.Workshop.Profile.ProfileListEntryView"
|
||||
x:DataType="profile:ProfileListEntryViewModel">
|
||||
<Border Classes="card">
|
||||
<Grid ColumnDefinitions="Auto,*,Auto">
|
||||
<avalonia:MaterialIcon Kind="Abacus" Width="80" Height="80" Margin="0 0 10 0" Grid.Column="0" VerticalAlignment="Center" />
|
||||
<StackPanel Grid.Column="1" VerticalAlignment="Center">
|
||||
<TextBlock Classes="h4 no-margin" Text="{CompiledBinding Entry.Name, FallbackValue=Title}"></TextBlock>
|
||||
<TextBlock Classes="subtitle" Text="{CompiledBinding Entry.Summary, FallbackValue=Summary}"></TextBlock>
|
||||
|
||||
<ItemsControl 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}"></TextBlock>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Column="2">
|
||||
<TextBlock>Downloads</TextBlock>
|
||||
<TextBlock>Last updated</TextBlock>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Border>
|
||||
</UserControl>
|
||||
@@ -1,18 +0,0 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
|
||||
namespace Artemis.UI.Screens.Workshop.Profile;
|
||||
|
||||
public partial class ProfileListEntryView : UserControl
|
||||
{
|
||||
public ProfileListEntryView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
using Artemis.UI.Shared;
|
||||
using Artemis.WebClient.Workshop;
|
||||
|
||||
namespace Artemis.UI.Screens.Workshop.Profile;
|
||||
|
||||
public class ProfileListEntryViewModel : ViewModelBase
|
||||
{
|
||||
public ProfileListEntryViewModel(IGetEntries_Entries_Nodes entry)
|
||||
{
|
||||
Entry = entry;
|
||||
}
|
||||
|
||||
public IGetEntries_Entries_Nodes Entry { get; }
|
||||
}
|
||||
@@ -1,15 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Reactive.Disposables;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Artemis.UI.Screens.Workshop.Categories;
|
||||
using Artemis.UI.Screens.Workshop.Entries;
|
||||
using Artemis.UI.Screens.Workshop.Parameters;
|
||||
using Artemis.UI.Shared;
|
||||
using Artemis.UI.Shared.Routing;
|
||||
using Artemis.WebClient.Workshop;
|
||||
using DynamicData;
|
||||
using DynamicData.Alias;
|
||||
using ReactiveUI;
|
||||
using StrawberryShake;
|
||||
|
||||
@@ -21,21 +24,31 @@ public class ProfileListViewModel : RoutableScreen<ActivatableViewModelBase, Wor
|
||||
private readonly IWorkshopClient _workshopClient;
|
||||
private int _page;
|
||||
|
||||
public ProfileListViewModel(IWorkshopClient workshopClient, CategoriesViewModel categoriesViewModel)
|
||||
public ProfileListViewModel(IWorkshopClient workshopClient, IRouter router, CategoriesViewModel categoriesViewModel)
|
||||
{
|
||||
_workshopClient = workshopClient;
|
||||
CategoriesViewModel = categoriesViewModel;
|
||||
|
||||
_entries = new SourceList<IGetEntries_Entries_Nodes>();
|
||||
_entries.Connect()
|
||||
.Transform(e => new ProfileListEntryViewModel(e))
|
||||
.Bind(out ReadOnlyObservableCollection<ProfileListEntryViewModel> observableEntries)
|
||||
.Transform(e => new EntryListViewModel(e, router))
|
||||
.Bind(out ReadOnlyObservableCollection<EntryListViewModel> observableEntries)
|
||||
.Subscribe();
|
||||
|
||||
this.WhenActivated(d =>
|
||||
{
|
||||
CategoriesViewModel._categories.Connect()
|
||||
.AutoRefresh(c => c.IsSelected)
|
||||
.Filter(e => e.IsSelected)
|
||||
.Select(e => e.Id)
|
||||
.Subscribe(_ => ReactiveCommand.CreateFromTask(GetEntries).Execute().Subscribe())
|
||||
.DisposeWith(d);
|
||||
});
|
||||
Entries = observableEntries;
|
||||
}
|
||||
|
||||
public CategoriesViewModel CategoriesViewModel { get; }
|
||||
public ReadOnlyObservableCollection<ProfileListEntryViewModel> Entries { get; set; }
|
||||
public ReadOnlyObservableCollection<EntryListViewModel> Entries { get; set; }
|
||||
|
||||
public int Page
|
||||
{
|
||||
@@ -64,7 +77,13 @@ public class ProfileListViewModel : RoutableScreen<ActivatableViewModelBase, Wor
|
||||
|
||||
private EntryFilterInput CreateFilter()
|
||||
{
|
||||
return new EntryFilterInput {EntryType = new EntryTypeOperationFilterInput {Eq = WebClient.Workshop.EntryType.Profile}};
|
||||
EntryFilterInput filter = new() {EntryType = new EntryTypeOperationFilterInput {Eq = WebClient.Workshop.EntryType.Profile}};
|
||||
|
||||
List<int?> categories = CategoriesViewModel.Categories.Where(c => c.IsSelected).Select(c => (int?) c.Id).ToList();
|
||||
if (categories.Any())
|
||||
filter.Categories = new ListFilterInputTypeOfCategoryFilterInput {All = new CategoryFilterInput {Id = new IntOperationFilterInput {In = categories}}};
|
||||
|
||||
return filter;
|
||||
}
|
||||
|
||||
public EntryType? EntryType => null;
|
||||
|
||||
Reference in new issue
Block a user