Skip to content

Commit

Permalink
Add a copy button on the error dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
Al12rs committed Jan 30, 2025
1 parent fadd08b commit 0519445
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,15 @@
Text="Description" />

<!-- Supporting Markdown -->
<reactiveUi:ViewModelViewHost x:Name="MarkdownRendererViewModelViewHost" MaxHeight="640"
MaxWidth="600" />
<StackPanel Orientation="Vertical" x:Name="DetailsSection">
<controls:StandardButton x:Name="CopyDetailsButton"
LeftIcon="{x:Static icons:IconValues.Copy}"
ShowIcon="Left"
ShowLabel="False"/>
<reactiveUi:ViewModelViewHost x:Name="MarkdownRendererViewModelViewHost" MaxHeight="640"
MaxWidth="600" />
</StackPanel>

</StackPanel>

</DockPanel>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Reactive.Disposables;
using System.Reactive.Linq;
using Avalonia.Controls;
using Avalonia.ReactiveUI;
using R3;
using ReactiveUI;
Expand Down Expand Up @@ -28,7 +29,7 @@ public MessageBoxOkView()

this.WhenAnyValue(view => view.ViewModel!.MarkdownRenderer)
.Select(vm => vm != null)
.BindTo(this, v => v.MarkdownRendererViewModelViewHost.IsVisible)
.BindTo(this, v => v.DetailsSection.IsVisible)
.DisposeWith(disposables);

// Bind commands
Expand All @@ -41,6 +42,11 @@ public MessageBoxOkView()
{
ViewModel!.Complete(Unit.Default);
});

CopyDetailsButton.Command = ReactiveCommand.CreateFromTask(async () =>
{
await TopLevel.GetTopLevel(this)!.Clipboard!.SetTextAsync(ViewModel?.MarkdownRenderer?.Contents);
});
});
}
}
Expand Down

0 comments on commit 0519445

Please sign in to comment.