Skip to content

Commit

Permalink
more highlighting
Browse files Browse the repository at this point in the history
  • Loading branch information
erri120 committed Sep 6, 2023
1 parent 8c73618 commit c328032
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System.Reactive;
using System.Reactive.Disposables;
using System.Reactive.Linq;
using NexusMods.App.UI;
using NexusMods.Common.GuidedInstaller;
using NexusMods.Common.GuidedInstaller.ValueObjects;
Expand All @@ -25,7 +27,19 @@ public GuidedInstallerStepDesignViewModel()
Groups = step.Groups
.Select(group => (IGuidedInstallerGroupViewModel)new GuidedInstallerGroupDesignViewModel(group))
.ToArray();
HighlightedOption = step.Groups[0].Options[0];

this.WhenActivated(disposables =>
{
Groups
.Select(groupVM => groupVM
.WhenAnyValue(x => x.HighlightedOption))
.CombineLatest()
.SubscribeWithErrorLogging(logger: default, options =>
{
HighlightedOption = options.FirstOrDefault();
})
.DisposeWith(disposables);
});
}

private static GuidedInstallationStep SetupInstallationStep()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Reactive.Disposables;
using Avalonia.ReactiveUI;
using NexusMods.App.UI;
using ReactiveUI;

namespace NexusMods.Games.FOMOD.UI;
Expand All @@ -15,7 +16,11 @@ public GuidedInstallerStepView()
this.OneWayBind(ViewModel, vm => vm.InstallationStep!.Name, view => view.StepName.Text)
.DisposeWith(disposables);
this.OneWayBind(ViewModel, vm => vm.HighlightedOption!.Description, view => view.HighlightedOptionDescription.Text)
this.WhenAnyValue(x => x.ViewModel!.HighlightedOption)
.SubscribeWithErrorLogging(logger: default, option =>
{
HighlightedOptionDescription.Text = option?.Description ?? string.Empty;
})
.DisposeWith(disposables);
this.OneWayBind(ViewModel, vm => vm.Groups, view => view.GroupItemsControl.ItemsSource)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,64 @@ public GuidedInstallerStepViewModel(ILogger<GuidedInstallerStepViewModel> logger
.ToArray();
})
.DisposeWith(disposables);
this.WhenAnyValue(x => x.Groups)
.Where(x => x.Length != 0)
.Select(groupVMs => groupVMs
.Select(groupVM => groupVM
.WhenAnyValue(x => x.HighlightedOption)
)
.CombineLatest()
)
.SubscribeWithErrorLogging(logger: default, observable =>
{
// TODO: clean this up
observable
.SubscribeWithErrorLogging(logger: default, options =>
{
HighlightedOption = options.FirstOrDefault();
})
.DisposeWith(disposables);
})
.DisposeWith(disposables);
// Groups
// .Select(groupVM => groupVM
// .WhenAnyValue(x => x.HighlightedOption)
// )
// .CombineLatest()
// // .SelectMany(x => x)
// .SubscribeWithErrorLogging(logger: default, options =>
// {
// HighlightedOption = options.FirstOrDefault(x => x is not null);
// })
// .DisposeWith(disposables);
// Groups
// .Select(groupVM => groupVM
// .WhenAnyValue(x => x.HighlightedOption)
// .Select(x => (groupVM, option: x))
// )
// .CombineLatest()
// .SubscribeWithErrorLogging(logger: default, options =>
// {
// var previousOption = HighlightedOption;
// if (previousOption is null)
// {
// HighlightedOption = options
// .Select(x => x.option)
// .FirstOrDefault(x => x is not null);
// return;
// }
//
// var highlightedOptions = options
// .Where(x => x.option is not null)
// .Select(x => x)
// .ToArray();
//
//
// })
// .DisposeWith(disposables);
});
}
}

0 comments on commit c328032

Please sign in to comment.