Workshop - Show required plugins on profile pages

Workshop - Show related profiles on plugin pages
This commit is contained in:
RobertBeekman committed 2024-03-03 22:09:10 +01:00
1 parent 36bff3c5f3
commit 9132301dbf
25 files changed
+286 -111

No files matched your search

@@ -10,10 +10,10 @@ namespace Artemis.UI.Screens.Workshop.Entries.Details;
public class EntryInfoViewModel : ViewModelBase
{
private readonly INotificationService _notificationService;
public IGetEntryById_Entry Entry { get; }
public IEntryDetails Entry { get; }
public DateTimeOffset? UpdatedAt { get; }
public EntryInfoViewModel(IGetEntryById_Entry entry, INotificationService notificationService)
public EntryInfoViewModel(IEntryDetails entry, INotificationService notificationService)
{
_notificationService = notificationService;
Entry = entry;
@@ -20,7 +20,7 @@ public class EntryReleasesViewModel : ViewModelBase
private readonly IWindowService _windowService;
private readonly INotificationService _notificationService;
public EntryReleasesViewModel(IGetEntryById_Entry entry, EntryInstallationHandlerFactory factory, IWindowService windowService, INotificationService notificationService)
public EntryReleasesViewModel(IEntryDetails entry, EntryInstallationHandlerFactory factory, IWindowService windowService, INotificationService notificationService)
{
_factory = factory;
_windowService = windowService;
@@ -31,7 +31,7 @@ public class EntryReleasesViewModel : ViewModelBase
OnInstallationStarted = Confirm;
}
public IGetEntryById_Entry Entry { get; }
public IEntryDetails Entry { get; }
public ReactiveCommand<Unit, Unit> DownloadLatestRelease { get; }
public Func<IEntryDetails, Task<bool>> OnInstallationStarted { get; set; }
@@ -21,9 +21,11 @@
HorizontalContentAlignment="Stretch"
Command="{CompiledBinding NavigateToEntry}"
IsVisible="{CompiledBinding Entry, Converter={x:Static ObjectConverters.IsNotNull}}">
<Grid ColumnDefinitions="Auto,*,Auto">
<Grid ColumnDefinitions="Auto,*,Auto" RowDefinitions="*, Auto">
<!-- Icon -->
<Border Grid.Column="0"
Grid.Row="0"
Grid.RowSpan="2"
CornerRadius="6"
VerticalAlignment="Center"
Margin="0 0 10 0"
@@ -34,7 +36,7 @@
</Border>
<!-- Body -->
<Grid Grid.Column="1" VerticalAlignment="Stretch" RowDefinitions="Auto,*,Auto">
<Grid Grid.Column="1" Grid.Row="0" Grid.RowSpan="2" VerticalAlignment="Stretch" RowDefinitions="Auto,*,Auto">
<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>
@@ -65,7 +67,7 @@
</Grid>
<!-- Info -->
<StackPanel Grid.Column="2" Margin="0 0 4 0">
<StackPanel Grid.Column="2" Grid.Row="0" Margin="0 0 4 0" HorizontalAlignment="Right">
<TextBlock TextAlignment="Right" Text="{CompiledBinding Entry.CreatedAt, FallbackValue=01-01-1337, Converter={StaticResource DateTimeConverter}}" />
<TextBlock TextAlignment="Right">
<avalonia:MaterialIcon Kind="Downloads" />
@@ -73,6 +75,18 @@
<Run>downloads</Run>
</TextBlock>
</StackPanel>
<!-- Install state -->
<StackPanel Grid.Column="2" Grid.Row="1" Margin="0 0 4 0" HorizontalAlignment="Right" VerticalAlignment="Bottom" IsVisible="{CompiledBinding IsInstalled}">
<TextBlock TextAlignment="Right" IsVisible="{CompiledBinding !UpdateAvailable}">
<avalonia:MaterialIcon Kind="CheckCircle" Foreground="{DynamicResource SystemAccentColorLight1}"/>
<Run>installed</Run>
</TextBlock>
<TextBlock TextAlignment="Right" IsVisible="{CompiledBinding UpdateAvailable}">
<avalonia:MaterialIcon Kind="Update" Foreground="{DynamicResource SystemAccentColorLight1}"/>
<Run>update available</Run>
</TextBlock>
</StackPanel>
</Grid>
</Button>
</UserControl>
@@ -1,26 +1,39 @@
using System;
using System.Reactive;
using System.Reactive.Disposables;
using System.Threading.Tasks;
using Artemis.UI.Shared;
using Artemis.UI.Shared.Routing;
using Artemis.WebClient.Workshop;
using Artemis.WebClient.Workshop.Models;
using Artemis.WebClient.Workshop.Services;
using PropertyChanged.SourceGenerator;
using ReactiveUI;
namespace Artemis.UI.Screens.Workshop.Entries.List;
public class EntryListItemViewModel : ActivatableViewModelBase
public partial class EntryListItemViewModel : ActivatableViewModelBase
{
private readonly IRouter _router;
[Notify] private bool _isInstalled;
[Notify] private bool _updateAvailable;
public EntryListItemViewModel(IGetEntries_Entries_Items entry, IRouter router)
public EntryListItemViewModel(IEntrySummary entry, IRouter router, IWorkshopService workshopService)
{
_router = router;
Entry = entry;
NavigateToEntry = ReactiveCommand.CreateFromTask(ExecuteNavigateToEntry);
this.WhenActivated((CompositeDisposable _) =>
{
InstalledEntry? installedEntry = workshopService.GetInstalledEntry(entry.Id);
IsInstalled = installedEntry != null;
UpdateAvailable = installedEntry != null && installedEntry.ReleaseId != entry.LatestReleaseId;
});
}
public IGetEntries_Entries_Items Entry { get; }
public IEntrySummary Entry { get; }
public ReactiveCommand<Unit, Unit> NavigateToEntry { get; }
private async Task ExecuteNavigateToEntry()
@@ -21,7 +21,7 @@ namespace Artemis.UI.Screens.Workshop.Entries.List;
public abstract partial class EntryListViewModel : RoutableScreen<WorkshopListParameters>
{
private readonly SourceList<IGetEntries_Entries_Items> _entries = new();
private readonly SourceList<IEntrySummary> _entries = new();
private readonly ObservableAsPropertyHelper<bool> _isLoading;
private readonly INotificationService _notificationService;
private readonly string _route;
@@ -37,13 +37,13 @@ public abstract partial class EntryListViewModel : RoutableScreen<WorkshopListPa
CategoriesViewModel categoriesViewModel,
EntryListInputViewModel entryListInputViewModel,
INotificationService notificationService,
Func<IGetEntries_Entries_Items, EntryListItemViewModel> getEntryListViewModel)
Func<IEntrySummary, EntryListItemViewModel> getEntryListViewModel)
{
_route = route;
_workshopClient = workshopClient;
_notificationService = notificationService;
_showPagination = this.WhenAnyValue<EntryListViewModel, int>(vm => vm.TotalPages).Select(t => t > 1).ToProperty(this, vm => vm.ShowPagination);
_isLoading = this.WhenAnyValue<EntryListViewModel, bool, int, int>(vm => vm.Page, vm => vm.LoadedPage, (p, c) => p != c).ToProperty(this, vm => vm.IsLoading);
_showPagination = this.WhenAnyValue(vm => vm.TotalPages).Select(t => t > 1).ToProperty(this, vm => vm.ShowPagination);
_isLoading = this.WhenAnyValue(vm => vm.Page, vm => vm.LoadedPage, (p, c) => p != c).ToProperty(this, vm => vm.IsLoading);
CategoriesViewModel = categoriesViewModel;
InputViewModel = entryListInputViewModel;
@@ -14,7 +14,7 @@ public class LayoutListViewModel : List.EntryListViewModel
CategoriesViewModel categoriesViewModel,
EntryListInputViewModel entryListInputViewModel,
INotificationService notificationService,
Func<IGetEntries_Entries_Items, EntryListItemViewModel> getEntryListViewModel)
Func<IEntrySummary, EntryListItemViewModel> getEntryListViewModel)
: base("workshop/entries/layouts", workshopClient, router, categoriesViewModel, entryListInputViewModel, notificationService, getEntryListViewModel)
{
entryListInputViewModel.SearchWatermark = "Search layouts";
@@ -14,7 +14,7 @@ public class PluginListViewModel : EntryListViewModel
CategoriesViewModel categoriesViewModel,
EntryListInputViewModel entryListInputViewModel,
INotificationService notificationService,
Func<IGetEntries_Entries_Items, EntryListItemViewModel> getEntryListViewModel)
Func<IEntrySummary, EntryListItemViewModel> getEntryListViewModel)
: base("workshop/entries/plugins", workshopClient, router, categoriesViewModel, entryListInputViewModel, notificationService, getEntryListViewModel)
{
entryListInputViewModel.SearchWatermark = "Search plugins";
@@ -14,7 +14,7 @@ public class ProfileListViewModel : List.EntryListViewModel
CategoriesViewModel categoriesViewModel,
EntryListInputViewModel entryListInputViewModel,
INotificationService notificationService,
Func<IGetEntries_Entries_Items, EntryListItemViewModel> getEntryListViewModel)
Func<IEntrySummary, EntryListItemViewModel> getEntryListViewModel)
: base("workshop/entries/profiles", workshopClient, router, categoriesViewModel, entryListInputViewModel, notificationService, getEntryListViewModel)
{
entryListInputViewModel.SearchWatermark = "Search profiles";