mirror of
https://github.com/BlossomiShymae/Needlework.Net.git
synced 2025-12-06 10:10:48 +01:00
feat: save offsets in viewmodels
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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<SchemaItemViewModel> _schemaItems = [];
|
||||
|
||||
[ObservableProperty]
|
||||
private Vector _offset = new();
|
||||
|
||||
partial void OnSearchChanged(string? value)
|
||||
{
|
||||
_debounceDispatcher.Debounce(() =>
|
||||
|
||||
@@ -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<EventViewModel> 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();
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -59,7 +59,13 @@
|
||||
Margin="0 8 0 0"
|
||||
FontSize="12"
|
||||
Grid.Row="1"
|
||||
Grid.Column="0"/>
|
||||
Grid.Column="0">
|
||||
<avaloniaEdit:TextEditor.Styles>
|
||||
<Style Selector="ScrollViewer#PART_ScrollViewer">
|
||||
<Setter Property="Offset" Value="{Binding Request.RequestDocumentOffset, Mode=TwoWay}"/>
|
||||
</Style>
|
||||
</avaloniaEdit:TextEditor.Styles>
|
||||
</avaloniaEdit:TextEditor>
|
||||
</Grid>
|
||||
<Grid RowDefinitions="35,*"
|
||||
ColumnDefinitions="*"
|
||||
@@ -83,7 +89,13 @@
|
||||
ShowLineNumbers="True"
|
||||
IsReadOnly="True"
|
||||
Text=""
|
||||
FontSize="12"/>
|
||||
FontSize="12">
|
||||
<avaloniaEdit:TextEditor.Styles>
|
||||
<Style Selector="ScrollViewer#PART_ScrollViewer">
|
||||
<Setter Property="Offset" Value="{Binding Request.ResponseDocumentOffset, Mode=TwoWay}"/>
|
||||
</Style>
|
||||
</avaloniaEdit:TextEditor.Styles>
|
||||
</avaloniaEdit:TextEditor>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</controls:BusyArea>
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
x:DataType="vm:EndpointListViewModel">
|
||||
<Grid RowDefinitions="auto,auto,*" ColumnDefinitions="*">
|
||||
<TextBox Watermark="Search" Margin="0 0 0 4" Text="{Binding Search}" Grid.Row="1" Grid.Column="0"/>
|
||||
<ScrollViewer Grid.Row="2" Grid.Column="0">
|
||||
<ScrollViewer Grid.Row="2" Grid.Column="0" Offset="{Binding Offset, Mode=TwoWay}">
|
||||
<ItemsControl ItemsSource="{Binding EndpointSearchDetails}">
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
|
||||
@@ -50,6 +50,11 @@
|
||||
Margin="0 0 0 0"
|
||||
Grid.Row="1"
|
||||
Grid.Column="0">
|
||||
<ListBox.Styles>
|
||||
<Style Selector="ScrollViewer#PART_ScrollViewer">
|
||||
<Setter Property="Offset" Value="{Binding Offset, Mode=TwoWay}"/>
|
||||
</Style>
|
||||
</ListBox.Styles>
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate x:DataType="vm:PathOperationViewModel">
|
||||
<ContentControl Content="{Binding}"/>
|
||||
@@ -92,7 +97,7 @@
|
||||
<Grid Grid.Row="1" Grid.Column="2">
|
||||
<TabControl>
|
||||
<TabItem Header="Params">
|
||||
<ScrollViewer>
|
||||
<ScrollViewer Offset="{Binding ParamsOffset, Mode=TwoWay}">
|
||||
<StackPanel IsVisible="{Binding SelectedPathOperation, Converter={StaticResource NullableToVisibilityConverter}}">
|
||||
<controls:Card
|
||||
Margin="0 4"
|
||||
@@ -155,7 +160,13 @@
|
||||
VerticalScrollBarVisibility="Visible"
|
||||
Text=""
|
||||
ShowLineNumbers="True"
|
||||
FontSize="12"/>
|
||||
FontSize="12">
|
||||
<avalonEdit:TextEditor.Styles>
|
||||
<Style Selector="ScrollViewer#PART_ScrollViewer">
|
||||
<Setter Property="Offset" Value="{Binding SelectedPathOperation.Request.Value.RequestDocumentOffset, Mode=TwoWay}"/>
|
||||
</Style>
|
||||
</avalonEdit:TextEditor.Styles>
|
||||
</avalonEdit:TextEditor>
|
||||
</TabItem>
|
||||
<TabItem Header="Auth">
|
||||
<Grid RowDefinitions="auto,auto,auto,*" ColumnDefinitions="*,4*">
|
||||
@@ -197,7 +208,7 @@
|
||||
</Grid>
|
||||
</TabItem>
|
||||
<TabItem Header="Schemas">
|
||||
<ScrollViewer>
|
||||
<ScrollViewer Offset="{Binding SchemasOffset, Mode=TwoWay}">
|
||||
<StackPanel>
|
||||
<controls:Card Margin="0 4" IsVisible="{Binding SelectedPathOperation.Operation.RequestBodyType, Converter={StaticResource NullableToVisibilityConverter}}">
|
||||
<TextBlock>
|
||||
@@ -266,7 +277,13 @@
|
||||
ShowLineNumbers="True"
|
||||
IsReadOnly="True"
|
||||
Text=""
|
||||
FontSize="12"/>
|
||||
FontSize="12">
|
||||
<avalonEdit:TextEditor.Styles>
|
||||
<Style Selector="ScrollViewer#PART_ScrollViewer">
|
||||
<Setter Property="Offset" Value="{Binding SelectedPathOperation.Request.Value.ResponseDocumentOffset, Mode=TwoWay}"/>
|
||||
</Style>
|
||||
</avalonEdit:TextEditor.Styles>
|
||||
</avalonEdit:TextEditor>
|
||||
</TabItem>
|
||||
</TabControl>
|
||||
</controls:BusyArea>
|
||||
|
||||
@@ -93,7 +93,8 @@
|
||||
Grid.Row="0">Libraries</TextBlock>
|
||||
<ScrollViewer Grid.Column="0"
|
||||
Grid.Row="1"
|
||||
HorizontalScrollBarVisibility="Disabled">
|
||||
HorizontalScrollBarVisibility="Disabled"
|
||||
Offset="{Binding LibrariesOffset, Mode=TwoWay}">
|
||||
<ItemsRepeater ItemsSource="{Binding Libraries}">
|
||||
<ItemsRepeater.ItemTemplate>
|
||||
<DataTemplate x:DataType="vm:LibraryViewModel">
|
||||
|
||||
@@ -19,7 +19,8 @@
|
||||
Grid.Row="0"
|
||||
Grid.Column="0"/>
|
||||
<ScrollViewer Grid.Row="1"
|
||||
Grid.Column="0">
|
||||
Grid.Column="0"
|
||||
Offset="{Binding Offset, Mode=TwoWay}">
|
||||
<ItemsControl ItemsSource="{Binding SchemaItems}">
|
||||
<ItemsControl.Styles>
|
||||
<Style Selector="views|SchemaItemView">
|
||||
|
||||
@@ -54,6 +54,11 @@
|
||||
ItemsSource="{Binding FilteredEventLog}"
|
||||
SelectedItem="{Binding SelectedEventLog}"
|
||||
ScrollViewer.HorizontalScrollBarVisibility="Auto">
|
||||
<ListBox.Styles>
|
||||
<Style Selector="ScrollViewer#PART_ScrollViewer">
|
||||
<Setter Property="Offset" Value="{Binding EventLogOffset, Mode=TwoWay}"/>
|
||||
</Style>
|
||||
</ListBox.Styles>
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate x:DataType="vm:EventViewModel">
|
||||
<ContentControl Content="{Binding}"/>
|
||||
@@ -72,7 +77,13 @@
|
||||
HorizontalScrollBarVisibility="Auto"
|
||||
VerticalScrollBarVisibility="Visible"
|
||||
Text=""
|
||||
FontSize="12"/>
|
||||
FontSize="12">
|
||||
<avaloniaEdit:TextEditor.Styles>
|
||||
<Style Selector="ScrollViewer#PART_ScrollViewer">
|
||||
<Setter Property="Offset" Value="{Binding DocumentOffset, Mode=TwoWay}"/>
|
||||
</Style>
|
||||
</avaloniaEdit:TextEditor.Styles>
|
||||
</avaloniaEdit:TextEditor>
|
||||
</Border>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
|
||||
Reference in New Issue
Block a user