Fix some edge cases
This commit is contained in:
@@ -1,8 +0,0 @@
|
||||
using Avalonia.Controls;
|
||||
|
||||
namespace Bitvault.Avalonia;
|
||||
|
||||
public partial class AddItemActionView : UserControl
|
||||
{
|
||||
public AddItemActionView() => InitializeComponent();
|
||||
}
|
||||
@@ -83,7 +83,7 @@ public partial class App : Application
|
||||
|
||||
services.AddTemplate<SearchHeaderViewModel, SearchHeaderView>("SearchHeader");
|
||||
services.AddTemplate<ContainerHeaderViewModel, ContainerHeaderView>("ContainerHeader");
|
||||
services.AddTemplate<AddItemActionViewModel, AddItemActionView>();
|
||||
services.AddTemplate<CreateItemActionViewModel, CreateItemActionView>();
|
||||
|
||||
services.AddTemplate<ItemNavigationViewModel, ItemNavigationView>();
|
||||
services.AddTemplate<ItemViewModel, ItemView>("Item");
|
||||
@@ -92,6 +92,9 @@ public partial class App : Application
|
||||
|
||||
services.AddTemplate<ConfirmItemActionViewModel, ConfirmItemActionView>();
|
||||
services.AddTemplate<DismissItemActionViewModel, DismissItemActionView>();
|
||||
services.AddTemplate<ArchiveItemActionViewModel, ArchiveItemActionView>();
|
||||
services.AddTemplate<EditItemActionViewModel, EditItemActionView>();
|
||||
services.AddTemplate<DeleteItemActionViewModel, DeleteItemActionView>();
|
||||
|
||||
services.AddTemplate<ItemHeaderViewModel, ItemHeaderView>();
|
||||
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
<UserControl
|
||||
x:Class="Bitvault.Avalonia.ArchiveItemActionView"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:vm="using:Bitvault"
|
||||
x:DataType="vm:ArchiveItemActionViewModel">
|
||||
<Button
|
||||
Width="{StaticResource ButtonWidth}"
|
||||
Height="{StaticResource ButtonHeight}"
|
||||
VerticalAlignment="Center"
|
||||
Command="{Binding InvokeCommand}"
|
||||
Foreground="{DynamicResource IconForegroundBrush}"
|
||||
ToolTip.Tip="Archive">
|
||||
<TextBlock
|
||||
VerticalAlignment="Center"
|
||||
FontFamily="{DynamicResource SymbolThemeFontFamily}"
|
||||
FontSize="16"
|
||||
Foreground="{DynamicResource IconForegroundBrush}"
|
||||
Text="" />
|
||||
</Button>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,8 @@
|
||||
using Avalonia.Controls;
|
||||
|
||||
namespace Bitvault.Avalonia;
|
||||
|
||||
public partial class ArchiveItemActionView : UserControl
|
||||
{
|
||||
public ArchiveItemActionView() => InitializeComponent();
|
||||
}
|
||||
@@ -40,8 +40,8 @@
|
||||
<ProjectReference Include="..\Toolkit\Toolkit.UI.Controls.Avalonia\Toolkit.UI.Controls.Avalonia.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Update="AddItemActionView.axaml.cs">
|
||||
<DependentUpon>AddItemActionView.axaml</DependentUpon>
|
||||
<Compile Update="CreateItemActionView.axaml.cs">
|
||||
<DependentUpon>CreateItemActionView.axaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="ItemCommandHeaderView.axaml.cs">
|
||||
<DependentUpon>ItemCommandHeaderView.axaml</DependentUpon>
|
||||
|
||||
@@ -21,7 +21,9 @@
|
||||
Grid.Column="0"
|
||||
Margin="2,-1,0,0"
|
||||
ItemTemplate="{ReflectionBinding Template}"
|
||||
ItemsSource="{Binding}">
|
||||
ItemsSource="{Binding}"
|
||||
SelectedIndex="{Binding SelectedIndex}"
|
||||
SelectionMode="AlwaysSelected">
|
||||
<ListBox.Styles>
|
||||
<Style Selector="ListBoxItem">
|
||||
<Setter Property="IsSelected" Value="{ReflectionBinding Selected}" />
|
||||
|
||||
+7
-3
@@ -1,9 +1,9 @@
|
||||
<UserControl
|
||||
x:Class="Bitvault.Avalonia.AddItemActionView"
|
||||
x:Class="Bitvault.Avalonia.CreateItemActionView"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:vm="using:Bitvault"
|
||||
x:DataType="vm:AddItemActionViewModel">
|
||||
x:DataType="vm:CreateItemActionViewModel">
|
||||
<Button
|
||||
Grid.Column="1"
|
||||
Width="{StaticResource ButtonWidth}"
|
||||
@@ -22,7 +22,11 @@
|
||||
<NavigateAction
|
||||
Context="{Binding Named, StringFormat='{}{0}:Content'}"
|
||||
Route="Item"
|
||||
Scope="self" />
|
||||
Scope="self">
|
||||
<NavigateAction.ParameterBindings>
|
||||
<ParameterBinding Key="Immutable" Value="{x:False}" />
|
||||
</NavigateAction.ParameterBindings>
|
||||
</NavigateAction>
|
||||
</EventTriggerBehavior>
|
||||
</Interaction.Behaviors>
|
||||
</Button>
|
||||
@@ -0,0 +1,8 @@
|
||||
using Avalonia.Controls;
|
||||
|
||||
namespace Bitvault.Avalonia;
|
||||
|
||||
public partial class CreateItemActionView : UserControl
|
||||
{
|
||||
public CreateItemActionView() => InitializeComponent();
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<UserControl
|
||||
x:Class="Bitvault.Avalonia.DeleteItemActionView"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:vm="using:Bitvault"
|
||||
x:DataType="vm:DeleteItemActionViewModel">
|
||||
<Button
|
||||
Width="{StaticResource ButtonWidth}"
|
||||
Height="{StaticResource ButtonHeight}"
|
||||
VerticalAlignment="Center"
|
||||
Command="{Binding InvokeCommand}"
|
||||
Foreground="{DynamicResource IconForegroundBrush}"
|
||||
ToolTip.Tip="Delete">
|
||||
<TextBlock
|
||||
VerticalAlignment="Center"
|
||||
FontFamily="{DynamicResource SymbolThemeFontFamily}"
|
||||
FontSize="16"
|
||||
Foreground="{DynamicResource IconForegroundBrush}"
|
||||
Text="" />
|
||||
</Button>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,12 @@
|
||||
using Avalonia.Controls;
|
||||
|
||||
namespace Bitvault.Avalonia
|
||||
{
|
||||
public partial class DeleteItemActionView : UserControl
|
||||
{
|
||||
public DeleteItemActionView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@
|
||||
Height="{StaticResource ButtonHeight}"
|
||||
VerticalAlignment="Center"
|
||||
Foreground="{DynamicResource IconForegroundBrush}"
|
||||
ToolTip.Tip="Save">
|
||||
ToolTip.Tip="Cancel">
|
||||
<TextBlock
|
||||
VerticalAlignment="Center"
|
||||
FontFamily="{DynamicResource SymbolThemeFontFamily}"
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
<UserControl
|
||||
x:Class="Bitvault.Avalonia.EditItemActionView"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:vm="using:Bitvault"
|
||||
x:DataType="vm:EditItemActionViewModel">
|
||||
<Button
|
||||
Width="{StaticResource ButtonWidth}"
|
||||
Height="{StaticResource ButtonHeight}"
|
||||
VerticalAlignment="Center"
|
||||
Command="{Binding InvokeCommand}"
|
||||
Foreground="{DynamicResource IconForegroundBrush}"
|
||||
ToolTip.Tip="Edit">
|
||||
<TextBlock
|
||||
VerticalAlignment="Center"
|
||||
FontFamily="{DynamicResource SymbolThemeFontFamily}"
|
||||
FontSize="16"
|
||||
Foreground="{DynamicResource IconForegroundBrush}"
|
||||
Text="" />
|
||||
</Button>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,8 @@
|
||||
using Avalonia.Controls;
|
||||
|
||||
namespace Bitvault.Avalonia;
|
||||
|
||||
public partial class EditItemActionView : UserControl
|
||||
{
|
||||
public EditItemActionView() => InitializeComponent();
|
||||
}
|
||||
@@ -11,7 +11,15 @@
|
||||
DisplayName="{Binding Value}" />
|
||||
<TextBox
|
||||
MaxWidth="360"
|
||||
IsVisible="{Binding !Immutable}"
|
||||
Text="{Binding Value}"
|
||||
TextAlignment="Center"
|
||||
Watermark="Enter name" />
|
||||
<SelectableTextBlock
|
||||
MaxWidth="360"
|
||||
IsVisible="{Binding Immutable}"
|
||||
SelectionBrush="Red"
|
||||
Text="{Binding Value}"
|
||||
TextAlignment="Center" />
|
||||
</StackPanel>
|
||||
</UserControl>
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
Scope="self" />
|
||||
<NavigateAction Context="{Binding Named, StringFormat='{}{0}:Content'}" Route="Item">
|
||||
<NavigateAction.ParameterBindings>
|
||||
<ParameterBinding Key="Immutable" Value="{x:True}" />
|
||||
<ParameterBinding Key="Id" Value="{Binding Id}" />
|
||||
<ParameterBinding Key="Name" Value="{Binding Name}" />
|
||||
</NavigateAction.ParameterBindings>
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace Bitvault;
|
||||
|
||||
public record Archive
|
||||
{
|
||||
public static ArchiveEventArgs<TValue> As<TValue>(TValue value) =>
|
||||
new(value);
|
||||
|
||||
public static ArchiveEventArgs<TValue> As<TValue>() where TValue : new() =>
|
||||
new(new TValue());
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
namespace Bitvault;
|
||||
|
||||
public record ArchiveEventArgs<TValue>(TValue Value);
|
||||
@@ -0,0 +1,15 @@
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public partial class ArchiveItemActionViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
ISubscriber subscriber,
|
||||
IDisposer disposer) : ObservableViewModel(provider, factory, mediator, publisher, subscriber, disposer)
|
||||
{
|
||||
[RelayCommand]
|
||||
public async Task Invoke() => await Publisher.Publish(Archive.As<Item>());
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
namespace Bitvault;
|
||||
|
||||
public partial class ContainerHeaderViewModel : ObservableCollectionViewModel<string, IDisposable>,
|
||||
INotificationHandler<ActivateEventArgs<Filter<string>>>
|
||||
INotificationHandler<RequestEventArgs<Filter<string>>>
|
||||
{
|
||||
public ContainerHeaderViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
@@ -15,12 +15,12 @@ public partial class ContainerHeaderViewModel : ObservableCollectionViewModel<st
|
||||
{
|
||||
Template = template;
|
||||
|
||||
Add<AddItemActionViewModel>(scope: true);
|
||||
Add<CreateItemActionViewModel>(scope: true);
|
||||
}
|
||||
|
||||
public IContentTemplate Template { get; set; }
|
||||
|
||||
public Task Handle(ActivateEventArgs<Filter<string>> args,
|
||||
public Task Handle(RequestEventArgs<Filter<string>> args,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (args.Value is Filter<string> filter)
|
||||
|
||||
@@ -3,7 +3,7 @@ using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public partial class AddItemActionViewModel(IServiceProvider provider,
|
||||
public partial class CreateItemActionViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
@@ -1,4 +1,5 @@
|
||||
using Toolkit.Foundation;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
@@ -7,4 +8,8 @@ public partial class DeleteItemActionViewModel(IServiceProvider provider,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
ISubscriber subscriber,
|
||||
IDisposer disposer) : ObservableViewModel(provider, factory, mediator, publisher, subscriber, disposer);
|
||||
IDisposer disposer) : ObservableViewModel(provider, factory, mediator, publisher, subscriber, disposer)
|
||||
{
|
||||
[RelayCommand]
|
||||
public async Task Invoke() => await Publisher.Publish(Delete.As<Item>());
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Toolkit.Foundation;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
@@ -7,5 +8,9 @@ public partial class EditItemActionViewModel(IServiceProvider provider,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
ISubscriber subscriber,
|
||||
IDisposer disposer) : ObservableViewModel(provider, factory, mediator, publisher, subscriber, disposer);
|
||||
IDisposer disposer) : ObservableViewModel(provider, factory, mediator, publisher, subscriber, disposer)
|
||||
{
|
||||
[RelayCommand]
|
||||
public async Task Invoke() => await Publisher.Publish(Edit.As<Item>());
|
||||
}
|
||||
|
||||
|
||||
@@ -38,5 +38,5 @@ public partial class FilterContainerNavigationViewModel : ObservableViewModel,
|
||||
Task.FromResult(Activated = true);
|
||||
|
||||
[RelayCommand]
|
||||
public async Task Invoke() => await Publisher.Publish(Request.As(new Filter<string>(Filter)));
|
||||
public async Task Invoke() => await Publisher.Publish(Request.As(new Filter<string>(Filter)), nameof(ContainerViewModel));
|
||||
}
|
||||
@@ -14,6 +14,9 @@ public partial class ItemCommandHeaderViewModel : ObservableCollectionViewModel
|
||||
{
|
||||
Add<ConfirmItemActionViewModel>();
|
||||
Add<DismissItemActionViewModel>();
|
||||
Add<EditItemActionViewModel>();
|
||||
Add<DeleteItemActionViewModel>();
|
||||
Add<ArchiveItemActionViewModel>();
|
||||
|
||||
Template = template;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Toolkit.Foundation;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
@@ -8,10 +9,13 @@ public partial class ItemHeaderViewModel(IServiceProvider provider,
|
||||
IPublisher publisher,
|
||||
ISubscriber subscriber,
|
||||
IDisposer disposer,
|
||||
bool immutable,
|
||||
string? value = null) : ObservableViewModel<string, string>(provider, factory, mediator, publisher, subscriber, disposer, value),
|
||||
IItemViewModel
|
||||
{
|
||||
[ObservableProperty]
|
||||
private bool immutable = immutable;
|
||||
|
||||
public void Invoke(ItemConfiguration args) =>
|
||||
args.Name = Value;
|
||||
|
||||
}
|
||||
|
||||
@@ -14,7 +14,9 @@ public partial class ItemNavigationViewModel(IServiceProvider provider,
|
||||
int id,
|
||||
string name,
|
||||
string description) :
|
||||
ObservableViewModel(provider, factory, mediator, publisher, subscriber, disposer)
|
||||
ObservableViewModel(provider, factory, mediator, publisher, subscriber, disposer),
|
||||
INotificationHandler<ArchiveEventArgs<Item>>,
|
||||
IRemovable
|
||||
{
|
||||
[ObservableProperty]
|
||||
private string? description = description;
|
||||
@@ -31,4 +33,11 @@ public partial class ItemNavigationViewModel(IServiceProvider provider,
|
||||
[ObservableProperty]
|
||||
private bool selected;
|
||||
public IContentTemplate Template { get; set; } = template;
|
||||
|
||||
public Task Handle(ArchiveEventArgs<Item> args,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
Dispose();
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,9 @@ public partial class ItemViewModel :
|
||||
[ObservableProperty]
|
||||
private string named;
|
||||
|
||||
[ObservableProperty]
|
||||
private bool immutable;
|
||||
|
||||
public ItemViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
@@ -21,14 +24,16 @@ public partial class ItemViewModel :
|
||||
IDisposer disposer,
|
||||
IContentTemplate template,
|
||||
NamedComponent named,
|
||||
bool immutable = true,
|
||||
int? id = null,
|
||||
string? name = null) : base(provider, factory, mediator, publisher, subscriber, disposer)
|
||||
{
|
||||
Template = template;
|
||||
Named = $"{named}";
|
||||
Id = id;
|
||||
Immutable = immutable;
|
||||
|
||||
Add<ItemHeaderViewModel>(name ?? "");
|
||||
Add<ItemHeaderViewModel>(immutable, name ?? "");
|
||||
}
|
||||
|
||||
public IContentTemplate Template { get; set; }
|
||||
|
||||
Reference in New Issue
Block a user