Improvement to navigation regions
This commit is contained in:
@@ -12,10 +12,12 @@
|
|||||||
<CornerRadius x:Key="NavigationViewContentGridCornerRadius">0</CornerRadius>
|
<CornerRadius x:Key="NavigationViewContentGridCornerRadius">0</CornerRadius>
|
||||||
<Thickness x:Key="NavigationViewContentGridBorderThickness">1,0,0,0</Thickness>
|
<Thickness x:Key="NavigationViewContentGridBorderThickness">1,0,0,0</Thickness>
|
||||||
</NavigationView.Resources>
|
</NavigationView.Resources>
|
||||||
<Frame x:Name="Main">
|
<Frame>
|
||||||
<Interaction.Behaviors>
|
<Interaction.Behaviors>
|
||||||
<EventTriggerBehavior EventName="Loaded">
|
<EventTriggerBehavior EventName="Loaded">
|
||||||
<NavigateAction Context="Main" Route="Vault" />
|
<NavigateRegionAction Name="Main">
|
||||||
|
<NavigateAction Context="Main" Route="Vault" />
|
||||||
|
</NavigateRegionAction>
|
||||||
</EventTriggerBehavior>
|
</EventTriggerBehavior>
|
||||||
</Interaction.Behaviors>
|
</Interaction.Behaviors>
|
||||||
</Frame>
|
</Frame>
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Toolkit.Foundation;
|
|
||||||
|
|
||||||
namespace Bitvault.Avalonia;
|
namespace Bitvault.Avalonia;
|
||||||
|
|
||||||
[NavigationTarget("Main")]
|
|
||||||
public partial class MainView : UserControl
|
public partial class MainView : UserControl
|
||||||
{
|
{
|
||||||
public MainView() => InitializeComponent();
|
public MainView() => InitializeComponent();
|
||||||
|
|||||||
@@ -7,10 +7,12 @@
|
|||||||
x:DataType="vm:MainWindowViewModel"
|
x:DataType="vm:MainWindowViewModel"
|
||||||
Background="Transparent"
|
Background="Transparent"
|
||||||
TransparencyLevelHint="Mica">
|
TransparencyLevelHint="Mica">
|
||||||
<ContentControl x:Name="Window">
|
<ContentControl>
|
||||||
<Interaction.Behaviors>
|
<Interaction.Behaviors>
|
||||||
<AttachedBehaviour>
|
<AttachedBehaviour>
|
||||||
<NavigateAction Context="Window" Route="Main" />
|
<NavigateRegionAction Name="Window">
|
||||||
|
<NavigateAction Context="Window" Route="Main" />
|
||||||
|
</NavigateRegionAction>
|
||||||
</AttachedBehaviour>
|
</AttachedBehaviour>
|
||||||
</Interaction.Behaviors>
|
</Interaction.Behaviors>
|
||||||
</ContentControl>
|
</ContentControl>
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
using FluentAvalonia.UI.Windowing;
|
using FluentAvalonia.UI.Windowing;
|
||||||
using Toolkit.Foundation;
|
|
||||||
|
|
||||||
namespace Bitvault.Avalonia;
|
namespace Bitvault.Avalonia;
|
||||||
|
|
||||||
[NavigationTarget("Window")]
|
|
||||||
public partial class MainWindow : AppWindow
|
public partial class MainWindow : AppWindow
|
||||||
{
|
{
|
||||||
public MainWindow()
|
public MainWindow()
|
||||||
|
|||||||
@@ -5,11 +5,21 @@
|
|||||||
xmlns:vm="using:Bitvault"
|
xmlns:vm="using:Bitvault"
|
||||||
x:Name="Name"
|
x:Name="Name"
|
||||||
x:CompileBindings="False"
|
x:CompileBindings="False"
|
||||||
x:DataType="vm:VaultContentNavigationViewModel"
|
x:DataType="vm:VaultContentNavigationViewModel">
|
||||||
Content="{Binding Name}">
|
|
||||||
<Interaction.Behaviors>
|
<Interaction.Behaviors>
|
||||||
<DataTriggerBehavior Binding="{Binding Selected}" Value="True">
|
<DataTriggerBehavior Binding="{Binding Selected}" Value="True">
|
||||||
<NavigateAction Context="Content" Route="VaultContent" />
|
<NavigateAction Context="{Binding Named, StringFormat='{}{0}:Content'}" Route="VaultContent" />
|
||||||
</DataTriggerBehavior>
|
</DataTriggerBehavior>
|
||||||
</Interaction.Behaviors>
|
</Interaction.Behaviors>
|
||||||
|
<Grid ColumnDefinitions="Auto,*">
|
||||||
|
<PersonPicture
|
||||||
|
Grid.Column="0"
|
||||||
|
Height="34"
|
||||||
|
Margin="0"
|
||||||
|
DisplayName="{Binding Name}" />
|
||||||
|
<StackPanel Grid.Column="1" Margin="12,12,6,12">
|
||||||
|
<TextBlock FontWeight="SemiBold" Text="{Binding Name}" />
|
||||||
|
<TextBlock Opacity="0.7" Text="{Binding Name}" />
|
||||||
|
</StackPanel>
|
||||||
|
</Grid>
|
||||||
</ListBoxItem>
|
</ListBoxItem>
|
||||||
|
|||||||
@@ -47,9 +47,21 @@
|
|||||||
Padding="4"
|
Padding="4"
|
||||||
BorderBrush="{DynamicResource DividerStrokeColorDefaultBrush}"
|
BorderBrush="{DynamicResource DividerStrokeColorDefaultBrush}"
|
||||||
BorderThickness="0,0,0,1">
|
BorderThickness="0,0,0,1">
|
||||||
<ContentControl x:Name="ContentHeader" />
|
<ContentControl x:Name="ContentHeader">
|
||||||
|
<Interaction.Behaviors>
|
||||||
|
<AttachedBehaviour>
|
||||||
|
<NavigateRegionAction Name="{Binding Named, StringFormat='{}{0}:ContentHeader'}" />
|
||||||
|
</AttachedBehaviour>
|
||||||
|
</Interaction.Behaviors>
|
||||||
|
</ContentControl>
|
||||||
</Border>
|
</Border>
|
||||||
<Frame x:Name="Content" Grid.Row="1" />
|
<Frame x:Name="Content" Grid.Row="1">
|
||||||
|
<Interaction.Behaviors>
|
||||||
|
<AttachedBehaviour>
|
||||||
|
<NavigateRegionAction Name="{Binding Named, StringFormat='{}{0}:Content'}" />
|
||||||
|
</AttachedBehaviour>
|
||||||
|
</Interaction.Behaviors>
|
||||||
|
</Frame>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Border>
|
</Border>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|||||||
@@ -1,10 +1,7 @@
|
|||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Toolkit.Foundation;
|
|
||||||
|
|
||||||
namespace Bitvault.Avalonia;
|
namespace Bitvault.Avalonia;
|
||||||
|
|
||||||
[NavigationTarget("Content")]
|
|
||||||
[NavigationTarget("ContentHeader")]
|
|
||||||
public partial class VaultView : UserControl
|
public partial class VaultView : UserControl
|
||||||
{
|
{
|
||||||
public VaultView() => InitializeComponent();
|
public VaultView() => InitializeComponent();
|
||||||
|
|||||||
@@ -10,18 +10,21 @@ public partial class VaultContentNavigationViewModel(IServiceProvider provider,
|
|||||||
ISubscriber subscriber,
|
ISubscriber subscriber,
|
||||||
IDisposer disposer,
|
IDisposer disposer,
|
||||||
IContentTemplate template,
|
IContentTemplate template,
|
||||||
|
NamedComponent named,
|
||||||
string name,
|
string name,
|
||||||
string description) :
|
string description) :
|
||||||
ObservableViewModel(provider, factory, mediator, publisher, subscriber, disposer)
|
ObservableViewModel(provider, factory, mediator, publisher, subscriber, disposer)
|
||||||
{
|
{
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private bool selected;
|
private string? description = description;
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private string? name = name;
|
private string? name = name;
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private string? description = description;
|
private string named = $"{named}";
|
||||||
|
|
||||||
|
[ObservableProperty]
|
||||||
|
private bool selected;
|
||||||
public IContentTemplate Template { get; set; } = template;
|
public IContentTemplate Template { get; set; } = template;
|
||||||
}
|
}
|
||||||
+14
-10
@@ -12,12 +12,16 @@ public partial class VaultViewModel(IServiceProvider provider,
|
|||||||
ISubscriber subscriber,
|
ISubscriber subscriber,
|
||||||
IDisposer disposer,
|
IDisposer disposer,
|
||||||
IContentTemplate template,
|
IContentTemplate template,
|
||||||
|
NamedComponent named,
|
||||||
string? filter = null) : ObservableCollectionViewModel<VaultContentNavigationViewModel>(provider, factory, mediator, publisher, subscriber, disposer),
|
string? filter = null) : ObservableCollectionViewModel<VaultContentNavigationViewModel>(provider, factory, mediator, publisher, subscriber, disposer),
|
||||||
INotificationHandler<Vault<Filter<string>>>
|
INotificationHandler<Vault<Filter<string>>>
|
||||||
{
|
{
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private string? filter = filter;
|
private string? filter = filter;
|
||||||
|
|
||||||
|
[ObservableProperty]
|
||||||
|
private string named = $"{named}";
|
||||||
|
|
||||||
public IContentTemplate Template { get; set; } = template;
|
public IContentTemplate Template { get; set; } = template;
|
||||||
|
|
||||||
public override async Task Activated()
|
public override async Task Activated()
|
||||||
@@ -32,16 +36,16 @@ public partial class VaultViewModel(IServiceProvider provider,
|
|||||||
await base.Deactivated();
|
await base.Deactivated();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override IEnumerate PrepareEnumeration(object? key) =>
|
public async Task Handle(Vault<Filter<string>> args,
|
||||||
Enumerate<VaultContentNavigationViewModel>.With(new VaultViewModelOptions { Filter = Filter }) with { Key = key };
|
CancellationToken cancellationToken = default)
|
||||||
|
|
||||||
public async Task Handle(Vault<Filter<string>> args,
|
|
||||||
CancellationToken cancellationToken = default)
|
|
||||||
{
|
|
||||||
if (args.Value is Filter<string> filter)
|
|
||||||
{
|
{
|
||||||
Filter = filter.Value;
|
if (args.Value is Filter<string> filter)
|
||||||
await Enumerate();
|
{
|
||||||
|
Filter = filter.Value;
|
||||||
|
await Enumerate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
protected override IEnumerate PrepareEnumeration(object? key) =>
|
||||||
|
Enumerate<VaultContentNavigationViewModel>.With(new VaultViewModelOptions { Filter = Filter }) with { Key = key };
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user