From d231ddd4da4343c0cef017a1f4e95f87bc4eb641 Mon Sep 17 00:00:00 2001 From: erri120 Date: Mon, 14 Oct 2024 15:19:26 +0200 Subject: [PATCH 1/3] Update collection card --- .../CollectionCardDesignViewModel.cs | 2 + .../Collections/CollectionCardView.axaml | 5 +- .../Collections/CollectionCardView.axaml.cs | 72 ++++++++----------- .../Collections/CollectionCardViewModel.cs | 24 +++++++ .../Collections/CollectionsViewModel.cs | 2 +- .../Collections/ICollectionCardViewModel.cs | 3 + 6 files changed, 64 insertions(+), 44 deletions(-) diff --git a/src/NexusMods.App.UI/Pages/LibraryPage/Collections/CollectionCardDesignViewModel.cs b/src/NexusMods.App.UI/Pages/LibraryPage/Collections/CollectionCardDesignViewModel.cs index 65935a0e93..867ef6631d 100644 --- a/src/NexusMods.App.UI/Pages/LibraryPage/Collections/CollectionCardDesignViewModel.cs +++ b/src/NexusMods.App.UI/Pages/LibraryPage/Collections/CollectionCardDesignViewModel.cs @@ -1,6 +1,7 @@ using Avalonia.Media.Imaging; using Avalonia.Platform; using NexusMods.Abstractions.Jobs; +using NexusMods.App.UI.Controls.Navigation; using NexusMods.Paths; namespace NexusMods.App.UI.Pages.LibraryPage.Collections; @@ -18,4 +19,5 @@ public class CollectionCardDesignViewModel : AViewModel Percent.CreateClamped(0.84); public string AuthorName => "FantasyAuthor"; public Bitmap AuthorAvatar => new(AssetLoader.Open(new Uri("avares://NexusMods.App.UI/Assets/DesignTime/avatar.webp"))); + public R3.ReactiveCommand OpenCollectionDownloadPageCommand { get; } = new(canExecuteSource: R3.Observable.Return(false), initialCanExecute: false); } diff --git a/src/NexusMods.App.UI/Pages/LibraryPage/Collections/CollectionCardView.axaml b/src/NexusMods.App.UI/Pages/LibraryPage/Collections/CollectionCardView.axaml index 8a0d157560..1d50721d17 100644 --- a/src/NexusMods.App.UI/Pages/LibraryPage/Collections/CollectionCardView.axaml +++ b/src/NexusMods.App.UI/Pages/LibraryPage/Collections/CollectionCardView.axaml @@ -8,6 +8,7 @@ xmlns:collections="clr-namespace:NexusMods.App.UI.Pages.LibraryPage.Collections" xmlns:panels="clr-namespace:Avalonia.Labs.Panels;assembly=Avalonia.Labs.Panels" xmlns:icons="clr-namespace:NexusMods.Icons;assembly=NexusMods.Icons" + xmlns:navigation="clr-namespace:NexusMods.App.UI.Controls.Navigation" mc:Ignorable="d" d:DesignWidth="508" d:DesignHeight="288" x:Class="NexusMods.App.UI.Pages.LibraryPage.Collections.CollectionCardView"> @@ -67,13 +68,13 @@ - + diff --git a/src/NexusMods.App.UI/Pages/LibraryPage/Collections/CollectionCardView.axaml.cs b/src/NexusMods.App.UI/Pages/LibraryPage/Collections/CollectionCardView.axaml.cs index 5c16955913..7fbbd93964 100644 --- a/src/NexusMods.App.UI/Pages/LibraryPage/Collections/CollectionCardView.axaml.cs +++ b/src/NexusMods.App.UI/Pages/LibraryPage/Collections/CollectionCardView.axaml.cs @@ -15,53 +15,43 @@ public CollectionCardView() InitializeComponent(); this.WhenActivated(d => - { - - this.WhenAnyValue(view => view.ViewModel!.Name) - .BindTo(this, view => view.TitleText.Text) - .DisposeWith(d); - - - this.WhenAnyValue(view => view.ViewModel!.Image) - .BindTo(this, view => view.TileImage.Source) - .DisposeWith(d); - - this.WhenAnyValue(view => view.ViewModel!.Category) - .BindTo(this, view => view.CategoryText.Text) - .DisposeWith(d); - - this.WhenAnyValue(view => view.ViewModel!.Summary) - .BindTo(this, view => view.SummaryText.Text) - .DisposeWith(d); - this.WhenAnyValue(view => view.ViewModel!.ModCount) - .BindTo(this, view => view.ModCount.Text) - .DisposeWith(d); + { + this.OneWayBind(ViewModel, vm => vm.Name, view => view.TitleText.Text) + .DisposeWith(d); - this.WhenAnyValue(view => view.ViewModel!.EndorsementCount) - .BindTo(this, view => view.Endorsements.Text) - .DisposeWith(d); + this.OneWayBind(ViewModel, vm => vm.Image, view => view.TileImage.Source) + .DisposeWith(d); - this.WhenAnyValue(view => view.ViewModel!.DownloadCount) - .BindTo(this, view => view.Downloads.Text) - .DisposeWith(d); + this.OneWayBind(ViewModel, vm => vm.Category, view => view.CategoryText.Text) + .DisposeWith(d); - this.WhenAnyValue(view => view.ViewModel!.TotalSize) - .BindTo(this, view => view.TotalSize.Text) - .DisposeWith(d); + this.OneWayBind(ViewModel, vm => vm.Summary, view => view.SummaryText.Text) + .DisposeWith(d); - this.WhenAnyValue(view => view.ViewModel!.OverallRating) - .BindTo(this, view => view.OverallRating.Text) - .DisposeWith(d); + this.OneWayBind(ViewModel, vm => vm.ModCount, view => view.ModCount.Text) + .DisposeWith(d); - this.WhenAnyValue(view => view.ViewModel!.AuthorName) - .BindTo(this, view => view.AuthorName.Text) - .DisposeWith(d); + this.OneWayBind(ViewModel, vm => vm.EndorsementCount, view => view.Endorsements.Text) + .DisposeWith(d); - this.WhenAnyValue(view => view.ViewModel!.AuthorAvatar) - .BindTo(this, view => view.AuthorAvatarImage.Source) - .DisposeWith(d); - } - ); + this.OneWayBind(ViewModel, vm => vm.DownloadCount, view => view.Downloads.Text) + .DisposeWith(d); + + this.OneWayBind(ViewModel, vm => vm.TotalSize, view => view.TotalSize.Text) + .DisposeWith(d); + + this.OneWayBind(ViewModel, vm => vm.OverallRating, view => view.OverallRating.Text) + .DisposeWith(d); + + this.OneWayBind(ViewModel, vm => vm.AuthorName, view => view.AuthorName.Text) + .DisposeWith(d); + + this.OneWayBind(ViewModel, vm => vm.AuthorAvatar, view => view.AuthorAvatarImage.Source) + .DisposeWith(d); + + this.BindCommand(ViewModel, vm => vm.OpenCollectionDownloadPageCommand, view => view.DownloadButton) + .DisposeWith(d); + }); } } diff --git a/src/NexusMods.App.UI/Pages/LibraryPage/Collections/CollectionCardViewModel.cs b/src/NexusMods.App.UI/Pages/LibraryPage/Collections/CollectionCardViewModel.cs index b8b0278919..5ac1d283c3 100644 --- a/src/NexusMods.App.UI/Pages/LibraryPage/Collections/CollectionCardViewModel.cs +++ b/src/NexusMods.App.UI/Pages/LibraryPage/Collections/CollectionCardViewModel.cs @@ -3,6 +3,10 @@ using NexusMods.Abstractions.NexusModsLibrary.Models; using NexusMods.Abstractions.NexusWebApi.Types; using NexusMods.Abstractions.Resources; +using NexusMods.App.UI.Controls.Navigation; +using NexusMods.App.UI.Pages.CollectionDownload; +using NexusMods.App.UI.Windows; +using NexusMods.App.UI.WorkspaceSystem; using NexusMods.MnemonicDB.Abstractions; using NexusMods.Paths; using R3; @@ -18,12 +22,31 @@ public class CollectionCardViewModel : AViewModel, ICo public CollectionCardViewModel( IResourceLoader tileImagePipeline, + IWindowManager windowManager, + WorkspaceId workspaceId, IConnection connection, RevisionId revision) { _revision = CollectionRevisionMetadata.FindByRevisionId(connection.Db, revision).First(); _collection = _revision.Collection; + var workspaceController = windowManager.ActiveWorkspaceController; + + OpenCollectionDownloadPageCommand = new ReactiveCommand(execute: info => + { + var page = new PageData + { + Context = new CollectionDownloadPageContext + { + CollectionRevisionMetadataId = _revision, + }, + FactoryId = CollectionDownloadPageFactory.StaticId, + }; + + var behavior = workspaceController.GetOpenPageBehavior(page, info); + workspaceController.OpenPage(workspaceId, page, behavior); + }); + this.WhenActivated(disposables => { Observable @@ -48,4 +71,5 @@ public CollectionCardViewModel( public Percent OverallRating => Percent.CreateClamped(_revision.OverallRating); public string AuthorName => _collection.Author.Name; public Bitmap AuthorAvatar => new(new MemoryStream(_collection.Author.AvatarImage.ToArray())); + public ReactiveCommand OpenCollectionDownloadPageCommand { get; } } diff --git a/src/NexusMods.App.UI/Pages/LibraryPage/Collections/CollectionsViewModel.cs b/src/NexusMods.App.UI/Pages/LibraryPage/Collections/CollectionsViewModel.cs index ca2e50697b..3a94835535 100644 --- a/src/NexusMods.App.UI/Pages/LibraryPage/Collections/CollectionsViewModel.cs +++ b/src/NexusMods.App.UI/Pages/LibraryPage/Collections/CollectionsViewModel.cs @@ -31,7 +31,7 @@ public CollectionsViewModel( var tileImagePipeline = ImagePipelines.GetCollectionTileImagePipeline(serviceProvider); CollectionMetadata.ObserveAll(conn) - .Transform(ICollectionCardViewModel (coll) => new CollectionCardViewModel(tileImagePipeline, conn, coll.Revisions.First().RevisionId)) + .Transform(ICollectionCardViewModel (coll) => new CollectionCardViewModel(tileImagePipeline, WindowManager, WorkspaceId, conn, coll.Revisions.First().RevisionId)) .Bind(out _collections) .Subscribe() .DisposeWith(d); diff --git a/src/NexusMods.App.UI/Pages/LibraryPage/Collections/ICollectionCardViewModel.cs b/src/NexusMods.App.UI/Pages/LibraryPage/Collections/ICollectionCardViewModel.cs index 683e87780e..7f4ff58e16 100644 --- a/src/NexusMods.App.UI/Pages/LibraryPage/Collections/ICollectionCardViewModel.cs +++ b/src/NexusMods.App.UI/Pages/LibraryPage/Collections/ICollectionCardViewModel.cs @@ -1,5 +1,6 @@ using Avalonia.Media.Imaging; using NexusMods.Abstractions.Jobs; +using NexusMods.App.UI.Controls.Navigation; using NexusMods.Paths; namespace NexusMods.App.UI.Pages.LibraryPage.Collections; @@ -63,4 +64,6 @@ public interface ICollectionCardViewModel : IViewModelInterface /// The author's avatar. /// public Bitmap AuthorAvatar { get; } + + R3.ReactiveCommand OpenCollectionDownloadPageCommand { get; } } From bbf67d1eda07440c33df3a872aea779d010b9637 Mon Sep 17 00:00:00 2001 From: erri120 Date: Mon, 14 Oct 2024 15:36:50 +0200 Subject: [PATCH 2/3] Add collection download page --- src/NexusMods.App.UI/Assets/black-box.png | Bin 0 -> 530 bytes src/NexusMods.App.UI/ImagePipelines.cs | 13 ++- .../CollectionDownloadDesignViewModel.cs | 12 +-- .../CollectionDownloadPage.cs | 41 ++++++++++ .../CollectionDownloadViewModel.cs | 77 ++++++++++++++++++ .../ICollectionDownloadViewModel.cs | 11 +-- .../Collections/CollectionCardViewModel.cs | 6 +- src/NexusMods.App.UI/Services.cs | 5 ++ src/NexusMods.App.UI/TypeFinder.cs | 2 + .../WorkspaceSystem/Panel/PanelViewModel.cs | 12 ++- 10 files changed, 162 insertions(+), 17 deletions(-) create mode 100644 src/NexusMods.App.UI/Assets/black-box.png create mode 100644 src/NexusMods.App.UI/Pages/CollectionDownload/CollectionDownloadPage.cs create mode 100644 src/NexusMods.App.UI/Pages/CollectionDownload/CollectionDownloadViewModel.cs diff --git a/src/NexusMods.App.UI/Assets/black-box.png b/src/NexusMods.App.UI/Assets/black-box.png new file mode 100644 index 0000000000000000000000000000000000000000..a4d5e02e87fd9138b5b164f2bd3b7e4779519eb7 GIT binary patch literal 530 zcmeAS@N?(olHy`uVBq!ia0vp^DImxlq%tsQ zOst(~>v7mY=4gEM(kLz2Hwzw3SZH z*A(1)v?lEJnp*#VhYB2{BcEBF4P3IJL$yOdVR0YVstp3mLzR!Zw0)Z__fPP+{v>a; zaMm6f?iG%$PktQy|Db$(T4B~DUoQ2=d*ZkMNia9UI+;ApA)#?)AI3_ov_b`7JT>5 CreateObservable(EntityId input, IResourceLoader pipeline) + { + return Observable + .Return(input) + .ObserveOnThreadPool() + .SelectAwait(async (id, cancellationToken) => await pipeline.LoadResourceAsync(id, cancellationToken), configureAwait: false) + .Select(static resource => resource.Data); + } public static IServiceCollection AddImagePipelines(this IServiceCollection serviceCollection) { @@ -82,7 +93,7 @@ private static IResourceLoader CreateCollectionBackgroundImage ) .Decode(decoderType: DecoderType.Skia) .ToAvaloniaBitmap() - // TODO: .UseFallbackValue() + .UseFallbackValue(CollectionBackgroundFallback) .EntityIdToIdentifier( connection: connection, attribute: CollectionMetadata.BackgroundImageUri diff --git a/src/NexusMods.App.UI/Pages/CollectionDownload/CollectionDownloadDesignViewModel.cs b/src/NexusMods.App.UI/Pages/CollectionDownload/CollectionDownloadDesignViewModel.cs index a1bcba65ee..bc8b7c8e89 100644 --- a/src/NexusMods.App.UI/Pages/CollectionDownload/CollectionDownloadDesignViewModel.cs +++ b/src/NexusMods.App.UI/Pages/CollectionDownload/CollectionDownloadDesignViewModel.cs @@ -2,12 +2,16 @@ using Avalonia.Platform; using NexusMods.Abstractions.Jobs; using NexusMods.Abstractions.NexusWebApi.Types; +using NexusMods.App.UI.Windows; +using NexusMods.App.UI.WorkspaceSystem; using NexusMods.Paths; namespace NexusMods.App.UI.Pages.CollectionDownload; -public class CollectionDownloadDesignViewModel : AViewModel, ICollectionDownloadViewModel +public class CollectionDownloadDesignViewModel : APageViewModel, ICollectionDownloadViewModel { + public CollectionDownloadDesignViewModel() : base(new DesignWindowManager()) { } + public string Name => "Vanilla+ [Quality of Life]"; public CollectionSlug Slug { get; } = CollectionSlug.From("tckf0m"); public RevisionNumber RevisionNumber { get; } = RevisionNumber.From(6); @@ -19,13 +23,11 @@ public class CollectionDownloadDesignViewModel : AViewModel 9; public int RequiredModCount => 7; public int OptionalModCount => 2; - public int EndorsementCount => 248; - public int DownloadCount => 35_123; + public ulong EndorsementCount => 248; + public ulong DownloadCount => 35_123; public Size TotalSize { get; } = Size.From(76_123_456); public Percent OverallRating { get; } = Percent.CreateClamped(0.82); public Bitmap TileImage { get; } = new(AssetLoader.Open(new Uri("avares://NexusMods.App.UI/Assets/DesignTime/collection_tile_image.png"))); - public Bitmap BackgroundImage { get; } = new(AssetLoader.Open(new Uri("avares://NexusMods.App.UI/Assets/DesignTime/header-background.webp"))); - public string CollectionStatusText { get; } = "0 of 9 mods downloaded"; } diff --git a/src/NexusMods.App.UI/Pages/CollectionDownload/CollectionDownloadPage.cs b/src/NexusMods.App.UI/Pages/CollectionDownload/CollectionDownloadPage.cs new file mode 100644 index 0000000000..7a71095ad6 --- /dev/null +++ b/src/NexusMods.App.UI/Pages/CollectionDownload/CollectionDownloadPage.cs @@ -0,0 +1,41 @@ +using JetBrains.Annotations; +using Microsoft.Extensions.DependencyInjection; +using NexusMods.Abstractions.NexusModsLibrary.Models; +using NexusMods.Abstractions.Serialization.Attributes; +using NexusMods.App.UI.WorkspaceSystem; +using NexusMods.MnemonicDB.Abstractions; + +namespace NexusMods.App.UI.Pages.CollectionDownload; + +[JsonName(nameof(CollectionDownloadPageContext))] +public record CollectionDownloadPageContext : IPageFactoryContext +{ + public required CollectionRevisionMetadataId CollectionRevisionMetadataId { get; init; } +} + +[UsedImplicitly] +public class CollectionDownloadPageFactory : APageFactory +{ + public static readonly PageFactoryId StaticId = PageFactoryId.From(Guid.Parse("50790b33-41cb-432e-a877-4730d2b3c13e")); + + private readonly IConnection _connection; + public CollectionDownloadPageFactory(IServiceProvider serviceProvider) : base(serviceProvider) + { + _connection = serviceProvider.GetRequiredService(); + } + + public override PageFactoryId Id => StaticId; + + public override ICollectionDownloadViewModel CreateViewModel(CollectionDownloadPageContext context) + { + var metadata = CollectionRevisionMetadata.Load(_connection.Db, context.CollectionRevisionMetadataId); + if (!metadata.IsValid()) throw new InvalidOperationException($"{nameof(CollectionRevisionMetadata)} is invalid for `{context.CollectionRevisionMetadataId}`"); + + return new CollectionDownloadViewModel( + windowManager: WindowManager, + tileImagePipeline: ImagePipelines.GetCollectionTileImagePipeline(ServiceProvider), + backgroundImagePipeline: ImagePipelines.GetCollectionBackgroundImagePipeline(ServiceProvider), + revisionMetadata: metadata + ); + } +} diff --git a/src/NexusMods.App.UI/Pages/CollectionDownload/CollectionDownloadViewModel.cs b/src/NexusMods.App.UI/Pages/CollectionDownload/CollectionDownloadViewModel.cs new file mode 100644 index 0000000000..5c1c388894 --- /dev/null +++ b/src/NexusMods.App.UI/Pages/CollectionDownload/CollectionDownloadViewModel.cs @@ -0,0 +1,77 @@ +using Avalonia.Media.Imaging; +using NexusMods.Abstractions.Jobs; +using NexusMods.Abstractions.NexusModsLibrary.Models; +using NexusMods.Abstractions.NexusWebApi.Types; +using NexusMods.Abstractions.Resources; +using NexusMods.App.UI.Windows; +using NexusMods.App.UI.WorkspaceSystem; +using NexusMods.MnemonicDB.Abstractions; +using NexusMods.Paths; +using R3; +using ReactiveUI; +using ReactiveUI.Fody.Helpers; + +namespace NexusMods.App.UI.Pages.CollectionDownload; + +public class CollectionDownloadViewModel : APageViewModel, ICollectionDownloadViewModel +{ + private readonly CollectionRevisionMetadata.ReadOnly _revision; + private readonly CollectionMetadata.ReadOnly _collection; + + public CollectionDownloadViewModel( + IWindowManager windowManager, + IResourceLoader tileImagePipeline, + IResourceLoader backgroundImagePipeline, + CollectionRevisionMetadata.ReadOnly revisionMetadata) : base(windowManager) + { + _revision = revisionMetadata; + _collection = revisionMetadata.Collection; + + // TODO: + CollectionStatusText = "TODO"; + + var requiredModCount = 0; + var optionalModCount = 0; + foreach (var file in _revision.Files) + { + var isOptional = file.IsOptional; + + requiredModCount += isOptional ? 0 : 1; + optionalModCount += isOptional ? 1 : 0; + } + + RequiredModCount = requiredModCount; + OptionalModCount = optionalModCount; + + this.WhenActivated(disposables => + { + ImagePipelines.CreateObservable(_collection.Id, tileImagePipeline) + .ObserveOnUIThreadDispatcher() + .Subscribe(this, static (bitmap, self) => self.TileImage = bitmap) + .AddTo(disposables); + + ImagePipelines.CreateObservable(_collection.Id, backgroundImagePipeline) + .ObserveOnUIThreadDispatcher() + .Subscribe(this, static (bitmap, self) => self.BackgroundImage = bitmap) + .AddTo(disposables); + }); + } + + public string Name => _collection.Name; + public string Summary => _collection.Summary; + public int ModCount => _revision.Files.Count; + public ulong EndorsementCount => _collection.Endorsements; + public ulong DownloadCount => _revision.Downloads; + public Size TotalSize => _revision.TotalSize; + public Percent OverallRating => Percent.CreateClamped(_revision.OverallRating); + public string AuthorName => _collection.Author.Name; + + public CollectionSlug Slug => _collection.Slug; + public RevisionNumber RevisionNumber => _revision.RevisionNumber; + public int RequiredModCount { get; } + public int OptionalModCount { get; } + + [Reactive] public Bitmap? TileImage { get; private set; } + [Reactive] public Bitmap? BackgroundImage { get; private set; } + [Reactive] public string CollectionStatusText { get; private set; } +} diff --git a/src/NexusMods.App.UI/Pages/CollectionDownload/ICollectionDownloadViewModel.cs b/src/NexusMods.App.UI/Pages/CollectionDownload/ICollectionDownloadViewModel.cs index 29782068a1..c272633463 100644 --- a/src/NexusMods.App.UI/Pages/CollectionDownload/ICollectionDownloadViewModel.cs +++ b/src/NexusMods.App.UI/Pages/CollectionDownload/ICollectionDownloadViewModel.cs @@ -1,11 +1,12 @@ using Avalonia.Media.Imaging; using NexusMods.Abstractions.Jobs; using NexusMods.Abstractions.NexusWebApi.Types; +using NexusMods.App.UI.WorkspaceSystem; using NexusMods.Paths; namespace NexusMods.App.UI.Pages.CollectionDownload; -public interface ICollectionDownloadViewModel : IViewModelInterface +public interface ICollectionDownloadViewModel : IPageViewModelInterface { /// /// Name of the collection @@ -50,12 +51,12 @@ public interface ICollectionDownloadViewModel : IViewModelInterface /// /// The number of endorsements the collection has /// - public int EndorsementCount { get; } + public ulong EndorsementCount { get; } /// /// The number of downloads the collection has /// - public int DownloadCount { get; } + public ulong DownloadCount { get; } /// /// The size of the collection including all downloads and the collection file iteself @@ -70,12 +71,12 @@ public interface ICollectionDownloadViewModel : IViewModelInterface /// /// The small tileable image of the collection /// - public Bitmap TileImage { get; } + public Bitmap? TileImage { get; } /// /// The background banner image of the collection /// - public Bitmap BackgroundImage { get; } + public Bitmap? BackgroundImage { get; } /// /// A text representation of the collection's status, such as "Downloading", "Installing", "Ready to Play", etc. diff --git a/src/NexusMods.App.UI/Pages/LibraryPage/Collections/CollectionCardViewModel.cs b/src/NexusMods.App.UI/Pages/LibraryPage/Collections/CollectionCardViewModel.cs index 5ac1d283c3..57e12044ef 100644 --- a/src/NexusMods.App.UI/Pages/LibraryPage/Collections/CollectionCardViewModel.cs +++ b/src/NexusMods.App.UI/Pages/LibraryPage/Collections/CollectionCardViewModel.cs @@ -49,11 +49,7 @@ public CollectionCardViewModel( this.WhenActivated(disposables => { - Observable - .Return(_collection.Id) - .ObserveOnThreadPool() - .SelectAwait(async (id, cancellationToken) => await tileImagePipeline.LoadResourceAsync(id, cancellationToken), configureAwait: false) - .Select(static resource => resource.Data) + ImagePipelines.CreateObservable(_collection.Id, tileImagePipeline) .ObserveOnUIThreadDispatcher() .Subscribe(this, static (bitmap, self) => self.Image = bitmap) .AddTo(disposables); diff --git a/src/NexusMods.App.UI/Services.cs b/src/NexusMods.App.UI/Services.cs index a4c123d75c..05e648b261 100644 --- a/src/NexusMods.App.UI/Services.cs +++ b/src/NexusMods.App.UI/Services.cs @@ -40,6 +40,7 @@ using NexusMods.App.UI.Overlays.Updater; using NexusMods.App.UI.Pages; using NexusMods.App.UI.Pages.Changelog; +using NexusMods.App.UI.Pages.CollectionDownload; using NexusMods.App.UI.Pages.Diagnostics; using NexusMods.App.UI.Pages.Diff.ApplyDiff; using NexusMods.App.UI.Pages.Downloads; @@ -205,6 +206,9 @@ public static IServiceCollection AddUI(this IServiceCollection c) .AddView() .AddView() + .AddView() + .AddViewModel() + // workspace system .AddSingleton() .AddWindowDataAttributesModel() @@ -238,6 +242,7 @@ public static IServiceCollection AddUI(this IServiceCollection c) .AddSingleton() .AddSingleton() .AddSingleton() + .AddSingleton() // LeftMenu factories .AddSingleton() diff --git a/src/NexusMods.App.UI/TypeFinder.cs b/src/NexusMods.App.UI/TypeFinder.cs index f0d4fac9af..83f1fed49f 100644 --- a/src/NexusMods.App.UI/TypeFinder.cs +++ b/src/NexusMods.App.UI/TypeFinder.cs @@ -1,5 +1,6 @@ using NexusMods.Abstractions.Serialization.ExpressionGenerator; using NexusMods.App.UI.Pages.Changelog; +using NexusMods.App.UI.Pages.CollectionDownload; using NexusMods.App.UI.Pages.Diagnostics; using NexusMods.App.UI.Pages.Diff.ApplyDiff; using NexusMods.App.UI.Pages.Downloads; @@ -41,6 +42,7 @@ public IEnumerable DescendentsOf(Type type) typeof(HomeContext), typeof(LoadoutContext), typeof(DownloadsContext), + typeof(CollectionDownloadPageContext), // other typeof(WindowData), diff --git a/src/NexusMods.App.UI/WorkspaceSystem/Panel/PanelViewModel.cs b/src/NexusMods.App.UI/WorkspaceSystem/Panel/PanelViewModel.cs index 5ace5a7280..10c3ff1680 100644 --- a/src/NexusMods.App.UI/WorkspaceSystem/Panel/PanelViewModel.cs +++ b/src/NexusMods.App.UI/WorkspaceSystem/Panel/PanelViewModel.cs @@ -229,7 +229,17 @@ public void FromData(PanelData data) for (uint i = 0; i < data.Tabs.Length; i++) { var tab = data.Tabs[i]; - var newTabPage = _factoryController.Create(tab.PageData, WindowId, WorkspaceId, Id, tabId: tab.Id); + + Page newTabPage; + try + { + newTabPage = _factoryController.Create(tab.PageData, WindowId, WorkspaceId, Id, tabId: tab.Id); + } + catch (Exception) + { + // TODO: logging + continue; + } var vm = new PanelTabViewModel(_workspaceController, WorkspaceId, Id, tab.Id) { From 33720e1e6e3f3b4e8f21e1db2ba19a1188fcbdab Mon Sep 17 00:00:00 2001 From: insomnious Date: Tue, 15 Oct 2024 12:55:15 +0100 Subject: [PATCH 3/3] Re-added styles from a previous branch --- .../CollectionDownloadView.axaml | 48 ++-- .../CollectionDownloadView.axaml.cs | 2 +- .../CollectionCardStyles.axaml | 2 +- .../CollectionDownloadPageStyles.axaml | 236 +++++++++++++----- 4 files changed, 210 insertions(+), 78 deletions(-) diff --git a/src/NexusMods.App.UI/Pages/CollectionDownload/CollectionDownloadView.axaml b/src/NexusMods.App.UI/Pages/CollectionDownload/CollectionDownloadView.axaml index 0fd2a97f08..1649812ce3 100644 --- a/src/NexusMods.App.UI/Pages/CollectionDownload/CollectionDownloadView.axaml +++ b/src/NexusMods.App.UI/Pages/CollectionDownload/CollectionDownloadView.axaml @@ -49,7 +49,7 @@ - + @@ -104,6 +104,7 @@ + @@ -114,26 +115,33 @@ + + + + + Required + + + + + + + TODO: Required mods will appear here + + + + + Optional + + + + + + + TODO: Optional mods will appear here + + - - - - - Required - - - - TODO: Grid of mods will appear here - - - - - Optional - - - - TODO: Grid of mods will appear here - diff --git a/src/NexusMods.App.UI/Pages/CollectionDownload/CollectionDownloadView.axaml.cs b/src/NexusMods.App.UI/Pages/CollectionDownload/CollectionDownloadView.axaml.cs index 9cf1bcf580..cb3df14b62 100644 --- a/src/NexusMods.App.UI/Pages/CollectionDownload/CollectionDownloadView.axaml.cs +++ b/src/NexusMods.App.UI/Pages/CollectionDownload/CollectionDownloadView.axaml.cs @@ -17,7 +17,7 @@ public CollectionDownloadView() // Uncomment this to enable the background image this.WhenAnyValue(view => view.ViewModel!.BackgroundImage) .WhereNotNull() - .SubscribeWithErrorLogging(image => Body.Background = new ImageBrush { Source = image, Stretch = Stretch.UniformToFill}) + .SubscribeWithErrorLogging(image => HeaderBorderBackground.Background = new ImageBrush { Source = image, Stretch = Stretch.UniformToFill, AlignmentY = AlignmentY.Top}) .DisposeWith(d); this.WhenAnyValue(view => view.ViewModel!.TileImage) diff --git a/src/Themes/NexusMods.Themes.NexusFluentDark/Styles/UserControls/CollectionCards/CollectionCardStyles.axaml b/src/Themes/NexusMods.Themes.NexusFluentDark/Styles/UserControls/CollectionCards/CollectionCardStyles.axaml index 2d32f2af4b..7e647d18e3 100644 --- a/src/Themes/NexusMods.Themes.NexusFluentDark/Styles/UserControls/CollectionCards/CollectionCardStyles.axaml +++ b/src/Themes/NexusMods.Themes.NexusFluentDark/Styles/UserControls/CollectionCards/CollectionCardStyles.axaml @@ -2,7 +2,6 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:panels="clr-namespace:Avalonia.Labs.Panels;assembly=Avalonia.Labs.Panels" xmlns:icons="clr-namespace:NexusMods.Icons;assembly=NexusMods.Icons" - xmlns:element="clr-namespace:NexusMods.App.UI.Controls.Spinner;assembly=NexusMods.App.UI" xmlns:collections="clr-namespace:NexusMods.App.UI.Pages.LibraryPage.Collections;assembly=NexusMods.App.UI"> @@ -55,6 +54,7 @@ diff --git a/src/Themes/NexusMods.Themes.NexusFluentDark/Styles/UserControls/CollectionDownloadPage/CollectionDownloadPageStyles.axaml b/src/Themes/NexusMods.Themes.NexusFluentDark/Styles/UserControls/CollectionDownloadPage/CollectionDownloadPageStyles.axaml index 73a21923f5..9d1312d948 100644 --- a/src/Themes/NexusMods.Themes.NexusFluentDark/Styles/UserControls/CollectionDownloadPage/CollectionDownloadPageStyles.axaml +++ b/src/Themes/NexusMods.Themes.NexusFluentDark/Styles/UserControls/CollectionDownloadPage/CollectionDownloadPageStyles.axaml @@ -13,35 +13,41 @@ @@ -82,85 +89,202 @@ - + - + - + + - - + + + + + + + + + + + + + + + + + + + + - + + + + + + - - - - - - - - - + - - + + + + + + + + + + + + +