Make it possible to remove enteries
This commit is contained in:
@@ -5,4 +5,4 @@
|
||||
xmlns:vm="using:Wallet"
|
||||
x:DataType="vm:CommentEntryViewModel"
|
||||
Content="{Binding Comment}"
|
||||
Description="{Binding Created}" />
|
||||
Description="{Binding Created, StringFormat=f}" />
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
<UserControl
|
||||
x:Class="Wallet.Avalonia.DeleteItemEntryView"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:vm="using:Wallet"
|
||||
x:CompileBindings="False"
|
||||
DataContext="{Binding $parent[SettingsExpander].DataContext}">
|
||||
<UserControl.Resources>
|
||||
<Thickness x:Key="MoreButtonMargin">0,0,12,0</Thickness>
|
||||
<Thickness x:Key="MoreButtonPadding">5,0,5,0</Thickness>
|
||||
<x:Double x:Key="MoreButtonMinWidth">32</x:Double>
|
||||
<x:Double x:Key="MoreButtonMinHeight">32</x:Double>
|
||||
</UserControl.Resources>
|
||||
<Button
|
||||
Grid.Column="1"
|
||||
MinWidth="{StaticResource MoreButtonMinWidth}"
|
||||
MinHeight="{StaticResource MoreButtonMinHeight}"
|
||||
Margin="{StaticResource MoreButtonMargin}"
|
||||
Padding="{StaticResource MoreButtonPadding}"
|
||||
HorizontalContentAlignment="Center"
|
||||
VerticalContentAlignment="Center"
|
||||
Theme="{StaticResource TransparentButton}">
|
||||
<Viewbox Width="14" Height="14">
|
||||
<PathIcon
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
Data="F1 M 8.52 5.799999 L 11.52 5.799999 C 11.52 5.373333 11.373333 5.013332 11.08 4.719999 C 10.786666 4.426666 10.426666 4.286667 10 4.299999 C 9.573333 4.313334 9.219999 4.459999 8.94 4.74 C 8.66 5.02 8.52 5.373333 8.52 5.799999 Z M 7.52 5.799999 C 7.52 5.106667 7.759999 4.52 8.24 4.039999 C 8.719999 3.560001 9.306666 3.313334 10 3.299999 C 10.693333 3.286667 11.28 3.526667 11.759999 4.02 C 12.239999 4.513334 12.479999 5.106667 12.48 5.799999 L 17.52 5.799999 C 17.653332 5.799999 17.766666 5.846666 17.859999 5.94 C 17.953331 6.033334 18 6.153334 18 6.299999 C 18 6.446667 17.953331 6.566668 17.859999 6.66 C 17.766666 6.753334 17.653332 6.8 17.52 6.799999 L 16.440001 6.799999 L 15.24 17.16 C 15.159999 17.906666 14.833332 18.533333 14.259999 19.039999 C 13.686666 19.546665 13.026666 19.799999 12.28 19.799999 L 7.72 19.799999 C 6.973333 19.799999 6.313333 19.546665 5.74 19.039999 C 5.166667 18.533333 4.84 17.906666 4.76 17.16 L 3.56 6.799999 L 2.52 6.799999 C 2.36 6.8 2.233333 6.753334 2.14 6.66 C 2.046667 6.566668 2 6.446667 2 6.299999 C 2 6.153334 2.046667 6.033334 2.14 5.94 C 2.233333 5.846666 2.36 5.799999 2.52 5.799999 Z M 5.76 17.039999 C 5.813333 17.546665 6.026666 17.966665 6.4 18.299999 C 6.773333 18.633333 7.213333 18.799999 7.72 18.799999 L 12.28 18.799999 C 12.786666 18.799999 13.226665 18.633333 13.599999 18.299999 C 13.973333 17.966665 14.186666 17.546665 14.24 17.039999 L 15.44 6.799999 L 4.56 6.799999 Z M 8.52 9.28 C 8.653333 9.306667 8.766666 9.366667 8.86 9.459999 C 8.953333 9.553333 9 9.666667 9 9.799999 L 9 15.799999 C 9 15.933332 8.953333 16.053333 8.86 16.16 C 8.766666 16.266666 8.646667 16.313332 8.5 16.299999 C 8.353333 16.286667 8.233333 16.233334 8.139999 16.139999 C 8.046666 16.046665 8 15.933332 8 15.799999 L 8 9.799999 C 8 9.666667 8.046666 9.546667 8.139999 9.44 C 8.233333 9.333334 8.346666 9.280001 8.48 9.28 Z M 12 9.799999 C 12 9.666667 11.953333 9.546667 11.86 9.44 C 11.766666 9.333334 11.646666 9.280001 11.5 9.28 C 11.353333 9.280001 11.233333 9.333334 11.139999 9.44 C 11.046666 9.546667 11 9.666667 11 9.799999 L 11 15.799999 C 11 15.933332 11.046666 16.046665 11.139999 16.139999 C 11.233333 16.233334 11.353333 16.286667 11.5 16.299999 C 11.646666 16.313332 11.766666 16.266666 11.86 16.16 C 11.953333 16.053333 12 15.933332 12 15.799999 Z "
|
||||
Foreground="{DynamicResource SystemFillColorCriticalBrush}" />
|
||||
</Viewbox>
|
||||
<Button.Styles>
|
||||
<Style Selector="Button.Hide">
|
||||
<Setter Property="IsVisible" Value="True" />
|
||||
</Style>
|
||||
<Style Selector="Button.Show">
|
||||
<Setter Property="IsVisible" Value="False" />
|
||||
</Style>
|
||||
</Button.Styles>
|
||||
<Interaction.Behaviors>
|
||||
<DataTriggerBehavior Binding="{Binding State}" Value="{x:Static vm:ItemState.Read}">
|
||||
<AddClassAction ClassName="Show" RemoveIfExists="True" />
|
||||
<RemoveClassAction ClassName="Hide" />
|
||||
</DataTriggerBehavior>
|
||||
<DataTriggerBehavior Binding="{Binding State}" Value="{x:Static vm:ItemState.New}">
|
||||
<AddClassAction ClassName="Hide" RemoveIfExists="True" />
|
||||
<RemoveClassAction ClassName="Show" />
|
||||
</DataTriggerBehavior>
|
||||
<DataTriggerBehavior Binding="{Binding State}" Value="{x:Static vm:ItemState.Write}">
|
||||
<AddClassAction ClassName="Hide" RemoveIfExists="True" />
|
||||
<RemoveClassAction ClassName="Show" />
|
||||
</DataTriggerBehavior>
|
||||
</Interaction.Behaviors>
|
||||
</Button>
|
||||
</UserControl>
|
||||
@@ -1,13 +0,0 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
|
||||
namespace Wallet.Avalonia;
|
||||
|
||||
public partial class DeleteItemEntryView : UserControl
|
||||
{
|
||||
public DeleteItemEntryView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
@@ -6,29 +6,71 @@
|
||||
x:CompileBindings="False"
|
||||
DataContext="{Binding $parent[SettingsExpander].DataContext}">
|
||||
<UserControl.Resources>
|
||||
<Thickness x:Key="MoreButtonMargin">12,0,0,0</Thickness>
|
||||
<Thickness x:Key="MoreButtonPadding">5,0,5,0</Thickness>
|
||||
<x:Double x:Key="MoreButtonMinWidth">32</x:Double>
|
||||
<x:Double x:Key="MoreButtonMinHeight">32</x:Double>
|
||||
<Thickness x:Key="ButtonMargin">12,0,0,0</Thickness>
|
||||
<Thickness x:Key="ButtonPadding">0</Thickness>
|
||||
<x:Double x:Key="ButtonMinWidth">32</x:Double>
|
||||
<x:Double x:Key="ButtonMinHeight">32</x:Double>
|
||||
</UserControl.Resources>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Button
|
||||
Grid.Column="1"
|
||||
MinWidth="{StaticResource MoreButtonMinWidth}"
|
||||
MinHeight="{StaticResource MoreButtonMinHeight}"
|
||||
Margin="{StaticResource MoreButtonMargin}"
|
||||
Padding="{StaticResource MoreButtonPadding}"
|
||||
MinWidth="{StaticResource ButtonMinWidth}"
|
||||
MinHeight="{StaticResource ButtonMinHeight}"
|
||||
Margin="{StaticResource ButtonMargin}"
|
||||
Padding="{StaticResource ButtonPadding}"
|
||||
HorizontalContentAlignment="Center"
|
||||
VerticalContentAlignment="Center"
|
||||
Command="{Binding RemoveCommand}"
|
||||
Theme="{StaticResource TransparentButton}">
|
||||
<Viewbox Height="20">
|
||||
<TextBlock
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
FontFamily="{StaticResource FluentThemeFontFamily}"
|
||||
FontSize="16"
|
||||
Foreground="{DynamicResource SystemFillColorCriticalBrush}"
|
||||
Text="" />
|
||||
</Viewbox>
|
||||
<Button.Styles>
|
||||
<Style Selector="Button.Hide">
|
||||
<Setter Property="IsVisible" Value="True" />
|
||||
</Style>
|
||||
<Style Selector="Button.Show">
|
||||
<Setter Property="IsVisible" Value="False" />
|
||||
</Style>
|
||||
</Button.Styles>
|
||||
<Interaction.Behaviors>
|
||||
<DataTriggerBehavior Binding="{Binding State}" Value="{x:Static vm:ItemState.Read}">
|
||||
<AddClassAction ClassName="Show" RemoveIfExists="True" />
|
||||
<RemoveClassAction ClassName="Hide" />
|
||||
</DataTriggerBehavior>
|
||||
<DataTriggerBehavior Binding="{Binding State}" Value="{x:Static vm:ItemState.New}">
|
||||
<AddClassAction ClassName="Hide" RemoveIfExists="True" />
|
||||
<RemoveClassAction ClassName="Show" />
|
||||
</DataTriggerBehavior>
|
||||
<DataTriggerBehavior Binding="{Binding State}" Value="{x:Static vm:ItemState.Write}">
|
||||
<AddClassAction ClassName="Hide" RemoveIfExists="True" />
|
||||
<RemoveClassAction ClassName="Show" />
|
||||
</DataTriggerBehavior>
|
||||
</Interaction.Behaviors>
|
||||
</Button>
|
||||
<Button
|
||||
Grid.Column="1"
|
||||
MinWidth="{StaticResource ButtonMinWidth}"
|
||||
MinHeight="{StaticResource ButtonMinHeight}"
|
||||
Margin="{StaticResource ButtonMargin}"
|
||||
Padding="{StaticResource ButtonPadding}"
|
||||
VerticalAlignment="Center"
|
||||
HorizontalContentAlignment="Center"
|
||||
VerticalContentAlignment="Center"
|
||||
Theme="{StaticResource TransparentButton}">
|
||||
<Viewbox
|
||||
Width="14"
|
||||
Height="14"
|
||||
Margin="0,2,0,0">
|
||||
<PathIcon
|
||||
<Viewbox Height="20">
|
||||
<TextBlock
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
Data="F1 M 6.24 11.799999 C 6.239999 12.146667 6.119999 12.440001 5.88 12.679999 C 5.64 12.92 5.346666 13.039999 5 13.039999 C 4.653333 13.039999 4.36 12.92 4.12 12.679999 C 3.88 12.440001 3.76 12.146667 3.76 11.799999 C 3.76 11.453333 3.88 11.16 4.12 10.919999 C 4.36 10.679999 4.653333 10.559999 5 10.559999 C 5.346666 10.559999 5.64 10.679999 5.88 10.919999 C 6.119999 11.16 6.239999 11.453333 6.24 11.799999 Z M 11.24 11.799999 C 11.24 12.146667 11.12 12.440001 10.88 12.679999 C 10.639999 12.92 10.346666 13.039999 10 13.039999 C 9.653333 13.039999 9.359999 12.92 9.12 12.679999 C 8.879999 12.440001 8.76 12.146667 8.76 11.799999 C 8.76 11.453333 8.879999 11.16 9.12 10.919999 C 9.359999 10.679999 9.653333 10.559999 10 10.559999 C 10.346666 10.559999 10.639999 10.679999 10.88 10.919999 C 11.12 11.16 11.24 11.453333 11.24 11.799999 Z M 15 13.039999 C 15.346665 13.039999 15.639999 12.92 15.88 12.679999 C 16.119999 12.440001 16.24 12.146667 16.24 11.799999 C 16.24 11.453333 16.119999 11.16 15.88 10.919999 C 15.639999 10.679999 15.346665 10.559999 15 10.559999 C 14.653333 10.559999 14.36 10.679999 14.12 10.919999 C 13.879999 11.16 13.759998 11.453333 13.759999 11.799999 C 13.759998 12.146667 13.879999 12.440001 14.12 12.679999 C 14.36 12.92 14.653333 13.039999 15 13.039999 Z " />
|
||||
FontFamily="{StaticResource FluentThemeFontFamily}"
|
||||
FontSize="16"
|
||||
Text="" />
|
||||
</Viewbox>
|
||||
<Button.Styles>
|
||||
<Style Selector="Button.Hide">
|
||||
@@ -182,4 +224,5 @@
|
||||
</DataTriggerBehavior>
|
||||
</Interaction.Behaviors>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
</UserControl>
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
</ResourceDictionary.ThemeDictionaries>
|
||||
</ResourceDictionary>
|
||||
<Thickness x:Key="TextControlMargin">0</Thickness>
|
||||
<Thickness x:Key="TextControlPadding">10,5,6,6</Thickness>
|
||||
<Thickness x:Key="TextControlPadding">10,6,6,5</Thickness>
|
||||
<Thickness x:Key="TextControlCompactPadding">0</Thickness>
|
||||
<Thickness x:Key="TextControlCompactMargin">0</Thickness>
|
||||
<BooleanToPasswordCharConverter x:Key="BooleanToPasswordCharConverter" PasswordChar="●" />
|
||||
|
||||
@@ -24,9 +24,7 @@
|
||||
<Thickness x:Key="TextControlCompactPadding">0</Thickness>
|
||||
<Thickness x:Key="TextControlCompactMargin">0</Thickness>
|
||||
</SettingsExpander.Resources>
|
||||
<SettingsExpander.Icon>
|
||||
<DeleteItemEntryView />
|
||||
</SettingsExpander.Icon>
|
||||
<SettingsExpander.Icon />
|
||||
<SettingsExpander.Action>
|
||||
<ItemEntryActionView />
|
||||
</SettingsExpander.Action>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Reflection;
|
||||
using System.Reactive.Disposables;
|
||||
using System.Reflection;
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Wallet;
|
||||
@@ -7,6 +8,7 @@ public class ItemContentViewModelActivationHandler(IDecoratorService<Item<(Guid,
|
||||
IDecoratorService<ItemConfiguration> itemConfigurationDecorator,
|
||||
IMediator mediator,
|
||||
IServiceFactory serviceFactory,
|
||||
IDisposer disposer,
|
||||
IPublisher publisher) :
|
||||
INotificationHandler<ActivationEventArgs<ItemSectionViewModel>>
|
||||
{
|
||||
@@ -39,6 +41,12 @@ public class ItemContentViewModelActivationHandler(IDecoratorService<Item<(Guid,
|
||||
if (await mediator.Handle<object, IItemEntryViewModel?>(message,
|
||||
entryConfiguration.GetType().Name) is IItemEntryViewModel entryViewModel)
|
||||
{
|
||||
// Should this be here?
|
||||
disposer.Add(entryViewModel, Disposable.Create(() =>
|
||||
{
|
||||
configurationSection.Entries.Remove(entryConfiguration);
|
||||
}));
|
||||
|
||||
publisher.Publish(Create.As(entryViewModel), id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace Wallet;
|
||||
public partial class ItemEntryViewModel<TValue> :
|
||||
Observable<string, TValue>,
|
||||
IItemEntryViewModel,
|
||||
IRemovable,
|
||||
IHandler<ValidateEventArgs<ItemEntry>, bool>,
|
||||
INotificationHandler<ConfirmEventArgs<ItemEntry>>,
|
||||
INotificationHandler<UpdateEventArgs<ItemEntry>>,
|
||||
@@ -69,6 +70,8 @@ public partial class ItemEntryViewModel<TValue> :
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public async Task<bool> Handle(ValidateEventArgs<ItemEntry> args,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
@@ -80,6 +83,9 @@ public partial class ItemEntryViewModel<TValue> :
|
||||
return await Task.FromResult(true);
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
private void Remove() => Dispose();
|
||||
|
||||
[RelayCommand]
|
||||
private void Copy() => Publisher.Publish(Write.As(new Clipboard<object>($"{Value}")));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user