Attempt to fix some wonky selection bugs
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Avalonia.Desktop" Version="11.2.999-cibuild0048140-alpha" />
|
||||
<PackageReference Include="Avalonia.Desktop" Version="11.1.0-beta2" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Bitvault.Avalonia\Bitvault.Avalonia.csproj" />
|
||||
|
||||
@@ -15,10 +15,10 @@
|
||||
<Compile Remove="Assets\Class1.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Condition="$(DefineConstants.Contains(ENABLE_XAML_HOT_RELOAD))" Include="Avalonia.Markup.Xaml.Loader" Version="11.2.999-cibuild0048140-alpha" />
|
||||
<PackageReference Condition="$(DefineConstants.Contains(ENABLE_XAML_HOT_RELOAD))" Include="Avalonia.Markup.Xaml.Loader" Version="11.1.0-beta2" />
|
||||
<PackageReference Condition="$(DefineConstants.Contains(ENABLE_XAML_HOT_RELOAD))" Include="HotAvalonia" Version="1.1.1" />
|
||||
<PackageReference Include="HotAvalonia.Extensions" Version="1.1.1" PrivateAssets="All" />
|
||||
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.2.999-cibuild0048140-alpha" />
|
||||
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.1.0-beta2" />
|
||||
<PackageReference Include="Avalonia.Labs.Controls" Version="11.0.10.1" />
|
||||
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
|
||||
<PackageReference Include="FluentAvaloniaUI" Version="2.1.0-preview5" />
|
||||
@@ -30,7 +30,7 @@
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
|
||||
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.2.999-cibuild0048140-alpha" />
|
||||
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.1.0-beta2" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Bitvault\Bitvault.csproj" />
|
||||
|
||||
@@ -36,7 +36,8 @@
|
||||
Region="{Binding Named, StringFormat='{}{0}:Content'}"
|
||||
Route="Item"
|
||||
Scope="self">
|
||||
<Parameter Key="Immutable" Value="{x:False}" />
|
||||
<Parameter Key="test" Value="{x:True}" />
|
||||
<Parameter Key="State" Value="{x:Static vm:ItemState.Write}" />
|
||||
</NavigateAction>
|
||||
</EventTriggerBehavior>
|
||||
</Interaction.Behaviors>
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
SelectionMode="Single">
|
||||
<ListBox.Styles>
|
||||
<Style Selector="ListBoxItem">
|
||||
<Setter Property="IsSelected" Value="{ReflectionBinding Selected, Mode=TwoWay}" />
|
||||
<Setter Property="IsSelected" Value="{ReflectionBinding Selected}" />
|
||||
</Style>
|
||||
</ListBox.Styles>
|
||||
</ListBox>
|
||||
|
||||
@@ -11,12 +11,20 @@
|
||||
DisplayName="{Binding Value}" />
|
||||
<TextBox
|
||||
MaxWidth="360"
|
||||
IsReadOnly="{Binding Immutable, Mode=TwoWay}"
|
||||
Text="{Binding Value, UpdateSourceTrigger=PropertyChanged}"
|
||||
Text="{Binding Value}"
|
||||
TextAlignment="Center"
|
||||
Watermark="Enter name">
|
||||
<Interaction.Behaviors>
|
||||
<DataTriggerBehavior Binding="{Binding State}" Value="{x:Static vm:ItemState.Read}">
|
||||
<AddClassAction ClassName="Read" RemoveIfExists="True" />
|
||||
</DataTriggerBehavior>
|
||||
<DataTriggerBehavior Binding="{Binding State}" Value="{x:Static vm:ItemState.Write}">
|
||||
<RemoveClassAction ClassName="Read" />
|
||||
</DataTriggerBehavior>
|
||||
</Interaction.Behaviors>
|
||||
<TextBox.Styles>
|
||||
<Style Selector="TextBox[IsReadOnly=True]">
|
||||
<Style Selector="TextBox.Read">
|
||||
<Setter Property="IsReadOnly" Value="True" />
|
||||
<Setter Property="BorderBrush" Value="Transparent" />
|
||||
<Setter Property="Background" Value="Transparent" />
|
||||
<Style Selector="^:pointerover">
|
||||
@@ -37,6 +45,7 @@
|
||||
</Style>
|
||||
</Style>
|
||||
</Style>
|
||||
<Style Selector="TextBox.Write" />
|
||||
</TextBox.Styles>
|
||||
</TextBox>
|
||||
</StackPanel>
|
||||
|
||||
@@ -3,8 +3,7 @@
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:vm="using:Bitvault"
|
||||
x:DataType="vm:ItemNavigationViewModel"
|
||||
IsSelected="{Binding Selected, Mode=TwoWay}">
|
||||
x:DataType="vm:ItemNavigationViewModel">
|
||||
<ListBoxItem.Resources>
|
||||
<SolidColorBrush x:Key="StarredIconForegroundBrush" Color="#FFEDB120" />
|
||||
</ListBoxItem.Resources>
|
||||
@@ -20,8 +19,8 @@
|
||||
Region="{Binding Named, StringFormat='{}{0}:Content'}"
|
||||
Route="Item"
|
||||
Scope="self">
|
||||
<Parameter Key="State" Value="{x:Static vm:ItemState.Read}" />
|
||||
<Parameter Key="Name" Value="{Binding Name}" />
|
||||
<Parameter Key="Immutable" Value="{x:True}" />
|
||||
<Parameter Key="Archived" Value="{Binding Archived}" />
|
||||
<Parameter Key="Favourite" Value="{Binding Favourite}" />
|
||||
</NavigateAction>
|
||||
@@ -32,10 +31,10 @@
|
||||
Region="{Binding Named, StringFormat='{}{0}:Content'}"
|
||||
Route="Item"
|
||||
Scope="self">
|
||||
<Parameter Key="Name" Value="{Binding Name}" />
|
||||
<Parameter Key="Immutable" Value="{x:True}" />
|
||||
<Parameter Key="Archived" Value="{Binding Archived}" />
|
||||
<Parameter Key="Favourite" Value="{Binding Favourite}" />
|
||||
<Parameter Key="Name" Value="{Binding Name}" />
|
||||
<Parameter Key="Immutable" Value="{x:Static vm:ItemState.Read}" />
|
||||
<Parameter Key="Archived" Value="{Binding Archived}" />
|
||||
<Parameter Key="Favourite" Value="{Binding Favourite}" />
|
||||
</NavigateAction>
|
||||
</DataTriggerBehavior>
|
||||
</Interaction.Behaviors>
|
||||
|
||||
@@ -11,6 +11,19 @@
|
||||
Route="ItemCommandHeader"
|
||||
Scope="self" />
|
||||
</AttachedBehaviour>
|
||||
<DataTriggerBehavior
|
||||
Binding="{Binding State}"
|
||||
ComparisonCondition="Equal"
|
||||
Value="{x:Static vm:ItemState.Read}">
|
||||
<ConditionAction>
|
||||
<ConditionAction.Condition>
|
||||
<ConditionalExpression ForwardChaining="And">
|
||||
<ComparisonCondition LeftOperand="{Binding Test}" RightOperand="True" />
|
||||
</ConditionalExpression>
|
||||
</ConditionAction.Condition>
|
||||
<NavigateBackAction Region="Left" />
|
||||
</ConditionAction>
|
||||
</DataTriggerBehavior>
|
||||
</Interaction.Behaviors>
|
||||
<ScrollViewer Padding="12,12,12,0">
|
||||
<ItemsControl ItemTemplate="{ReflectionBinding Template}" ItemsSource="{Binding}">
|
||||
|
||||
@@ -45,5 +45,7 @@ public class AggerateLockerItemViewModelHandler(IMediator mediator,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var d = cache;
|
||||
}
|
||||
}
|
||||
@@ -26,7 +26,8 @@ public class CreatedItemHandler(IServiceProvider serviceProvider,
|
||||
int index = cache.IndexOf(item);
|
||||
valueStore.Set(item);
|
||||
|
||||
publisher.Publish(Insert.As(index, viewModel), nameof(LockerViewModel));
|
||||
publisher.Publish(Insert.As(index, viewModel),
|
||||
nameof(ItemCollectionViewModel));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Toolkit.Foundation;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
@@ -27,6 +28,11 @@ public partial class ItemCollectionViewModel :
|
||||
|
||||
public IContentTemplate Template { get; set; }
|
||||
|
||||
public override Task OnDeactivated()
|
||||
{
|
||||
return base.OnDeactivated();
|
||||
}
|
||||
|
||||
public Task Handle(NotifyEventArgs<Filter> args)
|
||||
{
|
||||
if (args.Value is Filter filter)
|
||||
|
||||
@@ -14,7 +14,7 @@ public partial class ItemContentViewModel :
|
||||
ISubscription subscriber,
|
||||
IDisposer disposer,
|
||||
IContentTemplate template,
|
||||
bool immutable = true) : base(provider, factory, mediator, publisher, subscriber, disposer)
|
||||
ItemState state = ItemState.Read) : base(provider, factory, mediator, publisher, subscriber, disposer)
|
||||
{
|
||||
Template = template;
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ public partial class ItemHeaderViewModel : Observable<string, string>,
|
||||
IItemEntryViewModel
|
||||
{
|
||||
[ObservableProperty]
|
||||
private bool immutable;
|
||||
private ItemState state;
|
||||
|
||||
public ItemHeaderViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
@@ -20,10 +20,10 @@ public partial class ItemHeaderViewModel : Observable<string, string>,
|
||||
IPublisher publisher,
|
||||
ISubscription subscriber,
|
||||
IDisposer disposer,
|
||||
bool immutable,
|
||||
ItemState state,
|
||||
string? value = null) : base(provider, factory, mediator, publisher, subscriber, disposer, value)
|
||||
{
|
||||
Immutable = immutable;
|
||||
State = state;
|
||||
Value = value;
|
||||
|
||||
Track(nameof(Value), () => Value, newValue => Value = newValue);
|
||||
@@ -39,21 +39,21 @@ public partial class ItemHeaderViewModel : Observable<string, string>,
|
||||
CancellationToken cancellationToken) => Task.FromResult(new ItemHeaderConfiguration { Name = Value! });
|
||||
|
||||
public Task Handle(UpdateEventArgs<Item> args) =>
|
||||
Task.FromResult(Immutable = false);
|
||||
Task.FromResult(State = ItemState.Write);
|
||||
|
||||
public Task Handle(CancelEventArgs<Item> args)
|
||||
{
|
||||
Revert();
|
||||
Immutable = true;
|
||||
|
||||
State = ItemState.Read;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task Handle(ConfirmEventArgs<Item> args)
|
||||
{
|
||||
Commit();
|
||||
Immutable = true;
|
||||
|
||||
State = ItemState.Read;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace Bitvault;
|
||||
|
||||
public enum ItemState
|
||||
{
|
||||
Read,
|
||||
Write
|
||||
}
|
||||
+29
-19
@@ -17,7 +17,7 @@ public partial class ItemViewModel :
|
||||
private bool favourite;
|
||||
|
||||
[ObservableProperty]
|
||||
private bool immutable;
|
||||
private ItemState state;
|
||||
|
||||
[ObservableProperty]
|
||||
private string named;
|
||||
@@ -25,6 +25,8 @@ public partial class ItemViewModel :
|
||||
[ObservableProperty]
|
||||
private string name;
|
||||
|
||||
[ObservableProperty]
|
||||
private bool test;
|
||||
public ItemViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
@@ -33,20 +35,22 @@ public partial class ItemViewModel :
|
||||
IDisposer disposer,
|
||||
IContentTemplate template,
|
||||
NamedComponent named,
|
||||
ItemState state = ItemState.Read,
|
||||
bool test = false,
|
||||
string name = "",
|
||||
bool immutable = true,
|
||||
bool favourite = false,
|
||||
bool archived = false) : base(provider, factory, mediator, publisher, subscriber, disposer)
|
||||
{
|
||||
Test = test;
|
||||
Named = $"{named}";
|
||||
Template = template;
|
||||
Immutable = immutable;
|
||||
State = state;
|
||||
Favourite = favourite;
|
||||
Archived = archived;
|
||||
Name = name;
|
||||
|
||||
Add<ItemHeaderViewModel>(immutable, name);
|
||||
Add<ItemContentViewModel>(immutable);
|
||||
Add<ItemHeaderViewModel>(state, name);
|
||||
Add<ItemContentViewModel>(state);
|
||||
}
|
||||
|
||||
public IContentTemplate Template { get; set; }
|
||||
@@ -59,6 +63,7 @@ public partial class ItemViewModel :
|
||||
Factory.Create<DismissItemActionViewModel>(),
|
||||
})));
|
||||
|
||||
State = ItemState.Write;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
@@ -70,6 +75,7 @@ public partial class ItemViewModel :
|
||||
Factory.Create<ArchiveItemActionViewModel>(),
|
||||
})));
|
||||
|
||||
State = ItemState.Read;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
@@ -82,20 +88,13 @@ public partial class ItemViewModel :
|
||||
Factory.Create<ArchiveItemActionViewModel>(),
|
||||
})));
|
||||
|
||||
State = ItemState.Read;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public override Task OnActivated()
|
||||
{
|
||||
if (!Immutable)
|
||||
{
|
||||
Publisher.Publish(Notify.As(Factory.Create<ItemCommandHeaderCollection>(new List<IDisposable>
|
||||
{
|
||||
Factory.Create<ConfirmItemActionViewModel>(),
|
||||
Factory.Create<DismissItemActionViewModel>(),
|
||||
})));
|
||||
}
|
||||
else if (Archived)
|
||||
if (Archived)
|
||||
{
|
||||
Publisher.Publish(Notify.As(Factory.Create<ItemCommandHeaderCollection>(new List<IDisposable>
|
||||
{
|
||||
@@ -104,12 +103,23 @@ public partial class ItemViewModel :
|
||||
}
|
||||
else
|
||||
{
|
||||
Publisher.Publish(Notify.As(Factory.Create<ItemCommandHeaderCollection>(new List<IDisposable>
|
||||
if (State is ItemState.Write)
|
||||
{
|
||||
Factory.Create<FavouriteItemActionViewModel>(Favourite),
|
||||
Factory.Create<EditItemActionViewModel>(),
|
||||
Factory.Create<ArchiveItemActionViewModel>(),
|
||||
})));
|
||||
Publisher.Publish(Notify.As(Factory.Create<ItemCommandHeaderCollection>(new List<IDisposable>
|
||||
{
|
||||
Factory.Create<ConfirmItemActionViewModel>(),
|
||||
Factory.Create<DismissItemActionViewModel>(),
|
||||
})));
|
||||
}
|
||||
else
|
||||
{
|
||||
Publisher.Publish(Notify.As(Factory.Create<ItemCommandHeaderCollection>(new List<IDisposable>
|
||||
{
|
||||
Factory.Create<FavouriteItemActionViewModel>(Favourite),
|
||||
Factory.Create<EditItemActionViewModel>(),
|
||||
Factory.Create<ArchiveItemActionViewModel>(),
|
||||
})));
|
||||
}
|
||||
}
|
||||
|
||||
return base.OnActivated();
|
||||
|
||||
@@ -28,7 +28,8 @@ public class ModifiedItemHandler(IServiceProvider serviceProvider,
|
||||
int newIndex = cache.IndexOf(newItem);
|
||||
valueStore.Set(newItem);
|
||||
|
||||
publisher.Publish(MoveTo.As<ItemNavigationViewModel>(oldIndex, newIndex), nameof(LockerViewModel));
|
||||
publisher.Publish(MoveTo.As<ItemNavigationViewModel>(oldIndex, newIndex),
|
||||
nameof(ItemCollectionViewModel));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user