diff --git a/src/NexusMods.App.UI/Controls/LoadoutBadge/LoadoutBadge.axaml b/src/NexusMods.App.UI/Controls/LoadoutBadge/LoadoutBadge.axaml index 4fbead8af3..0223dd2c41 100644 --- a/src/NexusMods.App.UI/Controls/LoadoutBadge/LoadoutBadge.axaml +++ b/src/NexusMods.App.UI/Controls/LoadoutBadge/LoadoutBadge.axaml @@ -1,4 +1,4 @@ - - - - + + + - - - - + + + + diff --git a/src/NexusMods.App.UI/Controls/LoadoutCard/ILoadoutCardViewModel.cs b/src/NexusMods.App.UI/Controls/LoadoutCard/ILoadoutCardViewModel.cs index 59a1fbed8c..7c938ae144 100644 --- a/src/NexusMods.App.UI/Controls/LoadoutCard/ILoadoutCardViewModel.cs +++ b/src/NexusMods.App.UI/Controls/LoadoutCard/ILoadoutCardViewModel.cs @@ -1,6 +1,31 @@ +using System.Reactive; +using Avalonia.Media; +using NexusMods.App.UI.Controls.LoadoutBadge; +using ReactiveUI; + namespace NexusMods.App.UI.Controls.LoadoutCard; public interface ILoadoutCardViewModel : IViewModelInterface { + ILoadoutBadgeViewModel LoadoutBadgeViewModel { get; } + + string LoadoutName { get; } + + IImage LoadoutImage { get; } + + bool IsLoadoutApplied { get; } + + string HumanizedLoadoutLastApplyTime { get; } + + string HumanizedLoadoutCreationTime { get; } + + string LoadoutModCount { get; } + + bool IsDeleting { get; } + + ReactiveCommand VisitLoadoutCommand { get; } + + ReactiveCommand CloneLoadoutCommand { get; } + ReactiveCommand DeleteLoadoutCommand { get; } } diff --git a/src/NexusMods.App.UI/Controls/LoadoutCard/LoadoutCardDesignViewModel.cs b/src/NexusMods.App.UI/Controls/LoadoutCard/LoadoutCardDesignViewModel.cs new file mode 100644 index 0000000000..512d6d5fe1 --- /dev/null +++ b/src/NexusMods.App.UI/Controls/LoadoutCard/LoadoutCardDesignViewModel.cs @@ -0,0 +1,42 @@ +using System.Reactive; +using System.Reactive.Disposables; +using System.Reactive.Linq; +using Avalonia.Media; +using Avalonia.Media.Imaging; +using Avalonia.Platform; +using NexusMods.App.UI.Controls.LoadoutBadge; +using ReactiveUI; +using ReactiveUI.Fody.Helpers; + +namespace NexusMods.App.UI.Controls.LoadoutCard; + +public class LoadoutCardDesignViewModel : AViewModel, ILoadoutCardViewModel +{ + public LoadoutCardDesignViewModel() + { + this.WhenActivated(d => + { + // Cycle thorough all the states for preview purposes + Observable.Interval(TimeSpan.FromSeconds(2.5)) + .Subscribe(_ => + { + IsDeleting = !IsDeleting; + }) + .DisposeWith(d); + } + ); + } + + public ILoadoutBadgeViewModel LoadoutBadgeViewModel { get; } = new LoadoutBadgeDesignViewModel(); + public string LoadoutName { get; } = "Loadout B"; + public IImage LoadoutImage { get; } = new Bitmap(AssetLoader.Open(new Uri("avares://NexusMods.App.UI/Assets/DesignTime/cyberpunk_game.png"))); + + public bool IsLoadoutApplied { get; } = true; + public string HumanizedLoadoutLastApplyTime { get; } = "Last applied 2 months ago"; + public string HumanizedLoadoutCreationTime { get; } = "Created 10 months ago"; + public string LoadoutModCount { get; } = "Mods 276"; + [Reactive] public bool IsDeleting { get; private set; } = true; + public ReactiveCommand VisitLoadoutCommand { get; } = ReactiveCommand.Create(() => { }); + public ReactiveCommand CloneLoadoutCommand { get; } = ReactiveCommand.Create(() => { }); + public ReactiveCommand DeleteLoadoutCommand { get; } = ReactiveCommand.Create(() => { }); +} diff --git a/src/NexusMods.App.UI/Controls/LoadoutCard/LoadoutCardView.axaml b/src/NexusMods.App.UI/Controls/LoadoutCard/LoadoutCardView.axaml index 4b9a2833b3..1ca83d52df 100644 --- a/src/NexusMods.App.UI/Controls/LoadoutCard/LoadoutCardView.axaml +++ b/src/NexusMods.App.UI/Controls/LoadoutCard/LoadoutCardView.axaml @@ -7,79 +7,96 @@ xmlns:panels="clr-namespace:Avalonia.Labs.Panels;assembly=Avalonia.Labs.Panels" xmlns:icons="clr-namespace:NexusMods.Icons;assembly=NexusMods.Icons" xmlns:loadoutBadge="clr-namespace:NexusMods.App.UI.Controls.LoadoutBadge" + xmlns:spinner="clr-namespace:NexusMods.App.UI.Controls.Spinner" mc:Ignorable="d" d:DesignWidth="250" d:DesignHeight="400" x:Class="NexusMods.App.UI.Controls.LoadoutCard.LoadoutCardView"> - + - - + + + + - + + - + + + + + + + + + + + + + - - diff --git a/src/NexusMods.App.UI/Controls/LoadoutCard/LoadoutCardView.axaml.cs b/src/NexusMods.App.UI/Controls/LoadoutCard/LoadoutCardView.axaml.cs index e35f7bee06..2d83d3defe 100644 --- a/src/NexusMods.App.UI/Controls/LoadoutCard/LoadoutCardView.axaml.cs +++ b/src/NexusMods.App.UI/Controls/LoadoutCard/LoadoutCardView.axaml.cs @@ -1,4 +1,7 @@ +using System.Reactive.Disposables; +using System.Reactive.Linq; using Avalonia.ReactiveUI; +using ReactiveUI; namespace NexusMods.App.UI.Controls.LoadoutCard; @@ -7,6 +10,89 @@ public partial class LoadoutCardView : ReactiveUserControl + { + // LoadoutBadge + this.OneWayBind(ViewModel, + vm => vm.LoadoutBadgeViewModel, + view => view.LoadoutBadge.ViewModel) + .DisposeWith(d); + + // Game Image + this.OneWayBind(ViewModel, + vm => vm.LoadoutImage, + view => view.GameImage.Source) + .DisposeWith(d); + + // Loadout Name + this.OneWayBind(ViewModel, + vm => vm.LoadoutName, + view => view.LoadoutNameTextBlock.Text) + .DisposeWith(d); + + // Currently applied visibility + this.OneWayBind(ViewModel, + vm => vm.IsLoadoutApplied, + view => view.CurrentlyAppliedFlexPanel.IsVisible) + .DisposeWith(d); + + // Last applied visibility + this.WhenAnyValue(view => view.ViewModel!.IsLoadoutApplied) + .Select(isApplied => !isApplied) + .OnUI() + .BindToView(this, view => view.LastAppliedTimeTextBlock.IsVisible) + .DisposeWith(d); + + // Last applied time + this.OneWayBind(ViewModel, + vm => vm.HumanizedLoadoutLastApplyTime, + view => view.LastAppliedTimeTextBlock.Text) + .DisposeWith(d); + + // Created time + this.OneWayBind(ViewModel, + vm => vm.HumanizedLoadoutCreationTime, + view => view.CreatedTimeTextBlock.Text) + .DisposeWith(d); + + // Mod count + this.OneWayBind(ViewModel, + vm => vm.LoadoutModCount, + view => view.NumberOfModsTextBlock.Text) + .DisposeWith(d); + + // Deleting state + this.WhenAnyValue(view => view.ViewModel!.IsDeleting) + .OnUI() + .Subscribe(isDeleting => + { + IsEnabled = !isDeleting; + OverlayFlexPanel.IsVisible = isDeleting; + CreateCopyButton.IsVisible = !isDeleting; + DeleteButton.IsVisible = !isDeleting; + }) + .DisposeWith(d); + + // Clone loadout command + this.BindCommand(ViewModel, + vm => vm.CloneLoadoutCommand, + view => view.CreateCopyButton) + .DisposeWith(d); + + // Delete loadout command + this.BindCommand(ViewModel, + vm => vm.DeleteLoadoutCommand, + view => view.DeleteButton) + .DisposeWith(d); + + // Visit loadout command + this.BindCommand(ViewModel, + vm => vm.DeleteLoadoutCommand, + view => view.DeleteButton) + .DisposeWith(d); + } + ); } } diff --git a/src/NexusMods.App.UI/NexusMods.App.UI.csproj b/src/NexusMods.App.UI/NexusMods.App.UI.csproj index 5f73e613f6..1f8807b939 100644 --- a/src/NexusMods.App.UI/NexusMods.App.UI.csproj +++ b/src/NexusMods.App.UI/NexusMods.App.UI.csproj @@ -561,6 +561,12 @@ ISettingSectionViewModel.cs + + ILoadoutBadgeViewModel.cs + + + ILoadoutCardViewModel.cs + diff --git a/src/Themes/NexusMods.Themes.NexusFluentDark/Styles/UserControls/LoadoutBadge/LoadoutBadgeStyles.axaml b/src/Themes/NexusMods.Themes.NexusFluentDark/Styles/UserControls/LoadoutBadge/LoadoutBadgeStyles.axaml index ada0406120..16001c3dbf 100644 --- a/src/Themes/NexusMods.Themes.NexusFluentDark/Styles/UserControls/LoadoutBadge/LoadoutBadgeStyles.axaml +++ b/src/Themes/NexusMods.Themes.NexusFluentDark/Styles/UserControls/LoadoutBadge/LoadoutBadgeStyles.axaml @@ -2,12 +2,18 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:loadoutBadge="clr-namespace:NexusMods.App.UI.Controls.LoadoutBadge;assembly=NexusMods.App.UI" xmlns:icons="clr-namespace:NexusMods.Icons;assembly=NexusMods.Icons" - xmlns:spinner="clr-namespace:NexusMods.App.UI.Controls.Spinner;assembly=NexusMods.App.UI"> - + xmlns:spinner="clr-namespace:NexusMods.App.UI.Controls.Spinner;assembly=NexusMods.App.UI" + xmlns:panels="clr-namespace:Avalonia.Labs.Panels;assembly=Avalonia.Labs.Panels"> + - - - + + + + + + + @@ -15,34 +21,33 @@ + + - - - @@ -52,10 +57,6 @@ - @@ -63,10 +64,6 @@ - @@ -77,4 +74,29 @@ + + + + + + + + + + + diff --git a/src/Themes/NexusMods.Themes.NexusFluentDark/Styles/UserControls/LoadoutCards/LoadoutCardStyles.axaml b/src/Themes/NexusMods.Themes.NexusFluentDark/Styles/UserControls/LoadoutCards/LoadoutCardStyles.axaml index 81aa29fa4b..0bda499d5e 100644 --- a/src/Themes/NexusMods.Themes.NexusFluentDark/Styles/UserControls/LoadoutCards/LoadoutCardStyles.axaml +++ b/src/Themes/NexusMods.Themes.NexusFluentDark/Styles/UserControls/LoadoutCards/LoadoutCardStyles.axaml @@ -2,25 +2,39 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:loadoutCard="clr-namespace:NexusMods.App.UI.Controls.LoadoutCard;assembly=NexusMods.App.UI" xmlns:panels="clr-namespace:Avalonia.Labs.Panels;assembly=Avalonia.Labs.Panels" - xmlns:icons="clr-namespace:NexusMods.Icons;assembly=NexusMods.Icons"> + xmlns:icons="clr-namespace:NexusMods.Icons;assembly=NexusMods.Icons" + xmlns:element="clr-namespace:NexusMods.App.UI.Controls.Spinner;assembly=NexusMods.App.UI"> + - - - + + + + + + + + @@ -29,6 +43,21 @@ + + + + - - + + + + +