Ensure a locker is selected in first load

This commit is contained in:
TheXamlGuy
2024-05-30 20:02:34 +01:00
parent 3643cb21b4
commit 3cc0631079
9 changed files with 49 additions and 17 deletions
+4 -1
View File
@@ -9,6 +9,7 @@ public class AggerateMainViewModelHandler(IPublisher publisher,
{
public Task Handle(AggerateEventArgs<IMainNavigationViewModel> args)
{
bool selected = true;
foreach (IComponentHost locker in lockers.OrderBy(x => x.Services.GetRequiredService<IConfigurationDescriptor<LockerConfiguration>>()
is IConfigurationDescriptor<LockerConfiguration> descriptor ? descriptor.Name : null))
{
@@ -16,10 +17,12 @@ public class AggerateMainViewModelHandler(IPublisher publisher,
{
if (locker.Services.GetRequiredService<IServiceFactory>() is IServiceFactory factory)
{
if (factory.Create<LockerNavigationViewModel>(descriptor.Name) is LockerNavigationViewModel viewModel)
if (factory.Create<LockerNavigationViewModel>(descriptor.Name, selected) is LockerNavigationViewModel viewModel)
{
publisher.Publish(Create.As<IMainNavigationViewModel>(viewModel),
nameof(MainViewModel));
selected = false;
}
}
}
+4 -3
View File
@@ -26,7 +26,8 @@ public partial class ItemViewModel :
private string name;
[ObservableProperty]
private bool test;
private bool fromCategory;
public ItemViewModel(IServiceProvider provider,
IServiceFactory factory,
IMediator mediator,
@@ -36,12 +37,12 @@ public partial class ItemViewModel :
IContentTemplate template,
NamedComponent named,
ItemState state = ItemState.Read,
bool test = false,
bool fromCategory = false,
string name = "",
bool favourite = false,
bool archived = false) : base(provider, factory, mediator, publisher, subscriber, disposer)
{
Test = test;
FromCategory = fromCategory;
Named = $"{named}";
Template = template;
State = state;
+5 -2
View File
@@ -9,7 +9,8 @@ public partial class LockerNavigationViewModel :
INotificationHandler<OpenedEventArgs<Locker>>,
INotificationHandler<ClosedEventArgs<Locker>>,
INotificationHandler<ActivatedEventArgs<Locker>>,
INotificationHandler<DeactivatedEventArgs<Locker>>
INotificationHandler<DeactivatedEventArgs<Locker>>,
ISelectable
{
[ObservableProperty]
private bool activated;
@@ -33,10 +34,12 @@ public partial class LockerNavigationViewModel :
ISubscription subscriber,
IDisposer disposer,
IContentTemplate template,
string name) : base(provider, factory, mediator, publisher, subscriber, disposer)
string name,
bool selected) : base(provider, factory, mediator, publisher, subscriber, disposer)
{
Template = template;
Name = name;
Selected = selected;
}
public IContentTemplate Template { get; set; }