Fix more edge cases
This commit is contained in:
@@ -110,12 +110,12 @@ public partial class App : Application
|
||||
services.AddTemplate<ItemCategoryCollectionViewModel, ItemCategoryCollectionView>("ItemCategoryCollection");
|
||||
services.AddTemplate<ItemCategoryNavigationViewModel, ItemCategoryNavigationView>();
|
||||
|
||||
services.AddHandler<AggerateItemCategoryViewModelHandler>();
|
||||
services.AddHandler<AggregateItemCategoryViewModelHandler>();
|
||||
|
||||
services.AddTemplate<ItemNavigationViewModel, ItemNavigationView>();
|
||||
services.AddTemplate<ItemViewModel, ItemView>("Item");
|
||||
|
||||
services.AddHandler<AggerateItemContentViewModelHandler>();
|
||||
services.AddHandler<AggregateItemContentViewModelHandler>();
|
||||
|
||||
services.AddTemplate<ItemCommandHeaderViewModel, ItemCommandHeaderView>("ItemCommandHeader");
|
||||
|
||||
@@ -134,8 +134,8 @@ public partial class App : Application
|
||||
|
||||
services.AddScoped<IValueStore<Item<(Guid, string)>>, ValueStore<Item<(Guid, string)>>>();
|
||||
|
||||
services.AddHandler<ConfirmUpdateItemHandler>(nameof(Update));
|
||||
services.AddHandler<ConfirmCreateItemHandler>(nameof(Create));
|
||||
services.AddHandler<ConfirmUpdateItemHandler>(nameof(ItemState.Write));
|
||||
services.AddHandler<ConfirmCreateItemHandler>(nameof(ItemState.New));
|
||||
|
||||
services.AddHandler<ArchiveItemHandler>();
|
||||
services.AddHandler<UnarchiveItemHandler>();
|
||||
@@ -154,7 +154,7 @@ public partial class App : Application
|
||||
services.AddInitializer<LockerInitializer>();
|
||||
|
||||
services.AddTemplate<MainViewModel, MainView>("Main");
|
||||
services.AddHandler<AggerateMainViewModelHandler>();
|
||||
services.AddHandler<AggregateMainViewModelHandler>();
|
||||
|
||||
services.AddTransient<FooterViewModel>();
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
</DataTriggerBehavior>
|
||||
</Interaction.Behaviors>
|
||||
<ListBox
|
||||
x:Name="foo"
|
||||
Margin="2,-1,0,0"
|
||||
AutoScrollToSelectedItem="True"
|
||||
ItemTemplate="{ReflectionBinding Template}"
|
||||
|
||||
@@ -5,6 +5,14 @@ namespace Bitvault.Avalonia;
|
||||
public partial class ItemCollectionView :
|
||||
UserControl
|
||||
{
|
||||
public ItemCollectionView() =>
|
||||
public ItemCollectionView()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
foo.SelectionChanged += Foo_SelectionChanged;
|
||||
}
|
||||
|
||||
private void Foo_SelectionChanged(object? sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<PersonPicture
|
||||
Width="144"
|
||||
Height="144"
|
||||
DisplayName="{Binding Value}" />
|
||||
DisplayName="{Binding Value, UpdateSourceTrigger=PropertyChanged}" />
|
||||
<TextBox
|
||||
MaxWidth="360"
|
||||
Text="{Binding Value}"
|
||||
|
||||
@@ -3,40 +3,23 @@
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:vm="using:Bitvault"
|
||||
x:DataType="vm:ItemNavigationViewModel">
|
||||
x:DataType="vm:ItemNavigationViewModel"
|
||||
ListBoxExtension.IsItemInvokedEnabled="True">
|
||||
<ListBoxItem.Resources>
|
||||
<SolidColorBrush x:Key="StarredIconForegroundBrush" Color="#FFEDB120" />
|
||||
</ListBoxItem.Resources>
|
||||
<Interaction.Behaviors>
|
||||
<AttachedBehaviour>
|
||||
<ConditionAction>
|
||||
<ConditionAction.Condition>
|
||||
<ConditionalExpression ForwardChaining="And">
|
||||
<ComparisonCondition LeftOperand="{Binding Selected}" RightOperand="True" />
|
||||
</ConditionalExpression>
|
||||
</ConditionAction.Condition>
|
||||
<NavigateAction
|
||||
Region="{Binding Named, StringFormat='{}{0}:Content'}"
|
||||
Route="Item"
|
||||
Scope="self">
|
||||
<Parameter Key="State" Value="{x:Static vm:ItemState.Read}" />
|
||||
<Parameter Key="Name" Value="{Binding Name}" />
|
||||
<Parameter Key="Favourite" Value="{Binding Favourite}" />
|
||||
<Parameter Key="Archived" Value="{Binding Archived}" />
|
||||
</NavigateAction>
|
||||
</ConditionAction>
|
||||
</AttachedBehaviour>
|
||||
<DataTriggerBehavior Binding="{Binding Selected}" Value="True">
|
||||
<AttachedEventTriggerBehaviour RoutedEvent="{x:Static ListBoxExtension.ItemInvokedEvent}">
|
||||
<NavigateAction
|
||||
Region="{Binding Named, StringFormat='{}{0}:Content'}"
|
||||
Route="Item"
|
||||
Scope="self">
|
||||
<Parameter Key="Name" Value="{Binding Name}" />
|
||||
<Parameter Key="State" Value="{x:Static vm:ItemState.Read}" />
|
||||
<Parameter Key="Name" Value="{Binding Name}" />
|
||||
<Parameter Key="Favourite" Value="{Binding Favourite}" />
|
||||
<Parameter Key="Archived" Value="{Binding Archived}" />
|
||||
</NavigateAction>
|
||||
</DataTriggerBehavior>
|
||||
</AttachedEventTriggerBehaviour>
|
||||
</Interaction.Behaviors>
|
||||
<Grid Background="Transparent" ColumnDefinitions="Auto,*">
|
||||
<PersonPicture
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
Content="{Binding Name}"
|
||||
IsExpanded="{Binding Expanded}"
|
||||
MenuItemsSource="{Binding}"
|
||||
NavigationViewItemExtension.IsItemClickEnabled="True"
|
||||
NavigationViewExtension.IsItemInvokedEnabled="True"
|
||||
SelectsOnInvoked="True">
|
||||
<Interaction.Behaviors>
|
||||
<DataTriggerBehavior Binding="{Binding Opened}" Value="False">
|
||||
@@ -64,7 +64,7 @@
|
||||
<InvokeNavigationViewItemAction />
|
||||
</ConditionAction>
|
||||
</AttachedBehaviour>
|
||||
<AttachedEventTriggerBehaviour RoutedEvent="{x:Static NavigationViewItemExtension.ItemClickEvent}">
|
||||
<AttachedEventTriggerBehaviour RoutedEvent="{x:Static NavigationViewExtension.ItemInvokedEvent}">
|
||||
<ConditionAction>
|
||||
<ConditionAction.Condition>
|
||||
<ConditionalExpression ForwardChaining="And">
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class AggerateItemCategoryViewModelHandler(IEnumerable<IConfigurationDescriptor<ItemConfiguration>> descriptors,
|
||||
public class AggregateItemCategoryViewModelHandler(IEnumerable<IConfigurationDescriptor<ItemConfiguration>> descriptors,
|
||||
IServiceFactory serviceFactory,
|
||||
IPublisher publisher) :
|
||||
INotificationHandler<AggerateEventArgs<ItemCategoryNavigationViewModel>>
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class AggerateItemContentViewModelHandler(IValueStore<Item<(Guid, string)>> valueStore,
|
||||
public class AggregateItemContentViewModelHandler(IValueStore<Item<(Guid, string)>> valueStore,
|
||||
IMediator mediator,
|
||||
IServiceFactory serviceFactory,
|
||||
IPublisher publisher) :
|
||||
+5
-3
@@ -6,13 +6,15 @@ namespace Bitvault;
|
||||
public class AggerateItemViewModelHandler(IMediator mediator,
|
||||
IServiceProvider serviceProvider,
|
||||
ICache<Item<(Guid, string)>> cache,
|
||||
IPublisher publisher) :
|
||||
INotificationHandler<AggerateEventArgs<ItemNavigationViewModel,
|
||||
IPublisher publisher,
|
||||
LockerViewModelConfiguration dd) :
|
||||
INotificationHandler<AggregateEventArgs<ItemNavigationViewModel,
|
||||
LockerViewModelConfiguration>>
|
||||
{
|
||||
public async Task Handle(AggerateEventArgs<ItemNavigationViewModel,
|
||||
public async Task Handle(AggregateEventArgs<ItemNavigationViewModel,
|
||||
LockerViewModelConfiguration> args)
|
||||
{
|
||||
var ddddd = dd;
|
||||
if (args.Options is LockerViewModelConfiguration configuration)
|
||||
{
|
||||
cache.Clear();
|
||||
+1
-1
@@ -3,7 +3,7 @@ using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class AggerateMainViewModelHandler(IPublisher publisher,
|
||||
public class AggregateMainViewModelHandler(IPublisher publisher,
|
||||
ILockerHostCollection lockers) :
|
||||
INotificationHandler<AggerateEventArgs<IMainNavigationViewModel>>
|
||||
{
|
||||
@@ -1,5 +1,4 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
@@ -13,8 +12,4 @@ public partial class BackActionViewModel(IServiceProvider provider,
|
||||
{
|
||||
[ObservableProperty]
|
||||
private int index = 0;
|
||||
|
||||
[RelayCommand]
|
||||
public void Invoke() => Publisher.Publish(Notify.As(new Search(Value)),
|
||||
nameof(ItemCollectionViewModel));
|
||||
}
|
||||
@@ -13,5 +13,5 @@ public partial class ConfirmItemActionViewModel(IServiceProvider provider,
|
||||
{
|
||||
[RelayCommand]
|
||||
public void Invoke() => Publisher.Publish(Confirm.As<Item>(),
|
||||
state is ItemState.New ? nameof(Create) : nameof(Update));
|
||||
state is ItemState.New ? nameof(ItemState.New) : nameof(ItemState.Write));
|
||||
}
|
||||
@@ -7,10 +7,11 @@ namespace Bitvault;
|
||||
[Notification(typeof(CreateEventArgs<ItemNavigationViewModel>), nameof(ItemCollectionViewModel))]
|
||||
[Notification(typeof(InsertEventArgs<ItemNavigationViewModel>), nameof(ItemCollectionViewModel))]
|
||||
[Notification(typeof(MoveToEventArgs<ItemNavigationViewModel>), nameof(ItemCollectionViewModel))]
|
||||
[Notification(typeof(NotifyEventArgs<Search<string>>), nameof(ItemCollectionViewModel))]
|
||||
public partial class ItemCollectionViewModel :
|
||||
ObservableCollection<ItemNavigationViewModel>,
|
||||
INotificationHandler<NotifyEventArgs<Filter>>,
|
||||
INotificationHandler<NotifyEventArgs<Search>>,
|
||||
INotificationHandler<NotifyEventArgs<Search<string>>>,
|
||||
IBackStack
|
||||
{
|
||||
[ObservableProperty]
|
||||
@@ -42,18 +43,18 @@ public partial class ItemCollectionViewModel :
|
||||
if (args.Value is Filter filter)
|
||||
{
|
||||
configuration = configuration with { Filter = filter.Value };
|
||||
BeginAggregation();
|
||||
Fetch(true);
|
||||
}
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task Handle(NotifyEventArgs<Search> args)
|
||||
public Task Handle(NotifyEventArgs<Search<string>> args)
|
||||
{
|
||||
if (args.Value is Search search)
|
||||
if (args.Value is Search<string> search)
|
||||
{
|
||||
configuration = configuration with { Query = search.Value };
|
||||
BeginAggregation();
|
||||
Fetch(true);
|
||||
}
|
||||
|
||||
return Task.CompletedTask;
|
||||
@@ -70,11 +71,6 @@ public partial class ItemCollectionViewModel :
|
||||
return base.OnActivated();
|
||||
}
|
||||
|
||||
public override Task OnDeactivated()
|
||||
{
|
||||
return base.OnDeactivated();
|
||||
}
|
||||
protected override IAggerate OnAggerate(object? key) =>
|
||||
Aggerate.With<ItemNavigationViewModel, LockerViewModelConfiguration>(configuration)
|
||||
with { Key = key };
|
||||
protected override AggregateExpression CreateAggregateExpression() =>
|
||||
new(Aggregate.As<ItemNavigationViewModel, LockerViewModelConfiguration>(configuration));
|
||||
}
|
||||
|
||||
@@ -21,12 +21,6 @@ public partial class ItemContentViewModel :
|
||||
|
||||
public IContentTemplate Template { get; set; }
|
||||
|
||||
protected override IAggerate OnAggerate(object? key)
|
||||
{
|
||||
return base.OnAggerate(key);
|
||||
}
|
||||
|
||||
|
||||
public Task Handle(NotifyEventArgs<ItemCategory<string>> args)
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using Toolkit.Foundation;
|
||||
using Toolkit.UI.Avalonia;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
@@ -48,6 +49,7 @@ public partial class ItemNavigationViewModel(IServiceProvider provider,
|
||||
private bool selected = selected;
|
||||
|
||||
public IContentTemplate Template { get; set; } = template;
|
||||
public bool Attached { get; set; }
|
||||
|
||||
public Task Handle(ArchiveEventArgs<Item> args) =>
|
||||
Task.Run(Dispose);
|
||||
|
||||
@@ -3,13 +3,13 @@ using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
[Notification(typeof(ConfirmEventArgs<Item>), nameof(Create))]
|
||||
[Notification(typeof(ConfirmEventArgs<Item>), nameof(ItemState.New))]
|
||||
[Notification(typeof(ConfirmEventArgs<Item>), nameof(ItemState.Write))]
|
||||
public partial class ItemViewModel :
|
||||
ObservableCollection<IItemEntryViewModel>,
|
||||
INotificationHandler<UpdateEventArgs<Item>>,
|
||||
INotificationHandler<ConfirmEventArgs<Item>>,
|
||||
INotificationHandler<CancelEventArgs<Item>>
|
||||
|
||||
{
|
||||
[ObservableProperty]
|
||||
private bool archived;
|
||||
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
namespace Bitvault;
|
||||
|
||||
public record Search(string? Value);
|
||||
public record Search<TValue>(TValue? Value);
|
||||
@@ -15,6 +15,6 @@ public partial class SearchLockerActionViewModel(IServiceProvider provider,
|
||||
private int index = 2;
|
||||
|
||||
[RelayCommand]
|
||||
public void Invoke() => Publisher.Publish(Notify.As(new Search(Value)),
|
||||
public void Invoke() => Publisher.Publish(Notify.As(new Search<string>(Value)),
|
||||
nameof(ItemCollectionViewModel));
|
||||
}
|
||||
Reference in New Issue
Block a user