From 57334535cf99d0f40c8363d7c3a5311e7cc2c252 Mon Sep 17 00:00:00 2001 From: estrogen elf <87099578+BlossomiShymae@users.noreply.github.com> Date: Tue, 17 Jun 2025 13:37:03 -0500 Subject: [PATCH] feat: save offsets in viewmodels --- .../Pages/Endpoints/EndpointListViewModel.cs | 6 ++++- .../Pages/Endpoints/PluginViewModel.cs | 12 ++++++++- .../ViewModels/Pages/Home/HomeViewModel.cs | 7 +++++- .../Pages/Schemas/SchemasViewModel.cs | 6 ++++- .../Pages/Websocket/WebsocketViewModel.cs | 9 ++++++- .../ViewModels/Shared/RequestViewModel.cs | 15 ++++++++++- .../Views/Pages/Console/ConsoleView.axaml | 16 ++++++++++-- .../Pages/Endpoints/EndpointListView.axaml | 2 +- .../Views/Pages/Endpoints/PluginView.axaml | 25 ++++++++++++++++--- .../Views/Pages/Home/HomeView.axaml | 3 ++- .../Views/Pages/Schemas/SchemasView.axaml | 3 ++- .../Views/Pages/WebSocket/WebSocketView.axaml | 13 +++++++++- 12 files changed, 101 insertions(+), 16 deletions(-) diff --git a/Needlework.Net/ViewModels/Pages/Endpoints/EndpointListViewModel.cs b/Needlework.Net/ViewModels/Pages/Endpoints/EndpointListViewModel.cs index b20d6cf..fa634e9 100644 --- a/Needlework.Net/ViewModels/Pages/Endpoints/EndpointListViewModel.cs +++ b/Needlework.Net/ViewModels/Pages/Endpoints/EndpointListViewModel.cs @@ -1,4 +1,5 @@ -using AvaloniaEdit.Utils; +using Avalonia; +using AvaloniaEdit.Utils; using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; using Needlework.Net.Models; @@ -40,6 +41,9 @@ public partial class EndpointListViewModel : ObservableObject [ObservableProperty] private string _search = string.Empty; + [ObservableProperty] + private Vector _offset = new(); + partial void OnSearchChanged(string value) { EndpointSearchDetails.Clear(); diff --git a/Needlework.Net/ViewModels/Pages/Endpoints/PluginViewModel.cs b/Needlework.Net/ViewModels/Pages/Endpoints/PluginViewModel.cs index f60fc76..a5adccd 100644 --- a/Needlework.Net/ViewModels/Pages/Endpoints/PluginViewModel.cs +++ b/Needlework.Net/ViewModels/Pages/Endpoints/PluginViewModel.cs @@ -1,4 +1,5 @@ -using AvaloniaEdit.Utils; +using Avalonia; +using AvaloniaEdit.Utils; using CommunityToolkit.Mvvm.ComponentModel; using System; using System.Collections.Generic; @@ -31,6 +32,15 @@ public partial class PluginViewModel : ObservableObject [ObservableProperty] private string? _search; + [ObservableProperty] + private Vector _offset = new(); + + [ObservableProperty] + private Vector _paramsOffset = new(); + + [ObservableProperty] + private Vector _schemasOffset = new(); + partial void OnSearchChanged(string? value) { FilteredPathOperations.Clear(); diff --git a/Needlework.Net/ViewModels/Pages/Home/HomeViewModel.cs b/Needlework.Net/ViewModels/Pages/Home/HomeViewModel.cs index 6e34a14..0b262ae 100644 --- a/Needlework.Net/ViewModels/Pages/Home/HomeViewModel.cs +++ b/Needlework.Net/ViewModels/Pages/Home/HomeViewModel.cs @@ -1,4 +1,6 @@ -using Avalonia.Platform; +using Avalonia; +using Avalonia.Platform; +using CommunityToolkit.Mvvm.ComponentModel; using Needlework.Net.Models; using System; using System.Collections.Generic; @@ -17,6 +19,9 @@ public partial class HomeViewModel : PageBase .Select(library => new LibraryViewModel(library)) .ToList(); + [ObservableProperty] + private Vector _librariesOffset = new(); + public override Task InitializeAsync() { return Task.CompletedTask; diff --git a/Needlework.Net/ViewModels/Pages/Schemas/SchemasViewModel.cs b/Needlework.Net/ViewModels/Pages/Schemas/SchemasViewModel.cs index 86a22ba..c6808d5 100644 --- a/Needlework.Net/ViewModels/Pages/Schemas/SchemasViewModel.cs +++ b/Needlework.Net/ViewModels/Pages/Schemas/SchemasViewModel.cs @@ -1,4 +1,5 @@ -using Avalonia.Threading; +using Avalonia; +using Avalonia.Threading; using CommunityToolkit.Mvvm.ComponentModel; using DebounceThrottle; using Needlework.Net.Helpers; @@ -35,6 +36,9 @@ namespace Needlework.Net.ViewModels.Pages.Schemas [ObservableProperty] private List _schemaItems = []; + [ObservableProperty] + private Vector _offset = new(); + partial void OnSearchChanged(string? value) { _debounceDispatcher.Debounce(() => diff --git a/Needlework.Net/ViewModels/Pages/Websocket/WebsocketViewModel.cs b/Needlework.Net/ViewModels/Pages/Websocket/WebsocketViewModel.cs index 8382423..2b07ae7 100644 --- a/Needlework.Net/ViewModels/Pages/Websocket/WebsocketViewModel.cs +++ b/Needlework.Net/ViewModels/Pages/Websocket/WebsocketViewModel.cs @@ -1,4 +1,5 @@ -using Avalonia.Collections; +using Avalonia; +using Avalonia.Collections; using AvaloniaEdit.Document; using BlossomiShymae.Briar; using BlossomiShymae.Briar.WebSocket.Events; @@ -53,6 +54,9 @@ public partial class WebSocketViewModel : PageBase, IEnableLogger public IReadOnlyList FilteredEventLog => string.IsNullOrWhiteSpace(Search) ? EventLog : [.. EventLog.Where(x => x.Key.Contains(Search, StringComparison.InvariantCultureIgnoreCase))]; + [ObservableProperty] + private Vector _eventLogOffset = new(); + [NotifyPropertyChangedFor(nameof(FilteredEventLog))] [ObservableProperty] private string _search = string.Empty; @@ -75,6 +79,9 @@ public partial class WebSocketViewModel : PageBase, IEnableLogger [ObservableProperty] private TextDocument _document = new(); + [ObservableProperty] + private Vector _documentOffset = new(); + public override async Task InitializeAsync() { await InitializeEventTypes(); diff --git a/Needlework.Net/ViewModels/Shared/RequestViewModel.cs b/Needlework.Net/ViewModels/Shared/RequestViewModel.cs index 3c2647f..34f4677 100644 --- a/Needlework.Net/ViewModels/Shared/RequestViewModel.cs +++ b/Needlework.Net/ViewModels/Shared/RequestViewModel.cs @@ -1,4 +1,5 @@ -using Avalonia.Media; +using Avalonia; +using Avalonia.Media; using AvaloniaEdit.Document; using BlossomiShymae.Briar; using BlossomiShymae.Briar.Utils; @@ -42,9 +43,21 @@ public partial class RequestViewModel : ObservableObject, IEnableLogger [ObservableProperty] private TextDocument _requestDocument = new(); + [ObservableProperty] + private Vector _requestDocumentOffset = new(); + [ObservableProperty] private TextDocument _responseDocument = new(); + [ObservableProperty] + private Vector _responseDocumentOffset = new(); + + [ObservableProperty] + private double _responseDocumentHorizontalScrollBar; + + [ObservableProperty] + private double _responseDocumentVerticalScrollBar; + [ObservableProperty] private string? _responsePath; diff --git a/Needlework.Net/Views/Pages/Console/ConsoleView.axaml b/Needlework.Net/Views/Pages/Console/ConsoleView.axaml index bd91454..a78badd 100644 --- a/Needlework.Net/Views/Pages/Console/ConsoleView.axaml +++ b/Needlework.Net/Views/Pages/Console/ConsoleView.axaml @@ -59,7 +59,13 @@ Margin="0 8 0 0" FontSize="12" Grid.Row="1" - Grid.Column="0"/> + Grid.Column="0"> + + + + + FontSize="12"> + + + + diff --git a/Needlework.Net/Views/Pages/Endpoints/EndpointListView.axaml b/Needlework.Net/Views/Pages/Endpoints/EndpointListView.axaml index d8db123..e1b8853 100644 --- a/Needlework.Net/Views/Pages/Endpoints/EndpointListView.axaml +++ b/Needlework.Net/Views/Pages/Endpoints/EndpointListView.axaml @@ -10,7 +10,7 @@ x:DataType="vm:EndpointListViewModel"> - + diff --git a/Needlework.Net/Views/Pages/Endpoints/PluginView.axaml b/Needlework.Net/Views/Pages/Endpoints/PluginView.axaml index cb4f208..6283183 100644 --- a/Needlework.Net/Views/Pages/Endpoints/PluginView.axaml +++ b/Needlework.Net/Views/Pages/Endpoints/PluginView.axaml @@ -50,6 +50,11 @@ Margin="0 0 0 0" Grid.Row="1" Grid.Column="0"> + + + @@ -92,7 +97,7 @@ - + + FontSize="12"> + + + + @@ -197,7 +208,7 @@ - + @@ -266,7 +277,13 @@ ShowLineNumbers="True" IsReadOnly="True" Text="" - FontSize="12"/> + FontSize="12"> + + + + diff --git a/Needlework.Net/Views/Pages/Home/HomeView.axaml b/Needlework.Net/Views/Pages/Home/HomeView.axaml index fbd7214..eac1300 100644 --- a/Needlework.Net/Views/Pages/Home/HomeView.axaml +++ b/Needlework.Net/Views/Pages/Home/HomeView.axaml @@ -93,7 +93,8 @@ Grid.Row="0">Libraries + HorizontalScrollBarVisibility="Disabled" + Offset="{Binding LibrariesOffset, Mode=TwoWay}"> diff --git a/Needlework.Net/Views/Pages/Schemas/SchemasView.axaml b/Needlework.Net/Views/Pages/Schemas/SchemasView.axaml index fbbeb84..15e8c6a 100644 --- a/Needlework.Net/Views/Pages/Schemas/SchemasView.axaml +++ b/Needlework.Net/Views/Pages/Schemas/SchemasView.axaml @@ -19,7 +19,8 @@ Grid.Row="0" Grid.Column="0"/> + Grid.Column="0" + Offset="{Binding Offset, Mode=TwoWay}"> + @@ -72,7 +77,13 @@ HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Visible" Text="" - FontSize="12"/> + FontSize="12"> + + + +