File attachment UI work
This commit is contained in:
@@ -192,6 +192,8 @@ public partial class App : Application
|
||||
services.AddTemplate<CommentEntryCollectionViewModel, CommentEntryCollectionView>();
|
||||
|
||||
services.AddTemplate<AttachmentEntryCollectionViewModel, AttachmentEntryCollectionView>();
|
||||
services.AddTemplate<AttachmentEntryViewModel, AttachmentEntryView>();
|
||||
services.AddTemplate<LocalAttachmentEntryViewModel, AttachmentEntryView>();
|
||||
|
||||
services.AddTemplate<TextEntryViewModel, TextEntryView>();
|
||||
services.AddTemplate<PasswordEntryViewModel, PasswordEntryView>();
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
<SettingsExpanderItem
|
||||
x:Class="Wallet.Avalonia.AttachmentEntryView"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
Welcome to Avalonia!
|
||||
</SettingsExpanderItem>
|
||||
@@ -0,0 +1,10 @@
|
||||
using Toolkit.UI.Controls.Avalonia;
|
||||
|
||||
namespace Wallet.Avalonia;
|
||||
|
||||
public partial class AttachmentEntryView :
|
||||
SettingsExpanderItem
|
||||
{
|
||||
public AttachmentEntryView() =>
|
||||
InitializeComponent();
|
||||
}
|
||||
@@ -4,5 +4,5 @@
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:vm="using:Wallet"
|
||||
x:DataType="vm:CommentEntryViewModel"
|
||||
Content="{Binding Value}"
|
||||
Description="{Binding Key}" />
|
||||
Content="{Binding Comment}"
|
||||
Description="{Binding Created}" />
|
||||
|
||||
@@ -9,14 +9,17 @@ public partial class AttachmentEntryCollectionViewModel(IServiceProvider provide
|
||||
IPublisher publisher,
|
||||
ISubscriber subscriber,
|
||||
IDisposer disposer,
|
||||
IContentTemplate template,
|
||||
ItemState state,
|
||||
IItemEntryConfiguration<ICollection<Attachment>> configuration,
|
||||
string key,
|
||||
ICollection<Attachment> value,
|
||||
bool isConcealed,
|
||||
bool isRevealed,
|
||||
double width) : ItemEntryCollectionViewModel<AttachmentEntryViewModel, ICollection<Attachment>>(provider, factory, mediator, publisher, subscriber, disposer, state, configuration, key, value, isConcealed, isRevealed, width)
|
||||
double width) : ItemEntryCollectionViewModel<IAttachmentEntryViewModel, ICollection<Attachment>>(provider, factory, mediator, publisher, subscriber, disposer, state, configuration, key, value, isConcealed, isRevealed, width)
|
||||
{
|
||||
public IContentTemplate Template { get; set; } = template;
|
||||
|
||||
[RelayCommand]
|
||||
private async Task Invoke()
|
||||
{
|
||||
@@ -25,14 +28,19 @@ public partial class AttachmentEntryCollectionViewModel(IServiceProvider provide
|
||||
{
|
||||
foreach (IFileDescriptor file in fileDescriptors)
|
||||
{
|
||||
string path = file.Path;
|
||||
DateTimeOffset created = DateTimeOffset.Now;
|
||||
string name = file.Name;
|
||||
int size = file.Size;
|
||||
|
||||
Attachment attachment = new()
|
||||
{
|
||||
Name = file.Name,
|
||||
Path = file.Path,
|
||||
DateTime = DateTimeOffset.Now
|
||||
Name = name,
|
||||
Path = path,
|
||||
DateTime = created
|
||||
};
|
||||
|
||||
Add<AttachmentEntryViewModel>(attachment);
|
||||
Add<LocalAttachmentEntryViewModel>(path, created, size, name);
|
||||
Value.Add(attachment);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Toolkit.Foundation;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Wallet;
|
||||
|
||||
@@ -8,4 +9,21 @@ public partial class AttachmentEntryViewModel(IServiceProvider provider,
|
||||
IPublisher publisher,
|
||||
ISubscriber subscriber,
|
||||
IDisposer disposer,
|
||||
Attachment? value = default) : Observable<Attachment>(provider, factory, mediator, publisher, subscriber, disposer, value);
|
||||
Guid id,
|
||||
DateTimeOffset created,
|
||||
int size,
|
||||
string name) : Observable(provider, factory, mediator, publisher, subscriber, disposer),
|
||||
IAttachmentEntryViewModel
|
||||
{
|
||||
[ObservableProperty]
|
||||
private DateTimeOffset? created = created;
|
||||
|
||||
[ObservableProperty]
|
||||
private Guid id = id;
|
||||
|
||||
[ObservableProperty]
|
||||
private int size = size;
|
||||
|
||||
[ObservableProperty]
|
||||
private string name = name;
|
||||
}
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
|
||||
public record Comment
|
||||
{
|
||||
public DateTimeOffset DateTime { get; set; }
|
||||
public DateTimeOffset Created { get; set; }
|
||||
|
||||
public string? Text { get; set; }
|
||||
}
|
||||
@@ -30,7 +30,7 @@ public partial class CommentEntryCollectionViewModel : ItemEntryCollectionViewMo
|
||||
{
|
||||
if (args.Sender is Comment comment)
|
||||
{
|
||||
Insert<CommentEntryViewModel>(0, comment.DateTime, comment.Text);
|
||||
Insert<CommentEntryViewModel>(0, comment.Created, comment.Text);
|
||||
Value.Add(comment);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,9 +18,9 @@ public class CommentEntryCollectionViewModelHandler(IServiceFactory serviceFacto
|
||||
[.. args.Parameters, configuration, label, values, false, false, width])
|
||||
is CommentEntryCollectionViewModel viewModel)
|
||||
{
|
||||
foreach (Comment value in values.OrderByDescending(x => x.DateTime))
|
||||
foreach (Comment value in values.OrderByDescending(x => x.Created))
|
||||
{
|
||||
viewModel.Add<CommentEntryViewModel>(value.DateTime, value.Text);
|
||||
viewModel.Add<CommentEntryViewModel>(value.Created, value.Text);
|
||||
}
|
||||
|
||||
return Task.FromResult<IItemEntryViewModel?>(viewModel);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Toolkit.Foundation;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Wallet;
|
||||
|
||||
@@ -8,6 +9,13 @@ public partial class CommentEntryViewModel(IServiceProvider provider,
|
||||
IPublisher publisher,
|
||||
ISubscriber subscriber,
|
||||
IDisposer disposer,
|
||||
DateTimeOffset key,
|
||||
string? value = default) : Observable<DateTimeOffset, string>(provider, factory, mediator, publisher, subscriber, disposer, key, value),
|
||||
ICommentEntryViewModel;
|
||||
DateTimeOffset created,
|
||||
string comment) : Observable(provider, factory, mediator, publisher, subscriber, disposer),
|
||||
ICommentEntryViewModel
|
||||
{
|
||||
[ObservableProperty]
|
||||
private DateTimeOffset created = created;
|
||||
|
||||
[ObservableProperty]
|
||||
private string comment = comment;
|
||||
}
|
||||
@@ -14,7 +14,7 @@ public partial class CreateCommentEntryViewModel(IServiceProvider provider,
|
||||
[RelayCommand]
|
||||
private void Invoke()
|
||||
{
|
||||
Publisher.Publish(Create.As(new Comment { Text = Value, DateTime = DateTimeOffset.Now }));
|
||||
Publisher.Publish(Create.As(new Comment { Text = Value, Created = DateTimeOffset.Now }));
|
||||
Value = null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
namespace Wallet;
|
||||
|
||||
public interface IAttachmentEntryViewModel :
|
||||
IDisposable;
|
||||
@@ -0,0 +1,29 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Wallet;
|
||||
|
||||
public partial class LocalAttachmentEntryViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
ISubscriber subscriber,
|
||||
IDisposer disposer,
|
||||
string path,
|
||||
DateTimeOffset created,
|
||||
int size,
|
||||
string name) : Observable(provider, factory, mediator, publisher, subscriber, disposer),
|
||||
IAttachmentEntryViewModel
|
||||
{
|
||||
[ObservableProperty]
|
||||
private DateTimeOffset created = created;
|
||||
|
||||
[ObservableProperty]
|
||||
private string path = path;
|
||||
|
||||
[ObservableProperty]
|
||||
private int size = size;
|
||||
|
||||
[ObservableProperty]
|
||||
private string name = name;
|
||||
}
|
||||
Reference in New Issue
Block a user