Add KeyBindingBehavior
This commit is contained in:
@@ -17,47 +17,9 @@
|
|||||||
<Style Selector="ui|SettingsExpander /template/ Expander#Expander ToggleButton">
|
<Style Selector="ui|SettingsExpander /template/ Expander#Expander ToggleButton">
|
||||||
<Setter Property="CornerRadius" Value="{DynamicResource OverlayCornerRadius}" />
|
<Setter Property="CornerRadius" Value="{DynamicResource OverlayCornerRadius}" />
|
||||||
</Style>
|
</Style>
|
||||||
<Style Selector="Button">
|
|
||||||
<Setter Property="CornerRadius" Value="{DynamicResource OverlayCornerRadius}" />
|
|
||||||
</Style>
|
|
||||||
<Style Selector="TextBox">
|
|
||||||
<Setter Property="CornerRadius" Value="0" />
|
|
||||||
<Setter Property="BorderThickness" Value="0 0 0 2" />
|
|
||||||
<Style Selector="^:focus">
|
|
||||||
<Style Selector="^ /template/ Border#PART_BorderElement">
|
|
||||||
<Setter Property="Background" Value="Transparent" />
|
|
||||||
<Setter Property="BorderThickness" Value="0 0 0 2" />
|
|
||||||
</Style>
|
|
||||||
</Style>
|
|
||||||
</Style>
|
|
||||||
<Style Selector="OverlayPopupHost">
|
|
||||||
<Setter Property="Template">
|
|
||||||
<ControlTemplate>
|
|
||||||
<!-- Do not forget to update Templated_Control_With_Popup_In_Template_Should_Set_TemplatedParent test -->
|
|
||||||
<LayoutTransformControl LayoutTransform="{TemplateBinding Transform}">
|
|
||||||
<VisualLayerManager IsPopup="True">
|
|
||||||
<LayoutTransformControl>
|
|
||||||
<LayoutTransformControl.LayoutTransform>
|
|
||||||
<ScaleTransform ScaleX="1.4" ScaleY="1.4" />
|
|
||||||
</LayoutTransformControl.LayoutTransform>
|
|
||||||
<ContentPresenter
|
|
||||||
Name="PART_ContentPresenter"
|
|
||||||
Padding="{TemplateBinding Padding}"
|
|
||||||
Background="{TemplateBinding Background}"
|
|
||||||
Content="{TemplateBinding Content}"
|
|
||||||
ContentTemplate="{TemplateBinding ContentTemplate}" />
|
|
||||||
</LayoutTransformControl>
|
|
||||||
</VisualLayerManager>
|
|
||||||
</LayoutTransformControl>
|
|
||||||
</ControlTemplate>
|
|
||||||
</Setter>
|
|
||||||
</Style>
|
|
||||||
</Application.Styles>
|
</Application.Styles>
|
||||||
<Application.Resources>
|
<Application.Resources>
|
||||||
<Thickness x:Key="TextControlThemePadding">0,5,6,6</Thickness>
|
|
||||||
<FontFamily x:Key="SymbolFontFamily">avares://HyperX.Launcher.Avalonia/Assets/SegoeIcons.ttf#Segoe Fluent Icons</FontFamily>
|
<FontFamily x:Key="SymbolFontFamily">avares://HyperX.Launcher.Avalonia/Assets/SegoeIcons.ttf#Segoe Fluent Icons</FontFamily>
|
||||||
<StaticResource x:Key="TextControlBackground" ResourceKey="ControlFillColorTransparentBrush" />
|
|
||||||
<StaticResource x:Key="TextControlBackgroundPointerOver" ResourceKey="ControlFillColorTransparentBrush" />
|
|
||||||
<x:Double x:Key="SettingsExpanderItemAdaptiveWidthTrigger">0</x:Double>
|
<x:Double x:Key="SettingsExpanderItemAdaptiveWidthTrigger">0</x:Double>
|
||||||
<Thickness x:Key="SettingsExpanderItemBottomFooterMargin">0,8,0,0</Thickness>
|
<Thickness x:Key="SettingsExpanderItemBottomFooterMargin">0,8,0,0</Thickness>
|
||||||
</Application.Resources>
|
</Application.Resources>
|
||||||
|
|||||||
@@ -36,8 +36,7 @@ public partial class App : Application
|
|||||||
services.AddTemplate<MainViewModel, MainView>("Main");
|
services.AddTemplate<MainViewModel, MainView>("Main");
|
||||||
services.AddHandler<MainViewModelHandler>();
|
services.AddHandler<MainViewModelHandler>();
|
||||||
|
|
||||||
services.AddConfiguration<VaultConfiguration>(args => args.Name = "Personal",
|
services.AddConfiguration<VaultConfiguration>(args => args.Name = "Personal", "Vault:Personal");
|
||||||
$"{nameof(VaultConfiguration)}:Personal");
|
|
||||||
})
|
})
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,15 @@
|
|||||||
<Window xmlns="https://github.com/avaloniaui"
|
<UserControl
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
x:Class="Bitvault.Avalonia.LockView"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns="https://github.com/avaloniaui"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||||
x:Class="Bitvault.Avalonia.LockView"
|
<TextBox
|
||||||
Title="LockView">
|
Width="300"
|
||||||
Welcome to Avalonia!
|
Classes="revealPasswordButton"
|
||||||
</Window>
|
PasswordChar="●">
|
||||||
|
<TextBox.KeyBindings>
|
||||||
|
<KeyBinding Gesture="Enter" />
|
||||||
|
</TextBox.KeyBindings>
|
||||||
|
</TextBox>
|
||||||
|
</StackPanel>
|
||||||
|
</UserControl>
|
||||||
|
|||||||
@@ -1,12 +1,8 @@
|
|||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
|
|
||||||
namespace Bitvault.Avalonia
|
namespace Bitvault.Avalonia;
|
||||||
|
|
||||||
|
public partial class LockView : UserControl
|
||||||
{
|
{
|
||||||
public partial class LockView : Window
|
public LockView() => InitializeComponent();
|
||||||
{
|
|
||||||
public LockView()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,5 +16,7 @@ public class VaultComponent :
|
|||||||
services.AddTemplate<ArchiveNavigationViewModel, ArchiveNavigationView>();
|
services.AddTemplate<ArchiveNavigationViewModel, ArchiveNavigationView>();
|
||||||
|
|
||||||
services.AddTemplate<VaultViewModel, VaultView>("Vault");
|
services.AddTemplate<VaultViewModel, VaultView>("Vault");
|
||||||
|
services.AddTemplate<LockViewModel, LockView>("Lock");
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,4 +5,10 @@
|
|||||||
xmlns:vm="using:Bitvault"
|
xmlns:vm="using:Bitvault"
|
||||||
x:DataType="vm:VaultNavigationViewModel"
|
x:DataType="vm:VaultNavigationViewModel"
|
||||||
Content="{Binding Name}"
|
Content="{Binding Name}"
|
||||||
MenuItemsSource="{Binding}" />
|
MenuItemsSource="{Binding}">
|
||||||
|
<Interaction.Behaviors>
|
||||||
|
<EventTriggerBehavior EventName="Loaded">
|
||||||
|
<NavigateAction Context="Main" Route="Lock" />
|
||||||
|
</EventTriggerBehavior>
|
||||||
|
</Interaction.Behaviors>
|
||||||
|
</NavigationViewItem>
|
||||||
|
|||||||
@@ -7,4 +7,11 @@ public class LockViewModel(IServiceProvider serviceProvider,
|
|||||||
IPublisher publisher,
|
IPublisher publisher,
|
||||||
ISubscriber subscriber,
|
ISubscriber subscriber,
|
||||||
IDisposer disposer) :
|
IDisposer disposer) :
|
||||||
ObservableViewModel(serviceProvider, serviceFactory, publisher, subscriber, disposer);
|
ObservableViewModel(serviceProvider, serviceFactory, publisher, subscriber, disposer),
|
||||||
|
IConfirmation
|
||||||
|
{
|
||||||
|
public Task<bool> Confirm()
|
||||||
|
{
|
||||||
|
return Task.FromResult(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
+4
-2
@@ -1,3 +1,5 @@
|
|||||||
namespace Bitvault;
|
using Toolkit.Foundation;
|
||||||
|
|
||||||
public record Locked;
|
namespace Bitvault;
|
||||||
|
|
||||||
|
public record Locked : INotification;
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
namespace Bitvault;
|
using Toolkit.Foundation;
|
||||||
|
|
||||||
public record Unlocked;
|
namespace Bitvault;
|
||||||
|
|
||||||
|
public record Unlocked : INotification;
|
||||||
@@ -5,12 +5,13 @@ namespace Bitvault;
|
|||||||
|
|
||||||
public class VaultComponentsInitializer(IServiceProvider provider,
|
public class VaultComponentsInitializer(IServiceProvider provider,
|
||||||
IProxyServiceCollection<IComponentBuilder> proxy,
|
IProxyServiceCollection<IComponentBuilder> proxy,
|
||||||
IEnumerable<IConfiguration<VaultConfiguration>> configurations,
|
IEnumerable<IConfigurationDescriptor<VaultConfiguration>> configurations,
|
||||||
|
IComponentScopeCollection scopes,
|
||||||
IVaultHostCollection vaults) : IInitializer
|
IVaultHostCollection vaults) : IInitializer
|
||||||
{
|
{
|
||||||
public Task Initialize()
|
public async Task Initialize()
|
||||||
{
|
{
|
||||||
foreach (IConfiguration<VaultConfiguration> configuration in configurations)
|
foreach (IConfigurationDescriptor<VaultConfiguration> configuration in configurations)
|
||||||
{
|
{
|
||||||
if (provider.GetRequiredService<IVaultComponent>() is IVaultComponent component)
|
if (provider.GetRequiredService<IVaultComponent>() is IVaultComponent component)
|
||||||
{
|
{
|
||||||
@@ -36,16 +37,19 @@ public class VaultComponentsInitializer(IServiceProvider provider,
|
|||||||
provider.GetRequiredService<IComponentScopeProvider>());
|
provider.GetRequiredService<IComponentScopeProvider>());
|
||||||
|
|
||||||
services.AddRange(proxy.Services);
|
services.AddRange(proxy.Services);
|
||||||
|
|
||||||
|
services.AddSingleton(new ComponentScope(configuration.Section));
|
||||||
});
|
});
|
||||||
|
|
||||||
builder.AddConfiguration(configuration.Section, configuration.Value);
|
builder.AddConfiguration(configuration.Section, configuration.Value);
|
||||||
IComponentHost host = builder.Build();
|
IComponentHost host = builder.Build();
|
||||||
host.StartAsync();
|
|
||||||
|
scopes.Add(new ComponentScopeDescriptor(configuration.Section,
|
||||||
|
host.Services.GetRequiredService<IServiceProvider>()));
|
||||||
|
|
||||||
vaults.Add(host);
|
vaults.Add(host);
|
||||||
|
await host.StartAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Task.CompletedTask;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,13 +5,18 @@ namespace Bitvault;
|
|||||||
|
|
||||||
public partial class VaultNavigationViewModel :
|
public partial class VaultNavigationViewModel :
|
||||||
ObservableCollectionViewModel<IMainNavigationViewModel>,
|
ObservableCollectionViewModel<IMainNavigationViewModel>,
|
||||||
IMainNavigationViewModel
|
IMainNavigationViewModel,
|
||||||
|
INotificationHandler<Unlocked>,
|
||||||
|
INotificationHandler<Locked>
|
||||||
{
|
{
|
||||||
|
[ObservableProperty]
|
||||||
|
private bool locked;
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private string name;
|
private string name;
|
||||||
|
|
||||||
public VaultNavigationViewModel(IServiceProvider serviceProvider,
|
public VaultNavigationViewModel(IServiceProvider serviceProvider,
|
||||||
IServiceFactory serviceFactory,
|
IServiceFactory serviceFactory,
|
||||||
IPublisher publisher,
|
IPublisher publisher,
|
||||||
ISubscriber subscriber,
|
ISubscriber subscriber,
|
||||||
IDisposer disposer,
|
IDisposer disposer,
|
||||||
@@ -21,11 +26,30 @@ public partial class VaultNavigationViewModel :
|
|||||||
Template = template;
|
Template = template;
|
||||||
Name = name;
|
Name = name;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public IContentTemplate Template { get; set; }
|
||||||
|
|
||||||
|
public Task Handle(Unlocked args, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
Locked = true;
|
||||||
|
|
||||||
Add<AllNavigationViewModel>();
|
Add<AllNavigationViewModel>();
|
||||||
Add<StarredNavigationViewModel>();
|
Add<StarredNavigationViewModel>();
|
||||||
Add<ArchiveNavigationViewModel>();
|
Add<ArchiveNavigationViewModel>();
|
||||||
Add<CategoriesNavigationViewModel>();
|
Add<CategoriesNavigationViewModel>();
|
||||||
|
|
||||||
|
return Task.CompletedTask;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public IContentTemplate Template { get; set; }
|
public Task Handle(Locked args, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
Locked = true;
|
||||||
|
Clear();
|
||||||
|
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user