diff --git a/Wallet.Avalonia/App.axaml.cs b/Wallet.Avalonia/App.axaml.cs index 8ae09b9..cc05a02 100644 --- a/Wallet.Avalonia/App.axaml.cs +++ b/Wallet.Avalonia/App.axaml.cs @@ -192,6 +192,8 @@ public partial class App : Application services.AddTemplate(); services.AddTemplate(); + services.AddTemplate(); + services.AddTemplate(); services.AddTemplate(); services.AddTemplate(); diff --git a/Wallet.Avalonia/AttachmentEntryView.axaml b/Wallet.Avalonia/AttachmentEntryView.axaml new file mode 100644 index 0000000..a8b3315 --- /dev/null +++ b/Wallet.Avalonia/AttachmentEntryView.axaml @@ -0,0 +1,6 @@ + + Welcome to Avalonia! + diff --git a/Wallet.Avalonia/AttachmentEntryView.axaml.cs b/Wallet.Avalonia/AttachmentEntryView.axaml.cs new file mode 100644 index 0000000..08e96ad --- /dev/null +++ b/Wallet.Avalonia/AttachmentEntryView.axaml.cs @@ -0,0 +1,10 @@ +using Toolkit.UI.Controls.Avalonia; + +namespace Wallet.Avalonia; + +public partial class AttachmentEntryView : + SettingsExpanderItem +{ + public AttachmentEntryView() => + InitializeComponent(); +} diff --git a/Wallet.Avalonia/CommentEntryView.axaml b/Wallet.Avalonia/CommentEntryView.axaml index 51244db..1ba1106 100644 --- a/Wallet.Avalonia/CommentEntryView.axaml +++ b/Wallet.Avalonia/CommentEntryView.axaml @@ -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}" /> diff --git a/Wallet/AttachmentEntryCollectionViewModel.cs b/Wallet/AttachmentEntryCollectionViewModel.cs index 917a75f..2e09a4d 100644 --- a/Wallet/AttachmentEntryCollectionViewModel.cs +++ b/Wallet/AttachmentEntryCollectionViewModel.cs @@ -9,14 +9,17 @@ public partial class AttachmentEntryCollectionViewModel(IServiceProvider provide IPublisher publisher, ISubscriber subscriber, IDisposer disposer, + IContentTemplate template, ItemState state, IItemEntryConfiguration> configuration, string key, ICollection value, bool isConcealed, bool isRevealed, - double width) : ItemEntryCollectionViewModel>(provider, factory, mediator, publisher, subscriber, disposer, state, configuration, key, value, isConcealed, isRevealed, width) + double width) : ItemEntryCollectionViewModel>(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(attachment); + Add(path, created, size, name); Value.Add(attachment); } } diff --git a/Wallet/AttachmentEntryViewModel.cs b/Wallet/AttachmentEntryViewModel.cs index 223586b..b18a166 100644 --- a/Wallet/AttachmentEntryViewModel.cs +++ b/Wallet/AttachmentEntryViewModel.cs @@ -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(provider, factory, mediator, publisher, subscriber, disposer, value); \ No newline at end of file + 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; +} \ No newline at end of file diff --git a/Wallet/Comment.cs b/Wallet/Comment.cs index 4a1e675..88bb112 100644 --- a/Wallet/Comment.cs +++ b/Wallet/Comment.cs @@ -2,7 +2,7 @@ public record Comment { - public DateTimeOffset DateTime { get; set; } + public DateTimeOffset Created { get; set; } public string? Text { get; set; } } \ No newline at end of file diff --git a/Wallet/CommentEntryCollectionViewModel.cs b/Wallet/CommentEntryCollectionViewModel.cs index 643005d..6078df0 100644 --- a/Wallet/CommentEntryCollectionViewModel.cs +++ b/Wallet/CommentEntryCollectionViewModel.cs @@ -30,7 +30,7 @@ public partial class CommentEntryCollectionViewModel : ItemEntryCollectionViewMo { if (args.Sender is Comment comment) { - Insert(0, comment.DateTime, comment.Text); + Insert(0, comment.Created, comment.Text); Value.Add(comment); } diff --git a/Wallet/CommentEntryCollectionViewModelHandler.cs b/Wallet/CommentEntryCollectionViewModelHandler.cs index 6c1c6fc..1fb61f9 100644 --- a/Wallet/CommentEntryCollectionViewModelHandler.cs +++ b/Wallet/CommentEntryCollectionViewModelHandler.cs @@ -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(value.DateTime, value.Text); + viewModel.Add(value.Created, value.Text); } return Task.FromResult(viewModel); diff --git a/Wallet/CommentEntryViewModel.cs b/Wallet/CommentEntryViewModel.cs index 476b1ce..857bb41 100644 --- a/Wallet/CommentEntryViewModel.cs +++ b/Wallet/CommentEntryViewModel.cs @@ -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(provider, factory, mediator, publisher, subscriber, disposer, key, value), - ICommentEntryViewModel; \ No newline at end of file + DateTimeOffset created, + string comment) : Observable(provider, factory, mediator, publisher, subscriber, disposer), + ICommentEntryViewModel +{ + [ObservableProperty] + private DateTimeOffset created = created; + + [ObservableProperty] + private string comment = comment; +} \ No newline at end of file diff --git a/Wallet/CreateCommentEntryViewModel.cs b/Wallet/CreateCommentEntryViewModel.cs index a7cb6c4..cdd74ed 100644 --- a/Wallet/CreateCommentEntryViewModel.cs +++ b/Wallet/CreateCommentEntryViewModel.cs @@ -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; } } \ No newline at end of file diff --git a/Wallet/IAttachmentEntryViewModel.cs b/Wallet/IAttachmentEntryViewModel.cs new file mode 100644 index 0000000..5881795 --- /dev/null +++ b/Wallet/IAttachmentEntryViewModel.cs @@ -0,0 +1,4 @@ +namespace Wallet; + +public interface IAttachmentEntryViewModel : + IDisposable; diff --git a/Wallet/LocalAttachmentEntryViewModel.cs b/Wallet/LocalAttachmentEntryViewModel.cs new file mode 100644 index 0000000..4f8cd88 --- /dev/null +++ b/Wallet/LocalAttachmentEntryViewModel.cs @@ -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; +}