mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 11:56:30 +00:00
Workshop Library - Finished basic implementation of installed tab
This commit is contained in:
1 parent
876465cfdb
commit
3d1e53e395
32 files changed
+407
-191
No files matched your search
@@ -10,7 +10,6 @@ using Artemis.UI.Shared.Services;
|
||||
using Artemis.UI.Shared.Services.Builders;
|
||||
using Artemis.UI.Shared.Utilities;
|
||||
using Artemis.WebClient.Workshop;
|
||||
using Artemis.WebClient.Workshop.DownloadHandlers;
|
||||
using ReactiveUI;
|
||||
using StrawberryShake;
|
||||
|
||||
|
||||
@@ -15,8 +15,8 @@ using Artemis.UI.Shared.Services;
|
||||
using Artemis.UI.Shared.Utilities;
|
||||
using Artemis.WebClient.Workshop;
|
||||
using Artemis.WebClient.Workshop.Exceptions;
|
||||
using Artemis.WebClient.Workshop.Handlers.UploadHandlers;
|
||||
using Artemis.WebClient.Workshop.Services;
|
||||
using Artemis.WebClient.Workshop.UploadHandlers;
|
||||
using Avalonia.Media.Imaging;
|
||||
using ReactiveUI;
|
||||
using StrawberryShake;
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
xmlns:tabs="clr-namespace:Artemis.UI.Screens.Workshop.Library.Tabs"
|
||||
xmlns:asyncImageLoader="clr-namespace:AsyncImageLoader;assembly=AsyncImageLoader.Avalonia"
|
||||
xmlns:converters="clr-namespace:Artemis.UI.Converters"
|
||||
xmlns:avalonia="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="Artemis.UI.Screens.Workshop.Library.Tabs.InstalledTabItemView"
|
||||
x:DataType="tabs:InstalledTabItemViewModel">
|
||||
@@ -12,14 +13,14 @@
|
||||
<converters:EntryIconUriConverter x:Key="EntryIconUriConverter" />
|
||||
<converters:DateTimeConverter x:Key="DateTimeConverter" />
|
||||
</UserControl.Resources>
|
||||
<Border Classes="card-condensed"
|
||||
MinHeight="80"
|
||||
<Button MinHeight="65"
|
||||
MaxHeight="110"
|
||||
Padding="12 6"
|
||||
Padding="6"
|
||||
Margin="0 0 0 5"
|
||||
HorizontalAlignment="Stretch">
|
||||
<Grid ColumnDefinitions="Auto,*,Auto">
|
||||
<!-- Icon -->
|
||||
HorizontalAlignment="Stretch"
|
||||
HorizontalContentAlignment="Stretch"
|
||||
Command="{CompiledBinding ViewWorkshopPage}">
|
||||
<Grid ColumnDefinitions="Auto,*,*,*,Auto">
|
||||
<Border Grid.Column="0"
|
||||
CornerRadius="6"
|
||||
VerticalAlignment="Center"
|
||||
@@ -30,24 +31,28 @@
|
||||
<Image Stretch="UniformToFill" asyncImageLoader:ImageLoader.Source="{CompiledBinding InstalledEntry.EntryId, Converter={StaticResource EntryIconUriConverter}, Mode=OneWay}" />
|
||||
</Border>
|
||||
|
||||
<!-- Body -->
|
||||
<Grid Grid.Column="1" VerticalAlignment="Stretch" RowDefinitions="Auto,*,Auto">
|
||||
<TextBlock Grid.Row="0"
|
||||
Classes="h5 no-margin"
|
||||
TextTrimming="CharacterEllipsis"
|
||||
<StackPanel Grid.Column="1" VerticalAlignment="Center">
|
||||
<TextBlock TextTrimming="CharacterEllipsis"
|
||||
Text="{CompiledBinding InstalledEntry.Name, FallbackValue=Title}" />
|
||||
<TextBlock Grid.Row="1"
|
||||
Classes="subtitle"
|
||||
<TextBlock Classes="subtitle"
|
||||
TextWrapping="Wrap"
|
||||
TextTrimming="CharacterEllipsis"
|
||||
Text="{CompiledBinding InstalledEntry.Summary, FallbackValue=Summary}">
|
||||
Text="{CompiledBinding InstalledEntry.Author, FallbackValue=Summary}">
|
||||
</TextBlock>
|
||||
</Grid>
|
||||
|
||||
<!-- Info -->
|
||||
<StackPanel Grid.Column="2" Margin="0 0 4 0">
|
||||
<TextBlock TextAlignment="Right" Text="{CompiledBinding InstalledEntry.InstalledAt, FallbackValue=01-01-1337, Converter={StaticResource DateTimeConverter}}" />
|
||||
</StackPanel>
|
||||
|
||||
<TextBlock Grid.Column="2" VerticalAlignment="Center" Text="{CompiledBinding InstalledEntry.EntryType}"></TextBlock>
|
||||
<TextBlock Grid.Column="3" VerticalAlignment="Center">
|
||||
<Run>Installed</Run>
|
||||
<Run Text="{CompiledBinding InstalledEntry.InstalledAt, FallbackValue=01-01-1337, Converter={StaticResource DateTimeConverter}}" />
|
||||
</TextBlock>
|
||||
|
||||
<StackPanel Grid.Column="4" VerticalAlignment="Center" Orientation="Horizontal" Spacing="6">
|
||||
<Button Command="{CompiledBinding ViewLocal}">Open</Button>
|
||||
<Button Command="{CompiledBinding Uninstall}" Theme="{StaticResource TransparentButton}" Height="32">
|
||||
<avalonia:MaterialIcon Kind="Trash"/>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Border>
|
||||
</Button>
|
||||
</UserControl>
|
||||
@@ -1,14 +1,70 @@
|
||||
using System;
|
||||
using System.Reactive;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Artemis.UI.Shared;
|
||||
using Artemis.UI.Shared.Routing;
|
||||
using Artemis.UI.Shared.Services;
|
||||
using Artemis.WebClient.Workshop;
|
||||
using Artemis.WebClient.Workshop.Handlers.InstallationHandlers;
|
||||
using Artemis.WebClient.Workshop.Services;
|
||||
using ReactiveUI;
|
||||
|
||||
namespace Artemis.UI.Screens.Workshop.Library.Tabs;
|
||||
|
||||
public class InstalledTabItemViewModel : ViewModelBase
|
||||
{
|
||||
public InstalledTabItemViewModel(InstalledEntry installedEntry)
|
||||
private readonly IWorkshopService _workshopService;
|
||||
private readonly IRouter _router;
|
||||
private readonly EntryInstallationHandlerFactory _factory;
|
||||
private readonly IWindowService _windowService;
|
||||
private bool _isRemoved;
|
||||
|
||||
public InstalledTabItemViewModel(InstalledEntry installedEntry, IWorkshopService workshopService, IRouter router, EntryInstallationHandlerFactory factory, IWindowService windowService)
|
||||
{
|
||||
_workshopService = workshopService;
|
||||
_router = router;
|
||||
_factory = factory;
|
||||
_windowService = windowService;
|
||||
InstalledEntry = installedEntry;
|
||||
|
||||
ViewWorkshopPage = ReactiveCommand.CreateFromTask(ExecuteViewWorkshopPage);
|
||||
ViewLocal = ReactiveCommand.CreateFromTask(ExecuteViewLocal);
|
||||
Uninstall = ReactiveCommand.CreateFromTask(ExecuteUninstall);
|
||||
}
|
||||
|
||||
public bool IsRemoved
|
||||
{
|
||||
get => _isRemoved;
|
||||
private set => RaiseAndSetIfChanged(ref _isRemoved, value);
|
||||
}
|
||||
|
||||
public InstalledEntry InstalledEntry { get; }
|
||||
public ReactiveCommand<Unit, Unit> ViewWorkshopPage { get; }
|
||||
public ReactiveCommand<Unit,Unit> ViewLocal { get; }
|
||||
public ReactiveCommand<Unit, Unit> Uninstall { get; }
|
||||
|
||||
private async Task ExecuteViewWorkshopPage()
|
||||
{
|
||||
await _workshopService.NavigateToEntry(InstalledEntry.EntryId, InstalledEntry.EntryType);
|
||||
}
|
||||
|
||||
private async Task ExecuteViewLocal(CancellationToken cancellationToken)
|
||||
{
|
||||
if (InstalledEntry.EntryType == EntryType.Profile && Guid.TryParse(InstalledEntry.LocalReference, out Guid profileId))
|
||||
{
|
||||
await _router.Navigate($"profile-editor/{profileId}");
|
||||
}
|
||||
}
|
||||
|
||||
private async Task ExecuteUninstall(CancellationToken cancellationToken)
|
||||
{
|
||||
bool confirmed = await _windowService.ShowConfirmContentDialog("Do you want to uninstall this entry?", "Both the entry and its contents will be removed.");
|
||||
if (!confirmed)
|
||||
return;
|
||||
|
||||
IEntryInstallationHandler handler = _factory.CreateHandler(InstalledEntry.EntryType);
|
||||
await handler.UninstallAsync(InstalledEntry, cancellationToken);
|
||||
IsRemoved = true;
|
||||
}
|
||||
}
|
||||
@@ -6,13 +6,34 @@
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="Artemis.UI.Screens.Workshop.Library.Tabs.InstalledTabView"
|
||||
x:DataType="tabs:InstalledTabViewModel">
|
||||
<ScrollViewer>
|
||||
<ItemsRepeater ItemsSource="{CompiledBinding InstalledEntries}">
|
||||
<ItemsRepeater.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<ContentControl Content="{CompiledBinding}"></ContentControl>
|
||||
</DataTemplate>
|
||||
</ItemsRepeater.ItemTemplate>
|
||||
</ItemsRepeater>
|
||||
</ScrollViewer>
|
||||
<UserControl.Styles>
|
||||
<Styles>
|
||||
<Style Selector="StackPanel.empty-state > TextBlock">
|
||||
<Setter Property="TextAlignment" Value="Center"></Setter>
|
||||
<Setter Property="TextWrapping" Value="Wrap"></Setter>
|
||||
</Style>
|
||||
</Styles>
|
||||
</UserControl.Styles>
|
||||
|
||||
<Panel>
|
||||
<StackPanel IsVisible="{CompiledBinding Empty}" Margin="0 50 0 0" Classes="empty-state">
|
||||
<TextBlock Theme="{StaticResource TitleTextBlockStyle}">Not much here yet, huh!</TextBlock>
|
||||
<TextBlock>
|
||||
<Run>Any entries you download from the workshop you can later manage here</Run>
|
||||
</TextBlock>
|
||||
<Lottie Path="/Assets/Animations/empty.json" RepeatCount="1" Width="350" Height="350"></Lottie>
|
||||
<Button HorizontalAlignment="Center" Command="{CompiledBinding OpenWorkshop}">Browse the Workshop</Button>
|
||||
</StackPanel>
|
||||
|
||||
<ScrollViewer IsVisible="{CompiledBinding !Empty}">
|
||||
<ItemsRepeater ItemsSource="{CompiledBinding InstalledEntries}">
|
||||
<ItemsRepeater.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<ContentControl Content="{CompiledBinding}"/>
|
||||
</DataTemplate>
|
||||
</ItemsRepeater.ItemTemplate>
|
||||
</ItemsRepeater>
|
||||
</ScrollViewer>
|
||||
</Panel>
|
||||
|
||||
</UserControl>
|
||||
@@ -1,10 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Reactive.Disposables;
|
||||
using System.Reactive;
|
||||
using System.Reactive.Linq;
|
||||
using Artemis.UI.Shared.Routing;
|
||||
using Artemis.WebClient.Workshop.Services;
|
||||
using Avalonia.ReactiveUI;
|
||||
using DynamicData;
|
||||
using DynamicData.Binding;
|
||||
using ReactiveUI;
|
||||
@@ -15,27 +15,32 @@ public class InstalledTabViewModel : RoutableScreen
|
||||
{
|
||||
private string? _searchEntryInput;
|
||||
|
||||
public InstalledTabViewModel(IWorkshopService workshopService, Func<InstalledEntry, InstalledTabItemViewModel> getInstalledTabItemViewModel)
|
||||
public InstalledTabViewModel(IWorkshopService workshopService, IRouter router, Func<InstalledEntry, InstalledTabItemViewModel> getInstalledTabItemViewModel)
|
||||
{
|
||||
SourceList<InstalledEntry> installedEntries = new();
|
||||
IObservable<Func<InstalledEntry, bool>> pluginFilter = this.WhenAnyValue(vm => vm.SearchEntryInput).Throttle(TimeSpan.FromMilliseconds(100)).Select(CreatePredicate);
|
||||
|
||||
installedEntries.Connect()
|
||||
.Filter(pluginFilter)
|
||||
.Sort(SortExpressionComparer<InstalledEntry>.Ascending(p => p.Name))
|
||||
.Sort(SortExpressionComparer<InstalledEntry>.Descending(p => p.InstalledAt))
|
||||
.Transform(getInstalledTabItemViewModel)
|
||||
.ObserveOn(AvaloniaScheduler.Instance)
|
||||
.AutoRefresh(vm => vm.IsRemoved)
|
||||
.Filter(vm => !vm.IsRemoved)
|
||||
.Bind(out ReadOnlyObservableCollection<InstalledTabItemViewModel> installedEntryViewModels)
|
||||
.Subscribe();
|
||||
|
||||
List<InstalledEntry> entries = workshopService.GetInstalledEntries();
|
||||
installedEntries.AddRange(entries);
|
||||
|
||||
Empty = entries.Count == 0;
|
||||
InstalledEntries = installedEntryViewModels;
|
||||
|
||||
this.WhenActivated(d =>
|
||||
{
|
||||
installedEntries.AddRange(workshopService.GetInstalledEntries());
|
||||
Disposable.Create(installedEntries, e => e.Clear()).DisposeWith(d);
|
||||
});
|
||||
OpenWorkshop = ReactiveCommand.CreateFromTask(async () => await router.Navigate("workshop"));
|
||||
}
|
||||
|
||||
public bool Empty { get; }
|
||||
public ReactiveCommand<Unit, Unit> OpenWorkshop { get; }
|
||||
|
||||
public ReadOnlyObservableCollection<InstalledTabItemViewModel> InstalledEntries { get; }
|
||||
|
||||
public string? SearchEntryInput
|
||||
@@ -49,7 +54,6 @@ public class InstalledTabViewModel : RoutableScreen
|
||||
if (string.IsNullOrWhiteSpace(text))
|
||||
return _ => true;
|
||||
|
||||
return data => data.Name.Contains(text, StringComparison.InvariantCultureIgnoreCase) ||
|
||||
data.Summary.Contains(text, StringComparison.InvariantCultureIgnoreCase);
|
||||
return data => data.Name.Contains(text, StringComparison.InvariantCultureIgnoreCase);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
<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:tabs="clr-namespace:Artemis.UI.Screens.Workshop.Library.Tabs"
|
||||
xmlns:asyncImageLoader="clr-namespace:AsyncImageLoader;assembly=AsyncImageLoader.Avalonia"
|
||||
xmlns:avalonia1="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia"
|
||||
xmlns:converters="clr-namespace:Artemis.UI.Converters"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="Artemis.UI.Screens.Workshop.Library.Tabs.SubmissionsTabItemView"
|
||||
x:DataType="tabs:SubmissionsTabItemViewModel">
|
||||
<UserControl.Resources>
|
||||
<converters:EntryIconUriConverter x:Key="EntryIconUriConverter" />
|
||||
<converters:DateTimeConverter x:Key="DateTimeConverter" />
|
||||
</UserControl.Resources>
|
||||
<Button MinHeight="80"
|
||||
MaxHeight="110"
|
||||
Padding="12 6"
|
||||
Margin="0 0 0 5"
|
||||
HorizontalAlignment="Stretch"
|
||||
HorizontalContentAlignment="Stretch"
|
||||
Command="{CompiledBinding NavigateToEntry}">
|
||||
<Grid ColumnDefinitions="Auto,*,Auto">
|
||||
<!-- Icon -->
|
||||
<Border Grid.Column="0"
|
||||
CornerRadius="6"
|
||||
VerticalAlignment="Center"
|
||||
Margin="0 0 10 0"
|
||||
Width="50"
|
||||
Height="50"
|
||||
ClipToBounds="True">
|
||||
<Image Stretch="UniformToFill" asyncImageLoader: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"
|
||||
Classes="h5 no-margin"
|
||||
TextTrimming="CharacterEllipsis"
|
||||
Text="{CompiledBinding Entry.Name, FallbackValue=Title}" />
|
||||
<TextBlock Grid.Row="1"
|
||||
Classes="subtitle"
|
||||
TextWrapping="Wrap"
|
||||
TextTrimming="CharacterEllipsis"
|
||||
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">
|
||||
<avalonia1:MaterialIcon Kind="{CompiledBinding Icon}" Margin="0 0 3 0"></avalonia1:MaterialIcon>
|
||||
<TextBlock Text="{CompiledBinding Name}" TextTrimming="CharacterEllipsis" />
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
</Grid>
|
||||
|
||||
<!-- Info -->
|
||||
<StackPanel Grid.Column="2" Margin="0 0 4 0">
|
||||
<TextBlock TextAlignment="Right" Text="{CompiledBinding Entry.CreatedAt, FallbackValue=01-01-1337, Converter={StaticResource DateTimeConverter}}" />
|
||||
<TextBlock TextAlignment="Right">
|
||||
<avalonia1:MaterialIcon Kind="Downloads" />
|
||||
<Run Classes="h5" Text="{CompiledBinding Entry.Downloads, FallbackValue=0}" />
|
||||
<Run>downloads</Run>
|
||||
</TextBlock>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Button>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,13 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
|
||||
namespace Artemis.UI.Screens.Workshop.Library.Tabs;
|
||||
|
||||
public partial class SubmissionsTabItemView : UserControl
|
||||
{
|
||||
public SubmissionsTabItemView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
using System.Reactive;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Artemis.UI.Shared;
|
||||
using Artemis.UI.Shared.Routing;
|
||||
using Artemis.WebClient.Workshop;
|
||||
using ReactiveUI;
|
||||
|
||||
namespace Artemis.UI.Screens.Workshop.Library.Tabs;
|
||||
|
||||
public class SubmissionsTabItemViewModel : ViewModelBase
|
||||
{
|
||||
private readonly IRouter _router;
|
||||
|
||||
public SubmissionsTabItemViewModel(IGetSubmittedEntries_SubmittedEntries entry, IRouter router)
|
||||
{
|
||||
_router = router;
|
||||
Entry = entry;
|
||||
|
||||
NavigateToEntry = ReactiveCommand.CreateFromTask(ExecuteNavigateToEntry);
|
||||
}
|
||||
|
||||
public IGetSubmittedEntries_SubmittedEntries Entry { get; }
|
||||
public ReactiveCommand<Unit, Unit> NavigateToEntry { get; }
|
||||
|
||||
private async Task ExecuteNavigateToEntry(CancellationToken cancellationToken)
|
||||
{
|
||||
await _router.Navigate($"workshop/library/submissions/{Entry.Id}");
|
||||
}
|
||||
}
|
||||
@@ -3,17 +3,9 @@
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:tabs="clr-namespace:Artemis.UI.Screens.Workshop.Library.Tabs"
|
||||
xmlns:workshop="clr-namespace:Artemis.WebClient.Workshop;assembly=Artemis.WebClient.Workshop"
|
||||
xmlns:avalonia="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia"
|
||||
xmlns:asyncImageLoader="clr-namespace:AsyncImageLoader;assembly=AsyncImageLoader.Avalonia"
|
||||
xmlns:converters="clr-namespace:Artemis.UI.Converters"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="650"
|
||||
x:Class="Artemis.UI.Screens.Workshop.Library.Tabs.SubmissionsTabView"
|
||||
x:DataType="tabs:SubmissionsTabViewModel">
|
||||
<UserControl.Resources>
|
||||
<converters:EntryIconUriConverter x:Key="EntryIconUriConverter" />
|
||||
<converters:DateTimeConverter x:Key="DateTimeConverter" />
|
||||
</UserControl.Resources>
|
||||
|
||||
<UserControl.Styles>
|
||||
<Styles>
|
||||
@@ -44,71 +36,11 @@
|
||||
<Button HorizontalAlignment="Center" Command="{CompiledBinding AddSubmission}">Submit new entry</Button>
|
||||
</StackPanel>
|
||||
|
||||
<ScrollViewer>
|
||||
<ItemsRepeater IsVisible="{CompiledBinding Entries.Count}" ItemsSource="{CompiledBinding Entries}">
|
||||
<ScrollViewer IsVisible="{CompiledBinding Entries.Count}">
|
||||
<ItemsRepeater ItemsSource="{CompiledBinding Entries}">
|
||||
<ItemsRepeater.ItemTemplate>
|
||||
<DataTemplate DataType="workshop:IGetSubmittedEntries_SubmittedEntries">
|
||||
<Button MinHeight="80"
|
||||
MaxHeight="110"
|
||||
Padding="12 6"
|
||||
Margin="0 0 0 5"
|
||||
HorizontalAlignment="Stretch"
|
||||
HorizontalContentAlignment="Stretch"
|
||||
Command="{Binding $parent[tabs:SubmissionsTabView].DataContext.NavigateToEntry}"
|
||||
CommandParameter="{CompiledBinding}">
|
||||
<Grid ColumnDefinitions="Auto,*,Auto">
|
||||
<!-- Icon -->
|
||||
<Border Grid.Column="0"
|
||||
CornerRadius="6"
|
||||
VerticalAlignment="Center"
|
||||
Margin="0 0 10 0"
|
||||
Width="50"
|
||||
Height="50"
|
||||
ClipToBounds="True">
|
||||
<Image Stretch="UniformToFill" asyncImageLoader:ImageLoader.Source="{CompiledBinding Id, Converter={StaticResource EntryIconUriConverter}, Mode=OneWay}" />
|
||||
</Border>
|
||||
|
||||
<!-- Body -->
|
||||
<Grid Grid.Column="1" VerticalAlignment="Stretch" RowDefinitions="Auto,*,Auto">
|
||||
<TextBlock Grid.Row="0"
|
||||
Classes="h5 no-margin"
|
||||
TextTrimming="CharacterEllipsis"
|
||||
Text="{CompiledBinding Name, FallbackValue=Title}"/>
|
||||
<TextBlock Grid.Row="1"
|
||||
Classes="subtitle"
|
||||
TextWrapping="Wrap"
|
||||
TextTrimming="CharacterEllipsis"
|
||||
Text="{CompiledBinding Summary, FallbackValue=Summary}">
|
||||
</TextBlock>
|
||||
|
||||
<ItemsControl Grid.Row="2" ItemsSource="{CompiledBinding 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}" TextTrimming="CharacterEllipsis" />
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
</Grid>
|
||||
|
||||
<!-- Info -->
|
||||
<StackPanel Grid.Column="2" Margin="0 0 4 0">
|
||||
<TextBlock TextAlignment="Right" Text="{CompiledBinding CreatedAt, FallbackValue=01-01-1337, Converter={StaticResource DateTimeConverter}}" />
|
||||
<TextBlock TextAlignment="Right">
|
||||
<avalonia:MaterialIcon Kind="Downloads" />
|
||||
<Run Classes="h5" Text="{CompiledBinding Downloads, FallbackValue=0}" />
|
||||
<Run>downloads</Run>
|
||||
</TextBlock>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Button>
|
||||
<DataTemplate>
|
||||
<ContentControl Content="{CompiledBinding}"/>
|
||||
</DataTemplate>
|
||||
</ItemsRepeater.ItemTemplate>
|
||||
</ItemsRepeater>
|
||||
|
||||
@@ -21,21 +21,25 @@ public class SubmissionsTabViewModel : RoutableScreen
|
||||
private readonly IWorkshopClient _client;
|
||||
private readonly SourceCache<IGetSubmittedEntries_SubmittedEntries, Guid> _entries;
|
||||
private readonly IWindowService _windowService;
|
||||
private readonly IRouter _router;
|
||||
private bool _isLoading = true;
|
||||
private bool _workshopReachable;
|
||||
|
||||
public SubmissionsTabViewModel(IWorkshopClient client, IAuthenticationService authenticationService, IWindowService windowService, IWorkshopService workshopService, IRouter router)
|
||||
public SubmissionsTabViewModel(IWorkshopClient client,
|
||||
IAuthenticationService authenticationService,
|
||||
IWindowService windowService,
|
||||
IWorkshopService workshopService,
|
||||
Func<IGetSubmittedEntries_SubmittedEntries, SubmissionsTabItemViewModel> getSubmissionsTabItemViewModel)
|
||||
{
|
||||
_client = client;
|
||||
_windowService = windowService;
|
||||
_router = router;
|
||||
_entries = new SourceCache<IGetSubmittedEntries_SubmittedEntries, Guid>(e => e.Id);
|
||||
_entries.Connect().Bind(out ReadOnlyObservableCollection<IGetSubmittedEntries_SubmittedEntries> entries).Subscribe();
|
||||
_entries.Connect()
|
||||
.Transform(getSubmissionsTabItemViewModel)
|
||||
.Bind(out ReadOnlyObservableCollection<SubmissionsTabItemViewModel> entries)
|
||||
.Subscribe();
|
||||
|
||||
AddSubmission = ReactiveCommand.CreateFromTask(ExecuteAddSubmission, this.WhenAnyValue(vm => vm.WorkshopReachable));
|
||||
Login = ReactiveCommand.CreateFromTask(ExecuteLogin, this.WhenAnyValue(vm => vm.WorkshopReachable));
|
||||
NavigateToEntry = ReactiveCommand.CreateFromTask<IGetSubmittedEntries_SubmittedEntries>(ExecuteNavigateToEntry);
|
||||
|
||||
IsLoggedIn = authenticationService.IsLoggedIn;
|
||||
Entries = entries;
|
||||
@@ -53,7 +57,7 @@ public class SubmissionsTabViewModel : RoutableScreen
|
||||
public ReactiveCommand<IGetSubmittedEntries_SubmittedEntries, Unit> NavigateToEntry { get; }
|
||||
|
||||
public IObservable<bool> IsLoggedIn { get; }
|
||||
public ReadOnlyObservableCollection<IGetSubmittedEntries_SubmittedEntries> Entries { get; }
|
||||
public ReadOnlyObservableCollection<SubmissionsTabItemViewModel> Entries { get; }
|
||||
|
||||
public bool WorkshopReachable
|
||||
{
|
||||
@@ -77,12 +81,7 @@ public class SubmissionsTabViewModel : RoutableScreen
|
||||
{
|
||||
await _windowService.ShowDialogAsync<SubmissionWizardViewModel>();
|
||||
}
|
||||
|
||||
private async Task ExecuteNavigateToEntry(IGetSubmittedEntries_SubmittedEntries entry, CancellationToken cancellationToken)
|
||||
{
|
||||
await _router.Navigate($"workshop/library/submissions/{entry.Id}");
|
||||
}
|
||||
|
||||
|
||||
private async Task GetEntries(CancellationToken ct)
|
||||
{
|
||||
IsLoading = true;
|
||||
|
||||
@@ -10,8 +10,8 @@ using Artemis.UI.Shared.Services;
|
||||
using Artemis.UI.Shared.Services.Builders;
|
||||
using Artemis.UI.Shared.Utilities;
|
||||
using Artemis.WebClient.Workshop;
|
||||
using Artemis.WebClient.Workshop.DownloadHandlers;
|
||||
using Artemis.WebClient.Workshop.DownloadHandlers.Implementations;
|
||||
using Artemis.WebClient.Workshop.Handlers.InstallationHandlers;
|
||||
using Artemis.WebClient.Workshop.Handlers.InstallationHandlers.Implementations;
|
||||
using ReactiveUI;
|
||||
using StrawberryShake;
|
||||
|
||||
@@ -70,7 +70,7 @@ public class ProfileDetailsViewModel : RoutableScreen<WorkshopDetailParameters>
|
||||
if (!confirm)
|
||||
return;
|
||||
|
||||
EntryInstallResult<ProfileConfiguration> result = await _installationHandler.InstallProfileAsync(Entry, Entry.LatestRelease.Id, new Progress<StreamProgress>(), cancellationToken);
|
||||
EntryInstallResult result = await _installationHandler.InstallAsync(Entry, Entry.LatestRelease.Id, new Progress<StreamProgress>(), cancellationToken);
|
||||
if (result.IsSuccess)
|
||||
_notificationService.CreateNotification().WithTitle("Profile installed").WithSeverity(NotificationSeverity.Success).Show();
|
||||
else
|
||||
|
||||
@@ -8,8 +8,8 @@ using Artemis.UI.Shared.Services;
|
||||
using Artemis.UI.Shared.Utilities;
|
||||
using Artemis.WebClient.Workshop;
|
||||
using Artemis.WebClient.Workshop.Exceptions;
|
||||
using Artemis.WebClient.Workshop.Handlers.UploadHandlers;
|
||||
using Artemis.WebClient.Workshop.Services;
|
||||
using Artemis.WebClient.Workshop.UploadHandlers;
|
||||
using ReactiveUI;
|
||||
using StrawberryShake;
|
||||
|
||||
|
||||
Reference in new issue
Block a user