Improve sub navigations
This commit is contained in:
@@ -27,6 +27,7 @@
|
||||
<NavigateAction Region="Left" Route="ContentItemCollection">
|
||||
<Parameter Key="Filter" Value="{Binding Filter}" />
|
||||
<Parameter Key="Transition" Value="FromRight" />
|
||||
<Parameter Key="NavigationStackEnabled" Value="{x:True}" />
|
||||
</NavigateAction>
|
||||
</ConditionAction>
|
||||
</DataTriggerBehavior>
|
||||
|
||||
@@ -105,10 +105,11 @@ public partial class App : Application
|
||||
services.AddTemplate<ItemCollectionViewModel, ItemCollectionView>("ContentItemCollection");
|
||||
services.AddHandler<AggerateLockerItemViewModelHandler>();
|
||||
|
||||
services.AddTemplate<SearchLockerActionViewModel, SearchLockerActionView>();
|
||||
services.AddTemplate<LockerHeaderViewModel, LockerHeaderView>("LockerHeader");
|
||||
|
||||
services.AddTemplate<BackActionViewModel, BackActionView>();
|
||||
services.AddTemplate<CreateItemActionViewModel, CreateItemActionView>();
|
||||
services.AddTemplate<SearchLockerActionViewModel, SearchLockerActionView>();
|
||||
|
||||
services.AddTemplate<ItemCategoryCollectionViewModel, ItemCategoryCollectionView>("LockerItemCategoryCollection");
|
||||
services.AddTemplate<ItemCategoryNavigationViewModel, ItemCategoryNavigationView>();
|
||||
|
||||
@@ -116,6 +117,7 @@ public partial class App : Application
|
||||
|
||||
services.AddTemplate<ItemNavigationViewModel, ItemNavigationView>();
|
||||
services.AddTemplate<ItemViewModel, ItemView>("Item");
|
||||
|
||||
services.AddHandler<AggerateItemViewModelHandler>();
|
||||
|
||||
services.AddTemplate<ItemCommandHeaderViewModel, ItemCommandHeaderView>("ItemCommandHeader");
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
<NavigateAction Region="Left" Route="ContentItemCollection">
|
||||
<Parameter Key="Filter" Value="{Binding Filter}" />
|
||||
<Parameter Key="Transition" Value="FromRight" />
|
||||
<Parameter Key="NavigationStackEnabled" Value="{x:True}" />
|
||||
</NavigateAction>
|
||||
</ConditionAction>
|
||||
</DataTriggerBehavior>
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
<UserControl
|
||||
x:Class="Bitvault.Avalonia.BackActionView"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<UserControl.Resources>
|
||||
<ResourceDictionary>
|
||||
<x:Double x:Key="ButtonWidth">40</x:Double>
|
||||
<x:Double x:Key="ButtonHeight">36</x:Double>
|
||||
<SolidColorBrush x:Key="ButtonBackground" Color="{DynamicResource SubtleFillColorTransparent}" />
|
||||
<SolidColorBrush x:Key="ButtonBackgroundPointerOver" Color="{DynamicResource SubtleFillColorSecondary}" />
|
||||
<SolidColorBrush x:Key="ButtonBackgroundPressed" Color="{DynamicResource SubtleFillColorTertiary}" />
|
||||
<Thickness x:Key="ButtonBorderThemeThickness">0</Thickness>
|
||||
<ResourceDictionary.ThemeDictionaries>
|
||||
<ResourceDictionary x:Key="Light">
|
||||
<SolidColorBrush x:Key="IconForegroundBrush" Color="#AB000000" />
|
||||
</ResourceDictionary>
|
||||
<ResourceDictionary x:Key="Dark">
|
||||
<SolidColorBrush x:Key="IconForegroundBrush" Color="#ABFFFFFF" />
|
||||
</ResourceDictionary>
|
||||
</ResourceDictionary.ThemeDictionaries>
|
||||
</ResourceDictionary>
|
||||
</UserControl.Resources>
|
||||
<Button
|
||||
Width="{StaticResource ButtonWidth}"
|
||||
Height="{StaticResource ButtonHeight}"
|
||||
VerticalAlignment="Center"
|
||||
Foreground="{DynamicResource IconForegroundBrush}"
|
||||
ToolTip.Tip="Back">
|
||||
<TextBlock
|
||||
Margin="0,3,0,0"
|
||||
VerticalAlignment="Center"
|
||||
FontFamily="{DynamicResource FluentThemeFontFamily}"
|
||||
FontSize="16"
|
||||
Foreground="{DynamicResource IconForegroundBrush}"
|
||||
Text="" />
|
||||
<Interaction.Behaviors>
|
||||
<EventTriggerBehavior EventName="Click">
|
||||
<NavigateBackAction Region="Left" />
|
||||
</EventTriggerBehavior>
|
||||
</Interaction.Behaviors>
|
||||
</Button>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,9 @@
|
||||
using Avalonia.Controls;
|
||||
|
||||
namespace Bitvault.Avalonia;
|
||||
|
||||
public partial class BackActionView : UserControl
|
||||
{
|
||||
public BackActionView() =>
|
||||
InitializeComponent();
|
||||
}
|
||||
@@ -30,6 +30,7 @@
|
||||
<EventTriggerBehavior EventName="Click">
|
||||
<NavigateAction Region="Left" Route="LockerItemCategoryCollection">
|
||||
<Parameter Key="Transition" Value="FromRight" />
|
||||
<Parameter Key="NavigationStackEnabled" Value="{x:True}" />
|
||||
</NavigateAction>
|
||||
</EventTriggerBehavior>
|
||||
</Interaction.Behaviors>
|
||||
|
||||
@@ -4,4 +4,31 @@
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:vm="using:Bitvault"
|
||||
x:DataType="vm:ItemCategoryNavigationViewModel"
|
||||
Content="{Binding Name}" />
|
||||
Content="{Binding Name}"
|
||||
IsSelected="{Binding Selected, Mode=TwoWay}">
|
||||
<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="Immutable" Value="{x:False}" />
|
||||
</NavigateAction>
|
||||
</ConditionAction>
|
||||
</AttachedBehaviour>
|
||||
<DataTriggerBehavior Binding="{Binding Selected}" Value="True">
|
||||
<NavigateAction
|
||||
Region="{Binding Named, StringFormat='{}{0}:Content'}"
|
||||
Route="Item"
|
||||
Scope="self">
|
||||
<Parameter Key="Immutable" Value="{x:False}" />
|
||||
</NavigateAction>
|
||||
</DataTriggerBehavior>
|
||||
</Interaction.Behaviors>
|
||||
</ListBoxItem>
|
||||
|
||||
@@ -2,7 +2,7 @@ using Avalonia.Controls;
|
||||
|
||||
namespace Bitvault.Avalonia;
|
||||
|
||||
public partial class ItemCategoryNavigationView : UserControl
|
||||
public partial class ItemCategoryNavigationView : ListBoxItem
|
||||
{
|
||||
public ItemCategoryNavigationView() =>
|
||||
InitializeComponent();
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
Grid.Row="0"
|
||||
Grid.ColumnSpan="3"
|
||||
Height="44"
|
||||
Margin="8,0,0,0">
|
||||
Margin="4,2,0,0">
|
||||
<ContentControl VerticalAlignment="Center">
|
||||
<Interaction.Behaviors>
|
||||
<AttachedBehaviour>
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
<NavigateAction Region="Left" Route="ContentItemCollection">
|
||||
<Parameter Key="Filter" Value="{Binding Filter}" />
|
||||
<Parameter Key="Transition" Value="FromRight" />
|
||||
<Parameter Key="NavigationStackEnabled" Value="{x:True}" />
|
||||
</NavigateAction>
|
||||
</ConditionAction>
|
||||
</DataTriggerBehavior>
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public partial class BackActionViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
ISubscription subscriber,
|
||||
IDisposer disposer) : Observable<string>(provider, factory, mediator, publisher, subscriber, disposer)
|
||||
{
|
||||
[ObservableProperty]
|
||||
private int index = 0;
|
||||
|
||||
[RelayCommand]
|
||||
public void Invoke() => Publisher.Publish(Notify.As(new Search(Value)),
|
||||
nameof(ItemCollectionViewModel));
|
||||
}
|
||||
@@ -19,7 +19,7 @@ public partial class ItemCategoryCollectionViewModel(IServiceProvider provider,
|
||||
{
|
||||
Publisher.Publish(Notify.As(Factory.Create<LockerCommandHeaderCollection>(new List<IDisposable>
|
||||
{
|
||||
|
||||
Factory.Create<BackActionViewModel>(),
|
||||
})));
|
||||
|
||||
return base.OnActivated();
|
||||
|
||||
@@ -9,9 +9,20 @@ public partial class ItemCategoryNavigationViewModel(IServiceProvider provider,
|
||||
IPublisher publisher,
|
||||
ISubscription subscriber,
|
||||
IDisposer disposer,
|
||||
string name) :
|
||||
Observable(provider, factory, mediator, publisher, subscriber, disposer)
|
||||
NamedComponent named,
|
||||
string name,
|
||||
bool selected = false) :
|
||||
Observable(provider, factory, mediator, publisher, subscriber, disposer),
|
||||
ISelectable,
|
||||
IRemovable
|
||||
{
|
||||
[ObservableProperty]
|
||||
private string name = name;
|
||||
|
||||
[ObservableProperty]
|
||||
private string named = $"{named}";
|
||||
|
||||
[ObservableProperty]
|
||||
private bool selected = selected;
|
||||
|
||||
}
|
||||
|
||||
@@ -6,7 +6,8 @@ namespace Bitvault;
|
||||
public partial class ItemCollectionViewModel :
|
||||
ObservableCollection<ItemNavigationViewModel>,
|
||||
INotificationHandler<NotifyEventArgs<Filter>>,
|
||||
INotificationHandler<NotifyEventArgs<Search>>
|
||||
INotificationHandler<NotifyEventArgs<Search>>,
|
||||
IBackStack
|
||||
{
|
||||
private LockerViewModelConfiguration configuration;
|
||||
|
||||
|
||||
@@ -14,21 +14,6 @@ public partial class SearchLockerActionViewModel(IServiceProvider provider,
|
||||
[ObservableProperty]
|
||||
private int index = 2;
|
||||
|
||||
[RelayCommand]
|
||||
public void Invoke() => Publisher.Publish(Notify.As(new Search(Value)),
|
||||
nameof(ItemCollectionViewModel));
|
||||
}
|
||||
|
||||
public partial class BackContainerActionViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
ISubscription subscriber,
|
||||
IDisposer disposer) : Observable<string>(provider, factory, mediator, publisher, subscriber, disposer)
|
||||
{
|
||||
[ObservableProperty]
|
||||
private int index = 2;
|
||||
|
||||
[RelayCommand]
|
||||
public void Invoke() => Publisher.Publish(Notify.As(new Search(Value)),
|
||||
nameof(ItemCollectionViewModel));
|
||||
|
||||
Reference in New Issue
Block a user